Zephyr API Documentation 4.4.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mctp_uart.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 */
7
8#ifndef ZEPHYR_MCTP_UART_H_
9#define ZEPHYR_MCTP_UART_H_
10
11#include <stdint.h>
12#include <zephyr/kernel.h>
13#include <zephyr/device.h>
14#include <libmctp.h>
15
21 struct mctp_binding binding;
22 const struct device *dev;
23
24 /* receive buffers and state */
25 struct k_sem rx_disabled;
26 uint8_t rx_buf[2][256];
27 bool rx_buf_used[2];
28 struct mctp_pktbuf *rx_pkt;
29 uint8_t rx_exp_len;
30 uint16_t rx_fcs;
31 uint16_t rx_fcs_calc;
32 enum {
33 STATE_WAIT_SYNC_START,
34 STATE_WAIT_REVISION,
35 STATE_WAIT_LEN,
36 STATE_DATA,
37 STATE_DATA_ESCAPED,
38 STATE_WAIT_FCS1,
39 STATE_WAIT_FCS2,
40 STATE_WAIT_SYNC_END,
41 } rx_state;
42 int rx_res;
43
44 /* staging buffer for tx */
45 struct k_sem tx_done;
46 uint8_t tx_buf[256];
47 int tx_res;
48 bool waiting;
49
50 /* Keep track of all UART bindings */
51 sys_snode_t node;
52
54};
55
64
78
80int mctp_uart_start(struct mctp_binding *binding);
81int mctp_uart_tx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
83
90#define MCTP_UART_DT_DEFINE(_name, _dev) \
91 struct mctp_binding_uart _name = { \
92 .binding = \
93 { \
94 .name = STRINGIFY(_name), .version = 1, \
95 .pkt_size = MCTP_PACKET_SIZE(MCTP_BTU), \
96 .pkt_header = 0, .pkt_trailer = 0, \
97 .start = mctp_uart_start, .tx = mctp_uart_tx, \
98 }, \
99 .dev = _dev, \
100 .rx_state = STATE_WAIT_SYNC_START, \
101 .rx_pkt = NULL, \
102 .rx_res = 0, \
103 .tx_res = 0, \
104 };
105
106#endif /* ZEPHYR_MCTP_UART_H_ */
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
Public kernel APIs.
void mctp_uart_start_rx(struct mctp_binding_uart *uart)
Start the receive of mctp messages.
int mctp_uart_stop_rx(struct mctp_binding_uart *uart)
Stop the receive of mctp messages.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
Semaphore structure.
Definition kernel.h:3663
An MCTP binding for Zephyr's asynchronous UART interface.
Definition mctp_uart.h:19