From df80b4c954dcfb01259fa076b2de0f84de9d8528 Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Fri, 23 Dec 2022 11:35:07 +0100 Subject: [PATCH] nimble/phy/nrf5x: Fix PA for tx-tx transition --- nimble/drivers/nrf5x/src/ble_phy.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nimble/drivers/nrf5x/src/ble_phy.c b/nimble/drivers/nrf5x/src/ble_phy.c index c941cde7a..0663eba76 100644 --- a/nimble/drivers/nrf5x/src/ble_phy.c +++ b/nimble/drivers/nrf5x/src/ble_phy.c @@ -1014,7 +1014,7 @@ ble_phy_tx_end_isr(void) uint8_t transition; uint32_t rx_time; uint32_t tx_time; -#if PHY_USE_FEM_LNA +#if PHY_USE_FEM uint32_t fem_time; #endif uint32_t radio_time; @@ -1096,6 +1096,11 @@ ble_phy_tx_end_isr(void) tx_time = NRF_TIMER0->CC[2] + tifs; /* Adjust for delay between EVENT_END and actual TX end time */ tx_time += g_ble_phy_t_txenddelay[tx_phy_mode]; + +#if PHY_USE_FEM_PA + fem_time = tx_time - MYNEWT_VAL(BLE_FEM_PA_TURN_ON_US); +#endif + /* Adjust for delay between EVENT_READY and actual TX start time */ tx_time -= g_ble_phy_t_txdelay[g_ble_phy_data.phy_cur_phy_mode]; @@ -1104,7 +1109,11 @@ ble_phy_tx_end_isr(void) NRF_TIMER0->EVENTS_COMPARE[0] = 0; phy_ppi_timer0_compare0_to_radio_txen_enable(); - /* TODO handle PA */ +#if PHY_USE_FEM_PA + nrf_timer_cc_set(NRF_TIMER0, 2, fem_time); + NRF_TIMER0->EVENTS_COMPARE[2] = 0; + phy_fem_enable_pa(); +#endif nrf_timer_task_trigger(NRF_TIMER0, NRF_TIMER_TASK_CAPTURE3); if (NRF_TIMER0->CC[3] > NRF_TIMER0->CC[0]) {