Bluetooth: controller: Fix asymmetric PHY by using correct tIFS
Fix asymmetric PHY connection by using correct tIFS, considering previous PHY and next PHY chain delays while calculating the Tx and Rx tIFS. This fixes: TP/CON/SLA/BV-40-C [Initiating PHY Update Procedure] TP/CON/SLA/BV-42-C [Responding to PHY Update Procedure] TP/CON/MAS/BV-41-C [Initiating PHY Update Procedure] TP/CON/MAS/BV-43-C [Responding to PHY Update Procedure] conformance tests in LL.TS.5.0.0. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
df5deea218
commit
21935f7dd6
3 changed files with 35 additions and 30 deletions
|
@ -424,9 +424,11 @@ void *radio_pkt_scratch_get(void)
|
|||
#if !defined(CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW)
|
||||
static u8_t sw_tifs_toggle;
|
||||
|
||||
static void sw_switch(u8_t dir, u8_t phy, u8_t flags)
|
||||
static void sw_switch(u8_t dir, u8_t phy_curr, u8_t flags_curr, u8_t phy_next,
|
||||
u8_t flags_next)
|
||||
{
|
||||
u8_t ppi = 12 + sw_tifs_toggle;
|
||||
u32_t delay;
|
||||
|
||||
NRF_TIMER1->EVENTS_COMPARE[sw_tifs_toggle] = 0;
|
||||
|
||||
|
@ -436,26 +438,24 @@ static void sw_switch(u8_t dir, u8_t phy, u8_t flags)
|
|||
NRF_PPI->CH[ppi].EEP = (u32_t)
|
||||
&(NRF_TIMER1->EVENTS_COMPARE[sw_tifs_toggle]);
|
||||
if (dir) {
|
||||
u32_t delay = radio_tx_ready_delay_get(phy, flags) +
|
||||
radio_rx_chain_delay_get(phy, flags);
|
||||
delay = radio_tx_ready_delay_get(phy_next, flags_next) +
|
||||
radio_rx_chain_delay_get(phy_curr, flags_curr);
|
||||
|
||||
if (delay < NRF_TIMER1->CC[sw_tifs_toggle]) {
|
||||
NRF_TIMER1->CC[sw_tifs_toggle] -= delay;
|
||||
} else {
|
||||
NRF_TIMER1->CC[sw_tifs_toggle] = 1;
|
||||
}
|
||||
NRF_PPI->CH[ppi].TEP = (u32_t)&(NRF_RADIO->TASKS_TXEN);
|
||||
} else {
|
||||
u32_t delay = radio_rx_ready_delay_get(phy);
|
||||
delay = radio_rx_ready_delay_get(phy_next) -
|
||||
radio_tx_chain_delay_get(phy_curr, flags_curr) +
|
||||
4; /* 4us as +/- active jitter */
|
||||
|
||||
if (delay < NRF_TIMER1->CC[sw_tifs_toggle]) {
|
||||
NRF_TIMER1->CC[sw_tifs_toggle] -= delay;
|
||||
} else {
|
||||
NRF_TIMER1->CC[sw_tifs_toggle] = 1;
|
||||
}
|
||||
NRF_PPI->CH[ppi].TEP = (u32_t)&(NRF_RADIO->TASKS_RXEN);
|
||||
}
|
||||
|
||||
if (delay < NRF_TIMER1->CC[sw_tifs_toggle]) {
|
||||
NRF_TIMER1->CC[sw_tifs_toggle] -= delay;
|
||||
} else {
|
||||
NRF_TIMER1->CC[sw_tifs_toggle] = 1;
|
||||
}
|
||||
|
||||
NRF_PPI->CHENSET = PPI_CHEN_CH8_Msk | PPI_CHEN_CH11_Msk;
|
||||
|
||||
sw_tifs_toggle += 1;
|
||||
|
@ -463,7 +463,7 @@ static void sw_switch(u8_t dir, u8_t phy, u8_t flags)
|
|||
}
|
||||
#endif /* CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW */
|
||||
|
||||
void radio_switch_complete_and_rx(u8_t phy)
|
||||
void radio_switch_complete_and_rx(u8_t phy_rx)
|
||||
{
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW)
|
||||
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk |
|
||||
|
@ -472,11 +472,12 @@ void radio_switch_complete_and_rx(u8_t phy)
|
|||
#else /* !CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW */
|
||||
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk |
|
||||
RADIO_SHORTS_END_DISABLE_Msk;
|
||||
sw_switch(0, phy, 0);
|
||||
sw_switch(0, 0, 0, phy_rx, 0);
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW */
|
||||
}
|
||||
|
||||
void radio_switch_complete_and_tx(u8_t phy, u8_t flags)
|
||||
void radio_switch_complete_and_tx(u8_t phy_rx, u8_t flags_rx, u8_t phy_tx,
|
||||
u8_t flags_tx)
|
||||
{
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW)
|
||||
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk |
|
||||
|
@ -485,7 +486,7 @@ void radio_switch_complete_and_tx(u8_t phy, u8_t flags)
|
|||
#else /* !CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW */
|
||||
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk |
|
||||
RADIO_SHORTS_END_DISABLE_Msk;
|
||||
sw_switch(1, phy, flags);
|
||||
sw_switch(1, phy_rx, flags_rx, phy_tx, flags_tx);
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_TIFS_HW */
|
||||
}
|
||||
|
||||
|
|
|
@ -42,8 +42,9 @@ u32_t radio_crc_is_valid(void);
|
|||
void *radio_pkt_empty_get(void);
|
||||
void *radio_pkt_scratch_get(void);
|
||||
|
||||
void radio_switch_complete_and_rx(u8_t phy);
|
||||
void radio_switch_complete_and_tx(u8_t phy, u8_t flags);
|
||||
void radio_switch_complete_and_rx(u8_t phy_rx);
|
||||
void radio_switch_complete_and_tx(u8_t phy_rx, u8_t flags_rx, u8_t phy_tx,
|
||||
u8_t flags_tx);
|
||||
void radio_switch_complete_and_disable(void);
|
||||
|
||||
void radio_rssi_measure(void);
|
||||
|
|
|
@ -580,7 +580,7 @@ static inline void isr_radio_state_tx(void)
|
|||
|
||||
switch (_radio.role) {
|
||||
case ROLE_ADV:
|
||||
radio_switch_complete_and_tx(0, 0);
|
||||
radio_switch_complete_and_tx(0, 0, 0, 0);
|
||||
radio_pkt_rx_set(radio_pkt_scratch_get());
|
||||
|
||||
/* assert if radio packet ptr is not set and radio started rx */
|
||||
|
@ -608,7 +608,7 @@ static inline void isr_radio_state_tx(void)
|
|||
break;
|
||||
|
||||
case ROLE_SCAN:
|
||||
radio_switch_complete_and_tx(0, 0);
|
||||
radio_switch_complete_and_tx(0, 0, 0, 0);
|
||||
radio_pkt_rx_set(_radio.packet_rx[_radio.packet_rx_last]->
|
||||
pdu_data);
|
||||
|
||||
|
@ -637,10 +637,11 @@ static inline void isr_radio_state_tx(void)
|
|||
case ROLE_SLAVE:
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PHY)
|
||||
radio_switch_complete_and_tx(_radio.conn_curr->phy_tx,
|
||||
radio_switch_complete_and_tx(_radio.conn_curr->phy_rx, 0,
|
||||
_radio.conn_curr->phy_tx,
|
||||
_radio.conn_curr->phy_flags);
|
||||
#else /* !CONFIG_BLUETOOTH_CONTROLLER_PHY */
|
||||
radio_switch_complete_and_tx(0, 0);
|
||||
radio_switch_complete_and_tx(0, 0, 0, 0);
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_PHY */
|
||||
|
||||
rx_packet_set(_radio.conn_curr, (struct pdu_data *)_radio.
|
||||
|
@ -3095,7 +3096,7 @@ static inline u32_t isr_close_scan(void)
|
|||
dont_close = 1;
|
||||
|
||||
radio_tmr_tifs_set(RADIO_TIFS);
|
||||
radio_switch_complete_and_tx(0, 0);
|
||||
radio_switch_complete_and_tx(0, 0, 0, 0);
|
||||
radio_pkt_rx_set(_radio.packet_rx[_radio.packet_rx_last]->
|
||||
pdu_data);
|
||||
radio_rssi_measure();
|
||||
|
@ -5334,7 +5335,7 @@ static void event_scan(u32_t ticks_at_expire, u32_t remainder, u16_t lazy,
|
|||
}
|
||||
|
||||
radio_tmr_tifs_set(RADIO_TIFS);
|
||||
radio_switch_complete_and_tx(0, 0);
|
||||
radio_switch_complete_and_tx(0, 0, 0, 0);
|
||||
radio_pkt_rx_set(_radio.packet_rx[_radio.packet_rx_last]->pdu_data);
|
||||
radio_rssi_measure();
|
||||
|
||||
|
@ -6888,9 +6889,10 @@ static void event_slave(u32_t ticks_at_expire, u32_t remainder, u16_t lazy,
|
|||
radio_tmr_tifs_set(RADIO_TIFS);
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PHY)
|
||||
radio_switch_complete_and_tx(conn->phy_tx, conn->phy_flags);
|
||||
radio_switch_complete_and_tx(conn->phy_rx, 0, conn->phy_tx,
|
||||
conn->phy_flags);
|
||||
#else /* !CONFIG_BLUETOOTH_CONTROLLER_PHY */
|
||||
radio_switch_complete_and_tx(0, 0);
|
||||
radio_switch_complete_and_tx(0, 0, 0, 0);
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_PHY */
|
||||
|
||||
rx_packet_set(conn, (struct pdu_data *)
|
||||
|
@ -7090,9 +7092,10 @@ static void event_master(u32_t ticks_at_expire, u32_t remainder, u16_t lazy,
|
|||
radio_tmr_tifs_set(RADIO_TIFS);
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_CONTROLLER_PHY)
|
||||
radio_switch_complete_and_tx(conn->phy_tx, conn->phy_flags);
|
||||
radio_switch_complete_and_tx(conn->phy_rx, 0, conn->phy_tx,
|
||||
conn->phy_flags);
|
||||
#else /* !CONFIG_BLUETOOTH_CONTROLLER_PHY */
|
||||
radio_switch_complete_and_tx(0, 0);
|
||||
radio_switch_complete_and_tx(0, 0, 0, 0);
|
||||
#endif /* !CONFIG_BLUETOOTH_CONTROLLER_PHY */
|
||||
|
||||
rx_packet_set(conn, (struct pdu_data *)_radio.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue