HAL LTDC use cases

User Application LTDC Initialisation

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "Driver LTDC" as ltdc

participant "System" as system

participant "CORTEX" as cortex

participant "RCC" as rcc



== Prerequisite ==



user->system : HAL_Init()

system --> user

user->system : Configure system clock

system --> user



== Initialization ==



user->ltdc : HAL_LTDC_Init()



alt#grey #lightgrey If USE_HAL_LTDC_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO



ltdc->rcc : HAL_RCC_LTDC_EnableClock()

rcc --> ltdc

end



==LTDC System Initialization==

Note right user : LTDC System initialization can be called before\nLTDC HAL initialization



alt#grey #lightgrey If USE_HAL_LTDC_CLK_ENABLE_MODEL == HAL_CLK_ENABLE_NO



user->rcc : HAL_RCC_LTDC_EnableClock()

rcc --> user

end



Note right user : Clock enabling : 2 alternative \n\

- Either enable the LTDC clock at user code,\n\

- Either set the define USE_HAL_LTDC_CLK_ENABLE_MODEL \n\

to  HAL_CLK_ENABLE_PERIPH_ONLY and \n\

the clock will be enabled within the HAL_LTDC_Init

user->rcc : **Configure and activate the LTDC kernel clock source (PLL2 or PLL3)**

== Enable LTDC Interrupt ==



group #LightYellow Optional



user->cortex : HAL_CORTEX_NVIC_EnableIRQ()



end

@enduml

Called functions:

User Application LTDC Starting a Driver

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "Driver LTDC" as ltdc

participant "CORTEX" as cortex

participant "IRQ" as irq



==LTDC Configuration==



user->ltdc : HAL_LTDC_SetConfig()

ltdc --> user



group #LightYellow Optional

user->cortex : HAL_CORTEX_NVIC_EnableIRQ(LTDC_ER_IRQn)

end



alt#grey #lightgrey Set USE_HAL_LTDC_REGISTER_CALLBACKS to 1 in hal_conf



user->ltdc : HAL_LTDC_RegisterErrorCallback(User_ErrorCbk)

ltdc --> user



end



==LTDC Layer Configuration==

user->ltdc : HAL_LTDC_SetConfigLayer()

ltdc --> user



user->ltdc : HAL_LTDC_Start()

ltdc --> user



irq<- : Error interrupt



irq->ltdc : HAL_LTDC_IRQHandler() or\n\

HAL_LTDC_ErrorIRQHandler()



group #A0000099 If (USE_HAL_LTDC_GET_LAST_ERRORS == 1)

ltdc->ltdc : Update last_error_codes

end



ltdc->user : HAL_LTDC_ErrorCallback()



alt#grey #lightgrey IF USE_HAL_LTDC_REGISTER_CALLBACKS == 1

ltdc->user : User_ErrorCbk()

end



group #A0000099 If (USE_HAL_LTDC_GET_LAST_ERRORS == 1)

user->ltdc : HAL_LTDC_GetLastErrorCodes()

ltdc --> user :last errors code

end



@enduml

Called functions:

User Application LTDC Optional Layer Configurations

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "Driver LTDC" as ltdc

participant "IRQ" as irq



== Optional Configuration ==



group #LightYellow Optional



user->ltdc : HAL_LTDC_SetLayerWindowSize()

ltdc --> user



user->ltdc : HAL_LTDC_SetLayerWindowPosition()

ltdc --> user



user->ltdc : HAL_LTDC_SetLayerFrameBuffer()

ltdc --> user



user->ltdc :HAL_LTDC_SetLayerPitch()

ltdc --> user

user->ltdc : HAL_LTDC_SetLayerAlpha()

ltdc --> user



user->ltdc : HAL_LTDC_SetLayerBackgroundColor()

ltdc --> user



user->ltdc : HAL_LTDC_SetLayerAddress()

ltdc --> user



user->ltdc : HAL_LTDC_Layer_Enable()

ltdc --> user



user->ltdc : HAL_LTDC_Layer_Disable()

ltdc --> user



end

note right : These layer configurations are set by \n HAL_LTDC_SetConfigLayer() API \n but can be reconfigured by these unitary APIs



user->ltdc : HAL_LTDC_ForceReload()

note right : After reconfiguration, user must reload \n\

to apply those new layer configurations

ltdc --> user

group #A0000099 Interrupt management (if LTDC Interrupts enabled)



irq<- : Reload interrupt



irq->ltdc : HAL_LTDC_IRQHandler() or\n\

HAL_LTDC_ReloadEventIRQHandler()

ltdc->user : HAL_LTDC_ReloadEventCallback()



end

@enduml

Called functions:

User Application LTDC Optional Layer Features

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "Driver LTDC" as ltdc

participant "IRQ" as irq



== Optional Configuration ==



group #LightYellow Optional





user->ltdc :HAL_LTDC_EnableLayerColorKeying()

ltdc --> user

user->ltdc :HAL_LTDC_DisableLayerColorKeying()

ltdc --> user



user->ltdc :HAL_LTDC_IsEnabledLayerColorKeying()

ltdc --> user



user->ltdc :HAL_LTDC_SetConfigLayerColorKeying()

ltdc --> user

user->ltdc :HAL_LTDC_EnableLayerCLUT()

ltdc --> user

user->ltdc :HAL_LTDC_DisableLayerCLUT()

ltdc --> user

user->ltdc :HAL_LTDC_SetConfigLayerCLUT()

ltdc --> user







end



alt#grey #lightgrey

user->ltdc : HAL_LTDC_ForceReload()

note right : After configuration, user must reload \n\

to apply those new layer configurations

ltdc --> user

group #A0000099 Interrupt management (if LTDC Interrupts enabled)



irq<- : Reload interrupt



irq->ltdc : HAL_LTDC_IRQHandler() or\n\

HAL_LTDC_ReloadEventIRQHandler()

ltdc->user : HAL_LTDC_ReloadEventCallback()



end



@enduml

Called functions:

User Application LTDC Optional Configuration

@startuml

' To add a number by line

'autonumber

' Fix order of each column

participant "User Application" as user

participant "Driver LTDC" as ltdc



== Optional Configuration ==



group #LightYellow Optional



user->ltdc :<color:violet>HAL_LTDC_EnableGammaCorrection()

ltdc --> user

user->ltdc :<color:violet>HAL_LTDC_DisableGammaCorrection()

ltdc --> user



user->ltdc :<color:violet>HAL_LTDC_SetConfigGammaCorrection()

ltdc --> user

user->ltdc :<color:violet>HAL_LTDC_SetConfigGammaRedCorrection()

ltdc --> user

user->ltdc :<color:violet>HAL_LTDC_SetConfigGammaGreenCorrection()

ltdc --> user

user->ltdc :<color:violet>HAL_LTDC_SetConfigGammaBlueCorrection()

ltdc --> user



end

note right : These optional settings \n are done once \n and remain applicable



@enduml

Called functions:

User Application LTDC Line Interrupt

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "Driver LTDC" as ltdc

participant "CORTEX" as cortex

participant "IRQ" as irq



user->cortex : HAL_CORTEX_NVIC_EnableIRQ(LTDC_IRQn)



alt#grey #lightgrey Set USE_HAL_LTDC_REGISTER_CALLBACKS to 1 in hal_conf



user->ltdc : HAL_LTDC_RegisterLineDetectionCallback(User_LineDetectionCbk)

ltdc-->user



end



user->ltdc : HAL_LTDC_EnableLineDetection()

ltdc --> user



irq<- : Line interrupt



irq->ltdc : HAL_LTDC_IRQHandler() or\n\

HAL_LTDC_LineDetectionIRQHandler()



ltdc->user : HAL_LTDC_LineDetectionCallback()



alt#grey #lightgrey IF USE_HAL_LTDC_REGISTER_CALLBACKS == 1

ltdc->user : User_LineDetectionCbk()

end



@enduml

Called functions: