bluetooth: controller: radio: Add guards on TXPOWER

For tx_power_max_get and tx_power_floor, only allow for
positive values of txpower if they are defined.

Signed-off-by: Aurora Sletnes Bjørlo <aurora.sletnes@nordicsemi.no>
This commit is contained in:
Aurora Sletnes Bjørlo 2020-12-14 12:41:51 +01:00 committed by Anas Nashif
parent 37284c7035
commit 717687806c

View file

@ -232,19 +232,25 @@ static inline uint32_t hal_radio_tx_power_min_get(void)
static inline uint32_t hal_radio_tx_power_max_get(void)
{
#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm)
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
#else
return RADIO_TXPOWER_TXPOWER_0dBm;
#endif
}
static inline uint32_t hal_radio_tx_power_floor(int8_t tx_power_lvl)
{
#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm)
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
return RADIO_TXPOWER_TXPOWER_Pos4dBm;
}
#endif
#if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm)
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
return RADIO_TXPOWER_TXPOWER_Pos3dBm;
}
#endif
if (tx_power_lvl >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
return RADIO_TXPOWER_TXPOWER_0dBm;
}