HAL CRC use cases

CRC calculation with default configuration

This diagram illustrates the prerequisite steps for initializing the system

@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: **Configure the Flash prefetch, the time base source and the NVIC**

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return**

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance**

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return**

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" :  HAL_CRC_Calculate

note right: **CRC calculating**

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

note right: **return**

@enduml

Called functions:

CRC Calculation with User Configuration

@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: **Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return **

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Configuration ==

"User Application"->"HAL CRC Driver" : HAL_CRC_SetConfig

note right: **Global configuration **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

note right: **return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" :HAL_CRC_Calculate    

note right: **CRC calculating **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

note right: **return **

@enduml

Called functions:

CRC Calculations with Consistent User Configuration


@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: ** Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return **

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Configuration ==

"User Application"->"HAL CRC Driver" : HAL_CRC_SetConfig

note right: **Global configuration **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

note right: **return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **1rst CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

...
...
...
...
...

"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **nth CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

note right: **return **
@enduml

Called functions:

Continuing CRC Calculation on New Data

@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: **Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return **

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Configuration ==

"User Application"->"HAL CRC Driver" : HAL_CRC_SetConfig

note right: **Global configuration **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

note right: **return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

"User Application"->"HAL CRC Driver" : HAL_CRC_Accumulate

note right: **Continuing the previous CRC calculating with new data **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY
...
...
...
...
...

"User Application"->"HAL CRC Driver" : HAL_CRC_Accumulate

note right: **nth CRC accumulating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

note right: **return **
@enduml

Called functions:

CRC Calculations with Different Configurations

@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: **Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return **

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Configuration ==

"User Application"->"HAL CRC Driver" : HAL_CRC_SetConfig

note right: **1rst Global configuration **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

note right: **return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **1rst CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

...
...
...
...
...
== Configuration ==
"User Application"->"HAL CRC Driver" : HAL_CRC_SetConfig

note right: **nth Global configuration **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

== Process : Polling mode ==
"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **nth CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

note right: **return **
@enduml

Called functions:

Restoring Default CRC Configuration


@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: **Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return **

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **1rst CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

...
...
...
== Configuration ==
"User Application"->"HAL CRC Driver" : HAL_CRC_SetConfig

note right: **Global configuration **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

== Process : Polling mode ==
"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **nth CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY
...
...
...
== Configuration ==
"User Application"->"HAL CRC Driver" : HAL_CRC_ResetConfig

note right: **Restoring default global configuration**

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

== Process : Polling mode ==
"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **mth CRC calculating **

"HAL CRC Driver" --> "User Application": HAL_OK or HAL_INVALID_PARAM or HAL_BUSY
note right: **return **
@enduml

Called functions:

CRC Calculation with Different Polynomial Configuration


@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: **Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return **

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" :  HAL_CRC_Calculate

note right: **1rst CRC calculating **

"HAL CRC Driver" --> "User Application": hal status : HAL_INVALID_PARAM or HAL_BUSY

...
...
...
...
...

"User Application"->"HAL CRC Driver" : HAL_CRC_SetConfigPolynomial

note right: **Modifying the polynomial **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

"User Application"->"HAL CRC Driver" : HAL_CRC_Calculate

note right: **nth CRC calculating **

"HAL CRC Driver" --> "User Application": hal status : HAL_INVALID_PARAM or HAL_BUSY

note right: **return **
@enduml

Called functions:

Deinitializing CRC Peripheral for New Process

@startuml
' To add a number by line
'autonumber

' Fix order of each column
== Initialization ==

"User Application"->"System" : HAL_Init()

note right: **Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: **Return **

"User Application"->"System" : SystemClock_Config

note right: **Configure system clock**

"System" --> "User Application"

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" :  HAL_CRC_Calculate

note right: **CRC calculating **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

note right: **return **
== Deinitialization ==

"User Application"->"HAL CRC Driver" : HAL_CRC_DeInit()

note right: **Deinitialize the CRC peripheral **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK

note right: **Return **
== Initialization ==

"User Application"->"HAL CRC Driver" : HAL_CRC_Init()

note right: **Initialize the CRC handle and associate an instance **

"HAL CRC Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: **Return **

== Process : Polling mode ==

"User Application"->"HAL CRC Driver" :  HAL_CRC_Calculate

note right: **CRC new calculating **

"HAL CRC Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM or HAL_BUSY

note right: **return **

@enduml

Called functions: