Universal Asynchronous Receiver/Transmitter interfaces for serial communication.
More...
|
| MYRIOTA_HARDWARE_API void * | UARTInit (UARTInterface UARTNum, uint32_t BaudRate, uint32_t Options) |
| | Initialise a UART interface.
|
| |
| MYRIOTA_HARDWARE_API void | UARTDeinit (void *Handle) |
| | Deinitialise a UART interface.
|
| |
| MYRIOTA_HARDWARE_API int | UARTWrite (void *Handle, const uint8_t *Tx, size_t Length) |
| | Write to a UART interface synchronously.
|
| |
| MYRIOTA_HARDWARE_API int | UARTRead (void *Handle, uint8_t *Rx, size_t Length) |
| | Read from a UART interface synchronously.
|
| |
Universal Asynchronous Receiver/Transmitter interfaces for serial communication.
◆ UARTInterface
UART interfaces.
| Enumerator |
|---|
| UART_0 | Can be used for firmware update via the bootloader.
|
| UART_1 | Used by GNSS in the Developer Kit.
|
| LEUART | Low energy, only supports baudrate up to 9600.
|
◆ UARTOption
UART configuration bitflags.
- Note
- UART_STOPBITS_HALF and UART_STOPBITS_ONEANDHALF are not supported for the LEUART interface.
-
Parity flags and Stop Bit flags are mutually exclusive within their respective categories.
| Enumerator |
|---|
| UART_DEFAULT_OPTIONS | Default setting is 8N1 (8 data bits, no parity, 1 stop bit).
|
| UART_PARITY_ODD | Enable odd parity generation and checking.
|
| UART_PARITY_EVEN | Enable even parity generation and checking.
|
| UART_DATABITS_NINE | Configure payload for 9 data bits instead of the default 8.
|
| UART_STOPBITS_HALF | Configure frame to use 0.5 stop bits.
|
| UART_STOPBITS_ONEANDHALF | Configure frame to use 1.5 stop bits.
|
| UART_STOPBITS_TWO | Configure frame to use 2 stop bits.
|
◆ UARTInit()
| MYRIOTA_HARDWARE_API void * UARTInit |
( |
UARTInterface |
UARTNum, |
|
|
uint32_t |
BaudRate, |
|
|
uint32_t |
Options |
|
) |
| |
Initialise a UART interface.
- Parameters
-
| UARTNum | The UART number defined by enum UARTInterface. |
| BaudRate | The baud rate for the UART communication. |
| Options | Options for UART configuration. Bitmask of UARTOption flags. |
- Returns
- The handle if succeeded and NULL if failed.
◆ UARTDeinit()
| MYRIOTA_HARDWARE_API void UARTDeinit |
( |
void * |
Handle | ) |
|
Deinitialise a UART interface.
- Parameters
-
◆ UARTWrite()
| MYRIOTA_HARDWARE_API int UARTWrite |
( |
void * |
Handle, |
|
|
const uint8_t * |
Tx, |
|
|
size_t |
Length |
|
) |
| |
Write to a UART interface synchronously.
- Parameters
-
| Handle[in] | The UART handle returned by UARTInit(). |
| Tx[in] | Pointer to the data to be transmitted. |
| Length | Number of bytes to transmit. |
- Returns
- 0 if write succeeds and -1 if write fails.
◆ UARTRead()
| MYRIOTA_HARDWARE_API int UARTRead |
( |
void * |
Handle, |
|
|
uint8_t * |
Rx, |
|
|
size_t |
Length |
|
) |
| |
Read from a UART interface synchronously.
- Parameters
-
| Handle[in] | The UART handle returned by UARTInit(). |
| Rx[out] | Pointer to the buffer to store received data. |
| Length | Number of bytes to read. |
- Returns
- Number of bytes read if successful, -1 if read fails.