|
| 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_ */ |
0 commit comments