uart.h¶
Low-level UART peripheral driver interface definition.
-
UART_UNDEF
¶ Default UART undefined value.
1
(UINT_MAX)
-
UART_DEV
( x)¶ Default UART device access macro.
1
(x)
-
enum
@150
¶ - UART_OK
= 0
- everything in order
- UART_NODEV
= -1
- invalid UART device given
- UART_NOBAUD
= -2
- given baudrate is not applicable
- UART_INTERR
= -3
- all other internal errors
- UART_NOMODE
= -4
- given mode is not applicable
- UART_OK
-
unsigned int
uart_t
¶ Define default UART type identifier.
-
void(*
uart_rx_cb_t
()¶ Signature for receive interrupt callback.
Parameters
arg: context to the callback (optional) data: the byte that was received
-
int
uart_init
(uart.h::uart_t
uart, uint32_t baudrate,uart.h::uart_rx_cb_t
rx_cb, void * arg)¶ Initialize a given UART device.
The UART device will be initialized with the following configuration:
- 8 data bits
- no parity
- 1 stop bit
- baudrate as given
If no callback parameter is given (rx_cb := NULL), the UART will be initialized in TX only mode.
Parameters
uart: UART device to initialize baudrate: desired baudrate in baud/s rx_cb: receive callback, executed in interrupt context once for every byte that is received (RX buffer filled), set to NULL for TX only mode arg: optional context passed to the callback functions Return values
- UART_OK on success
- UART_NODEV on invalid UART device
- UART_NOBAUD on inapplicable baudrate
- UART_INTERR on other errors
-
void
uart_write
(uart.h::uart_t
uart, const uint8_t * data,msp430_types.h::size_t
len)¶ Write data from the given buffer to the specified UART device.
This function is blocking, as it will only return after
len
bytes from the given buffer have been send. The way this data is send is up to the implementation: active waiting, interrupt driven, DMA, etc.Parameters
uart: UART device to use for transmission data: data buffer to send len: number of bytes to send
-
void
uart_poweron
(uart.h::uart_t
uart)¶ Power on the given UART device.
Parameters
uart: the UART device to power on
-
void
uart_poweroff
(uart.h::uart_t
uart)¶ Power off the given UART device.
Parameters
uart: the UART device to power off
-
struct
uart_isr_ctx_t
¶ Interrupt context for a UART device.
-
uart.h::uart_rx_cb_t
rx_cb
¶ data received interrupt callback
-
void *
arg
¶ argument to both callback routines
-