HAL USART Types

HAL USART Types

group USART_Exported_Types

Typedefs

typedef struct hal_usart_handle_s hal_usart_handle_t

HAL USART handler type

typedef void ( * hal_usart_cb_t ) ( hal_usart_handle_t * husart )

HAL USART Generic USART callback Type

Enums

enum hal_usart_t

HAL USART Instance Definition.

Values:

enumerator HAL_USART1

Instance USART1

enumerator HAL_USART2

Instance USART2

enumerator HAL_USART3

Instance USART3

enum hal_usart_state_t

HAL USART State Structure Definition.

Values:

enumerator HAL_USART_STATE_RESET

Peripheral is not initialized

enumerator HAL_USART_STATE_INIT

Peripheral is initialized but not configured

enumerator HAL_USART_STATE_IDLE

Peripheral is initialized and a global config is set

enumerator HAL_USART_STATE_RX_ACTIVE

Peripheral Reception process is ongoing

enumerator HAL_USART_STATE_TX_ACTIVE

Peripheral Transmit process is ongoing

enumerator HAL_USART_STATE_TX_RX_ACTIVE

Peripheral Transmit/Receive process is ongoing

enumerator HAL_USART_STATE_ABORT

Peripheral process is aborting

enum hal_usart_request_t

HAL USART Request Definition.

Values:

enumerator HAL_USART_REQUEST_RX_DATA_FLUSH

Receive Data flush Request Receive Data flush Request Receive Data flush Request

enumerator HAL_USART_REQUEST_TX_DATA_FLUSH

Transmit data flush Request Transmit data flush Request Transmit Data flush Request

enum hal_usart_mode_t

HAL USART Master/Slave Mode Definition.

Values:

enumerator HAL_USART_MODE_MASTER

USART Master mode is configured

enumerator HAL_USART_MODE_SLAVE

USART Slave mode is configured

enum hal_usart_slave_select_config_t

HAL USART Slave Select Configuration Definition.

Values:

enumerator HAL_USART_SLAVE_SELECT_PIN_IGNORED

USART NSS PIN is ignored to select the slave 0x00000008 Slave Select (NSS) pin management

enumerator HAL_USART_SLAVE_SELECT_PIN_USED

USART NSS PIN is used to select the slave

struct hal_usart_handle_s
#include <stm32c5xx_hal_usart.h>

HAL USART Handle Structure Type.

Public Members

hal_usart_t instance

Peripheral instance

const uint8_t * p_tx_buff

Pointer to USART Tx transfer Buffer

volatile uint32_t tx_xfer_size

USART Tx Transfer size

volatile uint32_t tx_xfer_count

USART Tx Transfer Counter

uint8_t * p_rx_buff

Pointer to USART Rx transfer Buffer

volatile uint32_t rx_xfer_size

USART Rx Transfer size

volatile uint32_t rx_xfer_count

USART Rx Transfer Counter

volatile uint16_t rdr_register_mask

USART Rx RDR register mask

hal_usart_fifo_mode_status_t fifo_mode

Specifies if the FIFO mode is being used.

uint16_t nb_rx_data_to_process

Number of data to process during RX ISR execution

uint16_t nb_tx_data_to_process

Number of data to process during TX ISR execution

hal_usart_mode_t usart_mode

USART Master/Slave mode

void ( * p_rx_isr ) ( struct hal_usart_handle_s * husart )

Function pointer on Rx IRQ handler

void ( * p_tx_isr ) ( struct hal_usart_handle_s * husart )

Function pointer on Tx IRQ handler

hal_dma_handle_t * hdma_tx

USART Tx DMA Handle parameters

hal_dma_handle_t * hdma_rx

USART Rx DMA Handle parameters

volatile hal_usart_state_t global_state

USART state information related to global Handle management

hal_usart_cb_t p_tx_half_cplt_callback

USART Tx Half Complete Callback

hal_usart_cb_t p_tx_cplt_callback

USART Tx Complete Callback

hal_usart_cb_t p_rx_half_cplt_callback

USART Rx Half Complete Callback

hal_usart_cb_t p_rx_cplt_callback

USART Rx Complete Callback

hal_usart_cb_t p_tx_rx_cplt_callback

USART Tx/Rx Complete Callback

hal_usart_cb_t p_error_callback

USART Error Callback

hal_usart_cb_t p_abort_cplt_callback

USART Abort Complete Callback

hal_usart_cb_t p_rx_fifo_full_callback

USART Rx FIFO Full Callback

hal_usart_cb_t p_tx_fifo_empty_callback

USART Tx FIFO Empty Callback

hal_os_semaphore_t semaphore

USART OS semaphore

const void * p_user_data

User data pointer

volatile uint32_t last_error_codes

Last error codes on reception side

USART FIFO Mode Definition

group USART_FIFO_Mode

Enums

enum hal_usart_fifo_threshold_t

HAL USART FIFO Threshold Definition.

Values:

enumerator HAL_USART_FIFO_THRESHOLD_1_8

FIFO reaches 1/8 of its depth FIFO reaches 1/8 of its depth

enumerator HAL_USART_FIFO_THRESHOLD_1_4

FIFO reaches 1/4 of its depth FIFO reaches 1/4 of its depth

enumerator HAL_USART_FIFO_THRESHOLD_1_2

FIFO reaches 1/2 of its depth FIFO reaches 1/2 of its depth

enumerator HAL_USART_FIFO_THRESHOLD_3_4

FIFO reaches 3/4 of its depth FIFO reaches 3/4 of its depth

enumerator HAL_USART_FIFO_THRESHOLD_7_8

FIFO reaches 7/8 of its depth FIFO reaches 7/8 of its depth

enumerator HAL_USART_FIFO_THRESHOLD_8_8

FIFO reaches 8/8 of its depth FIFO becomes empty for TX and full for RX

enum hal_usart_fifo_mode_status_t

HAL USART FIFO Mode Status Definition.

Values:

enumerator HAL_USART_FIFO_MODE_DISABLED

USART FIFO Mode is disabled

enumerator HAL_USART_FIFO_MODE_ENABLED

USART FIFO Mode is enabled

USART Basic configuration Definition

group USART_Basic_config

Enums

enum hal_usart_word_length_t

HAL USART Word Length Definition.

Values:

enumerator HAL_USART_WORD_LENGTH_7_BIT

7-bit long USART frame 0x10000000 Word length - Bit 1 7 bit word length : Start bit, 7 data bits, n stop bits

enumerator HAL_USART_WORD_LENGTH_8_BIT

8-bit long USART frame 8 bit word length : Start bit, 8 data bits, n stop bits

enumerator HAL_USART_WORD_LENGTH_9_BIT

9-bit long USART frame 0x00001000 Word length - Bit 0 9 bit word length : Start bit, 9 data bits, n stop bits

enum hal_usart_stop_bits_t

HAL USART Stop Bits Definition.

Values:

enumerator HAL_USART_STOP_BIT_0_5

USART frame with 0.5 stop bit 0x00001000 0.5 stop bit

enumerator HAL_USART_STOP_BIT_1

USART frame with 1 stop bit 1 stop bit

enumerator HAL_USART_STOP_BIT_1_5

USART frame with 1.5 stop bits 1.5 stop bits

enumerator HAL_USART_STOP_BIT_2

USART frame with 2 stop bits 0x00002000 2 stop bits

enum hal_usart_parity_t

HAL USART Parity Definition.

Note

When parity is enabled, the computed parity is inserted at the MSB position of the transmitted data (9th bit when the word length is set to 9 data bits; 8th bit when the word length is set to 8 data bits).

Values:

enumerator HAL_USART_PARITY_NONE

No parity Parity control disabled

enumerator HAL_USART_PARITY_EVEN

Even parity 0x00000400 Parity Control Enable Parity control enabled and Even Parity is selected

enumerator HAL_USART_PARITY_ODD

Odd parity Parity control enabled and Odd Parity is selected

enum hal_usart_direction_t

HAL USART Direction Definition.

Values:

enumerator HAL_USART_DIRECTION_RX

RX mode 0x00000004 Receiver Enable Transmitter is disabled and Receiver is enabled

enumerator HAL_USART_DIRECTION_TX

TX mode 0x00000008 Transmitter Enable Transmitter is enabled and Receiver is disabled

enumerator HAL_USART_DIRECTION_TX_RX

RX and TX mode Transmitter and Receiver are enabled

enum hal_usart_prescaler_t

HAL USART Clock Prescaler Definition.

Values:

enumerator HAL_USART_PRESCALER_DIV1

fclk_pres = fclk Input clock not divided

enumerator HAL_USART_PRESCALER_DIV2

fclk_pres = fclk/2 Input clock divided by 2

enumerator HAL_USART_PRESCALER_DIV4

fclk_pres = fclk/4 Input clock divided by 4

enumerator HAL_USART_PRESCALER_DIV6

fclk_pres = fclk/6 Input clock divided by 6

enumerator HAL_USART_PRESCALER_DIV8

fclk_pres = fclk/8 Input clock divided by 8

enumerator HAL_USART_PRESCALER_DIV10

fclk_pres = fclk/10 Input clock divided by 10

enumerator HAL_USART_PRESCALER_DIV12

fclk_pres = fclk/12 Input clock divided by 12

enumerator HAL_USART_PRESCALER_DIV16

fclk_pres = fclk/16 Input clock divided by 16

enumerator HAL_USART_PRESCALER_DIV32

fclk_pres = fclk/32 Input clock divided by 32

enumerator HAL_USART_PRESCALER_DIV64

fclk_pres = fclk/64 Input clock divided by 64

enumerator HAL_USART_PRESCALER_DIV128

fclk_pres = fclk/128 Input clock divided by 128

enumerator HAL_USART_PRESCALER_DIV256

fclk_pres = fclk/256 Input clock divided by 256

enum hal_usart_clock_polarity_t

HAL USART Clock Polarity Definition.

Values:

enumerator HAL_USART_CLOCK_POLARITY_LOW

Steady low value on SCLK pin outside transmission window Steady low value on SCLK pin outside transmission window

enumerator HAL_USART_CLOCK_POLARITY_HIGH

Steady high value on SCLK pin outside transmission window 0x00000400 Clock Polarity Steady high value on SCLK pin outside transmission window

enum hal_usart_clock_phase_t

HAL USART Clock Phase Definition.

Values:

enumerator HAL_USART_CLOCK_PHASE_1_EDGE

USART frame phase on first clock transition The first clock transition is the first data capture edge

enumerator HAL_USART_CLOCK_PHASE_2_EDGE

USART frame phase on second clock transition 0x00000200 Clock Phase The second clock transition is the first data capture edge

enum hal_usart_clock_last_bit_state_t

HAL USART Clock Last Bit Status Definition.

Values:

enumerator HAL_USART_CLOCK_LAST_BIT_DISABLED

USART frame last data bit clock pulse not output to SCLK pin The clock pulse of the last data bit is not output to the SCLK pin

enumerator HAL_USART_CLOCK_LAST_BIT_ENABLED

USART frame last data bit clock pulse output to SCLK pin 0x00000100 Last Bit Clock pulse The clock pulse of the last data bit is output to the SCLK pin

struct hal_usart_config_t
#include <stm32c5xx_hal_usart.h>

HAL USART Global Config Structure Type.

Public Members

uint32_t baud_rate

This member configures the USART communication baud rate. The baud rate register is computed using the following formula: Baud Rate Register[15:4] = ((2 * hal_usart_config_t->clock_prescaler) / ((hal_usart_config_t->baud_rate)))[15:4] Baud Rate Register[3] = 0 Baud Rate Register[2:0] = (((2 * hal_usart_config_t->clock_prescaler) / ((hal_usart_config_t->baud_rate)))[3:0]) >> 1 where usart_ker_ck_pres is the USART input clock divided by a prescaler

hal_usart_prescaler_t clock_prescaler

Specifies the prescaler value used to divide the USART clock source.

hal_usart_word_length_t word_length

Specifies the number of data bits transmitted or received in a frame.

hal_usart_stop_bits_t stop_bits

Specifies the number of stop bits transmitted.

hal_usart_parity_t parity

Specifies the parity mode.

hal_usart_direction_t direction

Specifies the process direction, receive and/or transmit.

hal_usart_clock_polarity_t clock_polarity

Specifies the clock polarity.

hal_usart_clock_phase_t clock_phase

Specifies the clock phase.

hal_usart_clock_last_bit_state_t clock_last_bit

Specifies the clock last bit enabling.

hal_usart_mode_t mode

Specifies the Mode (Master or Slave), by default configured in Master Mode.