Skip to content

Commit 35a5603

Browse files
sada45sjanc
authored andcommitted
nimble/ll: Adjust start time of the first anchor point of connection
Set the start_time of the first anchor point of new connection to entry->end_time+1. For the 32768 Hz crystal in nrf chip, 1 tick is 30.517us. The connection state machine use anchor point to store the cpu ticks and anchor_point_usec to store the remainder. Therefore, to compensate the inaccuracy of the crystal, the ticks of anchor_point will be add with 1 once the value of anchor_point_usec exceed 31. If two connections have same connection interval, the time difference between the two start of schedule item will decreased 1, which lead to an overlap. To prevent this from happenning, we set the start_time of sch to 1 cpu tick after the end_time of entry.
1 parent ff51d48 commit 35a5603

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

nimble/controller/src/ble_ll_sched.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,19 @@ ble_ll_sched_insert(struct ble_ll_sched_item *sch, uint32_t max_delay,
237237
}
238238
} else {
239239
preempt_first = NULL;
240-
sch->start_time = entry->end_time;
240+
/*
241+
* For the 32768 Hz crystal in nrf chip, 1 tick is 30.517us.
242+
* The connection state machine use anchor point to store the
243+
* cpu ticks and anchor_point_usec to store the remainder.
244+
* Therefore, to compensate the inaccuracy of the crystal, the
245+
* ticks of anchor_point will be add with 1 once the value of
246+
* anchor_point_usec exceed 31. If two connections have same
247+
* connection interval, the time difference between the two
248+
* start of schedule item will decreased 1, which lead to
249+
* an overlap. To prevent this from happenning, we set the
250+
* start_time of sch to 1 cpu tick after the end_time of entry.
251+
*/
252+
sch->start_time = entry->end_time + 1;
241253

242254
if ((max_delay == 0) || CPUTIME_GEQ(sch->start_time,
243255
max_start_time)) {

0 commit comments

Comments
 (0)