diff --git a/samples/bluetooth/iso_time_sync/README.rst b/samples/bluetooth/iso_time_sync/README.rst index f4f35afb4d4..658c9f9260b 100644 --- a/samples/bluetooth/iso_time_sync/README.rst +++ b/samples/bluetooth/iso_time_sync/README.rst @@ -40,15 +40,15 @@ The sample demonstrates the following features: .. group-tab:: nRF52 and nRF53 DKs This sample configures a single device as a transmitter of its **Button 1** state. - The transmitting and receiving devices toggle **LED 1** synchronously with the accuracy of a few microseconds. - When the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 2** is toggled upon sending or receiving data. + The transmitting and receiving devices toggle **LED 2** synchronously with the accuracy of a few microseconds. + When the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 1** is toggled upon sending or receiving data. This allows you to measure the minimal end-to-end latency. .. group-tab:: nRF54 DKs This sample configures a single device as a transmitter of its **Button 0** state. - The transmitting and receiving devices toggle **LED 0** synchronously with the accuracy of a few microseconds. - When the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 1** is toggled upon sending or receiving data. + The transmitting and receiving devices toggle **LED 1** synchronously with the accuracy of a few microseconds. + When the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 0** is toggled upon sending or receiving data. This allows you to measure the minimal end-to-end latency. .. note:: @@ -69,7 +69,7 @@ Check and configure the following Kconfig options: .. _CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE: CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE - This configuration option enables immediate toggling of **LED 2** (nRF52 and nRF53 DKs) or **LED 1** (nRF54 DKs) when isochronous data is sent or received. + This configuration option enables immediate toggling of **LED 1** (nRF52 and nRF53 DKs) or **LED 0** (nRF54 DKs) when isochronous data is sent or received. It allows for measurement of the minimum end-to-end latency. .. _CONFIG_SDU_INTERVAL_US: @@ -180,9 +180,9 @@ The sample code is divided into multiple source files, which makes it easier to When a valid SDU is received, the following operations are performed: - * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 2** is toggled immediately. + * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 1** is toggled immediately. You can use this to observe that different receivers may receive the SDU at different points in time. - * A timer trigger is configured to toggle **LED 1** :ref:`CONFIG_TIMED_LED_PRESENTATION_DELAY_US ` after the received timestamp. + * A timer trigger is configured to toggle **LED 2** :ref:`CONFIG_TIMED_LED_PRESENTATION_DELAY_US ` after the received timestamp. This ensures that all receivers and the transmitter toggle it at the same time. ``iso_tx.c`` @@ -195,9 +195,9 @@ The sample code is divided into multiple source files, which makes it easier to * The SDU is transmitted on all the established isochronous channels with the same timestamp. This ensures that all the receivers can toggle their corresponding LEDs at the same time. The very first SDU is provided without a timestamp, because the timestamp is not known at this point in time. - * **LED 1** is configured to toggle synchronously with the **LED 1** on all the receivers. + * **LED 2** is configured to toggle synchronously with the **LED 2** on all the receivers. The toggle time is determined by the TX timestamp and defined relative to the synchronization reference on the receiver. - * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 2** is toggled right before sending the SDU. + * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 1** is toggled right before sending the SDU. You can use this to observe the end-to-end latency. ``timed_led_toggle.c`` @@ -257,9 +257,9 @@ The sample code is divided into multiple source files, which makes it easier to When a valid SDU is received, the following operations are performed: - * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 1** is toggled immediately. + * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 0** is toggled immediately. You can use this to observe that different receivers may receive the SDU at different points in time. - * A timer trigger is configured to toggle **LED 0** :ref:`CONFIG_TIMED_LED_PRESENTATION_DELAY_US ` after the received timestamp. + * A timer trigger is configured to toggle **LED 1** :ref:`CONFIG_TIMED_LED_PRESENTATION_DELAY_US ` after the received timestamp. This ensures that all receivers and the transmitter toggle it at the same time. ``iso_tx.c`` @@ -272,9 +272,9 @@ The sample code is divided into multiple source files, which makes it easier to * The SDU is transmitted on all the established isochronous channels with the same timestamp. This ensures that all the receivers can toggle their corresponding LEDs at the same time. The very first SDU is provided without a timestamp, because the timestamp is not known at this point in time. - * **LED 0** is configured to toggle synchronously with the **LED 0** on all the receivers. + * **LED 1** is configured to toggle synchronously with the **LED 1** on all the receivers. The toggle time is determined by the TX timestamp and defined relative to the synchronization reference on the receiver. - * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 1** is toggled right before sending the SDU. + * If the :ref:`CONFIG_LED_TOGGLE_IMMEDIATELY_ON_SEND_OR_RECEIVE ` Kconfig option is enabled, **LED 0** is toggled right before sending the SDU. You can use this to observe the end-to-end latency. ``timed_led_toggle.c`` @@ -318,7 +318,7 @@ After programming the sample to the development kits, perform the following step #. Select which BIS the receiver should synchronize to. #. Observe that the device(s) synchronize to the broadcaster and start receiving isochronous data. #. Press **Button 1** on the broadcaster. - #. Observe that **LED 1** toggles on both the broadcaster and the receivers. + #. Observe that **LED 2** toggles on both the broadcaster and the receivers. .. group-tab:: nRF54 DKs @@ -331,7 +331,7 @@ After programming the sample to the development kits, perform the following step #. Select which BIS the receiver should synchronize to. #. Observe that the device(s) synchronize to the broadcaster and start receiving isochronous data. #. Press **Button 0** on the broadcaster. - #. Observe that **LED 0** toggles on both the broadcaster and the receivers. + #. Observe that **LED 1** toggles on both the broadcaster and the receivers. Testing connected isochronous streams ===================================== @@ -353,7 +353,7 @@ After programming the sample to the development kits, perform the following step #. Select data direction. #. Observe that the peripheral(s) connect to the central and start receiving isochronous data. #. Press **Button 1** on the central device. - #. Observe that **LED 1** toggles on both the central and peripheral devices. + #. Observe that **LED 2** toggles on both the central and peripheral devices. .. group-tab:: nRF54 DKs @@ -368,7 +368,7 @@ After programming the sample to the development kits, perform the following step #. Select data direction. #. Observe that the peripheral(s) connect to the central and start receiving isochronous data. #. Press **Button 0** on the central device. - #. Observe that **LED 0** toggles on both the central and peripheral devices. + #. Observe that **LED 1** toggles on both the central and peripheral devices. Observe time-synchronized ISO data processing @@ -378,12 +378,12 @@ Observe time-synchronized ISO data processing .. group-tab:: nRF52 and nRF53 DKs - When you press **Button 1** on the transmitting device, you can observe that **LED 1** toggles simultaneously on all devices. + When you press **Button 1** on the transmitting device, you can observe that **LED 2** toggles simultaneously on all devices. To observe the accurate toggling, use a logic analyzer or an oscilloscope. .. group-tab:: nRF54 DKs - When you press **Button 0** on the transmitting device, you can observe that **LED 0** toggles simultaneously on all devices. + When you press **Button 0** on the transmitting device, you can observe that **LED 1** toggles simultaneously on all devices. To observe the accurate toggling, use a logic analyzer or an oscilloscope. Sample output diff --git a/samples/bluetooth/iso_time_sync/src/iso_rx.c b/samples/bluetooth/iso_time_sync/src/iso_rx.c index 0153bfa2472..3cbd61ca996 100644 --- a/samples/bluetooth/iso_time_sync/src/iso_rx.c +++ b/samples/bluetooth/iso_time_sync/src/iso_rx.c @@ -26,7 +26,7 @@ static void iso_disconnected(struct bt_iso_chan *chan, uint8_t reason); static void (*iso_chan_disconnected_cb)(void); -static struct gpio_dt_spec led_sdu_received = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led1), gpios, {0}); +static struct gpio_dt_spec led_sdu_received = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios, {0}); static struct bt_iso_chan_ops iso_ops = { .recv = iso_recv, diff --git a/samples/bluetooth/iso_time_sync/src/iso_tx.c b/samples/bluetooth/iso_time_sync/src/iso_tx.c index c585babd69f..0705024ff2c 100644 --- a/samples/bluetooth/iso_time_sync/src/iso_tx.c +++ b/samples/bluetooth/iso_time_sync/src/iso_tx.c @@ -30,7 +30,7 @@ #include "iso_time_sync.h" static const struct gpio_dt_spec button = GPIO_DT_SPEC_GET_OR(DT_ALIAS(sw0), gpios, {0}); -static struct gpio_dt_spec led_on_sdu_send = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led1), gpios, {0}); +static struct gpio_dt_spec led_on_sdu_send = GPIO_DT_SPEC_GET_OR(DT_ALIAS(led0), gpios, {0}); static void iso_sent(struct bt_iso_chan *chan); static void iso_connected(struct bt_iso_chan *chan); diff --git a/samples/bluetooth/iso_time_sync/src/timed_led_toggle.c b/samples/bluetooth/iso_time_sync/src/timed_led_toggle.c index 3b068db6481..c6181883a3d 100644 --- a/samples/bluetooth/iso_time_sync/src/timed_led_toggle.c +++ b/samples/bluetooth/iso_time_sync/src/timed_led_toggle.c @@ -21,6 +21,7 @@ #define GPIOTE_INST NRF_DT_GPIOTE_INST(DT_ALIAS(led1), gpios) #define GPIOTE_NODE DT_NODELABEL(_CONCAT(gpiote, GPIOTE_INST)) +#define GPIOTE_PORT DT_PROP(DT_PHANDLE(DT_ALIAS(led1), gpios), port) BUILD_ASSERT(IS_ENABLED(_CONCAT(CONFIG_, _CONCAT(NRFX_GPIOTE, GPIOTE_INST))), "NRFX_GPIOTE" STRINGIFY(GPIOTE_INST) " must be enabled in Kconfig"); @@ -50,14 +51,15 @@ int timed_led_toggle_init(void) return -ENOMEM; } + const nrfx_gpiote_pin_t abs_pin = NRF_GPIO_PIN_MAP(GPIOTE_PORT, led.pin); const nrfx_gpiote_task_config_t task_cfg_led_toggle = { .task_ch = gpiote_chan_led_toggle, .polarity = NRF_GPIOTE_POLARITY_TOGGLE, - .init_val = (led.dt_flags & GPIO_ACTIVE_HIGH) ? - NRF_GPIOTE_INITIAL_VALUE_LOW : NRF_GPIOTE_INITIAL_VALUE_HIGH, + .init_val = (led.dt_flags & GPIO_ACTIVE_LOW) ? + NRF_GPIOTE_INITIAL_VALUE_HIGH : NRF_GPIOTE_INITIAL_VALUE_LOW, }; - if (nrfx_gpiote_output_configure(&gpiote, led.pin, &gpiote_output_cfg, + if (nrfx_gpiote_output_configure(&gpiote, abs_pin, &gpiote_output_cfg, &task_cfg_led_toggle) != NRFX_SUCCESS) { printk("Failed configuring GPIOTE chan for toggling led\n"); return -ENOMEM; @@ -70,10 +72,10 @@ int timed_led_toggle_init(void) nrfx_gppi_channel_endpoints_setup(ppi_chan_led_toggle, controller_time_trigger_event_addr_get(), - nrfx_gpiote_out_task_address_get(&gpiote, led.pin)); + nrfx_gpiote_out_task_address_get(&gpiote, abs_pin)); nrfx_gppi_channels_enable(BIT(ppi_chan_led_toggle)); - nrfx_gpiote_out_task_enable(&gpiote, led.pin); + nrfx_gpiote_out_task_enable(&gpiote, abs_pin); return 0; }