L4 HAL Drivers

Embed: (wiki syntax)

« Back to documentation index

stm32l4xx_hal_opamp.c File Reference

stm32l4xx_hal_opamp.c File Reference

OPAMP HAL module driver. This file provides firmware functions to manage the following functionalities of the operational amplifier(s) peripheral: + OPAMP configuration + OPAMP calibration Thanks to + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions + Peripheral State functions. More...

Go to the source code of this file.

Functions

HAL_StatusTypeDef HAL_OPAMP_Init (OPAMP_HandleTypeDef *hopamp)
 Initializes the OPAMP according to the specified parameters in the OPAMP_InitTypeDef and initialize the associated handle.
HAL_StatusTypeDef HAL_OPAMP_DeInit (OPAMP_HandleTypeDef *hopamp)
 DeInitialize the OPAMP peripheral.
__weak void HAL_OPAMP_MspInit (OPAMP_HandleTypeDef *hopamp)
 Initialize the OPAMP MSP.
__weak void HAL_OPAMP_MspDeInit (OPAMP_HandleTypeDef *hopamp)
 DeInitialize OPAMP MSP.
HAL_StatusTypeDef HAL_OPAMP_Start (OPAMP_HandleTypeDef *hopamp)
 Start the OPAMP.
HAL_StatusTypeDef HAL_OPAMP_Stop (OPAMP_HandleTypeDef *hopamp)
 Stop the OPAMP.
HAL_StatusTypeDef HAL_OPAMP_SelfCalibrate (OPAMP_HandleTypeDef *hopamp)
 Run the self calibration of one OPAMP.
HAL_StatusTypeDef HAL_OPAMP_Lock (OPAMP_HandleTypeDef *hopamp)
 Lock the selected OPAMP configuration.
HAL_OPAMP_TrimmingValueTypeDef HAL_OPAMP_GetTrimOffset (OPAMP_HandleTypeDef *hopamp, uint32_t trimmingoffset)
 Return the OPAMP factory trimming value.
HAL_OPAMP_StateTypeDef HAL_OPAMP_GetState (OPAMP_HandleTypeDef *hopamp)
 Return the OPAMP handle state.

Detailed Description

OPAMP HAL module driver. This file provides firmware functions to manage the following functionalities of the operational amplifier(s) peripheral: + OPAMP configuration + OPAMP calibration Thanks to + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions + Peripheral State functions.

Author:
MCD Application Team
Version:
V1.1.0
Date:
16-September-2015
================================================================================
          ##### OPAMP Peripheral Features #####
================================================================================
           
  [..] The device integrates 2 operational amplifiers OPAMP1 & OPAMP2
       
       (#) The OPAMP(s) provide(s) several exclusive running modes.
       (++) Standalone mode
       (++) Programmable Gain Amplifier (PGA) mode (Resistor feedback output)
       (++) Follower mode

       (#) All OPAMP (same for all OPAMPs) can operate in
       (++) Either Low range (VDDA < 2.4V) power supply
       (++) Or High range (VDDA > 2.4V) power supply

       (#) Each OPAMP(s) can be configured in normal and low power mode.

       (#) The OPAMP(s) provide(s) calibration capabilities.  
       (++) Calibration aims at correcting some offset for running mode.
       (++) The OPAMP uses either factory calibration settings OR user defined 
           calibration (trimming) settings (i.e. trimming mode).
       (++) The user defined settings can be figured out using self calibration 
           handled by HAL_OPAMP_SelfCalibrate, HAL_OPAMPEx_SelfCalibrateAll
       (++) HAL_OPAMP_SelfCalibrate:
       (+++) Runs automatically the calibration.
       (+++) Enables the user trimming mode
       (+++) Updates the init structure with trimming values with fresh calibration 
            results. 
            The user may store the calibration results for larger 
            (ex monitoring the trimming as a function of temperature 
            for instance)
       (+++) HAL_OPAMPEx_SelfCalibrateAll
            runs calibration of all OPAMPs in parallel to save search time.
                    
       (#) Running mode: Standalone mode 
       (++) Gain is set externally (gain depends on external loads).
       (++) Follower mode also possible externally by connecting the inverting input to
           the output.
       
       (#) Running mode: Follower mode
       (++) No Inverting Input is connected.
       
       (#) Running mode: Programmable Gain Amplifier (PGA) mode 
           (Resistor feedback output)
       (++) The OPAMP(s) output(s) can be internally connected to resistor feedback
           output.
       (++) OPAMP gain is either 2, 4, 8 or 16.
        
       (#) The OPAMPs inverting input can be 
           selected among the list shown by table below.
       
       (#) The OPAMPs non inverting input can be 
           selected among the list shown by table below.
       
   [..] Table 1.  OPAMPs inverting/non-inverting inputs for the STM32L4 devices:
     
       (+) +------------------------------------------------------------------------|     
       (+) |                 |         | OPAMP1               | OPAMP2              |
       (+) |-----------------|---------|----------------------|---------------------|
       (+) | Inverting Input | VM_SEL  |                      |                     |
       (+) |                 |         |  IO0-> PA1           | IO0-> PA7           |
       (+) |                 |         |  LOW LEAKAGE IO (2)  | LOW LEAKAGE IO (2)  |
       (+) |                 |         |  Not connected       | Not connected       |
       (+) | (1)             |         |    PGA mode only     |   PGA mode only     |
       (+) |-----------------|---------|----------------------|---------------------|
       (+) |  Non Inverting  | VP_SEL  |                      |                     |
       (+) |                 |         |  IO0-> PA0 (GPIO)    | IO0-> PA6  (GPIO)   |
       (+) |    Input        |         |  DAC1_OUT1 internal  | DAC1_OUT2 internal  |
       (+) +------------------------------------------------------------------------|
       [..] (1): NA in follower mode.
       [..](2): Available on some package only (ex. BGA132).
           
   [..] Table 2.  OPAMPs outputs for the STM32L4 devices:

       (+) +-------------------------------------------------------------------------     
       (+) |                 |        | OPAMP1                | OPAMP2              |
       (+) |-----------------|--------|-----------------------|---------------------|
       (+) | Output          |  VOUT  |  PA3                  |  PB0                |
       (+) |                 |        |  & (2) ADC12_IN if    | & (2) ADC12_IN if   |
       (+) |                 |        |  connected internally | connected internally|
       (+) |-----------------|--------|-----------------------|---------------------|
    [..] (2): ADC1 or ADC2 shall select IN15.
      
            ##### How to use this driver #####
================================================================================
  [..] 

    *** Power supply range ***
    ============================================
    [..] To run in low power mode:

      (#) Configure the OPAMP using HAL_OPAMP_Init() function:
      (++) Select OPAMP_POWERSUPPLY_LOW (VDDA lower than 2.4V)
      (++) Otherwise select OPAMP_POWERSUPPLY_HIGH (VDDA higher than 2.4V)

    *** Low / normal power mode ***
    ============================================
    [..] To run in low power mode:

      (#) Configure the OPAMP using HAL_OPAMP_Init() function:
      (++) Select OPAMP_POWERMODE_LOWPOWER
      (++) Otherwise select OPAMP_POWERMODE_NORMAL

    *** Calibration ***
    ============================================
    [..] To run the OPAMP calibration self calibration:

      (#) Start calibration using HAL_OPAMP_SelfCalibrate. 
           Store the calibration results.

    *** Running mode ***
    ============================================
      
    [..] To use the OPAMP, perform the following steps:
            
      (#) Fill in the HAL_OPAMP_MspInit() to
      (++) Enable the OPAMP Peripheral clock using macro __HAL_RCC_OPAMP_CLK_ENABLE()
      (++) Configure the OPAMP input AND output in analog mode using 
           HAL_GPIO_Init() to map the OPAMP output to the GPIO pin.
  
      (#) Configure the OPAMP using HAL_OPAMP_Init() function:
      (++) Select the mode
      (++) Select the inverting input
      (++) Select the non-inverting input 
      (++) If PGA mode is enabled, Select if inverting input is connected.
      (++) Select either factory or user defined trimming mode.
      (++) If the user-defined trimming mode is enabled, select PMOS & NMOS trimming values
          (typically values set by HAL_OPAMP_SelfCalibrate function).
      
      (#) Enable the OPAMP using HAL_OPAMP_Start() function.
           
      (#) Disable the OPAMP using HAL_OPAMP_Stop() function.
      
      (#) Lock the OPAMP in running mode using HAL_OPAMP_Lock() function.
          Caution: On STM32L4, HAL OPAMP lock is software lock only (not 
          hardware lock as on some other STM32 devices)

      (#) If needed, unlock the OPAMP using HAL_OPAMPEx_Unlock() function.

    *** Running mode: change of configuration while OPAMP ON  ***
    ============================================
    [..] To Re-configure OPAMP when OPAMP is ON (change on the fly)
      (#) If needed, fill in the HAL_OPAMP_MspInit()
      (++) This is the case for instance if you wish to use new OPAMP I/O

      (#) Configure the OPAMP using HAL_OPAMP_Init() function:
      (++) As in configure case, select first the parameters you wish to modify.
      
      (#) Change from low power mode to normal power mode (& vice versa) requires  
          first HAL_OPAMP_DeInit() (force OPAMP OFF) and then HAL_OPAMP_Init(). 
          In other words, of OPAMP is ON, HAL_OPAMP_Init can NOT change power mode
          alone.

  
Attention:

© COPYRIGHT(c) 2015 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file stm32l4xx_hal_opamp.c.