Skip to content

Commit c8e9340

Browse files
kietavainenkartben
authored andcommitted
drivers: bluetooth: silabs: Set maximum TX power
Honor Kconfig option `BT_CTLR_TX_PWR_ANTENNA` for limiting the maximum TX power. The default value for this option is 0 dBm, which means that after this change the actual TX power is likely lower than before, unless increased by this option. Signed-off-by: Kalle Kietäväinen <kalle.kietavainen@silabs.com>
1 parent 13ac8fe commit c8e9340

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

drivers/bluetooth/hci/hci_silabs_efr32.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ static struct k_fifo slz_rx_fifo;
5252
/* FIXME: these functions should come from the SiSDK headers! */
5353
void BTLE_LL_EventRaise(uint32_t events);
5454
void BTLE_LL_Process(uint32_t events);
55+
int16_t BTLE_LL_SetMaxPower(int16_t power);
5556
bool sli_pending_btctrl_events(void);
5657
RAIL_Handle_t BTLE_LL_GetRadioHandle(void);
5758

@@ -256,6 +257,18 @@ static void slz_rx_thread_func(void *p1, void *p2, void *p3)
256257
}
257258
}
258259

260+
static void slz_set_tx_power(int16_t max_power_dbm)
261+
{
262+
const int16_t max_power_cbm = max_power_dbm * 10;
263+
const int16_t actual_max_power_cbm = BTLE_LL_SetMaxPower(max_power_cbm);
264+
const int16_t actual_max_power_dbm = DIV_ROUND_CLOSEST(actual_max_power_cbm, 10);
265+
266+
if (actual_max_power_dbm != max_power_dbm) {
267+
LOG_WRN("Unable to set max TX power to %d dBm, actual max is %d dBm", max_power_dbm,
268+
actual_max_power_dbm);
269+
}
270+
}
271+
259272
static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv)
260273
{
261274
struct hci_data *hci = dev->data;
@@ -303,6 +316,8 @@ static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv)
303316
goto deinit;
304317
}
305318

319+
slz_set_tx_power(CONFIG_BT_CTLR_TX_PWR_ANTENNA);
320+
306321
sl_btctrl_init_adv();
307322
sl_btctrl_init_scan();
308323
sl_btctrl_init_conn();

modules/hal_silabs/simplicity_sdk/src/blob_stubs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ void BTLE_LL_Process(uint32_t events)
3131
{
3232
}
3333

34+
int16_t BTLE_LL_SetMaxPower(int16_t power)
35+
{
36+
return 0;
37+
}
38+
3439
void sl_btctrl_disable_2m_phy(void)
3540
{
3641
}

0 commit comments

Comments
 (0)