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

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

Typedefs

typedef void(* uart_rxByteHandlerFunc) (uint8_t rxByte)
 

Functions

void uart_Init (void)
 Initializes the UART module. More...
 
void uart_Step (void)
 Copies the received bytes into the user-accessible queue. Reads all the available bytes in the DMA RX buffer, and copies them to the user-accessible queue. More...
 
cb_CircularBufferuart_GetRxQueue (void)
 Gets the user-accessible queue of the received bytes. More...
 
void uart_SendByteAsync (uint8_t data)
 Asynchronously sends the given byte through the UART bus. More...
 
void uart_SendBytesAsync (uint8_t *data, int length)
 Asynchronously sends the given bytes through the UART bus. More...
 
void uart_FlushTx (void)
 Start the DMA to send the bytes waiting in the intermediate buffer. More...
 

Detailed Description

Driver for the UART serial communication peripheral.

This driver controls the UART peripheral of the STM32, connected to the USB-to-serial chip.

Call uart_Init() first in the initialization code, specifiying the function to call when a byte arrives (sent from the computer). To send data, call uart_SendByte() or uart_SendBytes().

Note that this module should not be used directly. It is a better option to use it through the Communication module, to benefit from the already implemented communication protocol between the board and MATLAB.

Typedef Documentation

◆ uart_rxByteHandlerFunc

typedef void(* uart_rxByteHandlerFunc) (uint8_t rxByte)

Typedef for a pointer to a function to call automatically when a byte arrives from the computer.

Function Documentation

◆ uart_FlushTx()

void uart_FlushTx ( void  )

Start the DMA to send the bytes waiting in the intermediate buffer.

◆ uart_GetRxQueue()

cb_CircularBuffer* uart_GetRxQueue ( void  )

Gets the user-accessible queue of the received bytes.

Returns
the address of the queue.

◆ uart_Init()

void uart_Init ( void  )

Initializes the UART module.

◆ uart_SendByteAsync()

void uart_SendByteAsync ( uint8_t  data)

Asynchronously sends the given byte through the UART bus.

Parameters
datathe data byte to send.
Remarks
The byte may not be sent immediately, they are stored temporarily in an intermediate buffer that the DMA will copy to UART peripheral, when it is full. Call uart_FlushTx() to start the DMA transfer immediately.
Warning
This function will block until a write buffer is ready.

◆ uart_SendBytesAsync()

void uart_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).
Remarks
The bytes may not be sent immediately, they are stored temporarily in an intermediate buffer that the DMA will copy to UART peripheral, when it is full. Call uart_FlushTx() to start the DMA transfer immediately.
Warning
This function will block until a write buffer is ready, which can be very long.

◆ uart_Step()

void uart_Step ( void  )

Copies the received bytes into the user-accessible queue. Reads all the available bytes in the DMA RX buffer, and copies them to the user-accessible queue.

Remarks
This function must called often, otherwise the DMA RX buffer may be full.