Skip to content

Commit 3290b8b

Browse files
bjarki-andreasenrlubos
authored andcommitted
[nrf noup] modem: backend: uart: SLM optimized modem UART backend
This noup does the following: - Adds the modem_backend_uart_slm modem backend which is optimized for UART communication to SLM. The noup is intended to live until upstream zephyr has proper consistent RTS/CTS flow control support across multiple drivers, and DTR, RTS and CTS support has been added to the upstream modem UART backends, and lastly, SLM has been updated to use DTR, so everything is in sync. Ask Bjarki Arge Andreasen, Markus Lassila or Seppo Takalo when this noup is to be altered as part of an upmerge for example. Signed-off-by: Bjarki Arge Andreasen <[email protected]> Signed-off-by: Markus Lassila <[email protected]> (cherry picked from commit 964736d)
1 parent f8d6296 commit 3290b8b

File tree

4 files changed

+599
-0
lines changed

4 files changed

+599
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/drivers/uart.h>
9+
#include <zephyr/modem/pipe.h>
10+
#include <zephyr/modem/stats.h>
11+
12+
#ifndef ZEPHYR_MODEM_BACKEND_UART_SLM_
13+
#define ZEPHYR_MODEM_BACKEND_UART_SLM_
14+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
struct slm_rx_queue_event {
20+
uint8_t *buf;
21+
size_t len;
22+
};
23+
24+
struct modem_backend_uart_slm {
25+
const struct device *uart;
26+
struct modem_pipe pipe;
27+
struct k_work_delayable receive_ready_work;
28+
struct k_work transmit_idle_work;
29+
30+
#ifdef CONFIG_MODEM_STATS
31+
struct modem_stats_buffer receive_buf_stats;
32+
struct modem_stats_buffer transmit_buf_stats;
33+
#endif
34+
struct ring_buf transmit_rb;
35+
struct k_work rx_disabled_work;
36+
atomic_t state;
37+
38+
struct k_mem_slab rx_slab;
39+
struct k_msgq rx_queue;
40+
struct slm_rx_queue_event rx_event;
41+
struct slm_rx_queue_event rx_queue_buf[CONFIG_MODEM_BACKEND_UART_SLM_BUFFER_COUNT];
42+
uint32_t rx_buf_size;
43+
uint8_t rx_buf_count;
44+
};
45+
46+
struct modem_backend_uart_slm_config {
47+
const struct device *uart;
48+
uint8_t *receive_buf; /* Address must be word-aligned. */
49+
uint32_t receive_buf_size;
50+
uint8_t *transmit_buf;
51+
uint32_t transmit_buf_size;
52+
};
53+
54+
struct modem_pipe *modem_backend_uart_slm_init(struct modem_backend_uart_slm *backend,
55+
const struct modem_backend_uart_slm_config *config);
56+
57+
#ifdef __cplusplus
58+
}
59+
#endif
60+
61+
#endif /* ZEPHYR_MODEM_BACKEND_UART_SLM_ */

subsys/modem/backends/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ if(CONFIG_MODEM_BACKEND_UART_ASYNC)
1010
zephyr_library_sources_ifdef(CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC modem_backend_uart_async_hwfc.c)
1111
zephyr_library_sources_ifndef(CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC modem_backend_uart_async.c)
1212
endif()
13+
zephyr_library_sources_ifdef(CONFIG_MODEM_BACKEND_UART_SLM modem_backend_uart_slm.c)

subsys/modem/backends/Kconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,26 @@ endif # MODEM_BACKEND_UART_ASYNC_HWFC
6464
endif # MODEM_BACKEND_UART_ASYNC
6565

6666
endif # MODEM_BACKEND_UART
67+
68+
config MODEM_BACKEND_UART_SLM
69+
bool "SLM-optimized modem UART backend"
70+
select MODEM_PIPE
71+
select RING_BUFFER
72+
depends on UART_ASYNC_API
73+
74+
if MODEM_BACKEND_UART_SLM
75+
76+
config MODEM_BACKEND_UART_SLM_BUFFER_COUNT
77+
int "SLM modem UART backend buffer count"
78+
range 2 4
79+
default 3
80+
81+
config MODEM_BACKEND_UART_SLM_TRANSMIT_TIMEOUT_MS
82+
int "SLM modem UART transmit timeout in milliseconds"
83+
default 1000
84+
85+
config MODEM_BACKEND_UART_SLM_RECEIVE_IDLE_TIMEOUT_MS
86+
int "SLM modem UART receive idle timeout in milliseconds"
87+
default 30
88+
89+
endif # MODEM_BACKEND_UART_SLM

0 commit comments

Comments
 (0)