From 1dc847011b35019e5eb283aa1ae8c6f1a1d05199 Mon Sep 17 00:00:00 2001 From: Florian Grandel Date: Fri, 10 May 2024 16:34:23 +0200 Subject: [PATCH] samples: bluetooth: central_iso: phase configuration 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 --- samples/bluetooth/central_iso/src/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/samples/bluetooth/central_iso/src/main.c b/samples/bluetooth/central_iso/src/main.c index ba6c44d8f2ec046..e4e862cda7654ef 100644 --- a/samples/bluetooth/central_iso/src/main.c +++ b/samples/bluetooth/central_iso/src/main.c @@ -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; @@ -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;