[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.
diff --git a/examples/platforms/efr32/src/radio.c b/examples/platforms/efr32/src/radio.c
index 5621fb9..44e8380 100644
--- a/examples/platforms/efr32/src/radio.c
+++ b/examples/platforms/efr32/src/radio.c
@@ -1126,7 +1126,7 @@
// 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 @@
// 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;