Skip to content

Commit 8cea4b0

Browse files
maje-embrlubos
authored andcommitted
applications: machine_learning: Add configuration for nRF54L15 DK
Adds configuration files for nRF54L15 support. Support for simulated signals only. Signed-off-by: Marcin Jelinski <[email protected]>
1 parent a732d97 commit 8cea4b0

File tree

8 files changed

+489
-18
lines changed

8 files changed

+489
-18
lines changed

applications/machine_learning/app_desc.rst

Lines changed: 75 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ By default, the following sensors are used by the application:
3434
* nRF5340 DK - Simulated sensor (:ref:`sensor_sim`).
3535
The simulated sensor generates predefined waves as acceleration.
3636
This development kit does not have a built-in accelerometer.
37+
* nRF54L15 DK - Simulated sensor (:ref:`sensor_sim`).
38+
The simulated sensor generates predefined waves as acceleration.
39+
This development kit does not have a built-in accelerometer.
3740
* nRF54H20 DK - The development kit does not have a built-in accelerometer.
3841
However, it supports the following configurations:
3942

@@ -52,6 +55,7 @@ By default, the following transports are used:
5255
* Thingy:53 uses :ref:`nus_service_readme`.
5356
* The nRF52840 DK uses :ref:`zephyr:uart_api`.
5457
* The nRF5340 DK uses :ref:`zephyr:uart_api`.
58+
* The nRF54L15 DK uses :ref:`zephyr:uart_api`.
5559
* The nRF54H20 DK uses :ref:`nus_service_readme`.
5660

5761
Machine learning model
@@ -72,7 +76,7 @@ By default, the application uses pre-trained machine learning models deployed in
7276
* ``tap`` - The device is tapped while placed on a flat surface.
7377

7478
Unknown gestures, such as shaking the device, are recognized as anomalies.
75-
* Both the nRF52840 DK and the nRF5340 DK use the `nRF Connect SDK simulated sensor machine learning model`_.
79+
* The nRF52840, nRF5340 and nRF54L15 DKs use the `nRF Connect SDK simulated sensor machine learning model`_.
7680
The model uses simulated sensor data to recognize the following simulated wave types:
7781

7882
* ``sine``
@@ -232,6 +236,11 @@ By default, the following buttons are used by the application:
232236
* **Button 1** switches between data forwarding and running a machine learning model.
233237
* **Button 3** changes the signal generated by the simulated sensor.
234238

239+
.. group-tab:: nRF54L15 DK
240+
241+
* **Button 0** switches between data forwarding and running a machine learning model.
242+
* **Button 2** changes the signal generated by the simulated sensor.
243+
235244
.. group-tab:: nRF54H20 DK
236245

237246
**Button 0** button switches between data forwarding and running the machine learning model.
@@ -266,30 +275,51 @@ By default, the application uses the following LED effects:
266275
The LED effect is overridden on the next successful detection.
267276
* If the device forwards data, the LED color turns red and uses the following blinking patterns:
268277

269-
* LED blinks slowly if it is not connected.
270-
* LED blinks with an average frequency if it is connected but is not actively forwarding data.
271-
* LED blinks rapidly if it is connected and is actively forwarding data.
278+
* Blinks slowly if it is not connected.
279+
* Blinks with an average frequency if it is connected but is not actively forwarding data.
280+
* Blinks rapidly if it is connected and is actively forwarding data.
272281

273282
.. group-tab:: nRF52840 and nRF5340 DKs
274283

275284
Both nRF5340 DK and nRF52840 DK use monochromatic LEDs to display the application state.
276-
The **LED1** displays the application state, and the **LED2** displays the signal generated by the simulated sensor.
285+
The **LED1** displays the application state and the **LED2** displays the signal generated by the simulated sensor.
277286

278287
* If the device is returning the machine learning prediction results, the **LED1** blinks for a predefined number of times and then turns off for a period of time.
279288
Then the sequence is repeated.
280289
The machine learning result is represented by the number of blinks:
281290

282-
* ``sine`` - 1 blink
283-
* ``triangle`` - 2 blinks
284-
* ``square`` - 3 blinks
285-
* ``idle`` - 4 blinks
291+
* ``sine`` - one blink
292+
* ``triangle`` - two blinks
293+
* ``square`` - three blinks
294+
* ``idle`` - four blinks
286295

287296
If the machine learning model is running but has not detected anything yet or has detected an anomaly, the **LED1** is breathing.
288297
* If the device forwards data, the **LED1** has the following blinking patterns:
289298

290-
* LED blinks slowly if it is not connected.
291-
* LED blinks with an average frequency if it is connected but is not actively forwarding data.
292-
* LED blinks rapidly if it is connected and is actively forwarding data.
299+
* Blinks slowly if it is not connected.
300+
* Blinks with an average frequency if it is connected but is not actively forwarding data.
301+
* Blinks rapidly if it is connected and is actively forwarding data.
302+
303+
.. group-tab:: nRF54L15 DK
304+
305+
The nRF54L15 DK uses monochromatic LEDs to display the application state.
306+
The **LED1** displays the application state and the **LED3** displays the signal generated by the simulated sensor.
307+
308+
* If the device is returning the machine learning prediction results, the **LED1** blinks for a predefined number of times and then turns off for a period of time.
309+
Then the sequence is repeated.
310+
The machine learning result is represented by the number of blinks:
311+
312+
* ``sine`` - one blink
313+
* ``triangle`` - two blinks
314+
* ``square`` - three blinks
315+
* ``idle`` - four blinks
316+
317+
If the machine learning model is running but has not detected anything yet or has detected an anomaly, the **LED1** is breathing.
318+
* If the device forwards data, the **LED1** has the following blinking patterns:
319+
320+
* Blinks slowly if it is not connected.
321+
* Blinks with an average frequency if it is connected but is not actively forwarding data.
322+
* Blinks rapidly if it is connected and is actively forwarding data.
293323

294324
.. group-tab:: nRF54H20 DK
295325
nRF54H20 DK uses monochromatic LEDs to display the application state.
@@ -306,9 +336,9 @@ By default, the application uses the following LED effects:
306336
If the machine learning model is running, but it has not detected anything yet or the ``idle`` state is detected, **LED0**, **LED1**, and **LED2**, keep blinking.
307337
* If the device forwards data, **LED0**, **LED1** and **LED2** has the following blinking patterns:
308338

309-
* LED blinks slowly if it is not connected.
310-
* LED blinks with an average frequency if it is connected, but is not actively forwarding data.
311-
* LED blinks rapidly if it is connected and is actively forwarding data.
339+
* Blinks slowly if it is not connected.
340+
* Blinks with an average frequency if it is connected, but is not actively forwarding data.
341+
* Blinks rapidly if it is connected and is actively forwarding data.
312342

313343
.. _nrf_machine_learning_app_configuration:
314344

@@ -525,14 +555,14 @@ After programming the application, perform the following steps to test the nRF M
525555

526556
1. Turn on the development kit.
527557
The application starts in a mode that runs the machine learning model.
528-
Initially, **LED2** displays the LED effect representing ``sine`` wave (1 blink), and **LED1** is breathing, because the signal was not yet recognized by the machine learning model.
558+
Initially, **LED2** displays the LED effect representing ``sine`` wave (one blink), and **LED1** is breathing, because the signal was not yet recognized by the machine learning model.
529559
After a brief delay, the machine learning model recognizes the simulated signal.
530560
**LED1** and **LED2** display the same LED effect.
531561
#. Press **Button 3** to change the generated acceleration signal.
532562
Right after the signal change, the effects displayed by LEDs are different.
533-
After a brief delay, the machine learning model recognizes the ``triangle`` wave, and the same effect (2 blinks) is displayed by both LEDs.
563+
After a brief delay, the machine learning model recognizes the ``triangle`` wave, and the same effect (two blinks) is displayed by both LEDs.
534564
#. Press **Button 3** to again change the generated acceleration signal.
535-
The ``square`` wave (3 blinks) is displayed only by the **LED2**.
565+
The ``square`` wave (three blinks) is displayed only by the **LED2**.
536566
This signal is marked as an anomaly by the machine learning model, and **LED1** starts breathing.
537567
#. Press and hold **Button 1** for more than five seconds to switch to the data forwarding mode.
538568
After the mode is switched, **LED1** starts to blink rapidly.
@@ -545,6 +575,33 @@ After programming the application, perform the following steps to test the nRF M
545575
Optionally, you can also connect to the device using `Edge Impulse's data forwarder`_ and forward data to `Edge Impulse studio`_ (after logging in).
546576
See `Forwarding data to Edge Impulse studio`_ for details.
547577

578+
Testing with the nRF54L15 DK
579+
---------------------------------------
580+
581+
After programming the application, perform the following steps to test the nRF Machine Learning application on the DK:
582+
583+
1. Turn on the development kit.
584+
The application starts in a mode that runs the machine learning model.
585+
Initially, **LED3** displays the LED effect representing ``sine`` wave (one blink), and **LED1** is breathing, because the signal was not yet recognized by the machine learning model.
586+
After a brief delay, the machine learning model recognizes the simulated signal.
587+
**LED1** and **LED3** display the same LED effect.
588+
#. Press **Button 2** to change the generated acceleration signal.
589+
Right after the signal change, the effects displayed by LEDs are different.
590+
After a brief delay, the machine learning model recognizes the ``triangle`` wave, and the same effect (two blinks) is displayed by both LEDs.
591+
#. Press **Button 2** to again change the generated acceleration signal.
592+
The ``square`` wave (three blinks) is displayed only by the **LED3**.
593+
This signal is marked as an anomaly by the machine learning model, and **LED1** starts breathing.
594+
#. Press and hold **Button 0** for more than five seconds to switch to the data forwarding mode.
595+
After the mode is switched, **LED1** starts to blink rapidly.
596+
#. Connect to the development kit with a terminal emulator (for example, `nRF Connect Serial Terminal`_).
597+
See :ref:`test_and_optimize` for the required settings.
598+
#. Observe the sensor readouts represented as comma-separated values.
599+
Every line represents a single sensor readout.
600+
#. Turn off the terminal emulator to ensure that only one program has access to the data on UART.
601+
602+
Optionally, you can also connect to the device using `Edge Impulse's data forwarder`_ and forward data to `Edge Impulse studio`_ (after logging in).
603+
See `Forwarding data to Edge Impulse studio`_ for details.
604+
548605
Testing with the nRF54H20 DK
549606
-----------------------------
550607

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/ {
2+
chosen {
3+
ncs,ml-app-ei-data-forwarder-uart = &uart20;
4+
zephyr,console = &uart30;
5+
6+
};
7+
8+
sensor_sim: sensor-sim {
9+
compatible = "nordic,sensor-sim";
10+
acc-signal = "wave";
11+
};
12+
13+
/* Redefine pwmleds to fit CAF requirements. */
14+
/delete-node/ pwmleds;
15+
16+
pwmleds1 {
17+
compatible = "pwm-leds";
18+
status = "okay";
19+
20+
pwm_led1: led_pwm_1 {
21+
status = "okay";
22+
pwms = <&pwm20 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
23+
label = "State LED";
24+
};
25+
};
26+
27+
pwmleds3 {
28+
compatible = "pwm-leds";
29+
status = "okay";
30+
31+
pwm_led3: led_pwm_3 {
32+
status = "okay";
33+
pwms = <&pwm21 0 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
34+
label = "Simulated signal LED";
35+
};
36+
};
37+
};
38+
39+
&uart30 {
40+
status = "okay";
41+
};
42+
43+
&uart20 {
44+
status = "okay";
45+
};
46+
47+
&pwm20 {
48+
status = "okay";
49+
pinctrl-0 = <&pwm20_default_alt>;
50+
pinctrl-1 = <&pwm20_sleep_alt>;
51+
pinctrl-names = "default", "sleep";
52+
};
53+
54+
&pwm21 {
55+
status = "okay";
56+
pinctrl-0 = <&pwm21_default_alt>;
57+
pinctrl-1 = <&pwm21_sleep_alt>;
58+
pinctrl-names = "default", "sleep";
59+
};
60+
61+
&pinctrl {
62+
pwm20_default_alt: pwm20_default_alt {
63+
group1 {
64+
psels = <NRF_PSEL(PWM_OUT0, 1, 10)>;
65+
};
66+
};
67+
68+
pwm20_sleep_alt: pwm20_sleep_alt {
69+
group1 {
70+
psels = <NRF_PSEL(PWM_OUT0, 1, 10)>;
71+
low-power-enable;
72+
};
73+
};
74+
75+
pwm21_default_alt: pwm21_default_alt {
76+
group1 {
77+
psels = <NRF_PSEL(PWM_OUT0, 1, 14)>;
78+
};
79+
};
80+
81+
pwm21_sleep_alt: pwm21_sleep_alt {
82+
group1 {
83+
psels = <NRF_PSEL(PWM_OUT0, 1, 14)>;
84+
low-power-enable;
85+
};
86+
};
87+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <caf/gpio_pins.h>
8+
9+
/* This configuration file is included only once from buttons module and holds
10+
* information about pins forming keyboard matrix.
11+
*/
12+
13+
/* This structure enforces the header file is included only once in the build.
14+
* Violating this requirement triggers a multiple definition error at link time.
15+
*/
16+
const struct {} buttons_def_include_once;
17+
18+
static const struct gpio_pin col[] = {};
19+
20+
static const struct gpio_pin row[] = {
21+
{ .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(button0), gpios) },
22+
{ .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(button1), gpios) },
23+
{ .port = 1, .pin = DT_GPIO_PIN(DT_NODELABEL(button2), gpios) },
24+
{ .port = 0, .pin = DT_GPIO_PIN(DT_NODELABEL(button3), gpios) },
25+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <caf/click_detector.h>
9+
10+
/* This configuration file is included only once from click_detector module
11+
* and holds information about click detector configuration.
12+
*/
13+
14+
/* This structure enforces the header file is included only once in the build.
15+
* Violating this requirement triggers a multiple definition error at link time.
16+
*/
17+
const struct {} click_detector_def_include_once;
18+
19+
static const struct click_detector_config click_detector_config[] = {
20+
{
21+
.key_id = CONFIG_ML_APP_MODE_CONTROL_BUTTON_ID,
22+
.consume_button_event = true,
23+
},
24+
};
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <caf/led_effect.h>
8+
#include "led_state.h"
9+
#include "ei_data_forwarder_event.h"
10+
11+
/* This configuration file is included only once from led_state module and holds
12+
* information about LED effects associated with data forwarder states and machine
13+
* learning results.
14+
*/
15+
16+
/* This structure enforces the header file is included only once in the build.
17+
* Violating this requirement triggers a multiple definition error at link time.
18+
*/
19+
const struct {} led_state_def_include_once;
20+
21+
22+
/* Map function to LED ID */
23+
static const uint8_t led_map[] = {
24+
[LED_ID_ML_STATE] = 0,
25+
[LED_ID_SENSOR_SIM] = 1
26+
};
27+
28+
static const struct led_effect ei_data_forwarder_led_effects[] = {
29+
[EI_DATA_FORWARDER_STATE_DISCONNECTED] =
30+
LED_EFFECT_LED_BLINK(2000, LED_COLOR(100, 100, 100)),
31+
[EI_DATA_FORWARDER_STATE_CONNECTED] =
32+
LED_EFFECT_LED_BLINK(500, LED_COLOR(100, 100, 100)),
33+
[EI_DATA_FORWARDER_STATE_TRANSMITTING] =
34+
LED_EFFECT_LED_BLINK(50, LED_COLOR(100, 100, 100)),
35+
};
36+
37+
static const struct ml_result_led_effect ml_result_led_effects[] = {
38+
{
39+
.label = NULL,
40+
.effect = LED_EFFECT_LED_BREATH(500, LED_COLOR(100, 100, 100)),
41+
},
42+
{
43+
.label = ANOMALY_LABEL,
44+
.effect = LED_EFFECT_LED_BREATH(250, LED_COLOR(100, 100, 100)),
45+
},
46+
{
47+
.label = "sine",
48+
.effect = LED_EFFECT_LED_CLOCK(1, LED_COLOR(100, 100, 100)),
49+
},
50+
{
51+
.label = "triangle",
52+
.effect = LED_EFFECT_LED_CLOCK(2, LED_COLOR(100, 100, 100)),
53+
},
54+
{
55+
.label = "square",
56+
.effect = LED_EFFECT_LED_CLOCK(3, LED_COLOR(100, 100, 100)),
57+
},
58+
{
59+
.label = "idle",
60+
.effect = LED_EFFECT_LED_CLOCK(4, LED_COLOR(100, 100, 100)),
61+
},
62+
};

0 commit comments

Comments
 (0)