HAL JPEG Use Cases

JPEG Initialization

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG

participant "System" as system

participant "ISR" as isr



== Prerequisite ==



user->system : HAL_Init()

system --> user :hal_status_t

user->system : Configure system clock

system --> user :hal_status_t



== Initialization ==



user->JPEG : HAL_JPEG_Init()

alt#grey #lightgrey If USE_HAL_JPEG_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

JPEG->RCC : Enable the JPEG clock

RCC-->JPEG

end

JPEG --> user : (hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)

JPEG --> user :hal_jpeg_encode_config_state_t \n(hal_jpeg_state_t = HAL_JPEG_ENCODE_CONFIG_STATE_RESET)



==JPEG System Initialization==



Note right user : JPEG System initialization can be called before\nJPEG HAL initialization



group #LightYellow Optional : If Interrupt needed

user->isr : Enable HAL_NVIC Interrupt

isr-->user

end



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

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

- Either set the define USE_HAL_JPEG_CLK_ENABLE_MODEL \n\

to  HAL_CLK_ENABLE_PERIPH_ONLY  and \n\

the clock will be enabled within the HAL_JPEG_Init



alt#grey #lightgrey If USE_HAL_JPEG_CLK_ENABLE_MODEL == HAL_CLK_ENABLE_NO

user->RCC : Enable the JPEG clock

RCC --> user

end

@enduml

Called functions:

JPEG Optional Configuration

@startuml

participant "User Application" as user

participant "JPEG Driver" as JPEG



== Optional Configuration ==



group #LightYellow Optional

user->JPEG : HAL_JPEG_SetUserQuantTables1()

user<--JPEG : hal_status_t



user->JPEG : HAL_JPEG_SetUserQuantTables2()

user<--JPEG : hal_status_t



user->JPEG : HAL_JPEG_SetUserQuantTables3()

user<--JPEG : hal_status_t



user->JPEG : HAL_JPEG_SetUserQuantTables4()

user<--JPEG : hal_status_t



user->JPEG : HAL_JPEG_EnableHeaderProcessing()

user<--JPEG : hal_status_t



user->JPEG : HAL_JPEG_IsEnabledHeaderParsing()

user<--JPEG : hal_jpeg_header_parsing_status_t



user->JPEG : HAL_JPEG_DisableHeaderParsing()

user<--JPEG : hal_status_t

user->JPEG : HAL_JPEG_RegisterInfoReadyCallback()

user<--JPEG : hal_status_t

user->JPEG : HAL_JPEG_RegisterGetDataCallback()

user<--JPEG : hal_status_t

user->JPEG : HAL_JPEG_RegisterDataReadyCallback()

user<--JPEG : hal_status_t

user->JPEG : HAL_JPEG_RegisterEncodeCpltCallback()

user<--JPEG : hal_status_t

user->JPEG : HAL_JPEG_RegisterDecodeCpltCallback()

user<--JPEG : hal_status_t

user->JPEG : HAL_JPEG_RegisterErrorCallback()

user<--JPEG : hal_status_t

end



note right : These optional settings \n can be done once \n and remain applicable \n for next operation

@enduml

Called functions:

JPEG Encoding Configuration

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG



== Encoding Configuration ==



user->JPEG : HAL_JPEG_SetConfigEncoding() \n\t\t ==== Optional ==== \nHAL_JPEG_SetUserQuantTables1() or \nHAL_JPEG_SetUserQuantTables2() or \nHAL_JPEG_SetUserQuantTables3() or \nHAL_JPEG_SetUserQuantTables4()

user<--JPEG : (hal_jpeg_encode_config_state_t = HAL_JPEG_ENCODE_CONFIG_STATE_CONFIGURED)

user<--JPEG : (hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)



@enduml

Called functions:

JPEG Encoding - Polling Mode

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG

== Process Encoding  Polling mode==

user->JPEG : HAL_JPEG_SetConfigEncoding()



user<--JPEG : (hal_jpeg_state_t = HAL_JPEG_STATE_ACTIVE_ENCODE)



user->JPEG : HAL_JPEG_Encode()



group #LightYellow Optional

user->JPEG : HAL_JPEG_Abort()

end

user<-JPEG : HAL_JPEG_DataReadyCallback() \is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size



group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseOutputBuffer()

user->JPEG : HAL_JPEG_UpdateOutputBuffer()

user->JPEG : HAL_JPEG_ResumeOutputBuffer()

end



user<-JPEG : HAL_JPEG_GetDataCallback() \ is asserted when the input buffer has  \

  \nbeen consumed by the peripheral and to ask for a new data chunk



group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseInputBuffer()

user->JPEG : HAL_JPEG_UpdateInputBuffer()

user->JPEG : HAL_JPEG_ResumeInputBuffer()

end

user<-JPEG : HAL_JPEG_EncodeCpltCallback() is asserted when the HAL JPEG driver has \

         \nended the current JPEG encoding operation

user<--JPEG :(hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)



@enduml

Called functions:

JPEG Decoding - Polling Mode

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG



== Process Decoding  Polling mode==



user->JPEG : HAL_JPEG_Decode()

user<--JPEG : \n(hal_jpeg_state_t = HAL_JPEG_STATE_ACTIVE_DECODE)



group #LightYellow Optional

user->JPEG : HAL_JPEG_Abort()

end



user<-JPEG : HAL_JPEG_DataReadyCallback() is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size



group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseOutputBuffer()

user->JPEG : HAL_JPEG_UpdateOutputBuffer()

user->JPEG : HAL_JPEG_ResumeOutputBuffer()

end



user<-JPEG : HAL_JPEG_GetDataCallback()  is asserted when the input buffer has  \

  \nbeen consumed by the peripheral and to ask for a new data chunk



group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseInputBuffer()

user->JPEG : HAL_JPEG_UpdateInputBuffer()

user->JPEG : HAL_JPEG_ResumeInputBuffer()

end

user<-JPEG : HAL_JPEG_InfoReadyCallback()  is asserted when the JPEG peripheral \

             \nsuccessfully parse the JPEG header

group #LightYellow Optional

user->JPEG : HAL_JPEG_GetLastDecodeInfo()

end

user<-JPEG : HAL_JPEG_DecodeCpltCallback() is asserted when the HAL JPEG driver has \

         \nended the current JPEG decoding operation

user<--JPEG : encode config status \n(hal_jpeg_encode_config_state_t = HAL_JPEG_ENCODE_CONFIG_STATE_RESET)

user<--JPEG : (hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)





@enduml

Called functions:

JPEG Encoding - Interrupt Mode

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG

participant "JPEG HW" as hw

participant "ISR" as isr



== Process Encoding Interrupt mode==



user->JPEG : HAL_JPEG_Encode_IT()

user<--JPEG :(hal_jpeg_state_t = HAL_JPEG_STATE_ACTIVE_ENCODE)

group #LightYellow Optional

user->JPEG : HAL_JPEG_Abort()

user<--JPEG : (hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)

end



isr->hw : Interrupt

hw->JPEG : HAL_JPEG_IRQHandler()





user<-JPEG : HAL_JPEG_GetDataCallback() \ is asserted when the input buffer has  \

  \nbeen consumed by the peripheral and to ask for a new data chunk

group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseInputBuffer()

user->JPEG : HAL_JPEG_UpdateInputBuffer()

user->JPEG : HAL_JPEG_ResumeInputBuffer()

end

isr->hw : Interrupt

hw->JPEG : HAL_JPEG_IRQHandler()

user<-JPEG : HAL_JPEG_DataReadyCallback() \ is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size

group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseOutputBuffer()

user->JPEG : HAL_JPEG_UpdateOutputBuffer()

user->JPEG : HAL_JPEG_ResumeOutputBuffer()

end

isr->hw : Interrupt

hw->JPEG : HAL_JPEG_IRQHandler()

user<-JPEG : HAL_JPEG_EncodeCpltCallback() is asserted when the HAL JPEG driver has \

         \nended the current JPEG encoding operation

note right : If Encoding Complete Interrupt



@enduml

Called functions:

JPEG Decoding - Interrupt Mode

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG

participant "JPEG HW" as hw

participant "ISR" as isr



== Process Deccoding Interrupt mode==

user->JPEG : HAL_JPEG_Decode_IT()

user<--JPEG :(hal_jpeg_state_t = HAL_JPEG_STATE_ACTIVE_DECODE)

group #LightYellow Optional

user->JPEG : HAL_JPEG_Abort()

user<--JPEG :(hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)

end



isr->hw : Interrupt

hw->JPEG : HAL_JPEG_IRQHandler()



user<-JPEG : HAL_JPEG_GetDataCallback() \ occurs when the input buffer has  \

  \nbeen consumed by the peripheral and to ask for a new data chunk

note right : If Get Data Interrupt

group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseInputBuffer()

user->JPEG : HAL_JPEG_UpdateInputBuffer()

user->JPEG : HAL_JPEG_ResumeInputBuffer()

end

isr->hw : Interrupt

hw->JPEG : HAL_JPEG_IRQHandler()

user<-JPEG : HAL_JPEG_DataReadyCallback() \ is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size

note right : If Data Ready Interrupt



group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseOutputBuffer()

user->JPEG : HAL_JPEG_UpdateOutputBuffer()

user->JPEG : HAL_JPEG_ResumeOutputBuffer()

end

user<-JPEG : HAL_JPEG_InfoReadyCallback() \ is asserted when the JPEG peripheral \

             \nsuccessfully parse the JPEG header

note right : If Info Ready Interrupt

group #LightYellow Optional

user->JPEG : HAL_JPEG_GetLastDecodeInfo()

end

isr->hw : Interrupt

hw->JPEG : HAL_JPEG_IRQHandler()

user<-JPEG : HAL_JPEG_DecodeCpltCallback() \ is asserted when the HAL JPEG driver has \

         \nended the current JPEG decoding operation

note right : If Decode Complete Interrupt



@enduml

Called functions:

JPEG Encoding - DMA Mode

@startuml

' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG

participant "JPEG HW" as hw

participant "ISR" as isr



== Process Encoding DMA mode==

user->JPEG : HAL_JPEG_SetConfigEncoding()



user->JPEG : HAL_JPEG_Encode_DMA()

user<--JPEG :(hal_jpeg_state_t = HAL_JPEG_STATE_ACTIVE_ENCODE)



group #LightYellow Optional

user->JPEG : HAL_JPEG_Abort()

user<--JPEG :(hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)

end



user<-JPEG : HAL_JPEG_DataReadyCallback() is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size

group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseOutputBuffer()

user->JPEG : HAL_JPEG_UpdateOutputBuffer()

user->JPEG : HAL_JPEG_ResumeOutputBuffer()

end

user<-JPEG : HAL_JPEG_GetDataCallback()  is asserted when the input buffer has  \

  \nbeen consumed by the peripheral and to ask for a new data chunk

group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseInputBuffer()

user->JPEG : HAL_JPEG_UpdateInputBuffer()

user->JPEG : HAL_JPEG_ResumeInputBuffer()

end



user<-JPEG : HAL_JPEG_ErrorCallback() is asserted when an error occurred during \

         \nthe current operation \nor HAL_JPEG_EncodeCpltCallback()  is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size

@enduml

Called functions:

JPEG Decoding - DMA Mode

@startuml

'' To add a number by line

'autonumber



' Fix order of each column

participant "User Application" as user

participant "JPEG Driver" as JPEG

participant "JPEG HW" as hw

participant "ISR" as isr



== Process Decoding DMA mode==



user->JPEG : HAL_JPEG_Decode_DMA()

user<--JPEG : (hal_jpeg_state_t = HAL_JPEG_STATE_ACTIVE_DECODE)



group #LightYellow Optional

user->JPEG : HAL_JPEG_Abort()

user<--JPEG :(hal_jpeg_state_t = HAL_JPEG_STATE_IDLE)

end



user<-JPEG : HAL_JPEG_DataReadyCallback() is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size

group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseOutputBuffer()

user->JPEG : HAL_JPEG_UpdateOutputBuffer()

user->JPEG : HAL_JPEG_ResumeOutputBuffer()

end

user<-JPEG : HAL_JPEG_GetDataCallback()  is asserted when the input buffer has  \

  \nbeen consumed by the peripheral and to ask for a new data chunk

group #LightYellow Optional

user->JPEG : HAL_JPEG_PauseInputBuffer()

user->JPEG : HAL_JPEG_UpdateInputBuffer()

user->JPEG : HAL_JPEG_ResumeInputBuffer()

end



user<-JPEG : HAL_JPEG_InfoReadyCallback() \ is asserted when the JPEG peripheral \

             \nsuccessfully parse the JPEG header

group #LightYellow Optional

user->JPEG : HAL_JPEG_GetLastDecodeInfo()

end



user<-JPEG : HAL_JPEG_ErrorCallback() is asserted when an error occurred during \

         \nthe current operation \nor HAL_JPEG_EncodeCpltCallback()  \is asserted when the HAL JPEG driver \

         \nhas filled the given output buffer with the given size

@enduml

Called functions:

JPEG Driver DeInitialization

@startuml



== Driver DeInitialization==



user->JPEG : HAL_JPEG_DeInit()

user<--JPEG : (hal_jpeg_encode_config_state_t = HAL_JPEG_ENCODE_CONFIG_STATE_RESET)

user<--JPEG : (hal_jpeg_state_t = HAL_JPEG_STATE_RESET)



@enduml

Called functions: