HAL CRS Use Cases

CRS in Polling mode

@startuml

skinparam sequenceMessageAlign center

"User Application"->"Driver CRS" : HAL_CRS_Init()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

group Optional
"User Application"->"Driver CRS" : HAL_CRS_SetConfig()
rnote over "Driver CRS"
If not called, the default configuration is applied.
endrnote
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK
end

"User Application"->"Driver CRS" : HAL_CRS_StartSync()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

group Optional
"User Application"->"Driver CRS" : HAL_CRS_EnableAutoTrimming()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK
end

group Loop
"User Application"->"Driver CRS" : HAL_CRS_PollForSync(timeout)
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK
end

group Optional
"User Application"->"Driver CRS" : HAL_CRS_DisableAutoTrimming()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"User Application"->"Driver CRS" : HAL_CRS_StopSync()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"User Application"->"Driver CRS" : HAL_CRS_DeInit()
"Driver CRS" --> "User Application"
end

@enduml

Called functions:

CRS Software Synchronization

@startuml

skinparam sequenceMessageAlign center

rnote over "System"
Activate SysTick
endrnote

"User Application"->"Driver CRS" : HAL_CRS_Init()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"SYSTICK_IRQHandler" <[#Orange]- : SYSTICK interrupt

"SYSTICK_IRQHandler" -[#Orange]> "System" : HAL_CORTEX_SYSTICK_IRQHandler()

"User Application"->"Driver CRS" : HAL_CRS_GenerateSoftwareSync()
"Driver CRS" --> "User Application"


@enduml

Called functions:

CRS in Polling mode with Synchronization Error

@startuml

skinparam sequenceMessageAlign center

"User Application"->"Driver CRS" : HAL_CRS_Init()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

group Optional
"User Application"->"Driver CRS" : HAL_CRS_SetConfig()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK
end

"User Application"->"Driver CRS" : HAL_CRS_StartSync()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"User Application"->"Driver CRS" : HAL_CRS_PollForSync(timeout)
"Driver CRS" -[#Red]-> "User Application" : return HAL_ERROR

"User Application"->"Driver CRS" : HAL_CRS_GetLastErrorCodes()
"Driver CRS" -[#Red]-> "User Application" : return HAL_CRS_ERROR_SYNC_ERROR

"User Application"->"Driver CRS" : HAL_CRS_GetFrequencyErrorInfo()
"Driver CRS" --> "User Application"

"User Application"->"Driver CRS" : HAL_CRS_StopSync()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"User Application"->"Driver CRS" : HAL_CRS_SetConfig()
rnote over "User Application"
Adjust the source synchronization
endrnote
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"User Application"->"Driver CRS" : HAL_CRS_StartSync()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

group Loop
"User Application"->"Driver CRS" : HAL_CRS_PollForSync(timeout)
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK
end

@enduml

Called functions:

CRS in Interrupt mode with SYNC event OK interrupt

@startuml

skinparam sequenceMessageAlign center

"User Application"->"Driver CRS" : HAL_CRS_Init()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

rnote over "User Application"
The user can choose Option 1 or Option 2 or nothing.
endrnote

group Option 1 [USE REGISTER CALLBACKS]
"User Application" ->  "Driver CRS" : HAL_CRS_RegisterSyncOkCallback(myCRS_SyncOkCallback)
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK
end

group Optional
"User Application"->"Driver CRS" : HAL_CRS_SetConfig()
"Driver CRS" --[#Green]> "User Application" : return HAL_OK
end

"User Application"->"Driver CRS" : HAL_CRS_StartSync_IT()
"Driver CRS" --[#Green]> "User Application" : return HAL_OK

"CRS_IRQHandler" <[#Orange]- : CRS SYNC event OK interrupt

"CRS_IRQHandler" -[#Orange]> "Driver CRS" : HAL_CRS_IRQHandler()

group Option 1 [USE REGISTER CALLBACKS]
"Driver CRS" -> "User Application" : myCRS_SyncOkCallback()
"User Application" --> "Driver CRS"
end

group Option 2 [USE OVERRIDDEN WEAK CALLBACKS]
"Driver CRS" -> "User Application" : HAL_CRS_SyncOkCallback()
"User Application" --> "Driver CRS"
end

@enduml

Called functions:

CRS in Interrupt mode with synchronization missed interrupt

@startuml

skinparam sequenceMessageAlign center

skinparam sequenceMessageAlign center

"User Application"->"Driver CRS" : HAL_CRS_Init()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

rnote over "User Application"
The user can choose Option 1 or Option 2 or nothing.
endrnote

group Option 1 [USE REGISTER CALLBACKS]
"User Application" ->  "Driver CRS" : HAL_CRS_RegisterErrorCallback(myCRS_ErrorCallback)
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK
end

group Optional
"User Application"->"Driver CRS" : HAL_CRS_SetConfig()
"Driver CRS" --[#Green]> "User Application" : return HAL_OK
end

"User Application"->"Driver CRS" : HAL_CRS_StartSync_IT()
"Driver CRS" --[#Green]> "User Application" : return HAL_OK

"CRS_IRQHandler" <[#Orange]- : CRS SYNCMISS interrupt

"CRS_IRQHandler" -[#Orange]> "Driver CRS" : HAL_CRS_IRQHandler()

group Option 1 [USE REGISTER CALLBACKS]
"Driver CRS" -> "User Application" : myCRS_ErrorCallback()
"User Application" --> "Driver CRS"
end

group Option 2 [USE OVERRIDDEN WEAK CALLBACKS]
"Driver CRS" -> "User Application" : HAL_CRS_ErrorCallback()
"User Application" --> "Driver CRS"
end

"User Application"->"Driver CRS" : HAL_CRS_GetLastErrorCodes()
"Driver CRS" -[#Red]-> "User Application" : return HAL_CRS_ERROR_SYNC_MISSED

"User Application"->"Driver CRS" : HAL_CRS_GetFrequencyErrorInfo()
"Driver CRS" --> "User Application"

"User Application"->"Driver CRS" : HAL_CRS_StopSync_IT()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"User Application"->"Driver CRS" : HAL_CRS_SetConfig()
rnote over "User Application"
Adjust the source synchronization
endrnote
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

"User Application"->"Driver CRS" : HAL_CRS_StartSync()
"Driver CRS" -[#Green]-> "User Application" : return HAL_OK

@enduml

Called functions: