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

Read Guidance

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.

Driver Overview

 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_load_mode_t {
  kOPAMP_LoadModeDelayLoad = 0U,
  kOPAMP_LoadModeRealTimeLoad = 1U
}
 Load mode definition. More...
 
enum  opamp_power_mode_t {
  kOPAMP_PowerModeLowPower = 0U,
  kOPAMP_PowerModeHighSpeed = 1U
}
 Power mode definition. More...
 
enum  opamp_rotate_number_t {
  kOPAMP_RotateConfigSet0 = 0U,
  kOPAMP_RotateConfigSet0_1,
  kOPAMP_RotateConfigSet0_2,
  kOPAMP_RotateConfigSet0_3
}
 Rotation number definition. More...
 
enum  opamp_work_mode_t {
  kOPAMP_WorkModeBufferMode = 0U,
  kOPAMP_WorkModeInternalGain2X,
  kOPAMP_WorkModeInternalGain4X,
  kOPAMP_WorkModeInternalGain8X,
  kOPAMP_WorkModeInternalGain16X,
  kOPAMP_WorkModeExternalGain = OPAMP_OPAMP_CONFIG_SET0_VNEG_EN_MASK
}
 OPAMP work mode. More...
 
enum  opamp_vneg_t {
  kOPAMP_VNEG0 = 0U,
  kOPAMP_VNEG1 = 1U,
  kOPAMP_VNEG2 = 2U,
  kOPAMP_VNEG3 = 3U
}
 VNEG input selection. More...
 
enum  opamp_vpos_t {
  kOPAMP_VPOS0 = 0U,
  kOPAMP_VPOS1 = 1U,
  kOPAMP_VPOS2 = 2U,
  kOPAMP_VPOS3 = 3U
}
 VPOS input selection. More...
 
enum  opamp_config_set_index_t {
  kOPAMP_ConfigSet0 = 0U,
  kOPAMP_ConfigSet1,
  kOPAMP_ConfigSet2,
  kOPAMP_ConfigSet3
}
 Configuration set index. More...
 

Driver version

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

Initialization and configuration.

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

Configuration

status_t OPAMP_UpdateModuleConfig (OPAMP_Type *base, const opamp_config_t *psConfig)
 Configure the OPAMP module and enable the configuration load. More...
 
void OPAMP_SetOneConfigSet (OPAMP_Type *base, opamp_config_set_index_t eIndex, const opamp_config_set_t *psConfigSet)
 Set the rotation configuration set. More...
 
static void OPAMP_EnableConfigLoad (OPAMP_Type *base)
 Enable the new configuration load. More...
 

Status and flags

static bool OPAMP_GetLoadCompletionFlag (OPAMP_Type *base)
 Get the configuration load completion flag status. More...
 
static void OPAMP_ClearLoadCompletionFlag (OPAMP_Type *base)
 Clear the configuration load completion flag. More...
 
static uint8_t OPAMP_GetCurrentCounterValue (OPAMP_Type *base)
 Get current 4-bit window counter value. More...
 
static opamp_config_set_index_t OPAMP_GetCurrentConfigSet (OPAMP_Type *base)
 Get current working rotation configuration set. More...
 

Data Structure Documentation

struct opamp_config_set_t

Data Fields

opamp_work_mode_t eWorkMode
 Work mode. More...
 
opamp_vneg_t eVNEG
 VNEG pin selection, not used in buffer mode. More...
 
opamp_vpos_t eVPOS
 VPOS pin selection. More...
 
uint8_t u8PreviousConfigSetWindow
 How many clock counts the previous configuration set affects the amplifier, allowed region 0~15. More...
 

Field Documentation

opamp_work_mode_t opamp_config_set_t::eWorkMode
opamp_vneg_t opamp_config_set_t::eVNEG
opamp_vpos_t opamp_config_set_t::eVPOS
uint8_t opamp_config_set_t::u8PreviousConfigSetWindow
struct opamp_config_t

Data Fields

bool bEnableLoadCompletionInterrupt
 Set true to enable load completion interrupt. More...
 
bool bEnableWriteProtection
 Set true to lock configuration registers. More...
 
opamp_load_mode_t eLoadMode
 Configuration load mode. More...
 
opamp_power_mode_t ePowerMode
 Power mode. More...
 
opamp_rotate_number_t eRotateNumber
 How many configuration sets are involved in rotation. More...
 
opamp_config_set_t sConfigSet0
 Rotation configuration set 0. More...
 
opamp_config_set_t sConfigSet1
 Rotation configuration set 1. More...
 
opamp_config_set_t sConfigSet2
 Rotation configuration set 2. More...
 
opamp_config_set_t sConfigSet3
 Rotation configuration set 3. More...
 

Field Documentation

bool opamp_config_t::bEnableLoadCompletionInterrupt
bool opamp_config_t::bEnableWriteProtection
opamp_load_mode_t opamp_config_t::eLoadMode
opamp_power_mode_t opamp_config_t::ePowerMode
opamp_rotate_number_t opamp_config_t::eRotateNumber
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

Enumeration Type Documentation

Enumerator
kOPAMP_LoadModeDelayLoad 

Or named loop load mode.

Loading happens on every loop configuration completion.

kOPAMP_LoadModeRealTimeLoad 

Or named fast load mode.

Loading happens on any configuration completion.

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_RotateConfigSet0 

Only configuration set 0 participates in the rotation configuration mechanism.

kOPAMP_RotateConfigSet0_1 

Configuration sets 0 and 1 participate in the rotation configuration mechanism.

kOPAMP_RotateConfigSet0_2 

Configuration sets 0 to 2 participate in the rotation configuration mechanism.

kOPAMP_RotateConfigSet0_3 

Configuration sets 0 to 3 participate in the rotation configuration mechanism.

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.

Enumerator
kOPAMP_VNEG0 

Select VNEG0.

kOPAMP_VNEG1 

Select VNEG1.

kOPAMP_VNEG2 

Select VNEG2.

kOPAMP_VNEG3 

Select VNEG3.

Enumerator
kOPAMP_VPOS0 

Select VPOS0.

kOPAMP_VPOS1 

Select VPOS1.

kOPAMP_VPOS2 

Select VPOS2.

kOPAMP_VPOS3 

Select VPOS3.

Enumerator
kOPAMP_ConfigSet0 

Configuration set 0.

kOPAMP_ConfigSet1 

Configuration set 1.

kOPAMP_ConfigSet2 

Configuration set 2.

kOPAMP_ConfigSet3 

Configuration set 3.

Function Documentation

void OPAMP_Init ( OPAMP_Type *  base,
const opamp_config_t psConfig 
)

This function enables the OPAMP IP bus clock (optional, controlled by macro FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL), sets the configuration to OPAMP and enables the load.

Parameters
baseOPAMP peripheral base address.
psConfigPointer to configuration structure.
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->eRotateNumber = kOPAMP_RotateConfigSet0;
psConfig->sConfigSet0.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet0.eVNEG = kOPAMP_VNEG0;
psConfig->sConfigSet0.eVPOS = kOPAMP_VPOS0;
psConfig->sConfigSet0.u8PreviousConfigSetWindow = 15;
psConfig->sConfigSet1.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet1.eVNEG = kOPAMP_VNEG0;
psConfig->sConfigSet1.eVPOS = kOPAMP_VPOS0;
psConfig->sConfigSet1.u8PreviousConfigSetWindow = 15;
psConfig->sConfigSet2.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet2.eVNEG = kOPAMP_VNEG0;
psConfig->sConfigSet2.eVPOS = kOPAMP_VPOS0;
psConfig->sConfigSet2.u8PreviousConfigSetWindow = 15;
psConfig->sConfigSet3.eWorkMode = kOPAMP_WorkModeBufferMode;
psConfig->sConfigSet3.eVNEG = kOPAMP_VNEG0;
psConfig->sConfigSet3.eVPOS = kOPAMP_VPOS0;
psConfig->sConfigSet3.u8PreviousConfigSetWindow = 15;
Parameters
psConfigPointer to configuration structure.
void OPAMP_Deinit ( OPAMP_Type *  base)

This function only disables the OPAMP IP bus clock (optional, controlled by the macro FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL).

Parameters
baseOPAMP peripheral base address.
status_t OPAMP_UpdateModuleConfig ( OPAMP_Type *  base,
const opamp_config_t psConfig 
)

This function sets the new configuration, and enables the configuration load. If previous old configuration has not been loaded, this function returns kStatus_Fail. Application could use OPAMP_GetLoadCompletionFlag to check whether the old configuration has been loaded.

After calling this function, the new configuration will be loaed at the time decided by opamp_config_t::eLoadMode.

Parameters
baseOPAMP peripheral base address.
psConfigPointer to the configuration.
Return values
kStatus_SuccessThe configuration is set.
kStatus_FailCould not set configuration because old configuration has not been loaded.
void OPAMP_SetOneConfigSet ( OPAMP_Type *  base,
opamp_config_set_index_t  eIndex,
const opamp_config_set_t psConfigSet 
)

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

Parameters
baseOPAMP peripheral base address.
eIndexIndex of configuration set.
psConfigSetPointer to the configure structure.
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_GetLoadCompletionFlag or the interrupt. When load finished, the configuration load is disabled automatically.

Parameters
baseOPAMP peripheral base address.
static bool OPAMP_GetLoadCompletionFlag ( 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.
static uint8_t OPAMP_GetCurrentCounterValue ( OPAMP_Type *  base)
inlinestatic
Parameters
baseOPAMP peripheral base address.
Returns
Current counter value.
static opamp_config_set_index_t OPAMP_GetCurrentConfigSet ( OPAMP_Type *  base)
inlinestatic
Parameters
baseOPAMP peripheral base address.
Returns
Index of current working configuration set.