quasar_uart.h

This module configure UART and provides functions to transmit and receive.

Copyright

Copyright (C) 2026 SPARK Microsystems International Inc. All rights reserved.

License

This source code is proprietary and subject to the SPARK Microsystems Software EULA found in this package in file EULA.txt.

Author

SPARK FW Team.

Note

This driver only supports a UART protocol with 8 bits of data.

Typedefs

typedef enum quasar_uart_selection quasar_uart_selection_t

List of all available UART instances. Also used as index into Quasar FIFO buffer array.

typedef enum quasar_uart_baud_rate quasar_uart_baud_rate_t

List of most common baud rates.

typedef enum quasar_uart_stop quasar_uart_stop_t

List of available stop bits configurations.

typedef enum quasar_uart_parity quasar_uart_parity_t

List of available parity bits configurations.

typedef struct quasar_uart_config quasar_uart_config_t

Quasar BSP UART configuration.

Enums

enum quasar_uart_selection

List of all available UART instances. Also used as index into Quasar FIFO buffer array.

Values:

enumerator QUASAR_UART_SELECTION_USART1 = 0

Select the full feature USART 1.

enumerator QUASAR_UART_SELECTION_USART2 = 1

Select the full feature USART 2.

enumerator QUASAR_UART_SELECTION_USART3 = 2

Select the full feature USART 3.

enumerator QUASAR_UART_SELECTION_UART4 = 3

Select the basic feature UART 4.

enumerator QUASAR_UART_SELECTION_UART5 = 4

Select the basic feature UART 5.

enumerator QUASAR_UART_SELECTION_USART6 = 5

Select the full feature USART 6.

enumerator _QUASAR_UART_SELECTION_COUNT = 6

Indicate the number of possible UART selection.

enum quasar_uart_baud_rate

List of most common baud rates.

Values:

enumerator QUASAR_UART_BAUD_RATE_1200 = 1200

Select the UART communication at 1200 baud/s.

enumerator QUASAR_UART_BAUD_RATE_2400 = 2400

Select the UART communication at 2400 baud/s.

enumerator QUASAR_UART_BAUD_RATE_4800 = 4800

Select the UART communication at 4800 baud/s.

enumerator QUASAR_UART_BAUD_RATE_9600 = 9600

Select the UART communication at 9600 baud/s.

enumerator QUASAR_UART_BAUD_RATE_19200 = 19200

Select the UART communication at 19200 baud/s.

enumerator QUASAR_UART_BAUD_RATE_38400 = 38400

Select the UART communication at 38400 baud/s.

enumerator QUASAR_UART_BAUD_RATE_57600 = 57600

Select the UART communication at 57600 baud/s.

enumerator QUASAR_UART_BAUD_RATE_115200 = 115200

Select the UART communication at 115200 baud/s.

enumerator QUASAR_UART_BAUD_RATE_1152000 = 1152000

Select the UART communication at 1152000 baud/s.

enum quasar_uart_stop

List of available stop bits configurations.

Values:

enumerator QUASAR_UART_STOP_BITS_0B5 = 0

Select the 0.5 stop bit configuration.

enumerator QUASAR_UART_STOP_BITS_1B = 1

Select the 1 stop bit configuration.

enumerator QUASAR_UART_STOP_BITS_1B5 = 2

Select the 1.5 stop bits configuration.

enumerator QUASAR_UART_STOP_BITS_2B = 3

Select the 2 stop bits configuration.

enum quasar_uart_parity

List of available parity bits configurations.

Values:

enumerator QUASAR_UART_PARITY_NONE = 0

Select no parity bit configuration.

enumerator QUASAR_UART_PARITY_EVEN = 1

Select even parity bit configuration.

enumerator QUASAR_UART_PARITY_ODD = 2

Select odd parity bit configuration.

Functions

void quasar_uart_init(quasar_uart_config_t uart_config)

Initialize the UART peripheral.

Parameters:

uart_config[in] Configuration of the UART peripheral.

void quasar_uart_deinit(quasar_uart_config_t uart_config)

Deinitialize the UART peripheral.

Parameters:

uart_config[in] Configuration of the UART peripheral.

void quasar_uart_transmit_byte_irq(quasar_uart_selection_t uart_selection, uint8_t data_to_transmit)

Initiate UART transmission with interrupt for a specified UART instance.

Note

This function should be used only if the UART instance has been initialized with IRQ.

Parameters:
  • uart_selection[in] Selected UART peripheral.

  • data_to_transmit[in] Byte to be transmitted.

void quasar_uart_set_rx_callback(quasar_uart_selection_t uart_selection, void (*callback)(void))

Set the UART RX callback for a specified UART instance.

Note

This function should be used only if the UART instance has been initialized with IRQ.

Parameters:
  • uart_selection[in] Selected UART peripheral.

  • callback[in] Pointer to the UART RX callback.

void quasar_uart_transmit_bytes_irq(quasar_uart_selection_t uart_selection, uint8_t *data_array_to_transmit, uint32_t size)

Initiate UART transmission with interrupt for a specified UART instance.

Note

This function should be used only if the UART instance has been initialized with IRQ.

Parameters:
  • uart_selection[in] Selected UART peripheral.

  • data_array_to_transmit[in] Array of data to be transmitted.

  • size[in] Size of the data array to be transmitted.

void quasar_uart_transmit_string_irq(quasar_uart_selection_t uart_selection, char *string_to_transmit, uint32_t size)

Initiate UART transmission with interrupt for a specified UART instance.

Note

This function should be used only if the UART instance has been initialized with IRQ.

Parameters:
  • uart_selection[in] Selected UART peripheral.

  • string_to_transmit[in] String to be transmitted.

  • size[in] Size of the data array to be transmitted.

uint8_t quasar_uart_receive_irq(quasar_uart_selection_t uart_selection)

Retrieve received data from the associated FIFO buffer used for reception.

Note

Received data is automatically pushed into the reception FIFO buffer using interrupts. This function pulls data from this FIFO buffer.

Note

This function should be used only if the UART instance has been initialized with IRQ.

Parameters:

uart_selection[in] Selected UART peripheral.

Returns:

The received data.

void quasar_uart_transmit_dma(quasar_uart_selection_t uart_selection, uint8_t *data, uint16_t size, quasar_bsp_status_t *err)

Initiate UART transmission with DMA for a specified UART instance.

Note

This function should be used only if the UART instance has been initialized without IRQ and if the DMA has to be initialized before.

Parameters:
  • uart_selection[in] Selected UART peripheral.

  • data[in] Data to be transmitted.

  • size[in] Size of the data array to be transmitted.

  • err[out] Pointer to store error status.

uint8_t quasar_uart_receive_dma(quasar_uart_selection_t uart_selection)

Initiate UART reception with DMA for a specified UART instance.

Note

This function should be used only if the UART instance has been initialized without IRQ and if the DMA has to be initialized before.

Parameters:

uart_selection[in] Selected UART peripheral.

Returns:

The received data.

void quasar_uart_transmit_blocking(quasar_uart_selection_t uart_selection, uint8_t *data, uint16_t size, uint16_t timeout, quasar_bsp_status_t *err)

Transmit over UART using blocking method.

Note

This function should be used only if the UART instance has been initialized without IRQ and if no DMA has been initialized.

Parameters:
  • uart_selection[in] Selected UART peripheral.

  • data[in] Data to be transmitted.

  • size[in] Size of the data array to be transmitted.

  • timeout[in] Timeout period.

  • err[out] Pointer to store error status.

uint8_t quasar_uart_receive_blocking(quasar_uart_selection_t uart_selection, uint16_t timeout)

Receive over UART using blocking method.

Note

This function should be used only if the UART instance has been initialized without IRQ and if no DMA has been initialized.

Parameters:
  • uart_selection[in] Selected UART peripheral.

  • timeout[in] Timeout period.

Returns:

The received data.

UART_HandleTypeDef *quasar_uart_get_selected_handle(quasar_uart_selection_t uart_selection)

Return the handle from the selected UART.

Parameters:

uart_selection[in] Available UART selection.

Returns:

Selected UART handle.

USART_TypeDef *quasar_uart_get_instance(quasar_uart_selection_t uart_selection)

Return the instance from the selected UART.

Parameters:

uart_selection[in] Available UART selection.

Returns:

Selected UART instance.

struct quasar_uart_config
#include <quasar_uart.h>

Quasar BSP UART configuration.

Public Members

quasar_uart_selection_t uart_selection

Selected UART instance.

quasar_uart_baud_rate_t baud_rate

Selected baud rate configuration.

quasar_uart_parity_t parity

Selected parity bits configuration.

quasar_uart_stop_t stop

Selected stop bits configuration.

quasar_gpio_config_t gpio_config_rx

Selected GPIO configuration used for reception.

quasar_gpio_config_t gpio_config_tx

Selected GPIO configuration used for transmission.

quasar_irq_priority_t irq_priority

Available IRQ priority.