UARTs¶
API for UART serial ports.
Functions
-
void
metal_uart_init
(struct metal_uart *uart, int baud_rate)¶ Initialize UART device.
Initialize the UART device described by the UART handle. This function must be called before any other method on the UART can be invoked. It is invalid to initialize a UART more than once.
- Parameters
uart
: The UART device handlebaud_rate
: the baud rate to set the UART to
-
int
metal_uart_putc
(struct metal_uart *uart, unsigned char c)¶ Output a character over the UART.
- Return
- 0 upon success
- Parameters
uart
: The UART device handlec
: The character to send over the UART
-
int
metal_uart_getc
(struct metal_uart *uart, unsigned char *c)¶ Read a character sent over the UART.
- Return
- 0 upon success
- Parameters
uart
: The UART device handlec
: The varible to hold the read character
-
int
metal_uart_get_baud_rate
(struct metal_uart *uart)¶ Get the baud rate of the UART peripheral.
- Return
- The current baud rate of the UART
- Parameters
uart
: The UART device handle
-
int
metal_uart_set_baud_rate
(struct metal_uart *uart, int baud_rate)¶ Set the baud rate of the UART peripheral.
- Return
- the new baud rate of the UART
- Parameters
uart
: The UART device handlebaud_rate
: The baud rate to configure
-
struct metal_interrupt *
metal_uart_interrupt_controller
(struct metal_uart *uart)¶ Get the interrupt controller of the UART peripheral.
Get the interrupt controller for the UART peripheral. The interrupt controller must be initialized before any interrupts can be registered or enabled with it.
- Return
- The handle for the UART interrupt controller
- Parameters
uart
: The UART device handle
-
int
metal_uart_get_interrupt_id
(struct metal_uart *uart)¶ Get the interrupt ID of the UART controller.
- Return
- The UART interrupt id
- Parameters
uart
: The UART device handle
-
struct
metal_uart
¶ - #include <uart.h>
Handle for a UART serial device.