HAL UART Overview

Introducing UART

group UART_Introduction

  • This introduction is under development.

Module and files

The following diagram illustrates the UART module and its associated files.

Module and files diagram

Component diagram

The following diagram illustrates the software components involved in the UART module. It shows the interactions between the user application, HAL drivers, low-level drivers, and the hardware components.

@startuml

<style>

componentDiagram {

   arrow {

      FontSize 8

   }

}

</style>



title UART Software Component Diagram



package "HAL" {

    [HAL_SERVICE]

    [HAL_UART]

    [HAL_DMA]

}



package "Low Layer" {

    [LL_LPUART / LL_USART]

    [CMSIS]

    [UART Interrupt routine service]

    [DMA Interrupt routine service]

}



package "HW" {

    [STM32_HW]

}



[Appli] --> [HAL_UART] : HAL UART API

[Appli] <-- [HAL_UART] : UART callback

[HAL_UART] --> [LL_LPUART / LL_USART] : LL UART API

[HAL_UART] -r-> [HAL_DMA] : HAL DMA_Start_IT\nHAL_DMA_Abort_IT

[HAL_UART] -l-> [HAL_SERVICE] : HAL_GetTick

[HAL_UART] <-- [UART Interrupt routine service]

[HAL_UART] <-r- [HAL_DMA]:Half transfer complete\nTransfer complete\nError

[LL_LPUART / LL_USART] --> [CMSIS]:UART register def

[HAL_DMA] <-d- [DMA Interrupt routine service]

[STM32_HW] -u--> [UART Interrupt routine service]: UARTx Irq

[STM32_HW] -u--> [DMA Interrupt routine service] : DMA Channel Irq

[STM32_HW] <-u-- [LL_LPUART / LL_USART] : UART registers R/W

@enduml

Configuration table

The following table lists the configuration defines for the HAL UART module, specifying their locations, default values, and descriptions:

group UART_Configuration_Table

Configuration inside the UART driver:

Config defines

Where

Default value

Note

USE_HAL_UART_MODULE

hal_conf.h

1

Enable the HAL UART module.

USE_HAL_UART_REGISTER_CALLBACKS

hal_conf.h

0

Enable the register callbacks

USE_HAL_UART_CLK_ENABLE_MODEL

hal_conf.h

HAL_CLK_ENABLE_NO

Enable peripheral clock in the HAL_UART_Init

USE_HAL_UART_USER_DATA

hal_conf.h

0

Add a user data inside HAL UART handle

USE_HAL_UART_GET_LAST_ERRORS

hal_conf.h

0

Add error member inside HAL UART handle

USE_HAL_UART_DMA

hal_conf.h

1

Enable DMA code inside HAL UART

USE_HAL_CHECK_PARAM

hal_conf.h

0

Enable checking of vital parameters at runtime

USE_HAL_MUTEX

hal_conf.h

0

Enable the use of semaphore in the HAL driver

USE_HAL_CHECK_PROCESS_STATE

hal_conf.h

0

Enable atomic access to process state check

USE_ASSERT_DBG_PARAM

PreProcessor env

NA

Enable the params assert

USE_ASSERT_DBG_STATE

PreProcessor env

NA

Enable the state assert