UART Events Service¶
- group UART Events Service
Manages external communication via OSUSat Messaging.
This service abstracts the byte-level UART peripheral into a message-level interface. The command handler polls this service to receive instructions, and the telemetry service uses it to ship data out.
- group Structures
Data containers for UART state.
-
struct uart_events_t¶
- #include <uart_events.h>
UART Service State Object.
Contains the runtime state of the UART wrapper, including:
RX/TX Ring Buffers
Parsing state machine variables
Error counters
Initialization flags
-
struct uart_events_t¶
- group Public API
Functions for sending and receiving messaging packets.
Functions
-
void uart_events_init(uart_events_t *uart)¶
Initialize the UART hardware and internal buffers.
Configures the UART peripheral and initializes the Ring Buffers within the provided context.
- Parameters:
uart – [out] Pointer to the UART service instance to initialize.
-
void uart_events_update(uart_events_t *uart)¶
Periodic update task.
This function handles the low-level driver tasks:
Processing interrupt flags.
Parsing the raw RX byte buffer inside the context to identify valid packets.
Flushing the TX buffer to the hardware.
- Parameters:
uart – [inout] Pointer to the UART service instance.
-
bool uart_events_is_packet_available(uart_events_t *uart)¶
Check if a valid packet has been received and decoded.
- Parameters:
uart – [in] Pointer to the UART service instance.
- Return values:
true – A complete OSUSatPacket is waiting in the RX queue.
false – No packets available.
-
void uart_events_get_packet(uart_events_t *uart, OSUSatPacket *packet)¶
Retrieve the next available packet from the RX queue.
Pops the oldest packet from the internal FIFO.
- Parameters:
uart – [inout] Pointer to the UART service instance.
packet – [out] Pointer to the destination structure where the data will be copied.
- Pre:
Call uart_events_is_packet_available to ensure data exists.
-
void uart_events_send_packet(uart_events_t *uart, const OSUSatPacket *packet)¶
Queue a packet for transmission.
Serializes the given OSUSatPacket into a byte stream and adds it to the internal TX buffer.
- Parameters:
uart – [inout] Pointer to the UART service instance.
packet – [in] Pointer to the packet to send.
-
void uart_events_init(uart_events_t *uart)¶