Bluetooth: controller: Use single PPI channel for AA capture
Earlier design captured AA twice in the first Rx in a slave connection event and retained one of the capture until end of event to calculate drift. Design updated to use single capture of AA and save the first AA capture in a slave connection event in RAM instead. This frees up a PPI channel in the controller design. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
3cd37866cc
commit
74cd8d852e
3 changed files with 44 additions and 18 deletions
|
@ -644,7 +644,7 @@ void radio_tmr_status_reset(void)
|
|||
NRF_PPI->CHENCLR =
|
||||
(PPI_CHEN_CH0_Msk | PPI_CHEN_CH1_Msk | PPI_CHEN_CH2_Msk |
|
||||
PPI_CHEN_CH3_Msk | PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk |
|
||||
PPI_CHEN_CH6_Msk | PPI_CHEN_CH7_Msk);
|
||||
PPI_CHEN_CH6_Msk);
|
||||
}
|
||||
|
||||
void radio_tmr_tifs_set(u32_t tifs)
|
||||
|
@ -732,14 +732,14 @@ void radio_tmr_stop(void)
|
|||
|
||||
void radio_tmr_hcto_configure(u32_t hcto)
|
||||
{
|
||||
NRF_TIMER0->CC[2] = hcto;
|
||||
NRF_TIMER0->EVENTS_COMPARE[2] = 0;
|
||||
NRF_TIMER0->CC[1] = hcto;
|
||||
NRF_TIMER0->EVENTS_COMPARE[1] = 0;
|
||||
|
||||
NRF_PPI->CH[4].EEP = (u32_t)&(NRF_RADIO->EVENTS_ADDRESS);
|
||||
NRF_PPI->CH[4].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[2]);
|
||||
NRF_PPI->CH[5].EEP = (u32_t)&(NRF_TIMER0->EVENTS_COMPARE[2]);
|
||||
NRF_PPI->CH[5].TEP = (u32_t)&(NRF_RADIO->TASKS_DISABLE);
|
||||
NRF_PPI->CHENSET = (PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk);
|
||||
NRF_PPI->CH[3].EEP = (u32_t)&(NRF_RADIO->EVENTS_ADDRESS);
|
||||
NRF_PPI->CH[3].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[1]);
|
||||
NRF_PPI->CH[4].EEP = (u32_t)&(NRF_TIMER0->EVENTS_COMPARE[1]);
|
||||
NRF_PPI->CH[4].TEP = (u32_t)&(NRF_RADIO->TASKS_DISABLE);
|
||||
NRF_PPI->CHENSET = (PPI_CHEN_CH3_Msk | PPI_CHEN_CH4_Msk);
|
||||
}
|
||||
|
||||
void radio_tmr_aa_capture(void)
|
||||
|
@ -751,21 +751,34 @@ void radio_tmr_aa_capture(void)
|
|||
NRF_PPI->CHENSET = (PPI_CHEN_CH2_Msk | PPI_CHEN_CH3_Msk);
|
||||
}
|
||||
|
||||
u32_t radio_tmr_aa_get(void)
|
||||
{
|
||||
return NRF_TIMER0->CC[1];
|
||||
}
|
||||
|
||||
static u32_t radio_tmr_aa;
|
||||
|
||||
void radio_tmr_aa_save(u32_t aa)
|
||||
{
|
||||
radio_tmr_aa = aa;
|
||||
}
|
||||
|
||||
u32_t radio_tmr_aa_restore(void)
|
||||
{
|
||||
/* NOTE: we dont need to restore for now, but return the saved value. */
|
||||
return radio_tmr_aa;
|
||||
}
|
||||
|
||||
u32_t radio_tmr_ready_get(void)
|
||||
{
|
||||
return NRF_TIMER0->CC[0];
|
||||
}
|
||||
|
||||
u32_t radio_tmr_aa_get(void)
|
||||
{
|
||||
return (NRF_TIMER0->CC[1] - NRF_TIMER0->CC[0]);
|
||||
}
|
||||
|
||||
void radio_tmr_end_capture(void)
|
||||
{
|
||||
NRF_PPI->CH[7].EEP = (u32_t)&(NRF_RADIO->EVENTS_END);
|
||||
NRF_PPI->CH[7].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[2]);
|
||||
NRF_PPI->CHENSET = PPI_CHEN_CH7_Msk;
|
||||
NRF_PPI->CH[5].EEP = (u32_t)&(NRF_RADIO->EVENTS_END);
|
||||
NRF_PPI->CH[5].TEP = (u32_t)&(NRF_TIMER0->TASKS_CAPTURE[2]);
|
||||
NRF_PPI->CHENSET = PPI_CHEN_CH5_Msk;
|
||||
}
|
||||
|
||||
u32_t radio_tmr_end_get(void)
|
||||
|
|
|
@ -71,8 +71,10 @@ void radio_tmr_start_us(u8_t trx, u32_t us);
|
|||
void radio_tmr_stop(void);
|
||||
void radio_tmr_hcto_configure(u32_t hcto);
|
||||
void radio_tmr_aa_capture(void);
|
||||
u32_t radio_tmr_ready_get(void);
|
||||
u32_t radio_tmr_aa_get(void);
|
||||
void radio_tmr_aa_save(u32_t aa);
|
||||
u32_t radio_tmr_aa_restore(void);
|
||||
u32_t radio_tmr_ready_get(void);
|
||||
void radio_tmr_end_capture(void);
|
||||
u32_t radio_tmr_end_get(void);
|
||||
void radio_tmr_sample(void);
|
||||
|
|
|
@ -3374,6 +3374,11 @@ static inline void isr_rx_conn(u8_t crc_ok, u8_t trx_done,
|
|||
|
||||
isr_rx_conn_exit:
|
||||
|
||||
/* Save the AA captured for the first Rx in connection event */
|
||||
if (!radio_tmr_aa_restore()) {
|
||||
radio_tmr_aa_save(radio_tmr_aa_get());
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_PROFILE_ISR)
|
||||
/* get the ISR latency sample */
|
||||
sample = radio_tmr_sample_get();
|
||||
|
@ -3707,7 +3712,8 @@ static inline void isr_close_conn(void)
|
|||
u32_t preamble_to_addr_us;
|
||||
|
||||
/* calculate the drift in ticks */
|
||||
start_to_address_actual_us = radio_tmr_aa_get();
|
||||
start_to_address_actual_us = radio_tmr_aa_restore() -
|
||||
radio_tmr_ready_get();
|
||||
window_widening_event_us =
|
||||
_radio.conn_curr->slave.window_widening_event_us;
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
|
@ -7828,7 +7834,10 @@ static void event_slave(u32_t ticks_at_expire, u32_t remainder, u16_t lazy,
|
|||
radio_tmr_start(0, ticks_at_expire +
|
||||
TICKER_US_TO_TICKS(RADIO_TICKER_START_PART_US),
|
||||
_radio.remainder_anchor);
|
||||
|
||||
radio_tmr_aa_capture();
|
||||
radio_tmr_aa_save(0);
|
||||
|
||||
hcto = remainder_us + RADIO_TICKER_JITTER_US +
|
||||
(RADIO_TICKER_JITTER_US << 2) +
|
||||
(conn->slave.window_widening_event_us << 1) +
|
||||
|
@ -8003,7 +8012,9 @@ static void event_master(u32_t ticks_at_expire, u32_t remainder, u16_t lazy,
|
|||
radio_tmr_start(0, ticks_at_expire +
|
||||
TICKER_US_TO_TICKS(RADIO_TICKER_START_PART_US),
|
||||
_radio.remainder_anchor);
|
||||
|
||||
radio_tmr_aa_capture();
|
||||
radio_tmr_aa_save(0);
|
||||
|
||||
hcto = remainder_us + RADIO_TIFS;
|
||||
#if defined(CONFIG_BT_CTLR_PHY)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue