Skip to content
Permalink
Browse files

Bluetooth: controller: split: Fix continuous initiator

Fix the implementation of initiator to use correct anchor
tick and remainder microseconds when sending out CONNECT_REQ
PDU and then to scheduling the first connection event. This
is a fix when initiator is in continuous scan.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information...
cvinayak authored and carlescufi committed Jul 8, 2019
1 parent 479edc9 commit 8401fda961dca2103988421b64ac94356c476512
@@ -12,6 +12,7 @@
#include "util/mem.h"
#include "hal/ccm.h"
#include "hal/radio.h"
#include "hal/ticker.h"
#include "ll_sw/pdu.h"
#include "radio_nrf5.h"

@@ -729,6 +730,7 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
SW_SWITCH_TIMER->MODE = 0;
SW_SWITCH_TIMER->PRESCALER = 4;
SW_SWITCH_TIMER->BITMODE = 0; /* 16 bit */
/* FIXME: start alongwith EVENT_TIMER, to save power */
nrf_timer_task_trigger(SW_SWITCH_TIMER, NRF_TIMER_TASK_START);
#endif /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */

@@ -768,6 +770,34 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
return remainder;
}

u32_t radio_tmr_start_tick(u8_t trx, u32_t tick)
{
u32_t remainder_us;

nrf_timer_task_trigger(EVENT_TIMER, NRF_TIMER_TASK_STOP);
nrf_timer_task_trigger(EVENT_TIMER, NRF_TIMER_TASK_CLEAR);

/* Setup compare event with min. 1 us offset */
remainder_us = 1;
nrf_timer_cc_write(EVENT_TIMER, 0, remainder_us);

nrf_rtc_cc_set(NRF_RTC0, 2, tick);
nrf_rtc_event_enable(NRF_RTC0, RTC_EVTENSET_COMPARE2_Msk);

hal_event_timer_start_ppi_config();
nrf_ppi_channels_enable(BIT(HAL_EVENT_TIMER_START_PPI));

hal_radio_enable_on_tick_ppi_config_and_enable(trx);

#if !defined(CONFIG_BT_CTLR_TIFS_HW)
#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER)
last_pdu_end_us = 0U;
#endif /* CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */
#endif /* !CONFIG_BT_CTLR_TIFS_HW */

return remainder_us;
}

void radio_tmr_start_us(u8_t trx, u32_t us)
{
nrf_timer_cc_write(EVENT_TIMER, 0, us);
@@ -65,6 +65,7 @@ u32_t radio_bc_has_match(void);
void radio_tmr_status_reset(void);
void radio_tmr_tifs_set(u32_t tifs);
u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder);
u32_t radio_tmr_start_tick(u8_t trx, u32_t tick);
void radio_tmr_start_us(u8_t trx, u32_t us);
u32_t radio_tmr_start_now(u8_t trx);
u32_t radio_tmr_start_get(void);
@@ -48,6 +48,7 @@ static void ticker_op_start_cb(u32_t status, void *param);
static void isr_rx(void *param);
static void isr_tx(void *param);
static void isr_done(void *param);
static void isr_window(void *param);
static void isr_abort(void *param);
static void isr_cleanup(void *param);
static void isr_race(void *param);
@@ -289,7 +290,7 @@ static int is_abort_cb(void *next, int prio, void *curr,
return -EAGAIN;
}

radio_isr_set(isr_done, lll);
radio_isr_set(isr_window, lll);
radio_disable();

if (++lll->chan == 3U) {
@@ -467,10 +468,9 @@ static void isr_tx(void *param)
#endif /* CONFIG_BT_CTLR_GPIO_LNA_PIN */
}

static void isr_done(void *param)
static void isr_common_done(void *param)
{
struct node_rx_pdu *node_rx;
u32_t start_us;

/* TODO: MOVE to a common interface, isr_lll_radio_status? */
/* Clear radio status and events */
@@ -503,6 +503,13 @@ static void isr_done(void *param)
#endif /* CONFIG_BT_CTLR_PRIVACY */

radio_isr_set(isr_rx, param);
}

static void isr_done(void *param)
{
u32_t start_us;

isr_common_done(param);

#if defined(CONFIG_BT_CTLR_GPIO_LNA_PIN)
start_us = radio_tmr_start_now(0);
@@ -523,6 +530,31 @@ static void isr_done(void *param)
radio_tmr_end_capture();
}

static void isr_window(void *param)
{
u32_t ticks_at_start, remainder_us;

isr_common_done(param);

ticks_at_start = ticker_ticks_now_get() +
HAL_TICKER_CNTR_CMP_OFFSET_MIN;
remainder_us = radio_tmr_start_tick(0, ticks_at_start);

/* capture end of Rx-ed PDU, for initiator to calculate first
* master event.
*/
radio_tmr_end_capture();

#if defined(CONFIG_BT_CTLR_GPIO_LNA_PIN)
radio_gpio_lna_setup();
radio_gpio_pa_lna_enable(remainder_us +
radio_rx_ready_delay_get(0, 0) -
CONFIG_BT_CTLR_GPIO_LNA_OFFSET);
#else /* !CONFIG_BT_CTLR_GPIO_LNA_PIN */
ARG_UNUSED(remainder_us);
#endif /* !CONFIG_BT_CTLR_GPIO_LNA_PIN */
}

static void isr_abort(void *param)
{
/* Scanner stop can expire while here in this ISR.

0 comments on commit 8401fda

Please sign in to comment.
You can’t perform that action at this time.