Skip to content

Commit bccd3fc

Browse files
author
Hasnain Virk
committed
Adding assert if rx timeout is out of range
Rx timeout in symbols cannot become more than 255 as the preamble length is fixed. For diagonostics purposes we add an MBED_ASSERT.
1 parent d135987 commit bccd3fc

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

SX1272/SX1272_LoRaRadio.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,15 @@ void SX1272_LoRaRadio::receive(void)
896896
RF_RXCONFIG_AGCAUTO_ON |
897897
RF_RXCONFIG_RXTRIGER_PREAMBLEDETECT);
898898

899-
write_to_register(REG_RXTIMEOUT2, _rf_settings.fsk.rx_single_timeout <= 255 ?
900-
_rf_settings.fsk.rx_single_timeout : 255);
901-
write_to_register(REG_RXTIMEOUT3, 0x00);
902-
write_to_register(REG_RXTIMEOUT1, 0x00);
899+
if (!_rf_settings.fsk.rx_continuous) {
900+
// the value for rx timeout in symbols cannot be more than 255
901+
// as the preamble length is fixed. We assert here for quick
902+
// diagnostics
903+
MBED_ASSERT(_rf_settings.fsk.rx_single_timeout <= 255);
904+
write_to_register(REG_RXTIMEOUT2, _rf_settings.fsk.rx_single_timeout);
905+
write_to_register(REG_RXTIMEOUT3, 0x00);
906+
write_to_register(REG_RXTIMEOUT1, 0x00);
907+
}
903908

904909
_rf_settings.fsk_packet_handler.preamble_detected = 0;
905910
_rf_settings.fsk_packet_handler.sync_word_detected = 0;

SX1276/SX1276_LoRaRadio.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,11 @@ void SX1276_LoRaRadio::receive(void)
877877
| RF_RXCONFIG_RXTRIGER_PREAMBLEDETECT);
878878

879879
if (!_rf_settings.fsk.rx_continuous) {
880-
write_to_register(REG_RXTIMEOUT2, _rf_settings.fsk.rx_single_timeout <= 255 ?
881-
_rf_settings.fsk.rx_single_timeout : 255);
880+
// the value for rx timeout in symbols cannot be more than 255
881+
// as the preamble length is fixed. We assert here for quick
882+
// diagnostics
883+
MBED_ASSERT(_rf_settings.fsk.rx_single_timeout <= 255);
884+
write_to_register(REG_RXTIMEOUT2, _rf_settings.fsk.rx_single_timeout);
882885
write_to_register(REG_RXTIMEOUT3, 0x00);
883886
write_to_register(REG_RXTIMEOUT1, 0x00);
884887
}

0 commit comments

Comments
 (0)