mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-08-18 07:50:02 +00:00
nimble/phy/nrf5x: Move out TX power rounding
This commit is contained in:
@@ -1803,8 +1803,8 @@ ble_phy_tx(ble_phy_tx_pducb_t pducb, void *pducb_arg, uint8_t end_trans)
|
||||
int
|
||||
ble_phy_txpwr_set(int dbm)
|
||||
{
|
||||
/* "Rail" power level if outside supported range */
|
||||
dbm = ble_phy_txpower_round(dbm);
|
||||
/* Get actual TX power supported by radio */
|
||||
dbm = phy_txpower_round(dbm);
|
||||
|
||||
NRF_RADIO->TXPOWER = dbm;
|
||||
g_ble_phy_data.phy_txpwr_dbm = dbm;
|
||||
@@ -1821,40 +1821,10 @@ ble_phy_txpwr_set(int dbm)
|
||||
*
|
||||
* @return int Rounded power in dBm
|
||||
*/
|
||||
int ble_phy_txpower_round(int dbm)
|
||||
int
|
||||
ble_phy_txpower_round(int dbm)
|
||||
{
|
||||
/* TODO this should be per nRF52XXX */
|
||||
|
||||
/* "Rail" power level if outside supported range */
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
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;
|
||||
return phy_txpower_round(dbm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -163,3 +163,37 @@ phy_ppi_init(void)
|
||||
(uint32_t)&(NRF_TIMER0->EVENTS_COMPARE[3]),
|
||||
(uint32_t)&(NRF_RADIO->TASKS_DISABLE));
|
||||
}
|
||||
|
||||
int8_t
|
||||
phy_txpower_round(int8_t dbm)
|
||||
{
|
||||
if (dbm >= (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm) {
|
||||
return (int8_t)RADIO_TXPOWER_TXPOWER_Pos4dBm;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -76,4 +76,6 @@ void phy_ppi_init(void);
|
||||
#include "nrf52/phy_ppi.h"
|
||||
#endif
|
||||
|
||||
int8_t phy_txpower_round(int8_t dbm);
|
||||
|
||||
#endif /* H_PHY_PRIV_ */
|
||||
|
||||
Reference in New Issue
Block a user