Skip to content

Commit d503495

Browse files
committed
Fix STM32 radio driver when bandwith is 0
A bug was detected when the uint8_t SUBGRF_GetFskBandwidthRegValue( uint32_t bandwidth ) is called and the bandwith argument has a value of 0. Comparing the code to the STMCubeWL 1.1 we can see that an if statement is missing to address the condition where bandwith is equal to 0. Added the if statement to the radio driver to account for this edge case.
1 parent f75ff22 commit d503495

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

connectivity/drivers/lora/TARGET_STM32WL/STM32WL_LoRaRadio.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ uint8_t STM32WL_LoRaRadio::get_fsk_bw_reg_val(uint32_t bandwidth)
868868
{
869869
uint8_t i;
870870

871+
if (bandwidth == 0) {
872+
return 0x1F;
873+
}
874+
871875
for (i = 0; i < (sizeof(fsk_bandwidths) / sizeof(fsk_bw_t)) - 1; i++) {
872876
if ((bandwidth >= fsk_bandwidths[i].bandwidth)
873877
&& (bandwidth < fsk_bandwidths[i + 1].bandwidth)) {

0 commit comments

Comments
 (0)