Skip to content

Commit

Permalink
updated lowpower that Serial can work when uart rx is high
Browse files Browse the repository at this point in the history
  • Loading branch information
Heltec-Aaron-Lee committed Feb 3, 2021
1 parent 34b0ab7 commit afe4f46
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cores/asr650x/Serial/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ void HardwareSerial::begin(unsigned long baud , uint32_t config, int8_t uart_num

if( _uart_num == UART_NUM_0)
{
if(digitalRead(UART_RX)==UART_RX_LEVEL)//uart start when uart chip powered
{
//if(digitalRead(UART_RX)==UART_RX_LEVEL)//uart start when uart chip powered
//{
uint32_t div = (float)CYDEV_BCLK__HFCLK__HZ/SerialBaud/UART_1_UART_OVS_FACTOR + 0.5 - 1;
UART_1_Start();
UART_1_SCBCLK_DIV_REG = div<<8;
UART_1_UART_RX_CTRL_REG = rx_ctrl0;
UART_1_RX_CTRL_REG =rx_ctrl1;
UART_1_UART_TX_CTRL_REG =tx_ctrl0;
UART_1_TX_CTRL_REG = tx_ctrl1;
}
//}
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion cores/asr650x/device/asr6501_lrwan/radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,11 +1118,13 @@ void RadioOnCadTimeoutIrq( void )
RadioEvents->CadDone( 0 );
}
}

extern uint8 UART_1_initVar;
extern void enableUart(void);
void RadioOnDioIrq( void )
{
pinMode(P4_1,INPUT);
if(UART_1_initVar)
pinMode(P3_1,OUTPUT_PULLUP);
IrqFired = true;
RadioIrqProcess();
}
Expand Down
2 changes: 1 addition & 1 deletion cores/asr650x/loramac/mac/region/RegionCN470.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ bool RegionCN470TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, TimerTime
// Setup the radio frequency
Radio.SetChannel( Channels[txConfig->Channel].Frequency );

Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, 0, phyDr, 1, 16, false, true, 0, 0, false, 3000 );
Radio.SetTxConfig( MODEM_LORA, phyTxPower, 0, 0, phyDr, 1, 16, false, true, 0, 0, false, 4000 );
FREQ_PRINTF("TX on freq %u Hz at DR %d power %d\r\n", (unsigned int)Channels[txConfig->Channel].Frequency, txConfig->Datarate,phyTxPower);

// Setup maximum payload lenght of the radio driver
Expand Down
5 changes: 5 additions & 0 deletions cores/asr650x/loramac/system/low_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ uint32_t LowPower_GetState( void )
*/
extern uint32_t systime;
extern void systemTimer();
extern uint8 UART_1_initVar;

void lowPowerHandler( void )
{
Expand All @@ -118,13 +119,17 @@ void lowPowerHandler( void )
if (LowPower_State == 0 && wakeByUart == false) {
DBG_PRINTF_CRITICAL("dz\n\r");
pinMode(P4_1,ANALOG);// SPI0 MISO;
if(UART_1_initVar)
pinMode(P3_1,ANALOG);
aos_lrwan_chg_mode.enter_stop_mode();
/* mcu dependent. to be implemented by user*/
aos_lrwan_chg_mode.exit_stop_mode();
aos_lrwan_time_itf.set_uc_wakeup_time();
CySysTickSetCallback(4,systemTimer);
systime = (uint32_t)TimerGetCurrentTime();
pinMode(P4_1,INPUT);
if(UART_1_initVar)
pinMode(P3_1,OUTPUT_PULLUP);
} else {
//DBG_PRINTF_CRITICAL("z\n\r");
aos_lrwan_chg_mode.enter_sleep_mode();
Expand Down
Binary file modified cores/asr650x/projects/CubeCellLib.a
Binary file not shown.
8 changes: 8 additions & 0 deletions cores/asr650x/projects/PSoC4/CyLFClk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2863,6 +2863,8 @@ cystatus CySysClkIloRestoreFactoryTrim(void)
}
}

extern uint8 UART_1_initVar;

/*******************************************************************************
* Function Name: CySysTimerIsr
****************************************************************************//**
Expand Down Expand Up @@ -2891,6 +2893,8 @@ cystatus CySysClkIloRestoreFactoryTrim(void)
if(cySysTimerCallback[CY_SYS_TIMER0] != (void *) 0)
{
pinMode(P4_1,INPUT);
if(UART_1_initVar)
pinMode(P3_1, OUTPUT_PULLUP);
(void)(cySysTimerCallback[CY_SYS_TIMER0])();
}
}
Expand All @@ -2906,6 +2910,8 @@ cystatus CySysClkIloRestoreFactoryTrim(void)
if(cySysTimerCallback[CY_SYS_TIMER1] != (void *) 0)
{
pinMode(P4_1,INPUT);
if(UART_1_initVar)
pinMode(P3_1, OUTPUT_PULLUP);
(void)(cySysTimerCallback[CY_SYS_TIMER1])();
}
}
Expand All @@ -2919,6 +2925,8 @@ cystatus CySysClkIloRestoreFactoryTrim(void)
if(cySysTimerCallback[CY_SYS_TIMER2] != (void *) 0)
{
pinMode(P4_1,INPUT);
if(UART_1_initVar)
pinMode(P3_1, OUTPUT_PULLUP);
(void)(cySysTimerCallback[CY_SYS_TIMER2])();
}
}
Expand Down

0 comments on commit afe4f46

Please sign in to comment.