HAL OPAMP Functions ¶
Initialization, de-initialization, configuration, calibration functions ¶
- group OPAMP_Exported_Functions_Group1
-
This section provides functions allowing to:
initialize the OPAMP,
de-initialize the OPAMP,
configure the OPAMP,
calibration setting.
Functions
-
hal_status_t
HAL_OPAMP_Init
(
hal_opamp_handle_t
*
hopamp
,
hal_opamp_t
instance
)
¶
-
Initializes the OPAMP according to the specified parameters in the hal_opamp_config_t and initialize the associated handle.
Note
After calling this function the OPAMP jump to HAL_OPAMP_STATE_IDLE, and it is possible to call directly HAL_OPAMP_Start() without calling HAL_OPAMP_SetConfig()
.
The OPAMP default configuration parameters are:
OPAMP is disabled
normal mode operation (i.e.: not in calibration mode)
normal power mode
normal speed mode
standalone configuration
PGA gain x2
GPIO connected to non-inverting input
GPIO connected to inverting input
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
instance – A OPAMP hardware peripheral base address.
- Return values :
-
HAL_OK – OPAMP Instance has been correctly initialized.
HAL_INVALID_PARAM – A parameter is invalid.
-
void
HAL_OPAMP_DeInit
(
hal_opamp_handle_t
*
hopamp
)
¶
-
DeInitialize the OPAMP peripheral.
Note
Stop the OPAMP and restore the state machine to reset state.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
-
hal_status_t
HAL_OPAMP_SetConfig
(
hal_opamp_handle_t
*
hopamp
,
const
hal_opamp_config_t
*
p_config
)
¶
-
Configure the OPAMP peripheral according to the specified parameters in the hal_opamp_config_t.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
p_config – The configuration that contains information for the specified OPAMP.
- Return values :
-
HAL_OK – OPAMP Instance has been correctly configured.
HAL_INVALID_PARAM – If p_config is NULL
-
void
HAL_OPAMP_GetConfig
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_config_t
*
p_config
)
¶
-
Return the configuration parameters of the OPAMP peripheral in the hal_opamp_config_t.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
p_config – The configuration parameters.
-
void
HAL_OPAMP_ResetConfig
(
hal_opamp_handle_t
*
hopamp
)
¶
-
Reset the configuration parameters of the OPAMP peripheral.
Note
Configuration parameters of the OPAMP are reset to:
OPAMP is disabled
normal mode operation (i.e.: not in calibration mode)
normal power mode
normal speed mode
standalone configuration
PGA gain x2
GPIO connected to non-inverting input
GPIO connected to inverting input
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
-
hal_status_t
HAL_OPAMP_Calibrate
(
hal_opamp_handle_t
*
hopamp
,
hal_opamp_power_mode_t
power_mode
)
¶
-
Run the self calibration of one OPAMP according to power mode.
Note
At the end of calibration offset trimming values (PMOS & NMOS) are updated, user trimming is enabled, and the initial configuration mode is restored.
Note
Calibration runs about 10 ms (5 dichotomy steps, repeated for P and N transistors: 10 steps with 1 ms for each step).
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
power_mode – On this series, the only available value is HAL_OPAMP_POWER_MODE_NORMAL
- Return values :
-
HAL_OK – OPAMP Instance calibration has been correctly done.
HAL_INVALID_PARAM – A parameter is invalid.
HAL_BUSY – If the define USE_HAL_CHECK_PROCESS_STATE is set to “1” and the current state doesn’t match HAL_OPAMP_STATE_IDLE.
-
hal_status_t
HAL_OPAMP_SetConfigTrimming
(
const
hal_opamp_handle_t
*
hopamp
,
const
hal_opamp_trimming_offset_pair_t
*
p_config
,
hal_opamp_power_mode_t
power_mode
)
¶
-
Set the OPAMP peripheral offset trimming values according to the specified parameters in the hal_opamp_trimming_config_t, for normal-power or low-power mode.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
p_config – The offset trimming configuration that contains information for the specified OPAMP.
power_mode – Normal-power or low-power mode.
- Return values :
-
HAL_OK – OPAMP Instance offset trimming has been correctly configured.
HAL_INVALID_PARAM – If p_config is NULL
-
void
HAL_OPAMP_GetConfigTrimming
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_trimming_offset_pair_t
*
p_config
,
hal_opamp_power_mode_t
power_mode
)
¶
-
Get the OPAMP peripheral offset trimming values for normal-power or low-power mode.
Note
Careful: to retrieve the factory offset trimming pairs, this function must be called when OPAMP trimming_mode is still set to trimming factory, this means before:
OPAMP calibration process, (call of HAL_OPAMP_Calibrate()),
and before a user trimming has been set, (call of HAL_OPAMP_SetConfigTrimming()), Otherwise, the user trimming values are retrieved.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
p_config – The retrieved offset trimming values that contain information for the specified OPAMP.
power_mode – On this series, the only available value is HAL_OPAMP_POWER_MODE_NORMAL
-
hal_opamp_trimming_mode_t
HAL_OPAMP_GetTrimmingMode
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Get the user trimming mode for OPAMP peripheral.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
HAL_OPAMP_TRIMMING_MODE_FACTORY – If this function has been called before:
OPAMP calibration process, (call of HAL_OPAMP_Calibrate() or HAL_OPAMP_CalibrateParallel()),
and before a user trimming has been set, (call of HAL_OPAMP_SetConfigTrimming()).
HAL_OPAMP_TRIMMING_MODE_USER – After a call to one of the above functions.
Output operation functions ¶
- group OPAMP_Exported_Functions_Group2
-
This section provides functions allowing to:
start the OPAMP,
stop the OPAMP.
Functions
-
hal_status_t
HAL_OPAMP_Start
(
hal_opamp_handle_t
*
hopamp
)
¶
-
Start the OPAMP.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
HAL_OK –
-
hal_status_t
HAL_OPAMP_Stop
(
hal_opamp_handle_t
*
hopamp
)
¶
-
Stop the OPAMP.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
HAL_OK –
Peripheral Control functions ¶
- group OPAMP_Exported_Functions_Group3
-
This section provides functions allowing to set and control the OPAMP main features:
the configuration of input connection,
the Programmable Gain Amplifier gain.
Functions
-
hal_status_t
HAL_OPAMP_SetConfigInputConnection
(
const
hal_opamp_handle_t
*
hopamp
,
const
hal_opamp_config_input_connection_t
*
p_config
)
¶
-
Configure input connection of the OPAMP peripheral according to the specified parameters in the hal_opamp_config_input_connection_t.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
p_config – The configuration that contains input connections for the specified OPAMP.
- Return values :
-
HAL_OK – OPAMP Instance input connections has been correctly configured.
HAL_INVALID_PARAM – If p_config is NULL.
-
void
HAL_OPAMP_GetConfigInputConnection
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_config_input_connection_t
*
p_config
)
¶
-
Get the input connection of the OPAMP peripheral. the specified parameters in the hal_opamp_config_input_connection_t.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
p_config – Structure that contains input connection for the specified OPAMP.
-
hal_status_t
HAL_OPAMP_SetGain
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_pga_gain_t
gain
)
¶
-
Set the PGA gain to be used when the OPAMP is configured in Programmable Gain Amplifier (OPAMP_PGA_MODE).
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
gain – specifies the gain (x2, x4, x8 or x16) in PGA mode
- Return values :
-
HAL_OK – The PGA gain has been correctly set.
HAL_ERROR – If a parameter is invalid.
-
hal_opamp_pga_gain_t
HAL_OPAMP_GetGain
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Get the PGA gain used when the OPAMP is configured in Programmable Gain Amplifier (OPAMP_PGA_MODE).
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
HAL_OPAMP_PGA_GAIN_2 – When PGA gain is x2.
HAL_OPAMP_PGA_GAIN_4 – When PGA gain is x4.
HAL_OPAMP_PGA_GAIN_8 – When PGA gain is x8.
HAL_OPAMP_PGA_GAIN_16 – When PGA gain is x16.
-
hal_status_t
HAL_OPAMP_SetPGAExternalMode
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_pga_external_t
external_mode
)
¶
-
Set OPAMP PGA external connection configuration.
Note
Preliminarily, OPAMP must be set in mode PGA using function HAL_OPAMP_SetConfig().
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure
external_mode – This parameter can be one of the following values:
- Return values :
-
HAL_OK – PGA external connection configuration has been correctly set.
HAL_ERROR – If a parameter is invalid.
-
hal_opamp_pga_external_t
HAL_OPAMP_GetPGAExternalMode
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Get OPAMP PGA external connection configuration.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure
- Return values :
-
value – of type hal_opamp_pga_external_t
-
hal_status_t
HAL_OPAMP_SetConfigModeMuxSecondary
(
hal_opamp_handle_t
*
hopamp
,
hal_opamp_config_mode_t
configuration_mode
)
¶
-
Configure the OPAMP peripheral mode according to the specified parameters in the hal_opamp_config_t, in timer-controlled mode for secondary configuration.
Note
Timer-controlled secondary mode has constraints from timer-controlled primary mode, therefore function HAL_OPAMP_SetConfig() must be called prior to this function.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
configuration_mode – Value of type hal_opamp_config_mode_t
- Return values :
-
HAL_OK – OPAMP Instance has been correctly configured.
HAL_ERROR – Configuration error
-
hal_opamp_config_mode_t
HAL_OPAMP_GetConfigModeMuxSecondary
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Return the configuration parameters of the OPAMP peripheral mode in the hal_opamp_config_t, in timer-controlled mode for secondary configuration.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
value – of type hal_opamp_config_mode_t
-
hal_status_t
HAL_OPAMP_SetConfigInputMuxSecondaryConnection
(
const
hal_opamp_handle_t
*
hopamp
,
const
hal_opamp_config_input_connection_t
*
p_config
)
¶
-
Configure input secondary connection of the OPAMP peripheral according to the specified parameters in the hal_opamp_config_input_connection_t, in timer-controlled mode for secondary configuration.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
p_config – The configuration that contains input secondary connections for the specified OPAMP.
- Return values :
-
HAL_OK – OPAMP Instance input secondary connections has been correctly configured.
HAL_INVALID_PARAM – If p_config is NULL.
-
hal_status_t
HAL_OPAMP_SetPGAGainMuxSecondary
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_pga_gain_t
gain
)
¶
-
Set the PGA secondary gain to be used when the OPAMP is configured in Programmable Gain Amplifier (PGA), in timer-controlled mode for secondary configuration.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
gain – specifies the gain (x2, x4, x8, x16, x-1, x-3 ,x-7 or x-15) in PGA mode
- Return values :
-
HAL_OK – The PGA gain has been correctly set.
HAL_ERROR – If a parameter is invalid.
-
hal_opamp_pga_gain_t
HAL_OPAMP_GetPGAGainMuxSecondary
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Get the PGA gain used when the OPAMP is configured in Programmable Gain Amplifier (PGA), in timer-controlled mode for secondary configuration.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
HAL_OPAMP_PGA_GAIN_2 – When PGA gain is x2.
HAL_OPAMP_PGA_GAIN_4 – When PGA gain is x4.
HAL_OPAMP_PGA_GAIN_8 – When PGA gain is x8.
HAL_OPAMP_PGA_GAIN_16 – When PGA gain is x16.
HAL_OPAMP_PGA_GAIN_2_OR_MINUS_1 – When PGA gain is x2 or x-1.
HAL_OPAMP_PGA_GAIN_4_OR_MINUS_3 – When PGA gain is x4 or x-3.
HAL_OPAMP_PGA_GAIN_8_OR_MINUS_7 – When PGA gain is x8 or x-7.
HAL_OPAMP_PGA_GAIN_16_OR_MINUS_15 – When PGA gain is x16 or x-15.
-
hal_status_t
HAL_OPAMP_SetMuxInputCtrl
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_mux_inputs_ctrl_t
mux_inputs_ctrl
)
¶
-
Set the Timer signal selection for OPAMP input control.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
mux_inputs_ctrl – The configuration that contains input connections for the specified OPAMP.
- Return values :
-
HAL_OK – OPAMP Instance input connections has been correctly configured.
HAL_INVALID_PARAM – If p_config is NULL.
-
hal_opamp_mux_inputs_ctrl_t
HAL_OPAMP_GetMuxInputCtrl
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Get the Timer signal selection for OPAMP input control the specified parameters in the hal_opamp_mux_inputs_ctrl_t.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
value – of type hal_opamp_mux_inputs_ctrl_t
-
hal_status_t
HAL_OPAMP_SetMuxPGAGainCtrl
(
const
hal_opamp_handle_t
*
hopamp
,
hal_opamp_mux_pga_ctrl_tim_t
mux_pga_ctrl
)
¶
-
Set the Timer signal selection for OPAMP PGA gain selection.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
mux_pga_ctrl – The configuration that contains pga mode selection for the specified OPAMP.
- Return values :
-
HAL_OK – OPAMP Instance input connections has been correctly configured.
HAL_INVALID_PARAM – If p_config is NULL.
-
hal_opamp_mux_pga_ctrl_tim_t
HAL_OPAMP_GetMuxPGAGainCtrl
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Get the Timer signal selection for OPAMP input control the specified parameters in the hal_opamp_mux_pga_ctrl_tim_t.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
value – of type hal_opamp_mux_pga_ctrl_tim_t
Peripheral state functions ¶
- group OPAMP_Exported_Functions_Group4
-
This subsection permits to get in run-time the status of the peripheral:
retrieve the HAL OPAMP handle state.
Functions
-
hal_opamp_state_t
HAL_OPAMP_GetState
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Return the OPAMP handle state.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t structure.
- Return values :
-
HAL_OPAMP_STATE_RESET – If OPAMP not yet initialized or is de-initialized.
HAL_OPAMP_STATE_IDLE – If OPAMP is initialized.
HAL_OPAMP_STATE_CALIB – If OPAMP is being calibrated.
HAL_OPAMP_STATE_ACTIVE – If OPAMP is active.
User Data API functions ¶
- group OPAMP_Exported_Functions_Group6
-
This subsection provides functions allowing to:
set a user data pointer (ex: a user context) in a OPAMP handle,
get a user data pointer (ex: a user context) from a OPAMP handle.
Note
A typical usage is to set user data pointer before starting an OPAMP,
then retrieve it when needed.
Functions
-
void
HAL_OPAMP_SetUserData
(
hal_opamp_handle_t
*
hopamp
,
const
void
*
p_user_data
)
¶
-
Store user data pointer into the OPAMP handle.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t.
p_user_data – Pointer to the user data.
-
const
void
*
HAL_OPAMP_GetUserData
(
const
hal_opamp_handle_t
*
hopamp
)
¶
-
Retrieve user data pointer from the OPAMP handle.
- Parameters :
-
hopamp – Pointer to a hal_opamp_handle_t.
- Return values :
-
(void*) – The pointer to the user data, when previously set by HAL_OPAMP_SetUserData().
NULL – Other way.