1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/nrf24l01p: fix potentially undefined return value

This commit is contained in:
Alexandre Abadie 2019-10-27 17:15:28 +01:00
parent d4adcfd92d
commit 808e44243e
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405

View File

@ -618,30 +618,13 @@ int nrf24l01p_set_power(const nrf24l01p_t *dev, int pwr)
return nrf24l01p_write_reg(dev, REG_RF_SETUP, rf_setup);
}
static const int8_t _nrf24l01p_power_map[4] = { -18, -12, -6, 0 };
int nrf24l01p_get_power(const nrf24l01p_t *dev)
{
char rf_setup;
int pwr;
nrf24l01p_read_reg(dev, REG_RF_SETUP, &rf_setup);
if ((rf_setup & 0x6) == 0) {
pwr = -18;
}
if ((rf_setup & 0x6) == 2) {
pwr = -12;
}
if ((rf_setup & 0x6) == 4) {
pwr = -6;
}
if ((rf_setup & 0x6) == 6) {
pwr = 0;
}
return pwr;
return _nrf24l01p_power_map[(rf_setup & 0x6) >> 1];
}