Skip to content

Commit 63dce6f

Browse files
drivers: add lpuarte driver and sample
Add low power uarte driver and sample. Based on NCS LPUARTE driver and sample, nrfconnect/sdk-nrf/commit/d33871cc92bc50034a6d9b7bdcac94c0ff358390 Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 0155d3a commit 63dce6f

File tree

16 files changed

+1183
-0
lines changed

16 files changed

+1183
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# Drivers
3535
/drivers/clock_control/ @nrfconnect/ncs-bm
3636
/drivers/console/ @nrfconnect/ncs-bm
37+
/drivers/lpuarte/ @nrfconnect/ncs-bm
3738

3839
# Include
3940
/include/*.h @nrfconnect/ncs-bm

boards/nordic/bm_nrf54l15dk/include/board-config.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,30 @@ extern "C" {
8181
#define BOARD_APP_UARTE_PIN_CTS NRF_PIN_PORT_TO_PIN_NUMBER(3, 0)
8282
#endif
8383

84+
/* Application LPUART configuration */
85+
#ifndef BOARD_APP_LPUARTE_INST
86+
#define BOARD_APP_LPUARTE_INST 21
87+
#endif
88+
89+
#ifndef BOARD_APP_LPUARTE_PIN_TX
90+
#define BOARD_APP_LPUARTE_PIN_TX NRF_PIN_PORT_TO_PIN_NUMBER(11, 1)
91+
#endif
92+
#ifndef BOARD_APP_LPUARTE_PIN_RX
93+
#define BOARD_APP_LPUARTE_PIN_RX NRF_PIN_PORT_TO_PIN_NUMBER(10, 1)
94+
#endif
95+
#ifndef BOARD_APP_LPUARTE_PIN_RTS
96+
#define BOARD_APP_LPUARTE_PIN_RTS NRF_PIN_PORT_TO_PIN_NUMBER(14, 1)
97+
#endif
98+
#ifndef BOARD_APP_LPUARTE_PIN_CTS
99+
#define BOARD_APP_LPUARTE_PIN_CTS NRF_PIN_PORT_TO_PIN_NUMBER(13, 1)
100+
#endif
101+
#ifndef BOARD_APP_LPUARTE_PIN_REQ
102+
#define BOARD_APP_LPUARTE_PIN_REQ NRF_PIN_PORT_TO_PIN_NUMBER(8, 1)
103+
#endif
104+
#ifndef BOARD_APP_LPUARTE_PIN_RDY
105+
#define BOARD_APP_LPUARTE_PIN_RDY NRF_PIN_PORT_TO_PIN_NUMBER(9, 1)
106+
#endif
107+
84108
#ifdef __cplusplus
85109
}
86110
#endif

doc/nrf-bm/drivers.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.. _drivers:
2+
3+
Drivers
4+
#######
5+
6+
In supplement to nrfx drivers, |BMlong| provides drivers that implement typical use cases with Nordic Semiconductor devices.
7+
If the driver you are looking for is not available below, please check the nrfx documentation. TODO LINK.
8+
9+
Only nrfx drivers and the drivers located under :file:`nrf-bm/drivers` are in the scope of the |BMshort| option.
10+
All other drivers that are included in the distribution must be ignored when working with the |BMshort| option.
11+
12+
.. toctree::
13+
:maxdepth: 2
14+
:glob:
15+
:caption: Subpages:
16+
17+
drivers/lpuarte.rst

doc/nrf-bm/drivers/lpuarte.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.. _lpuarte:
2+
3+
Low Power UART with EasyDMA (LPUARTE)
4+
#####################################
5+
6+
The Low Power UART with EasyDMA (LPUARTE) driver implements the standard UART with two extra control lines for low power capabilities.
7+
The control lines allow for disabling the UART receiver during the idle period.
8+
This results in low power consumption, as you can shut down the high-frequency clock when UART is in idle state.
9+
10+
Control protocol
11+
****************
12+
13+
You can use the protocol for duplex transmission between two devices.
14+
15+
The control protocol uses two additional lines alongside the standard TX and RX lines:
16+
17+
* the *Request* line (REQ),
18+
* the *Ready* line (RDY).
19+
20+
The REQ line of the first device is connected with the RDY line of the second device.
21+
It is configured as an output and set to low.
22+
23+
The RDY line is configured as input without pull-up and the interrupt is configured to detect the transition from low to high state.
24+
25+
The driver implements the control protocol in the following way:
26+
27+
#. The transmitter initiates the transmission by calling :c:func:`bm_lpuarte_tx`.
28+
#. The driver reconfigures the REQ line to input with pull-up and enables the detection of high to low transition.
29+
#. The line is set to high due to the pull-up register, and that triggers an interrupt on the RDY line.
30+
#. On that interrupt, the driver starts the UART receiver.
31+
#. When the receiver is ready, the driver reconfigures the RDY line to output low.
32+
#. Then, the driver reconfigures the RDY line to input with pull-up and enables the interrupt on detection of high to low transition.
33+
#. This sequence results in a short pulse on the line, as the line goes low and high.
34+
#. The initiator detects the pulse and starts the standard UART transfer.
35+
#. When the transfer is completed, the driver reconfigures the REQ line to the initial state: output set to low.
36+
This results in a line state change.
37+
#. As the line goes low, the receiver detects the change.
38+
This indicates that the UARTE receiver can be stopped.
39+
40+
Once the receiver acknowledges the transfer, it must be capable of receiving the whole transfer until the REQ line goes down.
41+
42+
This requirement can be fulfilled in two ways:
43+
44+
* By providing a buffer of the size of the maximum packet length.
45+
* By continuously responding to the RX buffer request event.
46+
The latency of the event handling must be taken into account in that case.
47+
For example, a flash page erase on some devices might have a significant impact.
48+
49+
See :ref:`bm_lpuarte_sample` sample for the implementation of this driver.

drivers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ add_compile_options($<TARGET_PROPERTY:compiler,warning_shadow_variables>)
1010
add_subdirectory_ifdef(CONFIG_CONSOLE console)
1111
add_subdirectory_ifdef(CONFIG_CLOCK_CONTROL clock_control)
1212
add_subdirectory_ifdef(CONFIG_FLASH flash)
13+
add_subdirectory_ifdef(CONFIG_BM_SW_LPUARTE lpuarte)

drivers/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ menu "Device Drivers"
88
# zephyr-keep-sorted-start
99
rsource "console/Kconfig"
1010
rsource "flash/Kconfig"
11+
rsource "lpuarte/Kconfig"
1112
# zephyr-keep-sorted-stop
1213

1314
endmenu

drivers/lpuarte/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
zephyr_library()
7+
8+
zephyr_library_sources(lpuarte.c)

drivers/lpuarte/Kconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# LPUARTE configuration
2+
3+
# Copyright (c) 2025, Nordic Semiconductor ASA
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
6+
config BM_SW_LPUARTE
7+
bool "Low Power UARTE using REQ/RDY lines"
8+
help
9+
Low Power UARTE implements UARTE API and extends standard UARTE
10+
communication with a 2-pins protocol for receiver wake-up and flow control.
11+
12+
if BM_SW_LPUARTE
13+
14+
# Set number of event handlers used by the LPUART driver
15+
config NRFX_GPIOTE_NUM_OF_EVT_HANDLERS
16+
default 2
17+
18+
config BM_SW_LPUARTE_INT_DRV_TX_BUF_SIZE
19+
int "Tx buffer size"
20+
default 128
21+
depends on BM_SW_LPUARTE_INT_DRIVEN
22+
help
23+
Internal buffer of that size is created and used by uart_fifo_fill.
24+
For optimal performance it should be able to fit the longest possible
25+
packet.
26+
27+
module = BM_SW_LPUARTE
28+
module-str = Low Power UARTE
29+
source "subsys/logging/Kconfig.template.log_config"
30+
31+
endif

0 commit comments

Comments
 (0)