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.
pull/15217/head
LukaB 2022-01-31 08:34:07 +13:00
parent f75ff22714
commit d503495189
1 changed files with 4 additions and 0 deletions

View File

@ -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)) {