UART¶
A universal asynchronous receiver-transmitter (UART) is a peripheral device for asynchronous serial communication.
MiraOS supports independent operation of multiple UARTs.
Defines¶
Name | Value | Description |
---|---|---|
MIRA_IODEF_UART0 |
{ miraint_uart_read, miraint_uart_write, 0 } | |
MIRA_IODEF_UART1 |
{ miraint_uart_read, miraint_uart_write, 1 } | |
MIRA_IODEF_UART2 |
{ miraint_uart_read, miraint_uart_write, 2 } | |
MIRA_IODEF_UART(_ID) |
{ miraint_uart_read, miraint_uart_write, (_ID) } |
Types¶
Name | Type | Description |
---|---|---|
mira_uart_input_callback_t |
int(* )(uint8_t c, void *storage) |
Structs¶
mira_uart_config_t¶
Type | Name | Description |
---|---|---|
int32_t |
baudrate | |
mira_gpio_pin_t |
tx_pin | Pin to use as TXD |
mira_gpio_pin_t |
rx_pin | Pin to use as RXD |
Functions¶
mira_uart_init¶
mira_status_t mira_uart_init( uint8_t uart_id, const mira_uart_config_t* config);
Initialize the UART module of ID uart_id. The custom config passed as parameter (NULL for platform default). Note that this might start a higher resolution clock in the CPU, which can significantly increase the power consumption until CPU is restarted.
Parameters
Parameter | Description |
---|---|
uart_id |
The index of the UART peripheral. |
config |
Pointer to a configuration to setup. |
Return
See the enum definition.
mira_uart_set_input_callback¶
mira_status_t mira_uart_set_input_callback( uint8_t uart_id, mira_uart_input_callback_t cb, void* storage);
Set a callback to be called on uart byte input.
Parameters
Parameter | Description |
---|---|
uart_id |
The index of the UART peripheral. |
cb |
The callback to call. |
storage |
Pointer to be passed to the callback |
Return
See the enum definition.