Myriota UltraLite SDK 2.4.0
Loading...
Searching...
No Matches

Universal Asynchronous Receiver/Transmitter interfaces for serial communication. More...

Enumerations

enum  UARTInterface { UART_0 = 0 , UART_1 , LEUART }
 UART interfaces. More...
 
enum  UARTOption {
  UART_DEFAULT_OPTIONS = 0x00000000 , UART_PARITY_ODD = 0x00000001 , UART_PARITY_EVEN , UART_DATABITS_NINE = 0x00000004 ,
  UART_STOPBITS_HALF = 0x00000008 , UART_STOPBITS_ONEANDHALF , UART_STOPBITS_TWO = 0x00000020
}
 UART configuration bitflags. More...
 

Functions

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.
 

Detailed Description

Universal Asynchronous Receiver/Transmitter interfaces for serial communication.

Enumeration Type Documentation

◆ 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

enum 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.

Function Documentation

◆ UARTInit()

MYRIOTA_HARDWARE_API void * UARTInit ( UARTInterface  UARTNum,
uint32_t  BaudRate,
uint32_t  Options 
)

Initialise a UART interface.

Parameters
UARTNumThe UART number defined by enum UARTInterface.
BaudRateThe baud rate for the UART communication.
OptionsOptions 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
Handle[in]The UART handle returned by UARTInit().

◆ 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.
LengthNumber 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.
LengthNumber of bytes to read.
Returns
Number of bytes read if successful, -1 if read fails.