UART#

Serial UART Interface Driver.

Flexible UART driver implementation for communication with external devices.

Functions#

void
uart_init(void)

Initialize the configured USART peripheral for UART operation.

void

Disable the configured USART peripheral for UART operation.

int32_t
uart_sendBuffer(uint8_t *buffer, size_t length, bool blocking)

Write a data buffer to the UART.

int32_t
uart_sendByte(uint8_t byte)

Write one byte to the UART in a blocking fashion.

bool

Find out whether the UART can accept more data to send.

size_t

Get the number of bytes ready for reading.

int32_t
uart_receiveBuffer(uint8_t *buffer, size_t requestedLength, size_t *receivedLength, bool blocking, uint32_t timeout)

Read from the UART into a data buffer.

int32_t
uart_receiveByte(uint8_t *byte)

Get one byte from UART in a blocking fashion.

int32_t
uart_receiveByteTimeout(uint8_t *byte, uint32_t timeout)

Get one byte from UART in a blocking fashion.

int32_t
uart_flush(bool flushTx, bool flushRx)

Flush one or both UART buffers.

Function Documentation#

uart_init#

void uart_init (void )

Initialize the configured USART peripheral for UART operation.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Also sets up GPIO settings for TX, RX, and, if configured, flow control.


uart_deinit#

void uart_deinit (void )

Disable the configured USART peripheral for UART operation.

Parameters
TypeDirectionArgument NameDescription
voidN/A

uart_sendBuffer#

int32_t uart_sendBuffer (uint8_t * buffer, size_t length, bool blocking)

Write a data buffer to the UART.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[in]buffer

The data buffer to send

size_t[in]length

Number of bytes in the buffer to send

bool[in]blocking

Indicates whether this transfer can be offloaded to LDMA and return, or whether to wait on completion before returning.

Returns

  • BOOTLOADER_OK if successful, error code otherwise


uart_sendByte#

int32_t uart_sendByte (uint8_t byte)

Write one byte to the UART in a blocking fashion.

Parameters
TypeDirectionArgument NameDescription
uint8_t[in]byte

The byte to send

Returns

  • BOOTLOADER_OK if successful, error code otherwise


uart_isTxIdle#

bool uart_isTxIdle (void )

Find out whether the UART can accept more data to send.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • true if the UART is not currently transmitting


uart_getRxAvailableBytes#

size_t uart_getRxAvailableBytes (void )

Get the number of bytes ready for reading.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns


uart_receiveBuffer#

int32_t uart_receiveBuffer (uint8_t * buffer, size_t requestedLength, size_t * receivedLength, bool blocking, uint32_t timeout)

Read from the UART into a data buffer.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[out]buffer

The data buffer to receive into

size_t[in]requestedLength

Number of bytes to read

size_t *[out]receivedLength

Number of bytes read

bool[in]blocking

Indicates whether to wait for requestedLength bytes to be available and read before returning, or whether to read out data currently in the buffer and return.

uint32_t[in]timeout

Number of milliseconds to wait for data in blocking mode

Returns

  • BOOTLOADER_OK if successful, error code otherwise


uart_receiveByte#

int32_t uart_receiveByte (uint8_t * byte)

Get one byte from UART in a blocking fashion.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[out]byte

The byte to send

Returns

  • BOOTLOADER_OK if successful, error code otherwise


uart_receiveByteTimeout#

int32_t uart_receiveByteTimeout (uint8_t * byte, uint32_t timeout)

Get one byte from UART in a blocking fashion.

Parameters
TypeDirectionArgument NameDescription
uint8_t *[out]byte

The byte to send

uint32_t[in]timeout

Maximum timeout before aborting transfer

Returns

  • BOOTLOADER_OK if successful, error code otherwise


uart_flush#

int32_t uart_flush (bool flushTx, bool flushRx)

Flush one or both UART buffers.

Parameters
TypeDirectionArgument NameDescription
bool[in]flushTx

Flush the transmit buffer when true

bool[in]flushRx

Flush the receive buffer when true

Returns

  • BOOTLOADER_OK