Skip to content

Commit

Permalink
optimize and rename delay_ms
Browse files Browse the repository at this point in the history
  • Loading branch information
Forest-Rain committed Oct 29, 2020
1 parent 1a6a84a commit e6540d1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lora-radio/sx126x/lora-radio-sx126x.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ bool RadioIsChannelFree( RadioModems_t modem, uint32_t freq, int16_t rssiThresh,

RadioRx( 0 );

DelayMs( 1 );
SX126X_DELAY_MS( 1 );

carrierSenseTime = TimerGetCurrentTime( );

Expand Down Expand Up @@ -1152,7 +1152,7 @@ void RadioSleep( void )
params.Fields.WarmStart = 1;
SX126xSetSleep( params );

DelayMs(2);
SX126X_BLOCK_DELAY_1MS();
}

void RadioStandby( void )
Expand Down
3 changes: 3 additions & 0 deletions lora-radio/sx126x/lora-spi-sx126x.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ void SX126xWakeup( void )

// Wait for chip to be ready.
SX126xWaitOnBusy( );

// Update operating mode context variable
SX126xSetOperatingMode( MODE_STDBY_RC );
#else
#endif

Expand Down
3 changes: 2 additions & 1 deletion ports/lora-module/inc/sx126x-board.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
*/
#define BOARD_TCXO_WAKEUP_TIME 2

#define DelayMs( ms ) rt_thread_mdelay(ms)
#define SX126X_DELAY_MS( ms ) rt_thread_mdelay(ms)
#define SX126X_BLOCK_DELAY_1MS() rt_hw_us_delay(999)

/*!
* \brief Initializes the radio I/Os pins interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ uint32_t SX126xGetBoardTcxoWakeupTime( void )

void SX126xReset( void )
{
DelayMs( 20 );
SX126X_DELAY_MS( 20 );
rt_pin_mode(LORA_RADIO_RESET_PIN, PIN_MODE_OUTPUT);
rt_pin_write(LORA_RADIO_RESET_PIN, PIN_LOW);
DelayMs( 40 );
SX126X_DELAY_MS( 40 );
rt_pin_mode(LORA_RADIO_RESET_PIN, PIN_MODE_INPUT);
DelayMs( 20 );
SX126X_DELAY_MS( 20 );
}

void SX126xWaitOnBusy( void )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ uint32_t SX126xGetBoardTcxoWakeupTime( void )

void SX126xReset( void )
{
DelayMs( 10 );
SX126X_DELAY_MS( 10 );
rt_pin_mode(LORA_RADIO_RESET_PIN, PIN_MODE_OUTPUT);
rt_pin_write(LORA_RADIO_RESET_PIN, PIN_LOW);
DelayMs( 20 );
SX126X_DELAY_MS( 20 );
// internal pull-up
rt_pin_mode(LORA_RADIO_RESET_PIN, PIN_MODE_INPUT);
DelayMs( 10 );
SX126X_DELAY_MS( 10 );
}

void SX126xWaitOnBusy( void )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ uint32_t SX126xGetBoardTcxoWakeupTime( void )

void SX126xReset( void )
{
DelayMs( 10 );
SX126X_DELAY_MS( 10 );
rt_pin_mode(LORA_RADIO_RESET_PIN, PIN_MODE_OUTPUT);
rt_pin_write(LORA_RADIO_RESET_PIN, PIN_LOW);
DelayMs( 20 );
SX126X_DELAY_MS( 20 );
// internal pull-up
rt_pin_mode(LORA_RADIO_RESET_PIN, PIN_MODE_INPUT);
DelayMs( 10 );
SX126X_DELAY_MS( 10 );
}

void SX126xWaitOnBusy( void )
Expand Down
4 changes: 2 additions & 2 deletions ports/lora-module/stm32_adapter/SX1278_Ra-01/sx1278-board.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ void SX127xReset( void )
rt_pin_write(LORA_RADIO_RESET_PIN, PIN_LOW);

// Wait 1 ms
DelayMs( 1 );
SX127X_DELAY_MS( 1 );

// Configure RESET as input
rt_pin_mode(LORA_RADIO_RESET_PIN, PIN_MODE_INPUT);

// Wait 6 ms
DelayMs( 6 );
SX127X_DELAY_MS( 6 );
}

void SX127xSetAntSwLowPower( bool status )
Expand Down

0 comments on commit e6540d1

Please sign in to comment.