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 (ie: 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 :
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 (ie: 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 :
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_CalibrateParallel ( hal_opamp_handle_t * hopamp , hal_opamp_power_mode_t power_mode )

Run the self calibration of the opamp chained instances in parallel according to the specified power mode.

Note

Running all calibration in parallel reduce total calibration time.

Note

The head of the chained list of OPAMP handles is hopamp itself, the next element must have been linked previously by calling HAL_OPAMP_SetLinkNextHandle(hopamp_x, hopamp_y).

Note

At the end of calibration, for each opamp, offset trimming values (PMOS & NMOS) are updated, user trimming mode is enabled whenever calibration is successful, 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, this handle contains a linked list of OPAMP handle to be calibrated.

  • power_mode – Low_power or normal_power.

Return values :
  • HAL_OK – OPAMP Chained instances parallel 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_SetLinkNextHandle ( hal_opamp_handle_t * hopamp_x , hal_opamp_handle_t * hopamp_y )

Set hopamp_y handle element inside the circular list of hopamp_x handle.

Note

This function must be called to build a circular chained list of OPAMP handles that is calibrated later in parallel time when calling HAL_OPAMP_CalibrateParallel() . Handles must not be NULL.

Note

To remove a handle element from all chains, call this function with same handles in both params.

Parameters :
  • hopamp_x – Pointer to a hal_opamp_handle_t structure, this is the first linked element.

  • hopamp_y – Pointer to a hal_opamp_handle_t structure, this is the second linked element to be inserted in the circular list of the first element. By the way hopamp_y is removed from other non-singleton list.

Return values :

HAL_OK – OPAMP instances linkage has been correctly done.

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:

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 – Low_power or normal_power.

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 :

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.

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 :
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 :