Zephyr API Documentation 4.0.99
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 uint8_t rx_buf[2][256];
26 bool rx_buf_used[2];
27 struct mctp_pktbuf *rx_pkt;
28 uint8_t rx_exp_len;
29 uint16_t rx_fcs;
30 uint16_t rx_fcs_calc;
31 enum {
32 STATE_WAIT_SYNC_START,
33 STATE_WAIT_REVISION,
34 STATE_WAIT_LEN,
35 STATE_DATA,
36 STATE_DATA_ESCAPED,
37 STATE_WAIT_FCS1,
38 STATE_WAIT_FCS2,
39 STATE_WAIT_SYNC_END,
40 } rx_state;
41 int rx_res;
42
43 /* staging buffer for tx */
44 uint8_t tx_buf[256];
45 int tx_res;
46
48};
49
58
60int mctp_uart_start(struct mctp_binding *binding);
61int mctp_uart_tx(struct mctp_binding *binding, struct mctp_pktbuf *pkt);
70#define MCTP_UART_DT_DEFINE(_name, _dev) \
71 struct mctp_binding_uart _name = { \
72 .binding = \
73 { \
74 .name = STRINGIFY(_name), .version = 1, \
75 .pkt_size = MCTP_PACKET_SIZE(MCTP_BTU), \
76 .pkt_header = 0, .pkt_trailer = 0, \
77 .start = mctp_uart_start, .tx = mctp_uart_tx, \
78 }, \
79 .dev = _dev, \
80 .rx_state = STATE_WAIT_SYNC_START, \
81 .rx_pkt = NULL, \
82 .rx_res = 0, \
83 .tx_res = 0, \
84 };
85
86#endif /* ZEPHYR_MCTP_UART_H_ */
Public kernel APIs.
void mctp_uart_start_rx(struct mctp_binding_uart *uart)
Start the receive of a single mctp message.
__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:411
An MCTP binding for Zephyr's asynchronous UART interface.
Definition mctp_uart.h:19