mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-19 15:39:53 +00:00
nimble/phy/nrf5x: Fix variable tifs
We need to first read current tifs, the reset it to default value, otherwise handlers will always use default tifs value.
This commit is contained in:
@@ -590,23 +590,11 @@ nrf_wait_disabled(void)
|
||||
}
|
||||
|
||||
#if MYNEWT_VAL(BLE_PHY_VARIABLE_TIFS)
|
||||
static uint16_t
|
||||
ble_phy_tifs_get(void)
|
||||
{
|
||||
return g_ble_phy_data.tifs;
|
||||
}
|
||||
|
||||
void
|
||||
ble_phy_tifs_set(uint16_t tifs)
|
||||
{
|
||||
g_ble_phy_data.tifs = tifs;
|
||||
}
|
||||
#else
|
||||
static uint16_t
|
||||
ble_phy_tifs_get(void)
|
||||
{
|
||||
return BLE_LL_IFS;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -831,12 +819,19 @@ ble_phy_wfr_enable(int txrx, uint8_t tx_phy_mode, uint32_t wfr_usecs)
|
||||
{
|
||||
uint32_t end_time;
|
||||
uint8_t phy;
|
||||
uint16_t tifs;
|
||||
|
||||
phy = g_ble_phy_data.phy_cur_phy_mode;
|
||||
|
||||
#if MYNEWT_VAL(BLE_PHY_VARIABLE_TIFS)
|
||||
tifs = g_ble_phy_data.tifs;
|
||||
#else
|
||||
tifs = BLE_LL_IFS;
|
||||
#endif
|
||||
|
||||
if (txrx == BLE_PHY_WFR_ENABLE_TXRX) {
|
||||
/* RX shall start exactly T_IFS after TX end captured in CC[2] */
|
||||
end_time = NRF_TIMER0->CC[2] + ble_phy_tifs_get();
|
||||
end_time = NRF_TIMER0->CC[2] + tifs;
|
||||
/* Adjust for delay between EVENT_END and actual TX end time */
|
||||
end_time += g_ble_phy_t_txenddelay[tx_phy_mode];
|
||||
/* Wait a bit longer due to allowed active clock accuracy */
|
||||
@@ -1023,6 +1018,7 @@ ble_phy_tx_end_isr(void)
|
||||
uint32_t fem_time;
|
||||
#endif
|
||||
uint32_t radio_time;
|
||||
uint16_t tifs;
|
||||
|
||||
/* Store PHY on which we've just transmitted smth */
|
||||
tx_phy_mode = g_ble_phy_data.phy_cur_phy_mode;
|
||||
@@ -1047,6 +1043,12 @@ ble_phy_tx_end_isr(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MYNEWT_VAL(BLE_PHY_VARIABLE_TIFS)
|
||||
tifs = g_ble_phy_data.tifs;
|
||||
g_ble_phy_data.tifs = BLE_LL_IFS;
|
||||
#else
|
||||
tifs = BLE_LL_IFS;
|
||||
#endif
|
||||
transition = g_ble_phy_data.phy_transition;
|
||||
|
||||
if (g_ble_phy_data.txend_cb) {
|
||||
@@ -1064,7 +1066,7 @@ ble_phy_tx_end_isr(void)
|
||||
ble_phy_wfr_enable(BLE_PHY_WFR_ENABLE_TXRX, tx_phy_mode, 0);
|
||||
|
||||
/* Schedule RX exactly T_IFS after TX end captured in CC[2] */
|
||||
rx_time = NRF_TIMER0->CC[2] + ble_phy_tifs_get();
|
||||
rx_time = NRF_TIMER0->CC[2] + tifs;
|
||||
/* Adjust for delay between EVENT_END and actual TX end time */
|
||||
rx_time += g_ble_phy_t_txenddelay[tx_phy_mode];
|
||||
/* Start listening a bit earlier due to allowed active clock accuracy */
|
||||
@@ -1091,7 +1093,7 @@ ble_phy_tx_end_isr(void)
|
||||
*/
|
||||
} 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_phy_tifs_get();
|
||||
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];
|
||||
/* Adjust for delay between EVENT_READY and actual TX start time */
|
||||
@@ -1159,6 +1161,7 @@ ble_phy_rx_end_isr(void)
|
||||
uint32_t fem_time;
|
||||
#endif
|
||||
uint32_t radio_time;
|
||||
uint16_t tifs;
|
||||
struct ble_mbuf_hdr *ble_hdr;
|
||||
bool is_late;
|
||||
|
||||
@@ -1223,8 +1226,15 @@ ble_phy_rx_end_isr(void)
|
||||
* enough.
|
||||
*/
|
||||
|
||||
#if MYNEWT_VAL(BLE_PHY_VARIABLE_TIFS)
|
||||
tifs = g_ble_phy_data.tifs;
|
||||
g_ble_phy_data.tifs = BLE_LL_IFS;
|
||||
#else
|
||||
tifs = BLE_LL_IFS;
|
||||
#endif
|
||||
|
||||
/* Schedule TX exactly T_IFS after RX end captured in CC[2] */
|
||||
tx_time = NRF_TIMER0->CC[2] + ble_phy_tifs_get();
|
||||
tx_time = NRF_TIMER0->CC[2] + tifs;
|
||||
/* Adjust for delay between actual RX end time and EVENT_END */
|
||||
tx_time -= g_ble_phy_t_rxenddelay[ble_hdr->rxinfo.phy_mode];
|
||||
|
||||
@@ -1449,10 +1459,6 @@ ble_phy_isr(void)
|
||||
NRF_RADIO->EVENTS_DISABLED = 0;
|
||||
nrf_radio_int_disable(NRF_RADIO, RADIO_INTENCLR_DISABLED_Msk);
|
||||
|
||||
#if MYNEWT_VAL(BLE_PHY_VARIABLE_TIFS)
|
||||
g_ble_phy_data.tifs = BLE_LL_IFS;
|
||||
#endif
|
||||
|
||||
switch (g_ble_phy_data.phy_state) {
|
||||
case BLE_PHY_STATE_RX:
|
||||
#if MYNEWT_VAL(BLE_FEM_LNA)
|
||||
|
||||
Reference in New Issue
Block a user