HRI board firmware  v2.1
Microcontroller firmware of the board used during the HRI labs.
Functions
Driver / Extension UART

Driver for the UART serial communication peripheral. More...

Functions

void exuart_Init (uint32_t baudRate)
 Initializes the UART module. More...
 
void exuart_SendByteAsync (uint8_t data)
 Asynchronously sends the given byte through the UART bus. More...
 
void exuart_SendBytesAsync (uint8_t *data, int length)
 Asynchronously sends the given bytes through the UART bus. More...
 
uint16_t exuart_ReceivedBytesCount (void)
 Gets the number of bytes received and ready to read. More...
 
uint8_t exuart_GetByte (void)
 Gets the next received byte. More...
 

Detailed Description

Driver for the UART serial communication peripheral.

This driver controls the UART peripheral of the STM32, connected to the digital extension connector.

Call exuart_Init() first in the initialization code. To send data, call exuart_SendByteAsync(). To receive data, check first that bytes are available by calling exuart_ReceivedBytesCount(), then call exuart_GetByte().

Function Documentation

◆ exuart_GetByte()

uint8_t exuart_GetByte ( void  )

Gets the next received byte.

Returns
the value of the received byte.
Remarks
call exuart_ReceivedBytesCount() before calling this function.
Warning
this function return 0 if no byte is available.

◆ exuart_Init()

void exuart_Init ( uint32_t  baudRate)

Initializes the UART module.

Parameters
baudRateUART communication frequency (baud rate) [b/s].

◆ exuart_ReceivedBytesCount()

uint16_t exuart_ReceivedBytesCount ( void  )

Gets the number of bytes received and ready to read.

Returns
the number of bytes ready to be acquired with exuart_GetByte().
Remarks
This function must called often, otherwise the DMA RX buffer may be full, and data will be lost.

◆ exuart_SendByteAsync()

void exuart_SendByteAsync ( uint8_t  data)

Asynchronously sends the given byte through the UART bus.

Parameters
datathe data byte to send.

◆ exuart_SendBytesAsync()

void exuart_SendBytesAsync ( uint8_t *  data,
int  length 
)

Asynchronously sends the given bytes through the UART bus.

Parameters
datapointer to the data bytes array to send.
lengthnumber of bytes to send (array size).