HAL MDF Use Cases

Global MDF initialization

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "HAL DMA" as DMA

participant "HAL RCC" as RCC

participant "HAL GPIO" as GPIO

participant "System Driver" as SYSTEM



== MDF HAL initialization ==

App -> MDF : HAL_MDF_Init()

Note over MDF : Initialize MDF instance on handle\nGlobal state = INIT

alt#grey #lightgrey If USE_HAL_MDF_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

MDF->RCC : Enable the MDF clock

RCC-->MDF

end

App <-- MDF : HAL_OK



== MDF system initialization ==

Note over App : MDF system initialization can be called before\nMDF HAL initialization



App->SYSTEM : Configure and enable MDF kernel clock

SYSTEM --> App



alt#grey #lightgrey If USE_HAL_MDF_CLK_ENABLE_MODEL == HAL_CLK_ENABLE_NO

App->RCC : Enable the MDF clock

RCC --> App

end



alt#grey #lightgrey If USE_HAL_MDF_DMA == 1

App->DMA : Initialization of DMA

DMA-->App

App->MDF : HAL_MDF_SetDMA()

MDF-->App

end



alt#grey #lightgrey If GPIOs needed

App->GPIO : Initialization of GPIOs

GPIO-->App

end



@enduml

Called functions:

Global MDF de-initialization

@startuml

participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "HAL DMA" as DMA

participant "HAL RCC" as RCC

participant "HAL GPIO" as GPIO

participant "System Driver" as SYSTEM



== MDF HAL de-initialization ==

App-> MDF : HAL_MDF_DeInit()

Note over MDF : Global state = RESET

App<--MDF



== MDF system de-initalization ==

App->RCC : Disable the MDF clock

RCC --> App



App->SYSTEM : Disable MDF kernel clock

SYSTEM --> App



alt#grey #lightgrey If USE_HAL_MDF_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 MDF configuration

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== MDF global configuration ==

App -> MDF : HAL_MDF_SetConfig()

Note over MDF : Configure processing clock divider\nGlobal state = IDLE

App <-- MDF :HAL_OK



== Advanced MDF global configuration ==

alt#grey #lightgrey Output clock feature

App -> MDF : HAL_MDF_SetConfigOutputClock()

Note over MDF : Configure output clock divider and pins

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_EnableOutputClock()

App <-- MDF :HAL_OK

end

alt#grey #lightgrey Output clock trigger feature

App -> MDF : HAL_MDF_SetConfigOutputClockTrigger()

Note over MDF : Configure output clock trigger source and edge

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_EnableOutputClockTrigger()

App <-- MDF :HAL_OK

end

alt#grey #lightgrey Interleaved filters feature

App -> MDF : HAL_MDF_SetInterleavedFilters()

Note over MDF : Configure number of filters interleaved with filter 0

App <-- MDF :HAL_OK

end



@enduml

Called functions:

Global MDF start/stop

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== MDF global start ==

App -> MDF : HAL_MDF_Start()

Note over MDF : Enable clock generator\nGlobal state = ACTIVE

App <-- MDF :HAL_OK



== MDF global stop ==

App -> MDF : HAL_MDF_Stop()

Note over MDF : Disable clock generator\nGlobal state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

MDF acquisition configuration

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



alt#grey Not needed if digital filter source is ADC interface

== Serial interface configuration ==

App -> MDF : HAL_MDF_SITF_SetConfig(SITFi)

Note over MDF : Configure clock source, mode and threshold\nSITFi state = IDLE

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_SITF_Start(SITFi)

Note over MDF : Enable serial interface i\nSITFi state = ACTIVE

App <-- MDF :HAL_OK



== Bitstream matrix configuration ==

App -> MDF : HAL_MDF_BSMX_SetConfig(BSMXj, SITFi)

Note over MDF : Configure bitstream selection (serial interface and edge)

App <-- MDF :HAL_OK

end



== Digital filter configuration ==

App -> MDF : HAL_MDF_DFLT_SetConfig(DFTLj)

Note over MDF : Configure data source, CIC mode, decimation ratio,\ngain, acquisition mode and trigger\nDFLTj state = IDLE

App <-- MDF :HAL_OK

alt#grey #lightgrey Advanced digital filter configuration

App -> MDF : HAL_MDF_DFLT_SetSamplesDelay(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_SetOffsetCompensation(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_SetGain(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_SetIntegrator(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_SetFifoThreshold(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_SetDiscardSamples(DFTLj)

App <-- MDF :HAL_OK

alt#grey #lightgrey Usefull only if acquisition mode is synchronous snapshot

App -> MDF : HAL_MDF_DFLT_SetSnapshotFormat(DFTLj)

App <-- MDF :HAL_OK

end

App -> MDF : HAL_MDF_DFLT_EnableReshapeFilter(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_EnableHighPassFilter(DFTLj)

App <-- MDF :HAL_OK

end



@enduml

Called functions:

MDF acquisition in asynchronous continuous mode

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Asynchronous continuous acquisition in polling mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq(DFTLj)

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

App -> MDF : HAL_MDF_DFLT_PollForAcq(DFTLj)

Note over MDF : Wait available acquisition

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

end

App -> MDF : HAL_MDF_DFLT_StopAcq(DFTLj)

Note over MDF : Disable digital filter\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Asynchronous continuous acquisition in interrupt mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

Note over NVIC : FIFO threshold IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

MDF <-- App

NVIC <-- MDF

end

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

DMA mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "DMA" as DMA



== Asynchronous continuous acquisition in DMA mode ==

loop If not circular DMA

App -> MDF : HAL_MDF_DFLT_StartAcq_DMA(DFTLj)

Note over MDF : Enable DMA and interrupts

MDF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()

MDF <-- DMA : HAL_OK

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF : HAL_OK

loop If circular DMA

Note over DMA : Transfer half complete IT occurrence

DMA -> MDF : MDF_DMA_HalfCpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqHalfCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

Note over DMA : Transfer complete IT occurrence

DMA -> MDF : MDF_DMA_CpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

alt#grey If not circular DMA

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

end

DMA <-- MDF

end

end

App -> MDF : HAL_MDF_DFLT_StopAcq_DMA(DFTLj)

MDF -> DMA : HAL_DMA_Abort_IT()

alt#grey If DMA transfer in progress

MDF <-- DMA : HAL_OK

App <-- MDF :HAL_OK

DMA -> MDF : MDF_DMA_AbortCallback()

Note over MDF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

else If no DMA transfer in progress

MDF <-- DMA : HAL_ERROR

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

App <-- MDF :HAL_OK

end



@enduml

Called functions:

MDF acquisition in asynchronous single shot mode

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Asynchronous single shot acquisition in polling mode ==

loop

App -> MDF : HAL_MDF_DFLT_StartAcq(DFTLj)

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_PollForAcq(DFTLj)

Note over MDF : Wait available acquisition\nDisable digital filter\nDFLTj state = IDLE

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

end

App -> MDF : HAL_MDF_DFLT_StopAcq(DFTLj)

Note over MDF : Disable digital filter\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Asynchronous single shot acquisition in interrupt mode ==

loop

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

Note over NVIC : FIFO threshold IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

MDF <-- App

NVIC <-- MDF

end

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

DMA mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "DMA" as DMA



== Asynchronous single shot acquisition in DMA mode ==

loop

App -> MDF : HAL_MDF_DFLT_StartAcq_DMA(DFTLj)

Note over MDF : Enable DMA and interrupts

MDF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()

MDF <-- DMA : HAL_OK

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF : HAL_OK

Note over DMA : Transfer complete IT occurrence

DMA -> MDF : MDF_DMA_CpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle,\ndisable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

end

App -> MDF : HAL_MDF_DFLT_StopAcq_DMA(DFTLj)

MDF -> DMA : HAL_DMA_Abort_IT()

alt#grey If DMA transfer in progress

MDF <-- DMA : HAL_OK

App <-- MDF :HAL_OK

DMA -> MDF : MDF_DMA_AbortCallback()

Note over MDF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

else If no DMA transfer in progress

MDF <-- DMA : HAL_ERROR

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

App <-- MDF :HAL_OK

end



@enduml

Called functions:

MDF acquisition in synchronous continuous mode

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Synchronous continuous acquisition in polling mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq(DFTLj)

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

loop

App -> MDF : HAL_MDF_DFLT_PollForAcq(DFTLj)

Note over MDF : Wait available acquisition

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

end

App -> MDF : HAL_MDF_DFLT_StopAcq(DFTLj)

Note over MDF : Disable digital filter\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Synchronous continuous acquisition in interrupt mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

loop

Note over NVIC : FIFO threshold IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

MDF <-- App

NVIC <-- MDF

end

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

DMA mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "DMA" as DMA



== Synchronous continuous acquisition in DMA mode ==

loop If not circular DMA

App -> MDF : HAL_MDF_DFLT_StartAcq_DMA(DFTLj)

Note over MDF : Enable DMA and interrupts

MDF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()

MDF <-- DMA : HAL_OK

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF : HAL_OK

alt#grey Only at first loop cycle If DMA is not circular

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

end

loop If circular DMA

Note over DMA : Transfer half complete IT occurrence

DMA -> MDF : MDF_DMA_HalfCpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqHalfCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

Note over DMA : Transfer complete IT occurrence

DMA -> MDF : MDF_DMA_CpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

alt#grey If not circular DMA

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

end

DMA <-- MDF

end

end

App -> MDF : HAL_MDF_DFLT_StopAcq_DMA(DFTLj)

MDF -> DMA : HAL_DMA_Abort_IT()

alt#grey If DMA transfer in progress

MDF <-- DMA : HAL_OK

App <-- MDF :HAL_OK

DMA -> MDF : MDF_DMA_AbortCallback()

Note over MDF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

else If no DMA transfer in progress

MDF <-- DMA : HAL_ERROR

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

App <-- MDF :HAL_OK

end



@enduml

Called functions:

MDF acquisition in synchronous single shot mode

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Synchronous single shot acquisition in polling mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq(DFTLj)

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

App -> MDF : HAL_MDF_DFLT_PollForAcq(DFTLj)

Note over MDF : Wait available acquisition

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

end

App -> MDF : HAL_MDF_DFLT_StopAcq(DFTLj)

Note over MDF : Disable digital filter\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Synchronous single shot acquisition in interrupt mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

Note over NVIC : FIFO threshold IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

MDF <-- App

NVIC <-- MDF

end

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

DMA mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "DMA" as DMA



== Synchronous single shot acquisition in DMA mode ==

loop If not circular DMA

App -> MDF : HAL_MDF_DFLT_StartAcq_DMA(DFTLj)

Note over MDF : Enable DMA and interrupts

MDF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()

MDF <-- DMA : HAL_OK

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF : HAL_OK

loop If circular DMA

loop Repeat to fill DMA buffer

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

end

Note over DMA : Transfer half complete IT occurrence

DMA -> MDF : MDF_DMA_HalfCpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqHalfCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

Note over DMA : Transfer complete IT occurrence

DMA -> MDF : MDF_DMA_CpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

alt#grey If not circular DMA

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

end

DMA <-- MDF

end

end

App -> MDF : HAL_MDF_DFLT_StopAcq_DMA(DFTLj)

MDF -> DMA : HAL_DMA_Abort_IT()

alt#grey If DMA transfer in progress

MDF <-- DMA : HAL_OK

App <-- MDF :HAL_OK

DMA -> MDF : MDF_DMA_AbortCallback()

Note over MDF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

else If no DMA transfer in progress

MDF <-- DMA : HAL_ERROR

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

App <-- MDF :HAL_OK

end



@enduml

Called functions:

MDF acquisition in window continuous mode

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Window continuous acquisition in polling mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq(DFTLj)

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

MDF <-? :Start trigger occurence

loop

App -> MDF : HAL_MDF_DFLT_PollForAcq(DFTLj)

Note over MDF : Wait available acquisition

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

end

MDF <-? :Stop trigger occurence

end

App -> MDF : HAL_MDF_DFLT_StopAcq(DFTLj)

Note over MDF : Disable digital filter\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Window continuous acquisition in interrupt mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

MDF <-? :Start trigger occurence

loop

Note over NVIC : FIFO threshold IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF :Acquisition value

MDF <-- App

NVIC <-- MDF

end

MDF <-? :Stop trigger occurence

end

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

DMA mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "DMA" as DMA



== Window continuous acquisition in DMA mode ==

loop If not circular DMA

App -> MDF : HAL_MDF_DFLT_StartAcq_DMA(DFTLj)

Note over MDF : Enable DMA and interrupts

MDF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()

MDF <-- DMA : HAL_OK

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF : HAL_OK

loop If circular DMA or if DMA transfer not completed

MDF <-? :Start trigger occurence

loop If circular DMA

Note over DMA : Transfer half complete IT occurrence

DMA -> MDF : MDF_DMA_HalfCpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqHalfCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

Note over DMA : Transfer complete IT occurrence

DMA -> MDF : MDF_DMA_CpltCallback()

Note over MDF : Retrieve DFLT index from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

alt#grey If not circular DMA

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

end

DMA <-- MDF

end

MDF <-? :Stop trigger occurence

end

end

App -> MDF : HAL_MDF_DFLT_StopAcq_DMA(DFTLj)

MDF -> DMA : HAL_DMA_Abort_IT()

alt#grey If DMA transfer in progress

MDF <-- DMA : HAL_OK

App <-- MDF :HAL_OK

DMA -> MDF : MDF_DMA_AbortCallback()

Note over MDF : Retrieve DFLT index from DMA handle\nDisable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

else If no DMA transfer in progress

MDF <-- DMA : HAL_ERROR

Note over MDF : Disable digital filter, DMA and interrupts\nDFLTj state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLTj)

Note over App : User implementation

MDF <-- App

App <-- MDF :HAL_OK

end



@enduml

Called functions:

MDF acquisition in synchronous snapshot mode

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Synchronous snapshot acquisition in polling mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq(DFTLj)

Note over MDF : Enable digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

App -> MDF : HAL_MDF_DFLT_PollForSnapshotAcq(DFTLj)

Note over MDF : Wait available snapshot acquisition

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_GetSnapshotAcqValue(DFTLj)

App <-- MDF

end

App -> MDF : HAL_MDF_DFLT_StopAcq(DFTLj)

Note over MDF : Disable digital filter\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Synchronous snapshot acquisition in interrupt mode ==

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

loop

alt#grey If trigger is TRGO

App -> MDF : HAL_MDF_EnableTriggerOutput()

Note over MDF : Enable trigger output signal

App <-- MDF :HAL_OK

else If trigger isn't TRGO

MDF <-? :Trigger occurence

end

Note over NVIC : Snapshot data ready IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLTj)

App -> MDF : HAL_MDF_DFLT_GetSnapshotAcqValue(DFTLj)

App <-- MDF

MDF <-- App

NVIC <-- MDF

end

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK



@enduml

Called functions:

MDF interleaved filters mode

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Interleaved filters in interrupt mode ==

loop for j = 0 to n-1

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

end



loop If synchronous single-shot mode

MDF <-? :Trigger occurence



loop If synchronous continuous mode

Note over NVIC : FIFO threshold IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTL0)

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLT0)

MDF <-- App

NVIC <-- MDF

loop for j = 0 to n-1

App -> MDF : HAL_MDF_DFLT_GetAcqValue(DFTLj)

App <-- MDF

end

end

end

loop for j = 0 to n-1

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK

end



@enduml

Called functions:

DMA mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "DMA" as DMA



== Interleaved filters in DMA mode ==

loop for j = 1 to n-1

App -> MDF : HAL_MDF_DFLT_StartAcq_IT(DFTLj)

Note over MDF : Enable interrupts and digital filter\nDFLTj state = ACTIVE

App <-- MDF :HAL_OK

end



App -> MDF : HAL_MDF_DFLT_StartAcq_DMA(DFTL0)

Note over MDF : Enable DMA and interrupts

MDF -> DMA : HAL_DMA_StartPeriphXfer_IT_Opt()

MDF <-- DMA : HAL_OK

Note over MDF : Enable digital filter\nDFLT0 state = ACTIVE

App <-- MDF : HAL_OK



loop If circular DMA and single-shot mode



loop To fill DMA buffer if single-shot mode

MDF <-? :Trigger occurence

end



loop If circular DMA and continuous mode

Note over DMA : Transfer half complete IT occurrence

DMA -> MDF : MDF_DMA_HalfCpltCallback()

Note over MDF : Retrieve DFLT index  0 from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqHalfCpltCallback(DFLT0)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

Note over DMA : Transfer complete IT occurrence

DMA -> MDF : MDF_DMA_CpltCallback()

Note over MDF : Retrieve DFLT index  0 from DMA handle

MDF -> App : HAL_MDF_DFLT_AcqCpltCallback(DFLT0)

Note over App : User implementation

MDF <-- App

alt#grey If not circular DMA

Note over MDF : Disable digital filter, DMA and interrupts\nDFLT0 state = IDLE

end

DMA <-- MDF

end

MDF <-? :Stop trigger occurence

end

App -> MDF : HAL_MDF_DFLT_StopAcq_DMA(DFTL0)

MDF -> DMA : HAL_DMA_Abort_IT()

alt#grey If DMA transfer in progress

MDF <-- DMA : HAL_OK

App <-- MDF :HAL_OK

DMA -> MDF : MDF_DMA_AbortCallback()

Note over MDF : Retrieve DFLT index 0 from DMA handle\nDisable digital filter, DMA and interrupts\nDFLT0 state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLT0)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

else If no DMA transfer in progress

MDF <-- DMA : HAL_ERROR

Note over MDF : Disable digital filter, DMA and interrupts\nDFLT0 state = IDLE

MDF -> App : HAL_MDF_DFLT_AcqStopCpltCallback(DFLT0)

Note over App : User implementation

MDF <-- App

App <-- MDF :HAL_OK

end



loop for j = 1 to n-1

App -> MDF : HAL_MDF_DFLT_StopAcq_IT(DFTLj)

Note over MDF : Disable digital filter and interrupts\nDFLTj state = IDLE

App <-- MDF :HAL_OK

end







@enduml

Called functions:

MDF error handling during acquisition

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Error handling during acquisition in polling mode ==

App -> MDF : HAL_MDF_DFLT_PollForAcq(DFTLj) or\nHAL_MDF_DFLT_PollForSnapshotAcq(DFTLj)

Note over MDF : Wait available acquisition

alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

Note over MDF : 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_MDF_GET_LAST_ERRORS = 1

alt If data overflow or snapshot data overrun flag is set

Note over MDF : last_error_codes[j] |= DFLT_ACQ_OVERFLOW

end

alt If saturation flag is set

Note over MDF : last_error_codes[j] |= DFLT_SATURATION

end

alt If reshape filter overrun flag is set

Note over MDF : last_error_codes[j] |= DFLT_RSF_OVERRUN

end

end

Note over MDF : clear acquisition error flags

App <-- MDF : HAL_ERROR

else No error flag

App <-- MDF :HAL_OK

end

else Timeout elapsed without acquisition available

App <-- MDF :HAL_TIMEOUT

end

alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

App -> MDF : HAL_MDF_GetLastErrorCodes(DFTLj)

App <-- MDF :last_error_codes[j]

end



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Error handling during acquisition in interrupt mode ==

Note over NVIC : data overflow or snapshot data overrun IT occurrence\nand/or saturation IT occurrence\nand/or reshape filter overrun IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

Note over MDF : 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 MDF : Clear IT flag(s)

MDF -> App : HAL_MDF_ErrorCallback(DFLTj)

Note over App : User implementation

MDF <-- App

NVIC <-- MDF



alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

App -> MDF : HAL_MDF_GetLastErrorCodes(DFTLj)

App <-- MDF :last_error_codes[j]

end



@enduml

Called functions:

DMA mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC

participant "DMA" as DMA



== Error handling during acquisition in DMA mode ==

alt MDF error

Note over NVIC : data overflow or snapshot data overrun IT occurrence\nand/or saturation IT occurrence\nand/or reshape filter overrun IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(DFTLj)

alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

Note over MDF : 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 MDF : Clear IT flag(s)

MDF -> App : HAL_MDF_ErrorCallback(DFLTj)

Note over App : User implementation

MDF <-- App

NVIC <-- MDF

end



alt DMA error

Note over DMA : DMA error occurrence

DMA -> MDF : MDF_DMA_ErrorCallback()

Note over MDF : Retrieve DFLT index from DMA handle

alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

Note over MDF : last_error_codes[j] |= DMA

end

MDF -> App : HAL_MDF_ErrorCallback(DFLTj)

Note over App : User implementation

MDF <-- App

DMA <-- MDF

end



alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

App -> MDF : HAL_MDF_GetLastErrorCodes(DFTLj)

App <-- MDF :last_error_codes[j]

end



@enduml

Called functions:

MDF possible configurations during acquisition

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Possible configurations during acquisition ==

App -> MDF : HAL_MDF_DFLT_SetSamplesDelay(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_SetOffsetCompensation(DFTLj)

App <-- MDF :HAL_OK

App -> MDF : HAL_MDF_DFLT_SetGain(DFTLj)

App <-- MDF :HAL_OK



@enduml

Called functions:

Clock absence detection

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Clock absence detection in polling mode ==



App -> MDF : HAL_MDF_SITF_IsClockAbsenceDetected(SITFi)

Note over MDF : Check clock absence detection flag

alt If clock absence detection flag is set

App <-- MDF : HAL_MDF_SITF_CKAB_DETECTED

else if clock absence detection flag is not set

App <-- MDF : HAL_MDF_SITF_CKAB_NOT_DETECTED

end



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF

participant "NVIC" as NVIC



== Clock absence detection in interrupt mode ==



App -> MDF : HAL_MDF_SITF_StartClockAbsenceDetect_IT(SITFi)

Note over MDF : Enable clock absence detection interrupt

App <-- MDF : HAL_OK



Note over NVIC : Clock absence detection IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(SITFi)

Note over MDF : Clear clock absence detection flag

alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

Note over MDF : last_error_codes[i] |= SITF_CLOCK_ABSENCE

end

MDF -> App : HAL_MDF_ErrorCallback(SITFi)

Note over App : User implementation

MDF <-- App

NVIC <-- MDF



alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

App -> MDF : HAL_MDF_GetLastErrorCodes(SITFi)

App <-- MDF :last_error_codes[i]

end



App -> MDF : HAL_MDF_SITF_StopClockAbsenceDetect_IT(SITFi)

Note over MDF : Disable clock absence detection interrupt

App <-- MDF : HAL_OK



@enduml

Called functions:

Short-circuit detection

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Short-circuit detection in polling mode ==



App -> MDF : HAL_MDF_SCD_SetConfig(SCDj)

Note over MDF : Configure threshold and break signal\nSCDj state = IDLE

App <-- MDF : HAL_OK



App -> MDF : HAL_MDF_SCD_Start(SCDj)

Note over MDF : Enable short-circuit detection\nSCDj state = ACTIVE

App <-- MDF : HAL_OK



App -> MDF : HAL_MDF_SCD_IsDetected(SCDj)

Note over MDF : Check short-circuit detection flag

alt If short-circuit detection flag is set

Note over MDF : Clear short-circuit detection flag

App <-- MDF : HAL_MDF_SHORT_CIRCUIT_DETECTED

else if short-circuit detection flag is not set

App <-- MDF : HAL_MDF_SHORT_CIRCUIT_NOT_DETECTED

end



App -> MDF : HAL_MDF_SCD_Stop(SCDj)

Note over MDF : Disable short-circuit detection\nSCDj state = IDLE

App <-- MDF : HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Short-circuit detection in interrupt mode ==



App -> MDF : HAL_MDF_SCD_SetConfig(SCDj)

Note over MDF : Configure threshold and break signal\nSCDj state = IDLE

App <-- MDF : HAL_OK



App -> MDF : HAL_MDF_SCD_Start_IT(SCDj)

Note over MDF : Enable short-circuit detection interrupt\nEnable short-circuit detection\nSCDj state = ACTIVE

App <-- MDF : HAL_OK



Note over NVIC : Short-circuit detection IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(SCDj)

Note over MDF : Clear short-circuit detection flag

alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

Note over MDF : last_error_codes[j] |= SHORT_CIRCUIT

end

MDF -> App : HAL_MDF_ErrorCallback(SCDj)

Note over App : User implementation

MDF <-- App

NVIC <-- MDF



alt If USE_HAL_MDF_GET_LAST_ERRORS = 1

App -> MDF : HAL_MDF_GetLastErrorCodes(SCDj)

App <-- MDF :last_error_codes[j]

end



App -> MDF : HAL_MDF_SCD_Stop_IT(SCDj)

Note over MDF : Disable short-circuit detection interrupt\nDisable short-circuit detection\nSCDj state = IDLE

App <-- MDF : HAL_OK



@enduml

Called functions:

Out-of-limit detection

Polling mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Out-of-limit detection in polling mode ==



App -> MDF : HAL_MDF_OLD_SetConfig(OLDj)

Note over MDF : Configure cic order, decimation ratio,\nthresholds, event and break signal.\nOLDj state = IDLE

App <-- MDF : HAL_OK



App -> MDF : HAL_MDF_OLD_Start(OLDj)

Note over MDF : Enable out-of-limit detection\nOLDj state = ACTIVE

App <-- MDF : HAL_OK



App -> MDF : HAL_MDF_OLD_IsDetected(OLDj)

Note over MDF : Check out-of-limit detection flag

alt If out-of-limit detection flag is set

Note over MDF : Get threshold information\nClear out-of-limit detection flag

App <-- MDF : HAL_MDF_OUT_OF_LIMIT_DETECTED

else if out-of-limit detection flag is not set

App <-- MDF : HAL_MDF_OUT_OF_LIMIT_NOT_DETECTED

end



App -> MDF : HAL_MDF_OLD_Stop(OLDj)

Note over MDF : Disable out-of-limit detection\nOLDj state = IDLE

App <-- MDF : HAL_OK



@enduml

Called functions:

Interrupt mode

@startuml



participant App as "User application"

participant "<font color=green><b>HAL MDF</b></font>" as MDF



== Out-of-limit detection in interrupt mode ==



App -> MDF : HAL_MDF_OLD_SetConfig(OLDj)

Note over MDF : Configure cic order, decimation ratio,\nthresholds, event and break signal.\nOLDj state = IDLE

App <-- MDF : HAL_OK



App -> MDF : HAL_MDF_OLD_Start_IT(OLDj)

Note over MDF : Enable out-of-limit detection interrupt\nEnable out-of-limit detection\nOLDj state = ACTIVE

App <-- MDF : HAL_OK



Note over NVIC : Out-of-limit detection IT occurrence

NVIC -> MDF : HAL_MDF_IRQHandler(OLDj)

Note over MDF : Get threshold information\nClear out-of-limit detection flag

MDF -> App : HAL_MDF_OLD_Callback(OLDj)

Note over App : User implementation

MDF <-- App

NVIC <-- MDF



App -> MDF : HAL_MDF_OLD_Stop_IT(OOLDj)

Note over MDF : Disable out-of-limit detection interrupt\nDisable out-of-limit detection\nOLDj state = IDLE

App <-- MDF : HAL_OK



@enduml

Called functions: