nimble/phy/nrf52: Add tx-tx transition

This adds TX-TX transition, initially supported only on nRF52 PHY.
This commit is contained in:
Andrzej Kaczmarek
2022-09-06 14:27:15 +02:00
parent f85bbda005
commit 77cf738074
2 changed files with 26 additions and 6 deletions
@@ -65,6 +65,7 @@ struct os_mbuf;
#define BLE_PHY_TRANSITION_NONE (0)
#define BLE_PHY_TRANSITION_RX_TX (1)
#define BLE_PHY_TRANSITION_TX_RX (2)
#define BLE_PHY_TRANSITION_TX_TX (3)
/* PHY error codes */
#define BLE_PHY_ERR_RADIO_STATE (1)
+25 -6
View File
@@ -977,6 +977,7 @@ ble_phy_tx_end_isr(void)
uint8_t was_encrypted;
uint8_t transition;
uint32_t rx_time;
uint32_t tx_time;
/* Store PHY on which we've just transmitted smth */
tx_phy_mode = g_ble_phy_data.phy_cur_phy_mode;
@@ -1001,14 +1002,9 @@ ble_phy_tx_end_isr(void)
}
#endif
/* Call transmit end callback */
if (g_ble_phy_data.txend_cb) {
g_ble_phy_data.txend_cb(g_ble_phy_data.txend_arg);
}
transition = g_ble_phy_data.phy_transition;
if (transition == BLE_PHY_TRANSITION_TX_RX) {
if (transition == BLE_PHY_TRANSITION_TX_RX) {
#if (BLE_LL_BT5_PHY_SUPPORTED == 1)
ble_phy_mode_apply(g_ble_phy_data.phy_rx_phy_mode);
#endif
@@ -1032,6 +1028,25 @@ ble_phy_tx_end_isr(void)
nrf_ppi_channels_enable(NRF_PPI, PPI_CHEN_CH21_Msk);
ble_phy_plna_enable_lna();
} else if (transition == BLE_PHY_TRANSITION_TX_TX) {
/* Schedule TX exactly T_IFS after TX end captured in CC[2] */
tx_time = NRF_TIMER0->CC[2] + BLE_LL_IFS;
/* Adjust for delay between EVENT_END and actual TX end time */
tx_time += g_ble_phy_t_txenddelay[tx_phy_mode];
/* Adjust for radio ramp-up */
tx_time -= BLE_PHY_T_TXENFAST;
/* 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];
nrf_timer_cc_set(NRF_TIMER0, 0, tx_time);
NRF_TIMER0->EVENTS_COMPARE[0] = 0;
nrf_ppi_channels_enable(NRF_PPI, PPI_CHEN_CH20_Msk);
nrf_timer_task_trigger(NRF_TIMER0, NRF_TIMER_TASK_CAPTURE3);
if (NRF_TIMER0->CC[3] > NRF_TIMER0->CC[0]) {
nrf_ppi_channels_disable(NRF_PPI, PPI_CHEN_CH20_Msk);
g_ble_phy_data.phy_transition_late = 1;
}
} else {
/*
* XXX: not sure we need to stop the timer here all the time. Or that
@@ -1043,6 +1058,10 @@ ble_phy_tx_end_isr(void)
PPI_CHEN_CH20_Msk | PPI_CHEN_CH31_Msk);
assert(transition == BLE_PHY_TRANSITION_NONE);
}
if (g_ble_phy_data.txend_cb) {
g_ble_phy_data.txend_cb(g_ble_phy_data.txend_arg);
}
}
static inline uint8_t