HAL DTS Use Cases

User application Prerequisite

@startuml
skinparam backgroundColor #FFFFF0
'autonumber

' Fix order of each column
participant "User Application" as User
participant System

== Prerequisite ==

User -> System:HAL_Init()
note right
Configure the Flash prefetch, the time base source and the NVIC
end note

System --> User:
note right
Return hal_status: <color green> HAL_OK</color> or <color red>HAL_ERROR</color>
end note

User -> System:SystemClock_Config()
note right
Configure system clock
<font color=red>in case of using LSE as "**Reference Clock**", LSE must be configured before executing any process.
end note
User <-- System:
@enduml

User application Initialization

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A
participant "System driver" as System

== DTS HAL Initialization ==


User -> DTS:HAL_DTS_Init()
note over DTS
Initialize the DTS handle and associate an instance
end note
alt if (USE_HAL_DTS_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO)
DTS -> System:Enable the DTS clock
DTS <-- System:
end
note over DTS
Sensor state = <font color=green> IDLE
Global state  = <font color=green> CONFIGURED
end note
User <-- DTS:

note left
<font color=green>User can start any process or execute any configuration
end note

alt if (USE_HAL_DTS_CLK_ENABLE_MODEL == HAL_CLK_ENABLE_NO)
User -> System:Enable the DTS clock
User <-- System:
end
== DTS System Initialization ==
User -> System:Configure the NVIC
User <-- System:
note left
Configuring the NVIC is Optional
end note
@enduml

Called functions:

User application DeInitialization

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A
participant "System driver" as System


User -> DTS:HAL_DTS_DeInit()
note over DTS
DeInitialize the DTS handle
end note

note over DTS
Sensor state = <font color=green> RESET
Global state  = <font color=green> RESET
end note
User <-- DTS:

User -> System:Disable the DTS clock
User <-- System:

User -> System:Disable the DTS IRQ
User <-- System:
@enduml

Called functions:

User application Configuration

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A
participant "System driver" as System

== DTS Global Configuration ==

User -> DTS:HAL_DTS_SetConfig()

note over DTS
Set the DTS global configurations according to the user parameters
end note
User <-- DTS: HAL_OK
note left
<font color=green>User can start any process or execute any configuration
end note
== DTS Sensor Configuration ==

User -> DTS:HAL_DTS_SetConfigSensor()

note over DTS
Set the DTS Sensor configurations according to the user parameters
end note
User <-- DTS: HAL_OK
note left
<font color=green>User can start any process or execute any configuration
end note
== DTS Unitary Configurations ==

User -> DTS:HAL_DTS_SetSensorThresholds()

note over DTS
Configure the selected DTS Sensor thresholds
end note
User <-- DTS: HAL_OK
note left
<font color=green>User can start any process or execute any configuration
end note

User -> DTS:HAL_DTS_SetSensorSamplingTime()

note over DTS
Configure the selected DTS Sensor sampling time
end note
User <-- DTS: HAL_OK
note left
<font color=green>User can start any process or execute any configuration
end note


User -> DTS:HAL_DTS_SetSensorTrigger()

note over DTS
Configure the selected DTS Sensor trigger
end note
User <-- DTS: HAL_OK
note left
<font color=green>User can start any process or execute any configuration
end note
@enduml

Called functions:

User application to measure Temperature in Blocking mode with software trigger

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A

== Process: Polling mode ==
User -> DTS:HAL_DTS_StartSensor()
note over DTS
Sensor state = <font color=red> ACTIVE
end note

User <-- DTS: HAL_OK
note left
<font color=blue>sequential Measuring ongoing...
<font color=green>User can retrieve the Temperature
end note

User -> DTS:HAL_DTS_PollForSensorTemperature()
HW-->DTS: End of measurement
HW<--DTS:
note over DTS
check end of measurement flag
end note
User <-- DTS: HAL_OK
note left
<font color=green>Temperature is ready to retrieve
end note
User -> DTS:HAL_DTS_GetSensorTemperature()
User <-- DTS: HAL_OK

User -> DTS:HAL_DTS_StopSensor()
note over DTS
Sensor state = <font color=green> IDLE.
end note
User <-- DTS: HAL_OK
note left
User can execute any configuration
end note

@enduml

Called functions:

User application to measure Temperature in Blocking mode with hardware trigger

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A

== Process: Polling mode ==

User -> DTS:HAL_DTS_StartSensor()
note over DTS
Sensor state = <font color=red> ACTIVE
end note

User <-- DTS: HAL_OK
note left
<font color=blue>Driver is Ready to measure the Temperature
<font color=blue>and waiting for hardware trigger.
end note

HW <- : External HW trigger
note over HW
<font color=blue>Driver start measuring Temperature...
end note
User -> DTS:HAL_DTS_PollForSensorTemperature()
note over DTS
check end of measurement flag
end note
HW-->DTS: End of measurement
HW<--DTS: Clear flag
User <-- DTS: HAL_OK
note left
<font color=green>Temperature is ready to retrieve
end note
User -> DTS:HAL_DTS_GetSensorTemperature()
User <-- DTS: HAL_OK
note left
<font color=green>DTS is Ready and User can trigger it for another measurement
end note

User -> DTS:HAL_DTS_StopSensor()
note over DTS
Sensor state = <font color=green> IDLE.
end note
User <-- DTS: HAL_OK
note left
User can execute any configuration
end note
@enduml

Called functions:

User application to measure Temperature in non-Blocking mode with software trigger

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A
participant "NVIC" as NVIC
participant "HW" as HW

== Process: Non-Blocking mode ==

User -> DTS:HAL_DTS_StartSensor_IT()
note over DTS
Sensor state = <font color=red> ACTIVE
end note

User <-- DTS: HAL_OK
activate HW #BLUE
note OVER HW
<font color=blue>sequential Measuring ongoing...
end note
loop
NVIC <- HW : end of measurement interrupt
DTS <- NVIC : HAL_DTS_IRQHandler
User <- DTS: HAL_DTS_CpltCallback
User --> DTS:
DTS --> NVIC :

User -> DTS:HAL_DTS_GetSensorTemperature()
User <-- DTS: HAL_OK
end
User -> DTS:HAL_DTS_StopSensor_IT()
destroy HW #BLUE
note over DTS
Sensor state = <font color=green> IDLE.
end note
User <-- DTS: HAL_OK
note left
User can execute any configuration
end note
@enduml

Called functions:

User application to measure Temperature in non-Blocking mode with hardware trigger

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A

== Process: Polling mode ==

User -> DTS:HAL_DTS_StartSensor()
note over DTS
Sensor state = <font color=red> ACTIVE
end note

User <-- DTS: HAL_OK
note left
<font color=blue>Driver is Ready to measure the Temperature
<font color=blue>and waiting for hardware trigger.
end note

HW <- : External HW trigger
HW -->
note over HW
<font color=blue>Driver start measuring Temperature...
end note
User -> DTS:HAL_DTS_PollForSensorTemperature()
HW-->DTS: End of measurement
HW<--DTS:
note over DTS
check end of measurement flag
end note
User <-- DTS: HAL_OK
note left
<font color=green>Temperature is ready to retrieve
end note
User -> DTS:HAL_DTS_GetSensorTemperature()
User <-- DTS: HAL_OK
note left
<font color=green>DTS is Ready and User can trigger it for another measurement
end note

User -> DTS:HAL_DTS_StopSensor()
note over DTS
Sensor state = <font color=green> IDLE.
end note
User <-- DTS: HAL_OK
note left
User can execute any configuration
end note
@enduml

Called functions:

User application to measure Temperature in non-Blocking mode with hardware trigger

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A
participant "NVIC" as NVIC
participant "HW" as HW
== Process: non-blocking mode ==

User -> DTS:HAL_DTS_StartSensor_IT()
note over DTS
Sensor state = <font color=red> ACTIVE
end note

User <-- DTS: HAL_OK
note left
<font color=blue>Driver is Ready to measure the Temperature
<font color=blue>and waiting for hardware trigger.
end note

loop
HW <- : External HW trigger
note left
<font color=blue>Driver start measuring Temperature...
end note


NVIC <- HW : end of measurement interrupt
DTS <- NVIC : HAL_DTS_IRQHandler
User <- DTS: HAL_DTS_CpltCallback
note left
<font color=green>User can retrieve the Temperature
end note
User --> DTS:
DTS --> NVIC :



User -> DTS:HAL_DTS_GetSensorTemperature()
User <-- DTS: HAL_OK
note left
<font color=blue>User can trigger to start another measurement
<font color=green>or execute any configuration
end note
end
User -> DTS:HAL_DTS_StopSensor_IT()
note over DTS
Sensor state = <font color=green> IDLE.
end note

User <-- DTS: HAL_OK
note left
User can execute any configuration
end note


@enduml

Called functions:

User application to detect temperature thresholds in non-Blocking mode with hardware trigger

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A
participant "NVIC" as NVIC
participant "HW" as HW
== Process: non-blocking mode ==

User -> DTS:HAL_DTS_StartSensor_IT_Opt()
note over DTS
Sensor state = <font color=red> ACTIVE
Enable Only **Low & High thresholds** as optional interrupts
end note

User <-- DTS: HAL_OK
note left
<font color=blue>Driver is Ready to measure the Temperature
<font color=blue>and waiting for hardware trigger.
end note
loop #ivory
alt #aliceblue Temperature is Under High threshold value / Over Low threshold value
HW <- : External HW trigger
note left
<font color=blue>Driver start measuring Temperature...
end note
note over HW
<font color=red>Measuring ended without Threshold detection
end note

else #gainsboro Temperature is Over High threshold value / Under Low threshold value
HW <- : External HW trigger
note left
<font color=blue>Driver start measuring Temperature...
end note


NVIC <- HW : High or Low threshold detection interrupt
DTS <- NVIC : HAL_DTS_IRQHandler
User <- DTS: HAL_DTS_LowThresholdCallback \n(or HAL_DTS_HighThresholdCallback)
note left
<font color=green>User can retrieve the Temperature
end note
User --> DTS:
DTS --> NVIC :


User -> DTS:HAL_DTS_GetSensorTemperature()
User <-- DTS: HAL_OK
note left
<font color=blue>User can trigger to start another measurement
<font color=green>or execute any configuration
end note
end
end

User -> DTS:HAL_DTS_StopSensor_IT()
note over DTS
Sensor state = <font color=green> IDLE.
end note

User <-- DTS: HAL_OK
note left
User can execute any configuration
end note


@enduml

Called functions:

User application to Wakeup From Stop/Sleep mode at end of measurement

@startuml
skinparam backgroundColor #FFFFF0
participant "User Application" as User
participant "HAL DTS Driver" as DTS #19DD3A
participant "PWR" as PWR
participant "NVIC" as NVIC
participant "HW" as HW

== Process: non-blocking mode ==

User -> DTS:HAL_DTS_StartSensor_IT()
note over DTS
Sensor state = <font color=red> ACTIVE
end note

User <-- DTS: HAL_OK
note left
<font color=blue>Driver is Ready to measure the Temperature
<font color=blue>and waiting for hardware trigger.
end note

User -> PWR**: HAL_PWR_EnterStopMode()
hnote across #FFAAAA
<font color=red> ENTER IN STOP MODE
end note
HW <-: External HW trigger
note over HW
<font color=blue>DTS start measuring Temperature in <color red> **stop mode**</color>...
end note
note over HW
<font color=green>DTS complete measuring Temperature
end note

hnote across #99FF99
<font color=black> WAKEUP FROM STOP MODE
end note
User <-- PWR:
NVIC <- HW: end of measurement interrupt
DTS <- NVIC : HAL_DTS_IRQHandler
User <- DTS: HAL_DTS_CpltCallback
note left
<font color=green>User can retrieve the Temperature
end note
User --> DTS:
DTS --> NVIC :



User -> DTS:HAL_DTS_GetSensorTemperature()
User <-- DTS: HAL_OK
note left
<font color=blue>User can trigger to start another measurement
<font color=green>or execute any configuration
end note

User -> DTS:HAL_DTS_StopSensor_IT()
note over DTS
Sensor state = <font color=green> IDLE.
end note
User <-- DTS:HAL_OK
note left
User can execute any configuration
end note


@enduml

Called functions: