MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
OPAMP: Operational Amplifier Driver

Overview

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Modules

 OPAMP Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method.
 
 The Driver Change Log
 The current OPAMP driver version is 2.0.0.
 

Data Structures

struct  opamp_config_set_t
 Configuration set information. More...
 
struct  opamp_config_t
 Configuration structure. More...
 

Enumerations

enum  opamp_config_reg_sel_t {
  kOPAMP_ConfigRegSelCFG0 = 0U,
  kOPAMP_ConfigRegSelCFG1 = 1U,
  kOPAMP_ConfigRegSelCFG2 = 2U,
  kOPAMP_ConfigRegSelCFG3 = 3U,
  kOPAMP_ConfigRegSelA1OrA0 = 0x28U,
  kOPAMP_ConfigRegSelA1OrB0 = 0x30U,
  kOPAMP_ConfigRegSelA1OrC0 = 0x38U,
  kOPAMP_configRegSelB1OrA0 = 0x48U,
  kOPAMP_configRegSelB1OrB0 = 0x50U,
  kOPAMP_configRegSelB1OrC0 = 0x58U,
  kOPAMP_ConfigRegSelC1OrA0 = 0x68U,
  kOPAMP_ConfigRegSelC1OrB0 = 0x70U,
  kOPAMP_ConfigRegSelC1OrC0 = 0x78U
}
 The enumeration lists all options for software controlled opamps and other external signal controlled opamps. More...
 
enum  opamp_load_mode_t {
  kOPAMP_LoadModeDelayLoad = 0U,
  kOPAMP_LoadModeImmediatelyLoad = 1U
}
 The enumeration lists the opamp buffer's loading modes, delay loading and immediately loading modes. More...
 
enum  opamp_power_mode_t {
  kOPAMP_PowerModeLowPower = 0U,
  kOPAMP_PowerModeHighSpeed = 1U
}
 The enumeration lists the power modes of the opamp, including low power and high power modes. More...
 
enum  opamp_positive_channel_t {
  kOPAMP_PosChannel0 = 0U,
  kOPAMP_PosChannel1 = 1U,
  kOPAMP_PosChannel2 = 2U,
  kOPAMP_PosChannel3 = 3U
}
 The enumeration of positive input channel selection. More...
 
enum  opamp_negative_channel_t {
  kOPAMP_NegChannel0 = 0U,
  kOPAMP_NegChannel1 = 1U,
  kOPAMP_NegChannel2 = 2U,
  kOPAMP_NegChannel3 = 3U
}
 The enumeration of negative input channel selection. More...
 
enum  opamp_config_set_index_t {
  kOPAMP_ConfigSet0 = 0U,
  kOPAMP_ConfigSet1,
  kOPAMP_ConfigSet2,
  kOPAMP_ConfigSet3
}
 The enumeration of configuration set index. More...
 
enum  opamp_work_mode_t {
  kOPAMP_WorkModeBufferMode = 0U,
  kOPAMP_WorkModeInternalGain2X = OPAMP_CFG_GAIN_EN_MASK | OPAMP_CFG_GAIN_SEL(0),
  kOPAMP_WorkModeInternalGain4X = OPAMP_CFG_GAIN_EN_MASK | OPAMP_CFG_GAIN_SEL(1),
  kOPAMP_WorkModeInternalGain8X = OPAMP_CFG_GAIN_EN_MASK | OPAMP_CFG_GAIN_SEL(2),
  kOPAMP_WorkModeInternalGain16X = OPAMP_CFG_GAIN_EN_MASK | OPAMP_CFG_GAIN_SEL(3),
  kOPAMP_WorkModeExternalGain = OPAMP_CFG_VNEG_EN_MASK
}
 The enumeration lists the operating modes of the opamp, including buffer mode, internal gain and external gain mode. More...
 

Driver version

#define FSL_OPAMP_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 OPAMP driver version. More...
 

Initialization And De-initialization Interfaces

void OPAMP_Init (OPAMP_Type *base, const opamp_config_t *psConfig)
 Initializes the OPAMP module. More...
 
void OPAMP_GetDefaultConfig (opamp_config_t *psConfig)
 Gets default configuration for OPAMP. More...
 
void OPAMP_Deinit (OPAMP_Type *base)
 De-initializes the OPAMP module. More...
 

Configuration Interfaces

void OPAMP_SetOneConfigSet (OPAMP_Type *base, opamp_config_set_index_t eIndex, const opamp_config_set_t *psConfigSet)
 Sets configuration set. More...
 
void OPAMP_SetConfigSelection (OPAMP_Type *base, opamp_config_reg_sel_t eConfigRegSel)
 Changes configuration register selection. More...
 
static void OPAMP_EnableOPAMP (OPAMP_Type *base, bool bEnable)
 Enables the OPAMP. More...
 
static void OPAMP_EnableConfigLoad (OPAMP_Type *base)
 Enables the new configuration load. More...
 

Disables Write Protection Control Interfaces

static void OPAMP_DisableWriteProtection (OPAMP_Type *base)
 Disables write protection. More...
 

Power Control Interfaces

static void OPAMP_SetPowerMode (OPAMP_Type *base, opamp_power_mode_t ePowerMode)
 Changes the power mode. More...
 

Load Mode Control Interfaces

static void OPAMP_SetLoadMode (OPAMP_Type *base, opamp_load_mode_t eLoadMode)
 Changes the load mode. More...
 

Interrupt Control Interfaces

static void OPAMP_EnableLoadCompletionInterrupt (OPAMP_Type *base)
 Enables load completion interrupt. More...
 
static void OPAMP_DisableLoadCompletionInterrupt (OPAMP_Type *base)
 Disables load completion interrupt. More...
 

Status Flag Interface

static bool OPAMP_CheckLoadCompletionFlag (OPAMP_Type *base)
 Checks the configuration load completion flag status. More...
 
static void OPAMP_ClearLoadCompletionFlag (OPAMP_Type *base)
 Clears the configuration load completion flag. More...
 

Data Structure Documentation

struct opamp_config_set_t

Data Fields

opamp_work_mode_t eWorkMode
 Opamp work mode. More...
 
opamp_negative_channel_t eNegChannel
 Negative channel selection. More...
 
opamp_positive_channel_t ePosChannel
 Positive channel selection. More...
 

Field Documentation

opamp_work_mode_t opamp_config_set_t::eWorkMode
opamp_negative_channel_t opamp_config_set_t::eNegChannel
opamp_positive_channel_t opamp_config_set_t::ePosChannel
struct opamp_config_t

Data Fields

bool bEnableLoadCompletionInterrupt
 Enable load completion interrupt.
 
bool bEnableWriteProtection
 Enable write protection. More...
 
opamp_load_mode_t eLoadMode
 Configuration load mode. More...
 
opamp_power_mode_t ePowerMode
 Configuration Power mode. More...
 
opamp_config_reg_sel_t eConfigRegSel
 Selects configuration register. More...
 
opamp_config_set_t sConfigSet0
 Configuration register set 0. More...
 
opamp_config_set_t sConfigSet1
 Configuration register set 1. More...
 
opamp_config_set_t sConfigSet2
 Configuration register set 2. More...
 
opamp_config_set_t sConfigSet3
 Configuration register set 3. More...
 

Field Documentation

bool opamp_config_t::bEnableWriteProtection
opamp_load_mode_t opamp_config_t::eLoadMode
opamp_power_mode_t opamp_config_t::ePowerMode
opamp_config_reg_sel_t opamp_config_t::eConfigRegSel
opamp_config_set_t opamp_config_t::sConfigSet0
opamp_config_set_t opamp_config_t::sConfigSet1
opamp_config_set_t opamp_config_t::sConfigSet2
opamp_config_set_t opamp_config_t::sConfigSet3

Macro Definition Documentation

#define FSL_OPAMP_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Enumeration Type Documentation

Enumerator
kOPAMP_ConfigRegSelCFG0 

Software work register select CFG0 (internal signal).

kOPAMP_ConfigRegSelCFG1 

Software work register select CFG1 (internal signal).

kOPAMP_ConfigRegSelCFG2 

Software work register select CFG2 (internal signal).

kOPAMP_ConfigRegSelCFG3 

Software work register select CFG3 (internal signal).

kOPAMP_ConfigRegSelA1OrA0 

External signal cfg_sel_a1 or cfg_sel_a0 selects configuartion register.

kOPAMP_ConfigRegSelA1OrB0 

External signal cfg_sel_a1 or cfg_sel_b0 selects configuartion register.

kOPAMP_ConfigRegSelA1OrC0 

External signal cfg_sel_a1 or cfg_sel_c0 selects configuartion register.

kOPAMP_configRegSelB1OrA0 

External signal cfg_sel_b1 or cfg_sel_a0 selects configuartion register.

kOPAMP_configRegSelB1OrB0 

External signal cfg_sel_b1 or cfg_sel_b0 selects configuartion register.

kOPAMP_configRegSelB1OrC0 

External signal cfg_sel_b1 or cfg_sel_c0 selects configuartion register.

kOPAMP_ConfigRegSelC1OrA0 

External signal cfg_sel_c1 or cfg_sel_a0 selects configuartion register.

kOPAMP_ConfigRegSelC1OrB0 

External signal cfg_sel_c1 or cfg_sel_b0 selects configuartion register.

kOPAMP_ConfigRegSelC1OrC0 

External signal cfg_sel_c1 or cfg_sel_c0 selects configuartion register.

Enumerator
kOPAMP_LoadModeDelayLoad 

The buffer registers are loaded when the next configuration is complete, if CTRL[LDOK] is set.

kOPAMP_LoadModeImmediatelyLoad 

The buffer register shall be loaded immediately after CTRL[LDOK] is set.

Enumerator
kOPAMP_PowerModeLowPower 

Lower current consumption with slower slew rate and narrower unity gain bandwidth performance.

kOPAMP_PowerModeHighSpeed 

Higher current consumption with higher slew rate and wider unity gain bandwidth performance.

Enumerator
kOPAMP_PosChannel0 

Positive channel 0.

kOPAMP_PosChannel1 

Positive channel 1.

kOPAMP_PosChannel2 

Positive channel 2.

kOPAMP_PosChannel3 

Positive channel 3.

Enumerator
kOPAMP_NegChannel0 

Negative channel 0.

kOPAMP_NegChannel1 

Negative channel 1.

kOPAMP_NegChannel2 

Negative channel 2.

kOPAMP_NegChannel3 

Negative channel 3.

Enumerator
kOPAMP_ConfigSet0 

Configuration set 0.

kOPAMP_ConfigSet1 

Configuration set 1.

kOPAMP_ConfigSet2 

Configuration set 2.

kOPAMP_ConfigSet3 

Configuration set 3.

Enumerator
kOPAMP_WorkModeBufferMode 

Buffer mode.

kOPAMP_WorkModeInternalGain2X 

Internal gain 2X mode.

kOPAMP_WorkModeInternalGain4X 

Internal gain 4X mode.

kOPAMP_WorkModeInternalGain8X 

Internal gain 8X mode.

kOPAMP_WorkModeInternalGain16X 

Internal gain 16X mode.

kOPAMP_WorkModeExternalGain 

External gain mode.

Function Documentation

void OPAMP_Init ( OPAMP_Type *  base,
const opamp_config_t psConfig 
)

This function does initialization when using OPAMP module. The operations are:

  • Enable the clock for OPAMP.
  • Enable the write protection.
  • Enable the load completion interrupt.
  • Set configuration register for OPAMP.
  • Set Positive channel and Negative channel.
  • Set the power mode.
  • Set the gain value.
  • Set the load mode.
  • Enable the OPAMP.
Parameters
baseOPAMP peripheral base address.
psConfigPointer to configuration structure.See opamp_config_t.
void OPAMP_GetDefaultConfig ( opamp_config_t psConfig)

The default value:

psConfig->bEnableLoadCompletionInterrupt = false;
psConfig->bEnableWriteProtection = false;
psConfig->eLoadMode = kOPAMP_LoadModeDelayLoad;
psConfig->ePowerMode = kOPAMP_PowerModeLowPower;
psConfig->eConfigRegSel = kOPAMP_ConfigRegSelCFG0;
psConfig->sConfigSet0.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet0.eNegChannel = kOPAMP_NegChannel0;
psConfig->sConfigSet0.ePosChannel = kOPAMP_PosChannel0;
psConfig->sConfigSet1.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet1.eNegChannel = kOPAMP_NegChannel0;
psConfig->sConfigSet1.ePosChannel = kOPAMP_PosChannel0;
psConfig->sConfigSet2.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet2.eNegChannel = kOPAMP_NegChannel0;
psConfig->sConfigSet2.ePosChannel = kOPAMP_PosChannel0;
psConfig->sConfigSet3.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet3.eNegChannel = kOPAMP_NegChannel0;
psConfig->sConfigSet3.ePosChannel = kOPAMP_PosChannel0;
Parameters
psConfigPointer to configuration structure.
void OPAMP_Deinit ( OPAMP_Type *  base)

This function does de-initialization when using OPAMP module. The operations are:

  • Disable the OPAMP.
  • Disable the clock for OPAMP.
Parameters
baseOPAMP peripheral base address.
void OPAMP_SetOneConfigSet ( OPAMP_Type *  base,
opamp_config_set_index_t  eIndex,
const opamp_config_set_t psConfigSet 
)

This function only sets the configuration set, application should call OPAMP_EnableConfigLoad to enable the load after setting all desired configuration sets.

Parameters
baseOPAMP peripheral base address.
eIndexIndex of configuration set,please see opamp_config_set_index_t for details.
psConfigSetPointer to the configure structure,please see opamp_config_set_t for details.
void OPAMP_SetConfigSelection ( OPAMP_Type *  base,
opamp_config_reg_sel_t  eConfigRegSel 
)

This function can configure the working registers of the software and external signal. When the configuration set is updated using OPAMP_SetOneConfigSet and the external signal is not used, the software working register should also select the corresponding software working register according to the update of the configuration set.

Parameters
baseOPAMP peripheral base address.
eConfigRegSelconfiguration register selection, please see opamp_config_reg_sel_t for details.
static void OPAMP_EnableOPAMP ( OPAMP_Type *  base,
bool  bEnable 
)
inlinestatic
Note
Please use function OPAMP_EnableOPAMP to re-enable the OPAMP if it is disabled. Then load it with function OPAMP_EnableConfigLoad.
Parameters
baseOPAMP peripheral base address.
bEnableEnables/disables the module.
static void OPAMP_EnableConfigLoad ( OPAMP_Type *  base)
inlinestatic

After configuration load enabled, the new set configuration will be loaded at the time determined by load mode. Application could monitor the load completion by OPAMP_CheckLoadCompletionFlag or the interrupt. When the load finishes, the configuration load shall be disabled automatically.

Parameters
baseOPAMP peripheral base address.
static void OPAMP_DisableWriteProtection ( OPAMP_Type *  base)
inlinestatic

Write 10b to this field to disable the write protection.

Parameters
baseOPAMP peripheral base address.
static void OPAMP_SetPowerMode ( OPAMP_Type *  base,
opamp_power_mode_t  ePowerMode 
)
inlinestatic
Parameters
baseOPAMP peripheral base address.
ePowerModePower mode, please see opamp_power_mode_t for details.
static void OPAMP_SetLoadMode ( OPAMP_Type *  base,
opamp_load_mode_t  eLoadMode 
)
inlinestatic
Parameters
baseOPAMP peripheral base address.
eLoadModeload mode, please see opamp_load_mode_t for details.
static void OPAMP_EnableLoadCompletionInterrupt ( OPAMP_Type *  base)
inlinestatic
Parameters
baseOPAMP peripheral base address.
static void OPAMP_DisableLoadCompletionInterrupt ( OPAMP_Type *  base)
inlinestatic
Parameters
baseOPAMP peripheral base address.
static bool OPAMP_CheckLoadCompletionFlag ( OPAMP_Type *  base)
inlinestatic
Parameters
baseOPAMP peripheral base address.
Returns
Return true if the flag is set, otherwise return false.
static void OPAMP_ClearLoadCompletionFlag ( OPAMP_Type *  base)
inlinestatic
Parameters
baseOPAMP peripheral base address.