20#ifndef H_BLE_LL_SCHED_
21#define H_BLE_LL_SCHED_
28#define BLE_LL_SCHED_USECS_PER_SLOT (1250)
45#define BLE_LL_SCHED_ADV_MAX_USECS (852)
46#define BLE_LL_SCHED_DIRECT_ADV_MAX_USECS (502)
47#define BLE_LL_SCHED_MAX_ADV_PDU_USECS (376)
53extern uint8_t g_ble_ll_sched_offset_ticks;
60#define BLE_LL_SCHED_MAX_TXRX_SLOT (4 * BLE_LL_SCHED_USECS_PER_SLOT)
63#define BLE_LL_SCHED_ERR_OVERLAP (1)
66#define BLE_LL_SCHED_TYPE_ADV (1)
67#define BLE_LL_SCHED_TYPE_SCAN (2)
68#define BLE_LL_SCHED_TYPE_CONN (3)
69#define BLE_LL_SCHED_TYPE_DTM (5)
70#define BLE_LL_SCHED_TYPE_PERIODIC (6)
71#define BLE_LL_SCHED_TYPE_SYNC (7)
72#define BLE_LL_SCHED_TYPE_SCAN_AUX (8)
75#define BLE_LL_SCHED_STATE_RUNNING (0)
76#define BLE_LL_SCHED_STATE_DONE (1)
79struct ble_ll_sched_item;
80typedef int (*sched_cb_func)(
struct ble_ll_sched_item *sch);
81typedef void (*sched_remove_cb_func)(
struct ble_ll_sched_item *sch);
91struct ble_ll_sched_item
99 sched_cb_func sched_cb;
100 TAILQ_ENTRY(ble_ll_sched_item) link;
104int ble_ll_sched_init(
void);
107int ble_ll_sched_rmv_elem(
struct ble_ll_sched_item *sch);
109void ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb);
112struct ble_ll_conn_sm;
113int ble_ll_sched_conn_central_new(
struct ble_ll_conn_sm *connsm,
114 struct ble_mbuf_hdr *ble_hdr, uint8_t pyld_len);
117int ble_ll_sched_conn_periph_new(
struct ble_ll_conn_sm *connsm);
120typedef void ble_ll_sched_adv_new_cb(
struct ble_ll_adv_sm *advsm,
121 uint32_t sch_start,
void *arg);
124int ble_ll_sched_adv_new(
struct ble_ll_sched_item *sch,
125 ble_ll_sched_adv_new_cb cb,
void *arg);
128int ble_ll_sched_periodic_adv(
struct ble_ll_sched_item *sch,
bool first_event);
130int ble_ll_sched_sync_reschedule(
struct ble_ll_sched_item *sch,
131 uint32_t anchor_point,
132 uint8_t anchor_point_usecs,
133 uint32_t window_widening, int8_t phy_mode);
134int ble_ll_sched_sync(
struct ble_ll_sched_item *sch,
135 uint32_t beg_cputime, uint32_t rem_usecs, uint32_t offset,
139int ble_ll_sched_adv_reschedule(
struct ble_ll_sched_item *sch,
140 uint32_t max_delay_ticks);
143int ble_ll_sched_adv_resched_pdu(
struct ble_ll_sched_item *sch);
146int ble_ll_sched_conn_reschedule(
struct ble_ll_conn_sm * connsm);
158int ble_ll_sched_next_time(uint32_t *next_event_time);
160#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
161struct ble_ll_scan_sm;
162struct ble_ll_aux_data;
163int ble_ll_sched_aux_scan(
struct ble_mbuf_hdr *ble_hdr,
164 struct ble_ll_scan_sm *scansm,
165 struct ble_ll_aux_data *aux_scan);
167int ble_ll_sched_scan_aux(
struct ble_ll_sched_item *sch, uint32_t pdu_time,
168 uint8_t pdu_time_rem, uint32_t offset_us);
172void ble_ll_sched_stop(
void);
174#if MYNEWT_VAL(BLE_LL_DTM)
175int ble_ll_sched_dtm(
struct ble_ll_sched_item *sch);
178#if MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED)
179#if !MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
180void ble_ll_sched_css_set_params(uint32_t slot_us, uint32_t period_slots);
182void ble_ll_sched_css_set_conn_anchor(
struct ble_ll_conn_sm *connsm);
183#if MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_FIXED)
184static inline uint32_t
185ble_ll_sched_css_get_slot_us(
void)
187 return MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_SLOT_US);
190static inline uint32_t
191ble_ll_sched_css_get_period_slots(
void)
193 return MYNEWT_VAL(BLE_LL_CONN_STRICT_SCHED_PERIOD_SLOTS);
196static inline uint32_t
197ble_ll_sched_css_get_conn_interval_us(
void)
199 return ble_ll_sched_css_get_period_slots() *
200 ble_ll_sched_css_get_slot_us() / 1250;
203uint32_t ble_ll_sched_css_get_slot_us(
void);
204uint32_t ble_ll_sched_css_get_period_slots(
void);
205uint32_t ble_ll_sched_css_get_conn_interval_us(
void);