nRF Connect SDK API 2.8.0
Loading...
Searching...
No Matches
uart_async_adapter.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6#ifndef __UART_ASYNC_ADAPTER_H
7#define __UART_ASYNC_ADAPTER_H
8
12#include <zephyr/device.h>
13#include <zephyr/drivers/uart.h>
14#include <zephyr/kernel.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
38 const struct device *target;
40 uart_callback_t user_callback;
42 void *user_data;
43
44 /* The interface realization */
46 struct k_spinlock lock;
47
51 const uint8_t *buf;
53 const uint8_t *curr_buf;
55 volatile size_t size_left;
57 struct k_timer timeout_timer;
59 bool enabled;
60 } tx;
61
65 uint8_t *buf;
67 uint8_t *curr_buf;
71 size_t size_left;
73 uint8_t *next_buf;
77 int32_t timeout;
79 struct k_timer timeout_timer;
81 bool enabled;
82 } rx;
83};
84
90extern const struct uart_driver_api uart_async_adapter_driver_api;
91
97#define UART_ASYNC_ADAPTER_INST_DATA_NAME(_dev_name) _CONCAT(uart_async_adapter_data_, _dev_name)
98
99#define UART_ASYNC_ADAPTER_INST_STATE_NAME(_dev_name) _CONCAT(uart_async_adapter_state_, _dev_name)
100
101#define UART_ASYNC_ADAPTER_INST_NAME(_dev_name) _CONCAT(_dev_name, _inst)
102
108#define UART_ASYNC_ADAPTER_INST_DEFINE(_dev) \
109 static struct uart_async_adapter_data UART_ASYNC_ADAPTER_INST_DATA_NAME(_dev); \
110 static struct device_state UART_ASYNC_ADAPTER_INST_STATE_NAME(_dev); \
111 static const struct device UART_ASYNC_ADAPTER_INST_NAME(_dev) = { \
112 .name = STRINGIFY(_dev), \
113 .api = &uart_async_adapter_driver_api, \
114 .state = &UART_ASYNC_ADAPTER_INST_STATE_NAME(_dev), \
115 .data = &UART_ASYNC_ADAPTER_INST_DATA_NAME(_dev), \
116 }; \
117 static const struct device *const _dev = &UART_ASYNC_ADAPTER_INST_NAME(_dev)
118
128void uart_async_adapter_init(const struct device *dev, const struct device *target);
129
132#ifdef __cplusplus
133}
134#endif
135
136#endif /* __UART_ASYNC_ADAPTER_H */
void uart_async_adapter_init(const struct device *dev, const struct device *target)
Initialize adapter.
const struct uart_driver_api uart_async_adapter_driver_api
Driver API for async adapter.
volatile size_t size_left
Definition uart_async_adapter.h:55
const uint8_t * buf
Definition uart_async_adapter.h:51
bool enabled
Definition uart_async_adapter.h:59
const uint8_t * curr_buf
Definition uart_async_adapter.h:53
struct k_timer timeout_timer
Definition uart_async_adapter.h:57
Definition uart_async_adapter.h:49
struct k_timer timeout_timer
Definition uart_async_adapter.h:79
uint8_t * next_buf
Definition uart_async_adapter.h:73
int32_t timeout
Definition uart_async_adapter.h:77
uint8_t * curr_buf
Definition uart_async_adapter.h:67
bool enabled
Definition uart_async_adapter.h:81
uint8_t * buf
Definition uart_async_adapter.h:65
size_t size_left
Definition uart_async_adapter.h:71
size_t next_buf_len
Definition uart_async_adapter.h:75
uint8_t * last_notify_buf
Definition uart_async_adapter.h:69
Definition uart_async_adapter.h:63
const struct device * target
Definition uart_async_adapter.h:38
struct uart_async_adapter_data::uart_async_adapter_data_tx rx
struct k_spinlock lock
Definition uart_async_adapter.h:46
uart_callback_t user_callback
Definition uart_async_adapter.h:40
void * user_data
Definition uart_async_adapter.h:42
struct uart_async_adapter_data::uart_async_adapter_data_rx tx
UART asynch adapter data structure.
Definition uart_async_adapter.h:36