HAL ADF Use Cases

Global ADF initialization

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "HAL DMA" as DMA
participant "HAL RCC" as RCC
participant "HAL GPIO" as GPIO
participant "System Driver" as SYSTEM

== ADF HAL initialization ==
App -> ADF : HAL_ADF_Init()
Note over ADF : Initialize ADF instance on handle\nGlobal state = INIT
alt#grey #lightgrey If USE_HAL_ADF_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO
ADF->RCC : Enable the ADF clock
RCC-->ADF
end
App <-- ADF : HAL_OK

== ADF system initialization ==
Note over App : ADF system initialization can be called before\nADF HAL initialization

App->SYSTEM : Configure and enable ADF kernel clock
SYSTEM --> App

alt#grey #lightgrey If USE_HAL_ADF_CLK_ENABLE_MODEL == HAL_CLK_ENABLE_NO
App->RCC : Enable the ADF clock
RCC --> App
end

alt#grey #lightgrey If USE_HAL_ADF_DMA == 1
App->DMA : Initialization of DMA
DMA-->App
App->ADF : HAL_ADF_SetDMA()
ADF-->App
end

alt#grey #lightgrey If GPIOs needed
App->GPIO : Initialization of GPIOs
GPIO-->App
end

@enduml

Called functions:

Global ADF de-initialization

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "HAL DMA" as DMA
participant "HAL RCC" as RCC
participant "HAL GPIO" as GPIO
participant "System Driver" as SYSTEM

== ADF HAL de-initialization ==
App-> ADF : HAL_ADF_DeInit()
Note over ADF : Global state = RESET
App<--ADF

== ADF system de-initalization ==
App->RCC : Disable the ADF clock
RCC --> App

App->SYSTEM : Disable ADF kernel clock
SYSTEM --> App

alt#grey #lightgrey If USE_HAL_ADF_DMA == 1
App->DMA : De-initialization of DMA
DMA-->App
end

alt#grey #lightgrey If GPIOs needed
App->GPIO : De-initialization of GPIOs
GPIO-->App
end

@enduml

Called functions:

Global ADF configuration

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== ADF global configuration ==
App -> ADF : HAL_ADF_SetConfig()
Note over ADF : Configure processing clock divider\nGlobal state = IDLE
App <-- ADF :HAL_OK

== Advanced ADF global configuration ==
alt#grey #lightgrey Output clock feature
App -> ADF : HAL_ADF_SetConfigOutputClock()
Note over ADF : Configure output clock divider and pins
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_EnableOutputClock()
App <-- ADF :HAL_OK
end
alt#grey #lightgrey Output clock trigger feature
App -> ADF : HAL_ADF_SetConfigOutputClockTrigger()
Note over ADF : Configure output clock trigger source and edge
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_EnableOutputClockTrigger()
App <-- ADF :HAL_OK
end

@enduml

Called functions:

Global ADF start/stop

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== ADF global start ==
App -> ADF : HAL_ADF_Start()
Note over ADF : Enable clock generator\nGlobal state = ACTIVE
App <-- ADF :HAL_OK

== ADF global stop ==
App -> ADF : HAL_ADF_Stop()
Note over ADF : Disable clock generator\nGlobal state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

ADF acquisition configuration

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

alt#grey Not needed if digital filter source is ADC interface
== Serial interface configuration ==
App -> ADF : HAL_ADF_SITF_SetConfig(SITFi)
Note over ADF : Configure clock source, mode and threshold\nSITFi state = IDLE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SITF_Start(SITFi)
Note over ADF : Enable serial interface i\nSITFi state = ACTIVE
App <-- ADF :HAL_OK

== Bitstream matrix configuration ==
App -> ADF : HAL_ADF_BSMX_SetConfig(BSMXj, SITFi)
Note over ADF : Configure bitstream selection (serial interface and edge)
App <-- ADF :HAL_OK
end

== Digital filter configuration ==
App -> ADF : HAL_ADF_DFLT_SetConfig(DFTLj)
Note over ADF : Configure data source, CIC mode, decimation ratio, gain, acquisition mode and trigger\nDFLTj state = IDLE
App <-- ADF :HAL_OK
alt#grey #lightgrey Advanced digital filter configuration
App -> ADF : HAL_ADF_DFLT_SetSamplesDelay(DFTLj)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_SetGain(DFTLj)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_SetFifoThreshold(DFTLj)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_SetDiscardSamples(DFTLj)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_EnableReshapeFilter(DFTLj)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_EnableHighPassFilter(DFTLj)
App <-- ADF :HAL_OK
end

alt#grey If SAD usage
== Sound activity detector configuration ==
App -> ADF : HAL_ADF_SAD_SetConfig(SADi)
Note over ADF : Configure mode, memory transfer, trigger event and minimum ambient noise\nSADi state = IDLE
App <-- ADF :HAL_OK

alt#grey #lightgrey Advanced sound activity detector configuration
App -> ADF : HAL_ADF_SAD_SetFrameSize(SADi)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_SetLearningFrames(SADi)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_SetSignalToNoiseThreshold(SADi)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_SetAmbientNoiseSlope(SADi)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_SetHangoverTimeWindow(SADi)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_EnableHysteresis(SADi)
App <-- ADF :HAL_OK
end
end

@enduml

Called functions:

ADF acquisition in asynchronous continuous mode

Polling mode without SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Asynchronous continuous acquisition in polling mode without SAD usage ==
App -> ADF : HAL_ADF_DFLT_StartAcq(DFTLj)
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
loop
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
end
App -> ADF : HAL_ADF_DFLT_StopAcq(DFTLj)
Note over ADF : Disable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Polling mode with SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Asynchronous continuous acquisition in polling mode with SAD usage ==
App -> ADF : HAL_ADF_SAD_Start(SADj)
Note over ADF : Enable sound activity detector\nSADj state = ACTIVE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_StartAcq(DFTLj)
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK

loop if memory transfer allowed
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
end

loop
App -> ADF : HAL_ADF_SAD_IsDetected(SADj)
App <-- ADF :HAL_ADF_SOUND_ACTIVITY_NOT_DETECTED\nor HAL_ADF_SOUND_ACTIVITY_DETECTED
end

loop
App -> ADF : HAL_ADF_SAD_PollForSoundLevel(SADj)
Note over ADF : Wait available sound level
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_GetSoundAndAmbientNoiseLevels(DFTLj)
App <-- ADF :Sound level and ambient noise level
end

App -> ADF : HAL_ADF_DFLT_StopAcq(DFTLj)
Note over ADF : Disable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_Stop(SADj)
Note over ADF : Disable sound activity detector\nSADj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Interrupt mode without SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Asynchronous continuous acquisition in interrupt mode  without SAD usage ==
App -> ADF : HAL_ADF_DFLT_StartAcq_IT(DFTLj)
Note over ADF : Enable interrupts and digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
loop
Note over NVIC : FIFO threshold IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
ADF <-- App
NVIC <-- ADF
end
App -> ADF : HAL_ADF_DFLT_StopAcq_IT(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Interrupt mode with SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Asynchronous continuous acquisition in interrupt mode  with SAD usage ==
App -> ADF : HAL_ADF_SAD_Start_IT(SADj)
Note over ADF : Enable SAD interrupts and sound activity detector\nSADj state = ACTIVE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_StartAcq_IT(DFTLj)
Note over ADF : Enable DFLT interrupts and digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK

loop if memory transfer allowed
Note over NVIC : FIFO threshold IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
ADF <-- App
NVIC <-- ADF
end

loop
Note over NVIC : Sound level ready IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(SADj)
ADF -> App : HAL_ADF_SAD_SoundLevelCallback(SADj)
App -> ADF : HAL_ADF_SAD_GetSoundAndAmbientNoiseLevels(DFTLj)
App <-- ADF :Sound level and ambient noise level
ADF <-- App
NVIC <-- ADF
end

loop
Note over NVIC : Sound activity IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(SADj)
ADF -> App : HAL_ADF_SAD_SoundActivityCallback(SADj)
ADF <-- App
NVIC <-- ADF
end

App -> ADF : HAL_ADF_DFLT_StopAcq_IT(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_Stop_IT(SADj)
Note over ADF : Disable sound activity detector and interrupts\nSADj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

DMA mode without SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "DMA" as DMA

== Asynchronous continuous acquisition in DMA mode without SAD usage ==
loop If not circular DMA
App -> ADF : HAL_ADF_DFLT_StartAcq_DMA(DFTLj)
Note over ADF : Enable DMA and interrupts
ADF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()
ADF <-- DMA : HAL_OK
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF : HAL_OK
loop If circular DMA
Note over DMA : Transfer half complete IT occurrence
DMA -> ADF : ADF_DMA_HalfCpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqHalfCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
Note over DMA : Transfer complete IT occurrence
DMA -> ADF : ADF_DMA_CpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
alt#grey If not circular DMA
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
end
DMA <-- ADF
end
end
App -> ADF : HAL_ADF_DFLT_StopAcq_DMA(DFTLj)
ADF -> DMA : HAL_DMA_Abort_IT()
alt#grey If DMA transfer in progress
ADF <-- DMA : HAL_OK
App <-- ADF :HAL_OK
DMA -> ADF : ADF_DMA_AbortCallback()
Note over ADF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
else If no DMA transfer in progress
ADF <-- DMA : HAL_ERROR
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
App <-- ADF :HAL_OK
end

@enduml

Called functions:

DMA mode with SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "DMA" as DMA

== Asynchronous continuous acquisition in DMA mode with SAD usage ==
loop If not circular DMA
App -> ADF : HAL_ADF_SAD_Start_IT(SADj)
Note over ADF : Enable SAD interrupts and sound activity detector\nSADj state = ACTIVE
App <-- ADF :HAL_OK

App -> ADF : HAL_ADF_DFLT_StartAcq_DMA(DFTLj)
Note over ADF : Enable DMA and interrupts
ADF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()
ADF <-- DMA : HAL_OK
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF : HAL_OK

loop If circular DMA
Note over DMA : Transfer half complete IT occurrence
DMA -> ADF : ADF_DMA_HalfCpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqHalfCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
Note over DMA : Transfer complete IT occurrence
DMA -> ADF : ADF_DMA_CpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
alt#grey If not circular DMA
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
end
DMA <-- ADF
end
alt#grey If not circular DMA
App -> ADF : HAL_ADF_SAD_Stop_IT(SADj)
Note over ADF : Disable sound activity detector and interrupts\nSADj state = IDLE
App <-- ADF :HAL_OK
end
end

App -> ADF : HAL_ADF_DFLT_StopAcq_DMA(DFTLj)
ADF -> DMA : HAL_DMA_Abort_IT()
alt#grey If DMA transfer in progress
ADF <-- DMA : HAL_OK
App <-- ADF :HAL_OK
DMA -> ADF : ADF_DMA_AbortCallback()
Note over ADF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
else If no DMA transfer in progress
ADF <-- DMA : HAL_ERROR
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
App <-- ADF :HAL_OK
end

App -> ADF : HAL_ADF_SAD_Stop_IT(SADj)
Note over ADF : Disable sound activity detector and interrupts\nSADj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

ADF acquisition in asynchronous single shot mode

Polling mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Asynchronous single shot acquisition in polling mode ==
loop
App -> ADF : HAL_ADF_DFLT_StartAcq(DFTLj)
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition\nDisable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
end
App -> ADF : HAL_ADF_DFLT_StopAcq(DFTLj)
Note over ADF : Disable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Interrupt mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Asynchronous single shot acquisition in interrupt mode ==
loop
App -> ADF : HAL_ADF_DFLT_StartAcq_IT(DFTLj)
Note over ADF : Enable interrupts and digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
Note over NVIC : FIFO threshold IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
ADF <-- App
NVIC <-- ADF
end
App -> ADF : HAL_ADF_DFLT_StopAcq_IT(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

DMA mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "DMA" as DMA

== Asynchronous single shot acquisition in DMA mode ==
loop
App -> ADF : HAL_ADF_DFLT_StartAcq_DMA(DFTLj)
Note over ADF : Enable DMA and interrupts
ADF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()
ADF <-- DMA : HAL_OK
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF : HAL_OK
Note over DMA : Transfer complete IT occurrence
DMA -> ADF : ADF_DMA_CpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle,\ndisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
end
App -> ADF : HAL_ADF_DFLT_StopAcq_DMA(DFTLj)
ADF -> DMA : HAL_DMA_Abort_IT()
alt#grey If DMA transfer in progress
ADF <-- DMA : HAL_OK
App <-- ADF :HAL_OK
DMA -> ADF : ADF_DMA_AbortCallback()
Note over ADF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
else If no DMA transfer in progress
ADF <-- DMA : HAL_ERROR
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
App <-- ADF :HAL_OK
end

@enduml

Called functions:

ADF acquisition in synchronous continuous mode

Polling mode without SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Synchronous continuous acquisition in polling mode without SAD usage ==
App -> ADF : HAL_ADF_DFLT_StartAcq(DFTLj)
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end
loop
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
end
App -> ADF : HAL_ADF_DFLT_StopAcq(DFTLj)
Note over ADF : Disable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Polling mode with SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Synchronous continuous acquisition in polling mode with SAD usage ==
App -> ADF : HAL_ADF_SAD_Start(SADj)
Note over ADF : Enable sound activity detector\nSADj state = ACTIVE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_StartAcq(DFTLj)
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK

alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end

loop if memory transfer allowed
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
end

loop
App -> ADF : HAL_ADF_SAD_IsDetected(SADj)
App <-- ADF :HAL_ADF_SOUND_ACTIVITY_NOT_DETECTED\nor HAL_ADF_SOUND_ACTIVITY_DETECTED
end

loop
App -> ADF : HAL_ADF_SAD_PollForSoundLevel(SADj)
Note over ADF : Wait available sound level
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_GetSoundAndAmbientNoiseLevels(DFTLj)
App <-- ADF :Sound level and ambient noise level
end

App -> ADF : HAL_ADF_DFLT_StopAcq(DFTLj)
Note over ADF : Disable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_Stop(SADj)
Note over ADF : Disable sound activity detector\nSADj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Interrupt mode without SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Synchronous continuous acquisition in interrupt mode without SAD usage ==
App -> ADF : HAL_ADF_DFLT_StartAcq_IT(DFTLj)
Note over ADF : Enable interrupts and digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end
loop
Note over NVIC : FIFO threshold IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
ADF <-- App
NVIC <-- ADF
end
App -> ADF : HAL_ADF_DFLT_StopAcq_IT(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Interrupt mode with SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Synchronous continuous acquisition in interrupt mode with SAD usage ==
App -> ADF : HAL_ADF_SAD_Start_IT(SADj)
Note over ADF : Enable SAD interrupts and sound activity detector\nSADj state = ACTIVE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_StartAcq_IT(DFTLj)
Note over ADF : Enable interrupts and digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK

alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end

loop if memory transfer allowed
Note over NVIC : FIFO threshold IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
ADF <-- App
NVIC <-- ADF
end

loop
Note over NVIC : Sound level ready IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(SADj)
ADF -> App : HAL_ADF_SAD_SoundLevelCallback(SADj)
App -> ADF : HAL_ADF_SAD_GetSoundAndAmbientNoiseLevels(DFTLj)
App <-- ADF :Sound level and ambient noise level
ADF <-- App
NVIC <-- ADF
end

loop
Note over NVIC : Sound activity IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(SADj)
ADF -> App : HAL_ADF_SAD_SoundActivityCallback(SADj)
ADF <-- App
NVIC <-- ADF
end

App -> ADF : HAL_ADF_DFLT_StopAcq_IT(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_SAD_Stop_IT(SADj)
Note over ADF : Disable sound activity detector and interrupts\nSADj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

DMA mode without SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "DMA" as DMA

== Synchronous continuous acquisition in DMA mode without SAD usage ==
loop If not circular DMA
App -> ADF : HAL_ADF_DFLT_StartAcq_DMA(DFTLj)
Note over ADF : Enable DMA and interrupts
ADF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()
ADF <-- DMA : HAL_OK
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF : HAL_OK
alt#grey Only at first loop cycle If DMA is not circular
alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end
end
loop If circular DMA
Note over DMA : Transfer half complete IT occurrence
DMA -> ADF : ADF_DMA_HalfCpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqHalfCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
Note over DMA : Transfer complete IT occurrence
DMA -> ADF : ADF_DMA_CpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
alt#grey If not circular DMA
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
end
DMA <-- ADF
end
end
App -> ADF : HAL_ADF_DFLT_StopAcq_DMA(DFTLj)
ADF -> DMA : HAL_DMA_Abort_IT()
alt#grey If DMA transfer in progress
ADF <-- DMA : HAL_OK
App <-- ADF :HAL_OK
DMA -> ADF : ADF_DMA_AbortCallback()
Note over ADF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
else If no DMA transfer in progress
ADF <-- DMA : HAL_ERROR
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
App <-- ADF :HAL_OK
end

@enduml

Called functions:

DMA mode with SAD usage

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "DMA" as DMA

== Synchronous continuous acquisition in DMA mode with SAD usage ==
loop If not circular DMA
App -> ADF : HAL_ADF_SAD_Start_IT(SADj)
Note over ADF : Enable SAD interrupts and sound activity detector\nSADj state = ACTIVE
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_StartAcq_DMA(DFTLj)
Note over ADF : Enable DMA and interrupts
ADF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()
ADF <-- DMA : HAL_OK
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF : HAL_OK
alt#grey Only at first loop cycle If DMA is not circular
alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end
end
loop If circular DMA
Note over DMA : Transfer half complete IT occurrence
DMA -> ADF : ADF_DMA_HalfCpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqHalfCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
Note over DMA : Transfer complete IT occurrence
DMA -> ADF : ADF_DMA_CpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
alt#grey If not circular DMA
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
end
DMA <-- ADF
end
alt#grey If not circular DMA
App -> ADF : HAL_ADF_SAD_Stop_IT(SADj)
Note over ADF : Disable sound activity detector and interrupts\nSADj state = IDLE
App <-- ADF :HAL_OK
end
end

App -> ADF : HAL_ADF_DFLT_StopAcq_DMA(DFTLj)
ADF -> DMA : HAL_DMA_Abort_IT()
alt#grey If DMA transfer in progress
ADF <-- DMA : HAL_OK
App <-- ADF :HAL_OK
DMA -> ADF : ADF_DMA_AbortCallback()
Note over ADF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
else If no DMA transfer in progress
ADF <-- DMA : HAL_ERROR
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
App <-- ADF :HAL_OK
end

App -> ADF : HAL_ADF_SAD_Stop_IT(SADj)
Note over ADF : Disable sound activity detector and interrupts\nSADj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

ADF acquisition in synchronous single shot mode

Polling mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Synchronous single shot acquisition in polling mode ==
App -> ADF : HAL_ADF_DFLT_StartAcq(DFTLj)
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
loop
alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
end
App -> ADF : HAL_ADF_DFLT_StopAcq(DFTLj)
Note over ADF : Disable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Interrupt mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Synchronous single shot acquisition in interrupt mode ==
App -> ADF : HAL_ADF_DFLT_StartAcq_IT(DFTLj)
Note over ADF : Enable interrupts and digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
loop
alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end
Note over NVIC : FIFO threshold IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
ADF <-- App
NVIC <-- ADF
end
App -> ADF : HAL_ADF_DFLT_StopAcq_IT(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

DMA mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "DMA" as DMA

== Synchronous single shot acquisition in DMA mode ==
loop If not circular DMA
App -> ADF : HAL_ADF_DFLT_StartAcq_DMA(DFTLj)
Note over ADF : Enable DMA and interrupts
ADF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()
ADF <-- DMA : HAL_OK
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF : HAL_OK
loop If circular DMA
loop Repeat to fill DMA buffer
alt#grey If trigger is TRGO
App -> ADF : HAL_ADF_EnableTriggerOutput()
Note over ADF : Enable trigger output signal
App <-- ADF :HAL_OK
else If trigger isn't TRGO
ADF <-? :Trigger occurence
end
end
Note over DMA : Transfer half complete IT occurrence
DMA -> ADF : ADF_DMA_HalfCpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqHalfCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
Note over DMA : Transfer complete IT occurrence
DMA -> ADF : ADF_DMA_CpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
alt#grey If not circular DMA
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
end
DMA <-- ADF
end
end
App -> ADF : HAL_ADF_DFLT_StopAcq_DMA(DFTLj)
ADF -> DMA : HAL_DMA_Abort_IT()
alt#grey If DMA transfer in progress
ADF <-- DMA : HAL_OK
App <-- ADF :HAL_OK
DMA -> ADF : ADF_DMA_AbortCallback()
Note over ADF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
else If no DMA transfer in progress
ADF <-- DMA : HAL_ERROR
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
App <-- ADF :HAL_OK
end

@enduml

Called functions:

ADF acquisition in window continuous mode

Polling mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Window continuous acquisition in polling mode ==
App -> ADF : HAL_ADF_DFLT_StartAcq(DFTLj)
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
loop
ADF <-? :Start trigger occurence
loop
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
end
ADF <-? :Stop trigger occurence
end
App -> ADF : HAL_ADF_DFLT_StopAcq(DFTLj)
Note over ADF : Disable digital filter\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

Interrupt mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Window continuous acquisition in interrupt mode ==
App -> ADF : HAL_ADF_DFLT_StartAcq_IT(DFTLj)
Note over ADF : Enable interrupts and digital filter\nDFLTj state = ACTIVE
App <-- ADF :HAL_OK
loop
ADF <-? :Start trigger occurence
loop
Note over NVIC : FIFO threshold IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
App -> ADF : HAL_ADF_DFLT_GetAcqValue(DFTLj)
App <-- ADF :Acquisition value
ADF <-- App
NVIC <-- ADF
end
ADF <-? :Stop trigger occurence
end
App -> ADF : HAL_ADF_DFLT_StopAcq_IT(DFTLj)
Note over ADF : Disable digital filter and interrupts\nDFLTj state = IDLE
App <-- ADF :HAL_OK

@enduml

Called functions:

DMA mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "DMA" as DMA

== Window continuous acquisition in DMA mode ==
loop If not circular DMA
App -> ADF : HAL_ADF_DFLT_StartAcq_DMA(DFTLj)
Note over ADF : Enable DMA and interrupts
ADF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()
ADF <-- DMA : HAL_OK
Note over ADF : Enable digital filter\nDFLTj state = ACTIVE
App <-- ADF : HAL_OK
loop If circular DMA or if DMA transfer not completed
ADF <-? :Start trigger occurence
loop If circular DMA
Note over DMA : Transfer half complete IT occurrence
DMA -> ADF : ADF_DMA_HalfCpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqHalfCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
Note over DMA : Transfer complete IT occurrence
DMA -> ADF : ADF_DMA_CpltCallback()
Note over ADF : Retrieve DFLT index from DMA handle
ADF -> App : HAL_ADF_DFLT_AcqCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
alt#grey If not circular DMA
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
end
DMA <-- ADF
end
ADF <-? :Stop trigger occurence
end
end
App -> ADF : HAL_ADF_DFLT_StopAcq_DMA(DFTLj)
ADF -> DMA : HAL_DMA_Abort_IT()
alt#grey If DMA transfer in progress
ADF <-- DMA : HAL_OK
App <-- ADF :HAL_OK
DMA -> ADF : ADF_DMA_AbortCallback()
Note over ADF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
else If no DMA transfer in progress
ADF <-- DMA : HAL_ERROR
Note over ADF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE
ADF -> App : HAL_ADF_DFLT_AcqStopCpltCallback(DFLTj)
Note over App : User implementation
ADF <-- App
App <-- ADF :HAL_OK
end

@enduml

Called functions:

ADF error handling during acquisition

Polling mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Error handling during acquisition in polling mode ==
App -> ADF : HAL_ADF_DFLT_PollForAcq(DFTLj)
Note over ADF : Wait available acquisition
alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
Note over ADF : last_error_codes[j] = 0
end
alt If acquisition available before timeout elapsed
alt If at least one of following flags is set
alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
alt If data overflow or snapshot data overrun flag is set
Note over ADF : last_error_codes[j] |= DFLT_ACQ_OVERFLOW
end
alt If saturation flag is set
Note over ADF : last_error_codes[j] |= DFLT_SATURATION
end
alt If reshape filter overrun flag is set
Note over ADF : last_error_codes[j] |= DFLT_RSF_OVERRUN
end
end
Note over ADF : clear acquisition error flags
App <-- ADF : HAL_ERROR
else No error flag
App <-- ADF :HAL_OK
end
else Timeout elapsed without acquisition available
App <-- ADF :HAL_TIMEOUT
end
alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
App -> ADF : HAL_ADF_GetLastErrorCodes(DFTLj)
App <-- ADF :last_error_codes[j]
end

@enduml

Called functions:

Interrupt mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Error handling during acquisition in interrupt mode ==
Note over NVIC : data overflow IT occurrence\nand/or saturation IT occurrence\nand/or reshape filter overrun IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
Note over ADF : last_error_codes[j] |= DFLT_ACQ_OVERFLOW\nand/or last_error_codes[j] |= DFLT_SATURATION\nand/or last_error_codes[j] |= DFLT_RSF_OVERRUN
end
Note over ADF : Clear IT flag(s)
ADF -> App : HAL_ADF_ErrorCallback(DFLTj)
Note over App : User implementation
ADF <-- App
NVIC <-- ADF

alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
App -> ADF : HAL_ADF_GetLastErrorCodes(DFTLj)
App <-- ADF :last_error_codes[j]
end

@enduml

Called functions:

DMA mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC
participant "DMA" as DMA

== Error handling during acquisition in DMA mode ==
alt ADF error
Note over NVIC : data overflow IT occurrence\nand/or saturation IT occurrence\nand/or reshape filter overrun IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(DFTLj)
alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
Note over ADF : last_error_codes[j] |= DFLT_ACQ_OVERFLOW\nand/or last_error_codes[j] |= DFLT_SATURATION\nand/or last_error_codes[j] |= DFLT_RSF_OVERRUN
end
Note over ADF : Clear IT flag(s)
ADF -> App : HAL_ADF_ErrorCallback(DFLTj)
Note over App : User implementation
ADF <-- App
NVIC <-- ADF
end

alt DMA error
Note over DMA : DMA error occurrence
DMA -> ADF : ADF_DMA_ErrorCallback()
Note over ADF : Retrieve DFLT index from DMA handle
alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
Note over ADF : last_error_codes[j] |= DMA
end
ADF -> App : HAL_ADF_ErrorCallback(DFLTj)
Note over App : User implementation
ADF <-- App
DMA <-- ADF
end

alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
App -> ADF : HAL_ADF_GetLastErrorCodes(DFTLj)
App <-- ADF :last_error_codes[j]
end

@enduml

Called functions:

ADF possible configurations during acquisition

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Possible configurations during acquisition ==
App -> ADF : HAL_ADF_DFLT_SetSamplesDelay(DFTLj)
App <-- ADF :HAL_OK
App -> ADF : HAL_ADF_DFLT_SetGain(DFTLj)
App <-- ADF :HAL_OK

@enduml

Called functions:

Clock absence detection

Polling mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF

== Clock absence detection in polling mode ==

App -> ADF : HAL_ADF_SITF_IsClockAbsenceDetected(SITFi)
Note over ADF : Check clock absence detection flag
alt If clock absence detection flag is set
App <-- ADF : HAL_ADF_SITF_CKAB_DETECTED
else if clock absence detection flag is not set
App <-- ADF : HAL_ADF_SITF_CKAB_NOT_DETECTED
end

@enduml

Called functions:

Interrupt mode

@startuml

skinparam DefaultTextAlignment center

participant App as "User application"
participant "<font color=green><b>HAL ADF</b></font>" as ADF
participant "NVIC" as NVIC

== Clock absence detection in interrupt mode ==

App -> ADF : HAL_ADF_SITF_StartClockAbsenceDetect_IT(SITFi)
Note over ADF : Enable clock absence detection interrupt
App <-- ADF : HAL_OK

Note over NVIC : Clock absence detection IT occurrence
NVIC -> ADF : HAL_ADF_IRQHandler(SITFi)
Note over ADF : Clear clock absence detection flag
alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
Note over ADF : last_error_codes[i] |= SITF_CLOCK_ABSENCE
end
ADF -> App : HAL_ADF_ErrorCallback(SITFi)
Note over App : User implementation
ADF <-- App
NVIC <-- ADF

alt If USE_HAL_ADF_GET_LAST_ERRORS = 1
App -> ADF : HAL_ADF_GetLastErrorCodes(SITFi)
App <-- ADF :last_error_codes[i]
end

App -> ADF : HAL_ADF_SITF_StopClockAbsenceDetect_IT(SITFi)
Note over ADF : Disable clock absence detection interrupt
App <-- ADF : HAL_OK

@enduml

Called functions: