mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-29 05:10:04 +00:00
nimble/ll: Fix power value rounding for nRF52
This commit is contained in:
@@ -81,10 +81,6 @@ extern uint32_t g_nrf_irk_list[];
|
||||
#define NRF_MAXLEN (255)
|
||||
#define NRF_BALEN (3) /* For base address of 3 bytes */
|
||||
|
||||
/* Maximum tx power */
|
||||
#define NRF_TX_PWR_MAX_DBM (4)
|
||||
#define NRF_TX_PWR_MIN_DBM (-40)
|
||||
|
||||
/* NRF_RADIO->PCNF0 configuration values */
|
||||
#define NRF_PCNF0 (NRF_LFLEN_BITS << RADIO_PCNF0_LFLEN_Pos) | \
|
||||
(RADIO_PCNF0_S1INCL_Msk) | \
|
||||
@@ -1771,17 +1767,8 @@ ble_phy_tx(ble_phy_tx_pducb_t pducb, void *pducb_arg, uint8_t end_trans)
|
||||
int
|
||||
ble_phy_txpwr_set(int dbm)
|
||||
{
|
||||
/* Check valid range */
|
||||
assert(dbm <= BLE_PHY_MAX_PWR_DBM);
|
||||
|
||||
/* "Rail" power level if outside supported range */
|
||||
if (dbm > NRF_TX_PWR_MAX_DBM) {
|
||||
dbm = NRF_TX_PWR_MAX_DBM;
|
||||
} else {
|
||||
if (dbm < NRF_TX_PWR_MIN_DBM) {
|
||||
dbm = NRF_TX_PWR_MIN_DBM;
|
||||
}
|
||||
}
|
||||
dbm = ble_phy_txpower_round(dbm);
|
||||
|
||||
NRF_RADIO->TXPOWER = dbm;
|
||||
g_ble_phy_data.phy_txpwr_dbm = dbm;
|
||||
@@ -1800,16 +1787,38 @@ ble_phy_txpwr_set(int dbm)
|
||||
*/
|
||||
int ble_phy_txpower_round(int dbm)
|
||||
{
|
||||
/* TODO this should be per nRF52XXX */
|
||||
|
||||
/* "Rail" power level if outside supported range */
|
||||
if (dbm > NRF_TX_PWR_MAX_DBM) {
|
||||
dbm = NRF_TX_PWR_MAX_DBM;
|
||||
} else {
|
||||
if (dbm < NRF_TX_PWR_MIN_DBM) {
|
||||
dbm = NRF_TX_PWR_MIN_DBM;
|
||||
}
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
return dbm;
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Pos3dBm;
|
||||
}
|
||||
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_0dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_0dBm;
|
||||
}
|
||||
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Neg4dBm;
|
||||
}
|
||||
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Neg8dBm;
|
||||
}
|
||||
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Neg12dBm;
|
||||
}
|
||||
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Neg20dBm;
|
||||
}
|
||||
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Neg40dBm;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user