Skip to content

Commit

Permalink
Fix STM32 radio driver when bandwith is 0
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LukaB committed Feb 1, 2022
1 parent f75ff22 commit 5059706
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,10 @@ uint8_t STM32WL_LoRaRadio::get_fsk_bw_reg_val(uint32_t bandwidth)
{
uint8_t i;

if (bandwidth == 0) {
return( 0x1F );
}

for (i = 0; i < (sizeof(fsk_bandwidths) / sizeof(fsk_bw_t)) - 1; i++) {
if ((bandwidth >= fsk_bandwidths[i].bandwidth)
&& (bandwidth < fsk_bandwidths[i + 1].bandwidth)) {
Expand Down

0 comments on commit 5059706

Please sign in to comment.