From d23f3581eab9066c0e833cb064a5a7c5ec0704ca Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Thu, 10 Dec 2020 12:59:56 -0300 Subject: [PATCH] [efr32] radio: fix otPlatRadioGetTransmitPower (#5932) The efr32 platform shows the following behavior: > txpower -10 Done > > txpower -113 dBm Done The bug is caused by the C promotion rules during the division of int16_t by unsigned in otPlatRadioGetTransmitPower. This commit fixes the issue. --- examples/platforms/efr32/src/radio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/platforms/efr32/src/radio.c b/examples/platforms/efr32/src/radio.c index 5621fb981..44e8380de 100644 --- a/examples/platforms/efr32/src/radio.c +++ b/examples/platforms/efr32/src/radio.c @@ -1126,7 +1126,7 @@ otError otPlatRadioGetTransmitPower(otInstance *aInstance, int8_t *aPower) // RAIL_GetTxPowerDbm() returns power in deci-dBm (0.1dBm) // Divide by 10 because aPower is supposed be in units dBm - *aPower = RAIL_GetTxPowerDbm(gRailHandle) / 10U; + *aPower = RAIL_GetTxPowerDbm(gRailHandle) / 10; exit: return error; @@ -1140,7 +1140,7 @@ otError otPlatRadioSetTransmitPower(otInstance *aInstance, int8_t aPower) // RAIL_SetTxPowerDbm() takes power in units of deci-dBm (0.1dBm) // Divide by 10 because aPower is supposed be in units dBm - status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPower) * 10U); + status = RAIL_SetTxPowerDbm(gRailHandle, ((RAIL_TxPower_t)aPower) * 10); assert(status == RAIL_STATUS_NO_ERROR); return OT_ERROR_NONE;