Midnight Sun Firmware
Loading...
Searching...
No Matches
uart.h
1#pragma once
2
3/************************************************************************************************
4 * @file uart.h
5 *
6 * @brief UART Library Header file
7 *
8 * @date 2024-11-02
9 * @author Midnight Sun Team #24 - MSXVI
10 ************************************************************************************************/
11
12/* Standard library Headers */
13#include <stdint.h>
14
15/* Inter-component Headers */
16
17/* Intra-component Headers */
18#include "gpio.h"
19
27typedef enum { UART_PORT_1 = 0, UART_PORT_2, NUM_UART_PORTS } UartPort;
28
30#define UART_MAX_BUFFER_LEN 256U
32#define UART_TIMEOUT_MS 1U
33
39typedef enum {
45
53typedef struct {
56 uint32_t baudrate;
59
70
83StatusCode uart_rx(UartPort uart, uint8_t *data, size_t len);
84
97StatusCode uart_tx(UartPort uart, uint8_t *data, size_t len);
98
StatusCode
StatusCodes for various errors.
Definition: status.h:27
StatusCode uart_tx(UartPort uart, uint8_t *data, size_t len)
Transmit data from the UART port.
Definition: uart.c:145
UartPort
UART Port selection.
Definition: uart.h:27
StatusCode uart_init(UartPort uart, UartSettings *settings)
Initialize UART instance, assuming standard 8 bits 1 stop bit.
Definition: uart.c:149
UartFlowControl
UART Flow control selection.
Definition: uart.h:39
StatusCode uart_rx(UartPort uart, uint8_t *data, size_t len)
Receive data from the UART port.
Definition: uart.c:141
@ UART_FLOW_CONTROL_RTS_CTS
Definition: uart.h:43
@ UART_FLOW_CONTROL_CTS
Definition: uart.h:42
@ UART_FLOW_CONTROL_RTS
Definition: uart.h:41
@ UART_FLOW_CONTROL_NONE
Definition: uart.h:40
Port and pin data.
Definition: gpio.h:112
UART Settings.
Definition: uart.h:53
GpioAddress rx
Definition: uart.h:55
UartFlowControl flow_control
Definition: uart.h:57
uint32_t baudrate
Definition: uart.h:56
GpioAddress tx
Definition: uart.h:54