Nexus Embedded Platform 1.0.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
uart.h
Go to the documentation of this file.
1
9#ifndef NEXUS_UART_H
10#define NEXUS_UART_H
11
12#include "nexus/core/request.h"
13#include "nexus/io/stream.h"
14#include "nexus/io/wake.h"
15#ifdef __cplusplus
16extern "C" {
17#endif
24#define NX_UART_EVENT_PARITY 1u
25#define NX_UART_EVENT_FRAMING 2u
26#define NX_UART_EVENT_OVERRUN 4u
27#define NX_UART_EVENT_NOISE 8u
28#define NX_UART_EVENT_LOSS 16u
29#define NX_UART_EVENT_NO_BYTE 32u
41typedef struct {
43 uint32_t flags;
44 uint8_t byte;
46
50typedef struct {
52 const uint8_t* data;
53 size_t length;
55
62typedef struct {
63 nx_result_t (*submit)(void* context, nx_uart_tx_request_t* request);
64 nx_result_t (*start_admitted)(void* context, nx_uart_tx_request_t* request);
65 nx_result_t (*cancel)(void* context, nx_uart_tx_request_t* request);
66 void (*service)(void* context);
67 nx_result_t (*read_events)(void* context, nx_uart_rx_event_t* events,
68 size_t capacity, size_t* count);
69 nx_result_t (*read_bytes)(void* context, uint8_t* bytes, size_t capacity,
70 size_t* count);
71 nx_result_t (*stop)(void* context);
72 nx_result_t (*attach_wake)(void* context, const nx_irq_wake_t* wake,
73 uint8_t syscall_ceiling);
74 nx_result_t (*rx_start)(void* context, nx_stream_t* stream);
75 nx_result_t (*rx_stop)(void* context);
77
85 void* context;
86};
87
103 const uint8_t* data, size_t length,
104 nx_time_us_t deadline);
125 nx_uart_tx_request_t* request);
138 nx_uart_tx_request_t* request);
152 nx_uart_tx_request_t* request);
180 nx_uart_rx_event_t* events,
181 size_t capacity, size_t* count);
197 size_t capacity, size_t* count);
230 const nx_irq_wake_t* wake,
231 uint8_t syscall_ceiling);
248 nx_stream_t* stream);
261#ifdef __cplusplus
262}
263#endif
264
265#endif
Caller-owned admission, borrow, settlement and stable cancellation.
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
Bounded caller-owned blocks with explicit producer/consumer loans.
Optional immutable wake target borrowed by an IRQ provider.
Definition wake.h:26
Caller-owned request metadata, without payload or callbacks.
Definition request.h:38
Caller-owned stream control, initialized before publication.
Definition stream.h:53
Shared read-only methods using one provider state.
Definition uart.h:62
void(* service)(void *context)
Definition uart.h:66
nx_result_t(* stop)(void *context)
Definition uart.h:71
nx_result_t(* rx_stop)(void *context)
Definition uart.h:75
nx_result_t(* attach_wake)(void *context, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)
Definition uart.h:72
nx_result_t(* read_bytes)(void *context, uint8_t *bytes, size_t capacity, size_t *count)
Definition uart.h:69
nx_result_t(* read_events)(void *context, nx_uart_rx_event_t *events, size_t capacity, size_t *count)
Definition uart.h:67
nx_result_t(* cancel)(void *context, nx_uart_tx_request_t *request)
Definition uart.h:65
nx_result_t(* submit)(void *context, nx_uart_tx_request_t *request)
Definition uart.h:63
nx_result_t(* start_admitted)(void *context, nx_uart_tx_request_t *request)
Definition uart.h:64
nx_result_t(* rx_start)(void *context, nx_stream_t *stream)
Definition uart.h:74
Immutable interface pointing to caller-owned state.
Definition uart.h:83
const nx_uart_ops_t * ops
Definition uart.h:84
void * context
Definition uart.h:85
Timestamp belongs to provider clock; precision is hardware-specific.
Definition uart.h:41
uint32_t flags
Definition uart.h:43
uint8_t byte
Definition uart.h:44
nx_time_us_t timestamp_us
Definition uart.h:42
Caller-owned TX descriptor; initialize base before first prepare.
Definition uart.h:50
const uint8_t * data
Definition uart.h:52
nx_request_t base
Definition uart.h:51
uint64_t nx_time_us_t
Microseconds in one boot/clock domain; no wall-clock semantics.
Definition time.h:20
nx_result_t nx_uart_port_start_admitted(const nx_uart_port_t *port, nx_uart_tx_request_t *request)
Start an adapter-admitted QUEUED request without readmission.
struct nx_uart_port nx_uart_port_t
Definition uart.h:18
void nx_uart_port_service(const nx_uart_port_t *port)
Observe time/hardware completion and drain one active request.
nx_result_t nx_uart_port_submit(const nx_uart_port_t *port, nx_uart_tx_request_t *request)
Submit one direct request to a single-executor UART.
nx_result_t nx_uart_port_read_bytes(const nx_uart_port_t *port, uint8_t *bytes, size_t capacity, size_t *count)
Read buffered bytes from the selected byte profile.
nx_uart_rx_profile_t
Definition uart.h:19
@ NX_UART_RX_EVENTS
Definition uart.h:21
@ NX_UART_RX_BLOCKS
Definition uart.h:22
@ NX_UART_RX_BYTES
Definition uart.h:20
nx_result_t nx_uart_port_cancel(const nx_uart_port_t *port, nx_uart_tx_request_t *request)
Request cancellation; acceptance does not mean settlement.
nx_result_t nx_uart_tx_prepare(nx_uart_tx_request_t *request, const uint8_t *data, size_t length, nx_time_us_t deadline)
Prepare an unborrowed IRQ TX descriptor without copying data.
nx_result_t nx_uart_port_rx_start(const nx_uart_port_t *port, nx_stream_t *stream)
Start the selected RX block mode using exact caller storage.
nx_result_t nx_uart_port_read_events(const nx_uart_port_t *port, nx_uart_rx_event_t *events, size_t capacity, size_t *count)
Read buffered RX events from the selected event profile.
nx_result_t nx_uart_port_attach_wake(const nx_uart_port_t *port, const nx_irq_wake_t *wake, uint8_t syscall_ceiling)
Attach or detach one explicit IRQ wake target.
nx_result_t nx_uart_port_stop(const nx_uart_port_t *port)
Close admission and drain TX before releasing hardware.
nx_result_t nx_uart_port_rx_stop(const nx_uart_port_t *port)
Stop RX block production without revoking consumer loans.
Explicit borrowed IRQ wake target and syscall-ceiling check.