diff --git a/subsys/bluetooth/controller/Kconfig b/subsys/bluetooth/controller/Kconfig index fe247cd95b..46d9f53b32 100644 --- a/subsys/bluetooth/controller/Kconfig +++ b/subsys/bluetooth/controller/Kconfig @@ -108,6 +108,67 @@ config BT_CTLR_TX_BUFFER_SIZE Maximum is set to 16384 due to implementation limitations (use of u16_t for size/length variables). +choice + prompt "Tx Power" + default BT_CTLR_TX_PWR_0 + help + Select the supported BLE Radio transmit power level in dBm. + +config BT_CTLR_TX_PWR_PLUS_8 + bool "+8 dBm" + depends on SOC_NRF52840 + +config BT_CTLR_TX_PWR_PLUS_7 + bool "+7 dBm" + depends on SOC_NRF52840 + +config BT_CTLR_TX_PWR_PLUS_6 + bool "+6 dBm" + depends on SOC_NRF52840 + +config BT_CTLR_TX_PWR_PLUS_5 + bool "+5 dBm" + depends on SOC_NRF52840 + +config BT_CTLR_TX_PWR_PLUS_4 + bool "+4 dBm" + +config BT_CTLR_TX_PWR_PLUS_3 + bool "+3 dBm" + depends on SOC_SERIES_NRF52X + +config BT_CTLR_TX_PWR_PLUS_2 + bool "+2 dBm" + depends on SOC_NRF52840 + +config BT_CTLR_TX_PWR_0 + bool "0 dBm" + +config BT_CTLR_TX_PWR_MINUS_4 + bool "-4 dBm" + +config BT_CTLR_TX_PWR_MINUS_8 + bool "-8 dBm" + +config BT_CTLR_TX_PWR_MINUS_12 + bool "-12 dBm" + +config BT_CTLR_TX_PWR_MINUS_16 + bool "-16 dBm" + +config BT_CTLR_TX_PWR_MINUS_20 + bool "-20 dBm" + +config BT_CTLR_TX_PWR_MINUS_30 + bool "-30 dBm" + depends on SOC_SERIES_NRF51X + +config BT_CTLR_TX_PWR_MINUS_40 + bool "-40 dBm" + depends on SOC_SERIES_NRF52X + +endchoice + config BT_CTLR_COMPANY_ID prompt "Company Id" hex diff --git a/subsys/bluetooth/controller/hal/nrf5/radio/radio.c b/subsys/bluetooth/controller/hal/nrf5/radio/radio.c index 7b2f4840f4..5e9f5e029e 100644 --- a/subsys/bluetooth/controller/hal/nrf5/radio/radio.c +++ b/subsys/bluetooth/controller/hal/nrf5/radio/radio.c @@ -108,7 +108,7 @@ void radio_phy_set(u8_t phy, u8_t flags) void radio_tx_power_set(u32_t power) { - /* TODO map power to h/w values. */ + /* NOTE: valid value range is passed by Kconfig define. */ NRF_RADIO->TXPOWER = power; } diff --git a/subsys/bluetooth/controller/hal/nrf5/radio/radio_nrf5_txp.h b/subsys/bluetooth/controller/hal/nrf5/radio/radio_nrf5_txp.h new file mode 100644 index 0000000000..a49089282f --- /dev/null +++ b/subsys/bluetooth/controller/hal/nrf5/radio/radio_nrf5_txp.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#if defined(CONFIG_BT_CTLR_TX_PWR_PLUS_8) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos8dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_7) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos7dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_6) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos6dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_5) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos5dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_4) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos4dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_3) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos3dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_PLUS_2) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Pos2dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_0) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_0dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_4) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg4dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_8) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg8dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_12) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg12dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_16) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg16dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_20) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg20dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_30) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg30dBm +#elif defined(CONFIG_BT_CTLR_TX_PWR_MINUS_40) +#define RADIO_TXP_DEFAULT RADIO_TXPOWER_TXPOWER_Neg40dBm +#endif diff --git a/subsys/bluetooth/controller/hal/radio_txp.h b/subsys/bluetooth/controller/hal/radio_txp.h new file mode 100644 index 0000000000..961bab315b --- /dev/null +++ b/subsys/bluetooth/controller/hal/radio_txp.h @@ -0,0 +1,9 @@ +/* + * Copyright (c) 2018 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#if defined(CONFIG_SOC_FAMILY_NRF) +#include "nrf5/radio/radio_nrf5_txp.h" +#endif diff --git a/subsys/bluetooth/controller/ll_sw/ctrl.c b/subsys/bluetooth/controller/ll_sw/ctrl.c index 7c8fd034d7..21883d2c53 100644 --- a/subsys/bluetooth/controller/ll_sw/ctrl.c +++ b/subsys/bluetooth/controller/ll_sw/ctrl.c @@ -25,6 +25,7 @@ #include "hal/ecb.h" #include "hal/ccm.h" #include "hal/radio.h" +#include "hal/radio_txp.h" #include "hal/ticker.h" #include "hal/debug.h" @@ -5879,7 +5880,7 @@ again: static void adv_scan_conn_configure(void) { radio_reset(); - radio_tx_power_set(0); + radio_tx_power_set(RADIO_TXP_DEFAULT); radio_isr_set(isr); }