HAL OPAMP Use Cases

User Application Initialization of the OPAMP Driver

@startuml

title
  <font color=blue> Use case: initialization

end title

' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
note  over user: start the OPAMP initialization
user -> opamp : HAL_OPAMP_Init()
note over opamp : associate a OPAMP instance to an handle

opamp --> user : HAL_OK  or  HAL_INVALID_PARAM
note right: return hal_opamp_status_t

== OPAMP system initialization ==
user -> system : HAL_RCC_OPAMP_EnableClock()
system --> user
note over user, system: enable the OPAMP clock\n HAL_RCC_OPAMP_EnableClock() is also called inside HAL_OPAMP_Init() whenever \n (USE_HAL_OPAMP_CLK_ENABLE_MODEL \t != \t HAL_CLK_ENABLE_NO)

== Peripherals dependencies initialization ==

opt when GPIO needed
user -> system : HAL_RCC_GPIOx_EnableClock()
user -> system : HAL_GPIO_Init(...)
end

== OPAMP configuration ==
note over opamp : by default configuration is:\n power_mode = <font color=blue> normal \n speed_mode = <font color=blue> normal\n <font color=purple>STANDALONE \n normal mode (ie calibration disabled)\n non-inverted input connected to GPIO \n inverted input connected to GPIO\n PGA gain = x2 \n <font color=blue>OPAMP disabled\n

group optionnal
user -> opamp : HAL_OPAMP_SetConfig()
opamp --> user : HAL_OK or HAL_INVALID_PARAM
end

== OPAMP processing ==
user -> opamp : HAL_OPAMP_Start()
opamp --> user: HAL_OK
== ==
@enduml

Functions called:

OPAMP Deinitialization by User Application, Minimal Sequence

@startuml

title
  <font color=blue> OPAMP deinitialization,
  <font color=blue> minimal sequence

end title


participant "User application" as user
participant "OPAMP driver"       as opamp
participant "System driver"    as system

==OPAMP deinitialization==
user -> opamp : HAL_OPAMP_Stop()
opamp --> user
user -> opamp : HAL_OPAMP_DeInit()
== ==

@enduml

Functions called:

OPAMP Deinitialization by User Application, Full Sequence

@startuml

title
  <font color=blue> OPAMP deinitialization
  <font color=blue> full sequence

end title

participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

==OPAMP deinitialization==
user -> opamp : HAL_OPAMP_Stop()
opamp  --> user
user -> opamp : HAL_OPAMP_DeInit

==OPAMP system deinitialization==
note over user : To finish the work with the OPAMP, the user must do the following sequence:

user -> system : Disable the OPAMP clock ( void HAL_RCC_OPAMP_DisableClock(void) )
== ==

@enduml

Functions called:

Use Case: OPAMP Reset Configuration

@startuml

title
  <font color=blue> Use case: OPAMP reset configuration

end title

participant "User application" as user
participant "OPAMP driver" as opamp


== OPAMP initialization ==
== OPAMP configuration ==
alt optional
user -> opamp : HAL_OPAMP_SetConfig( hopampx, p_config )
opamp --> user: HAL_OK or HAL_INVALID_PARAM
end
== OPAMP processing ==

user -> opamp : HAL_OPAMP_Start( hopampx )
note right: <font color=green> ACTIVE state

== Stop OPAMP channel, then reset configuration ==
user -> opamp : HAL_OPAMP_Stop( hopampx )
note right: <font color=green> IDLE state

user -> opamp : <font color=blue>HAL_OPAMP_ResetConfig( hopampx )
note right:  Reset to the default parameters configuration of the OPAMP:\n power_mode = <font color=blue> normal \n speed_mode = <font color=blue> normal\n <font color=purple>STANDALONE \n normal mode (ie calibration disabled)\n non-inverted input connected to GPIO \n inverted input connected to GPIO\n PGA gain = x2 \n <font color=blue>OPAMP disabled\n\n<font color=red> Note: user trimming mode remains unchanged \n\n<font color=green> IDLE state
== ==
@enduml

Functions called:

Use Case: OPAMP Set Configuration in Standalone Mode, Detailed Sequence

@startuml
title
  <font color=blue> Use case: OPAMP set configuration in STANDALONE mode (external gain setting mode)
  <font color=blue> detailed sequence
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end

== OPAMP configuration STANDALONE ==
group optionnal
user -> opamp : HAL_OPAMP_SetConfig() \n \n
note right:  power_mode = <font color=blue> normal  ,  low\n speed_mode = <font color=blue> normal , high \n configuration = <font color=purple>STANDALONE \n \n<font color=blue> default  connections:\n  non inverting_input   VINP = GPIO connected \n inverting_input VINM = GPIO connected  \n output pin = connected internally to an ADC input, and by user to GPIO non-inverting input (through filtering component)\n\n<font color=blue> factory trimming
opamp --> user

end

opt optionnal
user -> opamp : HAL_OPAMP_SetConfigInputConnection(...)
note right: VINM can be connected internally to _DAC1_CH1
end

== OPAMP processing ==

user -> opamp : HAL_OPAMP_Start()
note right: OPAMP is operationnal in <font color=purple> STANDALONE </font> mode
opamp --> user

opt optionnal
user -> system : HAL_RCC_OPAMP_DisableClock()
note right: the clock is switched off, \nthe opamp register can no more been accessed,\n OPAMP still running as <font color=purple> STANDALONE
end
== ==
@enduml

Functions called:

Use Case: OPAMP Set Configuration in Follower Mode, Detailed Sequence

@startuml
title
  <font color=blue> Use case: OPAMP set configuration in FOLLOWER mode
  <font color=blue> detailed sequence
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"       as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end

== OPAMP configuration FOLLOWER  ==
group compulsory
user -> opamp : HAL_OPAMP_SetConfig() \n \n
note right:  power_mode = <font color=blue> normal  ,  low\n speed_mode = <font color=blue> normal , high \n configuration = <font color=purple> FOLLOWER \n \n<font color=blue> default  connections:\n  non inverting_input   VINP = GPIO connected \n inverting_input VINM = inverting input not externally connected \n output pin = connected internally to an ADC input\n\n<font color=blue> factory trimming
opamp --> user

end

opt optionnal
user -> opamp : HAL_OPAMP_SetConfigInputConnection(...)
note right: VINM can be connected internally to _DAC1_CH1
end

== OPAMP processing ==

user -> opamp : HAL_OPAMP_Start()
note right: OPAMP is operationnal in <font color=purple> FOLLOWER </font> mode
opamp --> user

opt optionnal
user -> system : HAL_RCC_OPAMP_DisableClock()
note right: the clock is switched off, \nthe opamp register can no more been accessed,\n OPAMP still running as <font color=purple> FOLLOWER
end
== ==
@enduml

Functions called:

Use Case: OPAMP Set Configuration in Programmable Gain Amplifier Mode, Detailed Sequence

@startuml
title
  <font color=blue> Use case: OPAMP set configuration in PROGRAMMABLE GAIN AMPLIFIER mode,
  <font color=blue> internal gain setting (x2, x4, x8, x16),
  <font color=blue> detailed sequence
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"       as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end

== OPAMP configuration GAIN AMPLIFIER ==
group compulsory
user -> opamp : HAL_OPAMP_SetConfig() \n \n
note right: power_mode = <font color=blue> normal  ,  low\n speed_mode = <font color=blue> normal , high \n configuration = <font color=purple> GAIN AMPLIFIER \n \n<font color=blue> default  connections:\n  non inverting_input   VINP = GPIO connected \n inverting_input VINM = not use, is not externally connected \n output pin = connected internally to an ADC input\n\n<font color=blue> factory trimming
opamp --> user : HAL_OK or HAL_INVALID_PARAM

user -> opamp : HAL_OPAMP_SetGain( gain )
note right:\n PGA gain set to <font color=purple> x2, x4, x8 or x16 \n
opamp --> user : HAL_OK
end

opt optionnal
user -> opamp : HAL_OPAMP_SetConfigInputConnection(...)
note right: VINP can be connected internally to _DAC1_CH1
opamp --> user : HAL_OK or HAL_INVALID_PARAM
end

== OPAMP processing ==

user -> opamp : HAL_OPAMP_Start()
note right: OPAMP is operationnal in <font color=purple> GAIN AMPLIFIER </font> mode
opamp --> user

opt optionnal
user -> system : HAL_RCC_OPAMP_DisableClock()
note right: the clock is switched off, \nthe opamp register can no more been accessed,\n OPAMP still running as <font color=purple> GAIN AMPLIFIER
end
== ==
@enduml

Functions called:

Use Case: OPAMP Set Configuration in Programmable Gain Amplifier with External Filtering Mode, Detailed Sequence

@startuml
title
  <font color=blue> Use case: OPAMP set configuration in PROGRAMMABLE GAIN AMPLIFIER
    <font color=blue> internal gain setting (x2, x4, x8, x16),
      <font color=blue> with external filtering,
  <font color=blue> detailed sequence
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end

== OPAMP configuration GAIN AMPLIFIER EXTERNAL FILTERING ==
group compulsory
user -> opamp : HAL_OPAMP_SetConfig() \n \n
note right: power_mode = <font color=blue> normal  ,  low\n speed_mode = <font color=blue> normal , high \n configuration = <font color=purple> GAIN AMPLIFIER \n \n<font color=blue> default  connections:\n  non inverting_input VINP = GPIO connected \n inverting_input VINM =  not use, is not externally connected  \n output pin = connected internally to an ADC input\n\n<font color=blue> factory trimming
opamp --> user : HAL_OK or HAL_INVALID_PARAM

user -> opamp : <font color=green>HAL_OPAMP_SetConfigInputConnection( ... )
note right: non_inverting_input VINM = GPIO connected or _DAC1_CH1 \n <font color=green>inverting_input VINM = GPIO connected
opamp --> user : HAL_OK

user -> opamp : HAL_OPAMP_SetGain( gain )
note right:\n PGA gain set to <font color=purple> x2, x4, x8 or x16 \n
opamp --> user : HAL_OK

user --> opamp : user add an external capacitor
note right:\n For example, a capacitor can be connected between VOUT and VINM for filtering purpose,\n the gain depends on the cut-off frequency.
opamp --> user : HAL_OK
end


== OPAMP processing ==

user -> opamp : HAL_OPAMP_Start()
note right: OPAMP is operationnal in <font color=purple> GAIN AMPLIFIER </font> mode
opamp --> user

opt optionnal
user -> system : HAL_RCC_OPAMP_DisableClock()
note right: the clock is switched off, \nthe opamp register can no more been accessed,\n OPAMP still running as <font color=purple> GAIN AMPLIFIER EXTERNAL FILTERING
end
== ==
@enduml

Functions called:

User Application Calibration in Parallel for Multi OPAMP in Normal-Power Mode

@startuml

title
  <font color=blue> Use case: calibration in parallel for multi opamp in normal-power mode

end title

' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
opamp -> opamp:
note right: <font color=green> IDLE state
end

== OPAMP calibration ==
user -> opamp : <font color=blue>HAL_OPAMP_SetLinkNextHandle(<font color=purple> hopampX, hopampY )\n \n
note right: circular chained list = [ <font color=purple>hopampX</font>, <font color=purple>hopampY</font> ]

user -> opamp : <font color=blue>HAL_OPAMP_SetLinkNextHandle(<font color=purple> hopampY, hopampZ )\n \n
note right: circular chained list = [ <font color=purple>hopampX</font>, <font color=purple>hopampY</font>, <font color=purple>hopampZ</font> ]

user -> opamp : <font color=blue>HAL_OPAMP_CalibrateParallel( <font color=purple><font color=purple>hopampX , normal-power</font>)
note right: <font color=green> CALIB state
opamp --> user : HAL_OK  or  HAL_INVALID_PARAM
note right: <font color=blue> when HAL_OK is returned, those parameters are set for <font color=purple>each opamp of list_of_hopamp </font> : \n . normal-power trimming for PMOS (high voltage) differential pairs , \n . normal-power trimming for NMOS (low voltage) differential pairs.

== OPAMP configuration set in normal-power mode ==
user -> opamp : HAL_OPAMP_SetConfig() \n \n
note right: power_mode = <font color=blue> normal \nspeed_mode = <font color=blue> normal , high \nconfiguration = <font color=blue> FOLLOWER, STANDALONE, GAIN AMPLIFIER \n \n<font color=blue> default  connections\n<font color=blue> user trimming
opamp --> user : HAL_OK or HAL_INVALID_PARAM
note right: <font color=green> IDLE state

== OPAMP processing with user trimming in normal-power mode ==
user -> opamp : HAL_OPAMP_Start()
note right: <font color=green> ACTIVE state

== ==
@enduml

Functions called:

User Application Calibration for a Single OPAMP in Normal-Power Mode

@startuml

title
  <font color=blue> Use case: calibration  for a single opamp in normal-power mode,
 <font color=blue>  the configuration mode is unchanged.
end title

' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
opamp -> opamp:
note right: <font color=green> IDLE state
end

== OPAMP configuration set in normal-power mode ==
user -> opamp : HAL_OPAMP_SetConfig( <font color=purple>hopampx </font>) \n \n
note right: power_mode = <font color=blue> normal \nspeed_mode = <font color=blue> normal , high \nconfiguration = <font color=blue> FOLLOWER, STANDALONE, GAIN AMPLIFIER \n \n<font color=blue> default connections\n<font color=blue> user trimming
opamp --> user : HAL_OK or HAL_INVALID_PARAM
note right: <font color=green> IDLE state

== OPAMP processing with user trimming in normal-power mode ==
user -> opamp : HAL_OPAMP_Start( <font color=purple>hopampx </font>)
note right: <font color=green> ACTIVE state
user -> opamp : HAL_OPAMP_Stop( <font color=purple>hopampx </font>)
note right: <font color=green> IDLE state

== OPAMP calibration ==
user -> opamp : <font color=blue>HAL_OPAMP_Calibrate( <font color=purple>hopampx, normal-power </font>)
note right: <font color=green> CALIB state
opamp --> user : HAL_OK  or  HAL_INVALID_PARAM
note right: <font color=blue> when HAL_OK is returned, those parameters are set for <font color=purple> hopampx </font>: \n . normal-power trimming for PMOS (high voltage) differential pairs , \n . normal-power trimming for NMOS (low voltage) differential pairs.\n . the configuration mode is unchanged\n\n\n<font color=green> IDLE state


== ==
@enduml

Functions called:

User Application Calibration for a Single OPAMP in Low-Power Mode

@startuml

title
  <font color=blue> Use case: calibration for a single opamp in low-power mode,
 <font color=blue>  the configuration mode is unchanged.
end title

' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
opamp -> opamp:
note right: <font color=green> IDLE state
end


== OPAMP configuration set in low-power mode ==
user -> opamp : HAL_OPAMP_SetConfig( <font color=purple>hopampx </font>) \n \n
note right: power_mode = <font color=blue> low \nspeed_mode = <font color=blue> normal , high \nconfiguration = <font color=blue> FOLLOWER, STANDALONE, GAIN AMPLIFIER \n \n<font color=blue> default connections\n<font color=blue> user trimming
opamp --> user : HAL_OK or HAL_INVALID_PARAM
note right: <font color=green> IDLE state

== OPAMP processing with user trimming in low-power mode ==
user -> opamp : HAL_OPAMP_Start( <font color=purple>hopampx </font>)
note right: <font color=green> ACTIVE state
user -> opamp : HAL_OPAMP_Stop( <font color=purple>hopampx </font>)
note right: <font color=green> IDLE state

== OPAMP calibration processing ==
user -> opamp : <font color=blue>HAL_OPAMP_Calibrate( <font color=purple>hopampx, low-power </font>)
note right: <font color=green> CALIB state
opamp --> user : HAL_OK  or  HAL_INVALID_PARAM
note right: <font color=blue> when HAL_OK is returned, those parameters are set for <font color=purple>hopampx </font>: \n . low-power trimming for PMOS (high voltage) differential pairs , \n . low-power trimming for NMOS (low voltage) differential pairs.\n . the configuration mode is unchanged\n\n <font color=green> IDLE state

== ==
@enduml

Functions called:

User Application Retrieve Factory Offset Trimming in Normal-Power Mode

@startuml

title
  <font color=blue> Use case: retrieve FACTORY offset trimming
 <font color=blue>  in normal-power mode
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end


== OPAMP retrieve factory offset trimming ==

user -> opamp : <font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=red>FACTORY</font>


user -> opamp : \n\n<font color=blue>HAL_OPAMP_GetConfigTrimming( <font color=purple>hopampx, *p_config, normal-power )
note right opamp: to be call before HAL_OPAMP_CalibrateXXX() \nand before HAL_OPAMP_SetConfigTrimming()


note right opamp: <font color=blue> when HAL_OK is returned, p_config is filled with those retrieved parameters: \n - <font color=purple>normal-power factory offset trimming for PMOS (high voltage) differential pairs , \n - <font color=purple>normal-power factory offset trimming for NMOS (low voltage) differential pairs.


user -> opamp : \n\n<font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=red>FACTORY </font>

== ==
@enduml

Functions called:

User Application Retrieve Factory Offset Trimming in Low-Power Mode

@startuml

title
  <font color=blue> Use case: retrieve FACTORY offset trimming
 <font color=blue>  in low-power mode
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end


== OPAMP retrieve factory offset trimming ==

user -> opamp : <font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=red>FACTORY </font>

user -> opamp : \n\n <font color=blue>HAL_OPAMP_GetConfigTrimming( <font color=purple>hopampx, *p_config , low-power)
note right opamp: to be call before HAL_OPAMP_CalibrateXXX() \nand before HAL_OPAMP_SetConfigTrimming()

note right opamp: <font color=blue> when HAL_OK is returned, p_config is filled with those retrieved parameters: \n - <font color=purple>low-power factory offset trimming for PMOS </font>(high voltage) differential pairs , \n - <font color=purple>low-power factory offset trimming for NMOS </font>(low voltage) differential pairs.

user -> opamp : \n\n<font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user :  trimming mode <font color=red>FACTORY </font>

== ==
@enduml

Functions called:

User Application Retrieve User Offset Trimming in Normal-Power Mode

@startuml

title
  <font color=blue> Use case: retrieve USER offset trimming
 <font color=blue>  in normal-power mode
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end

== OPAMP retrieve user offset trimming ==

user -> opamp : <font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=red>FACTORY </font>


user -> opamp : \n\n<font color=green>need to be called at first to compute and set the user offset trimming\n HAL_OPAMP_Calibrate( <font color=purple>hopampx, normal-power </font>)

user -> opamp : \n\n<font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=green> USER


user -> opamp : \n\n<font color=green>then retrieve the user offset trimming<font color=blue>\n HAL_OPAMP_GetConfigTrimming( <font color=purple>hopampx, *p_config, normal-power )

note right opamp: <font color=blue> when HAL_OK is returned, p_config is filled with those retrieved parameters: \n - <font color=purple>normal-power user offset trimming for PMOS </font>(high voltage) differential pairs , \n - <font color=purple>normal-power user offset trimming for NMOS </font>(low voltage) differential pairs.

user -> opamp : <font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=green> USER


== ==
@enduml

Functions called:

User Application Retrieve User Offset Trimming in Low-Power Mode

@startuml

title
  <font color=blue> Use case: retrieve USER offset trimming
 <font color=blue>  in low-power mode
end title


' Fix order of each column
participant "User application" as user
participant "OPAMP driver"     as opamp
participant "System driver"    as system

== OPAMP initialization ==
group initialization
end

== OPAMP retrieve user offset trimming ==

user -> opamp : <font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=red>FACTORY </font>

user -> opamp : \n\n<font color=green>need to be called at first to compute and set the user offset trimming \n HAL_OPAMP_Calibrate( <font color=purple>hopampx, low-power </font>)

user -> opamp : \n\n<font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=green> USER


user -> opamp : \n <font color=green>then retrieve the user offset trimming \n <font color=blue>HAL_OPAMP_GetConfigTrimming( <font color=purple>hopampx,*p_config, low-power)


note right opamp:  <font color=blue> when HAL_OK is returned, p_config is filled with those retrieved parameters: \n - <font color=purple>low-power user offset trimming for PMOS </font>(high voltage) differential pairs , \n - <font color=purple>low-power user offset trimming for NMOS </font>(low voltage) differential pairs.

user -> opamp : <font color=blue>HAL_OPAMP_GetTrimmingMode( <font color=purple>hopampx </font>);
opamp -> user : trimming mode <font color=green> USER

== ==
@enduml

Functions called: