Skip to content

Commit

Permalink
samples: bluetooth: central_iso: phase configuration
Browse files Browse the repository at this point in the history
Demonstrates fine tuning of the offset between the "measurement" (i.e.
production and scheduling of ISO SDUs) and the actual sending of the
corresponding PHY frames on the air interface to minimize latency.

Signed-off-by: Florian Grandel <[email protected]>
  • Loading branch information
Florian Grandel committed May 11, 2024
1 parent 6e5ff59 commit 1dc8470
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion samples/bluetooth/central_iso/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
#define LATENCY_MS 10U /* 10.0 ms */
#define INTERVAL_US (10U * USEC_PER_MSEC) /* 10.0 ms */

/* This is the time it takes to process a measurement inside the controller stack
* before it will be sent over the air.
*/
#define HCI_PROCESSING_OFFSET_US 2500U /* 2.5 ms */

static void start_scan(void);

static struct bt_conn *default_conn;
Expand Down Expand Up @@ -101,7 +106,7 @@ static void iso_timer_timeout(struct k_timer *timer)
* delivered with minimal latency and w/o accruing rounding errors.
*/
next_tick = first_tick +
(((int64_t)seq_num * INTERVAL_US) *
(((int64_t)(seq_num + 1U) * INTERVAL_US - HCI_PROCESSING_OFFSET_US) *
CONFIG_SYS_CLOCK_TICKS_PER_SEC) /
USEC_PER_SEC -
cur_tick;
Expand Down

0 comments on commit 1dc8470

Please sign in to comment.