Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
uart.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Trackunit Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include <zephyr/kernel.h>
8#include <zephyr/types.h>
9#include <zephyr/device.h>
10#include <zephyr/drivers/uart.h>
12#include <zephyr/sys/atomic.h>
13
14#include <zephyr/modem/pipe.h>
15#include <zephyr/modem/stats.h>
16
17#ifndef ZEPHYR_INCLUDE_MODEM_BACKEND_UART_H_
18#define ZEPHYR_INCLUDE_MODEM_BACKEND_UART_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
32
39
40#ifdef CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC
41
42struct rx_queue_event {
43 uint8_t *buf;
44 size_t len;
45};
46
48 struct modem_backend_uart_async_common common;
49 struct k_mem_slab rx_slab;
50 struct k_msgq rx_queue;
51 struct rx_queue_event rx_event;
52 struct rx_queue_event rx_queue_buf[CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC_BUFFER_COUNT];
53 uint32_t rx_buf_size;
54 uint8_t rx_buf_count;
55};
56
57#else
58
66
67#endif /* CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC */
68
70 const struct device *uart;
71 const struct gpio_dt_spec *dtr_gpio;
72 struct modem_pipe pipe;
75
78
79#if CONFIG_MODEM_STATS
80 struct modem_stats_buffer receive_buf_stats;
81 struct modem_stats_buffer transmit_buf_stats;
82#endif
83
84 union {
87 };
88};
89
91 const struct device *uart;
92 const struct gpio_dt_spec *dtr_gpio;
93 /* Address must be word-aligned when CONFIG_MODEM_BACKEND_UART_ASYNC_HWFC is enabled. */
98};
99
100struct modem_pipe *modem_backend_uart_init(struct modem_backend_uart *backend,
101 const struct modem_backend_uart_config *config);
102
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif /* ZEPHYR_INCLUDE_MODEM_BACKEND_UART_H_ */
Header file for the Atomic operations API.
APIs and macros for the Zephyr device model.
Main header file for UART driver API.
long atomic_t
Atomic integer variable.
Definition atomic_types.h:34
Public kernel APIs.
struct modem_pipe * modem_backend_uart_init(struct modem_backend_uart *backend, const struct modem_backend_uart_config *config)
uint32_t modem_backend_uart_get_receive_dropped(const struct modem_backend_uart *backend)
Get the number of received bytes the backend dropped.
Simple, header-only ring buffer implementation.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:543
Container for GPIO pin information specified in devicetree.
Definition gpio.h:296
Kernel Spin Lock.
Definition spinlock.h:45
A structure used to submit work after a delay.
Definition kernel.h:4955
A structure used to submit work.
Definition kernel.h:4913
uint32_t transmit_buf_size
Definition uart.h:35
struct k_work rx_disabled_work
Definition uart.h:36
uint8_t * transmit_buf
Definition uart.h:34
atomic_t state
Definition uart.h:37
Definition uart.h:59
uint32_t receive_buf_size
Definition uart.h:62
struct modem_backend_uart_async_common common
Definition uart.h:60
uint8_t * receive_bufs[2]
Definition uart.h:61
struct k_spinlock receive_rb_lock
Definition uart.h:64
struct ring_buf receive_rb
Definition uart.h:63
Definition uart.h:90
uint32_t receive_buf_size
Definition uart.h:95
const struct gpio_dt_spec * dtr_gpio
Definition uart.h:92
uint32_t transmit_buf_size
Definition uart.h:97
const struct device * uart
Definition uart.h:91
uint8_t * transmit_buf
Definition uart.h:96
uint8_t * receive_buf
Definition uart.h:94
Definition uart.h:24
atomic_t receive_buf_len
Definition uart.h:28
uint32_t transmit_buf_put_limit
Definition uart.h:30
atomic_t transmit_buf_len
Definition uart.h:27
struct ring_buf transmit_rb
Definition uart.h:26
uint8_t receive_rdb_used
Definition uart.h:29
struct ring_buf receive_rdb[2]
Definition uart.h:25
Definition uart.h:69
const struct device * uart
Definition uart.h:70
struct k_work_delayable receive_ready_work
Definition uart.h:73
struct modem_backend_uart_async async
Definition uart.h:86
struct modem_backend_uart_isr isr
Definition uart.h:85
struct k_work transmit_idle_work
Definition uart.h:74
const struct gpio_dt_spec * dtr_gpio
Definition uart.h:71
uint32_t receive_dropped
Received bytes dropped because the receive buffer was full.
Definition uart.h:77
struct modem_pipe pipe
Definition uart.h:72
A structure to represent a ring buffer.
Definition ring_buffer.h:68