MCUXpresso SDK API Reference Manual  Rev 2.11.0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
LPC_ACOMP: Analog comparator Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the Analog comparator (LPC_ACOMP) module of MCUXpresso SDK devices.

Typical use case

Polling Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/acomp/acomp_basic

Interrupt Configuration

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/acomp/acomp_interrupt

Files

file  fsl_acomp.h
 

Data Structures

struct  acomp_config_t
 The structure for ACOMP basic configuration. More...
 
struct  acomp_ladder_config_t
 The structure for ACOMP voltage ladder. More...
 

Enumerations

enum  acomp_ladder_reference_voltage_t {
  kACOMP_LadderRefVoltagePinVDD = 0U,
  kACOMP_LadderRefVoltagePinVDDCMP = 1U
}
 The ACOMP ladder reference voltage. More...
 
enum  acomp_interrupt_enable_t {
  kACOMP_InterruptsFallingEdgeEnable = 0U,
  kACOMP_InterruptsRisingEdgeEnable = 1U,
  kACOMP_InterruptsBothEdgesEnable = 2U,
  kACOMP_InterruptsDisable = 3U
}
 The ACOMP interrupts enable. More...
 
enum  acomp_hysteresis_selection_t {
  kACOMP_HysteresisNoneSelection = 0U,
  kACOMP_Hysteresis5MVSelection = 1U,
  kACOMP_Hysteresis10MVSelection = 2U,
  kACOMP_Hysteresis20MVSelection = 3U
}
 The ACOMP hysteresis selection. More...
 

Driver version

#define FSL_ACOMP_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))
 ACOMP driver version 2.1.0. More...
 

Initialization

void ACOMP_Init (ACOMP_Type *base, const acomp_config_t *config)
 Initialize the ACOMP module. More...
 
void ACOMP_Deinit (ACOMP_Type *base)
 De-initialize the ACOMP module. More...
 
void ACOMP_GetDefaultConfig (acomp_config_t *config)
 Gets an available pre-defined settings for the ACOMP's configuration. More...
 
void ACOMP_EnableInterrupts (ACOMP_Type *base, acomp_interrupt_enable_t enable)
 Enable ACOMP interrupts. More...
 
static bool ACOMP_GetInterruptsStatusFlags (ACOMP_Type *base)
 Get interrupts status flags. More...
 
static void ACOMP_ClearInterruptsStatusFlags (ACOMP_Type *base)
 Clear the ACOMP interrupts status flags. More...
 
static bool ACOMP_GetOutputStatusFlags (ACOMP_Type *base)
 Get ACOMP output status flags. More...
 
static void ACOMP_SetInputChannel (ACOMP_Type *base, uint32_t postiveInputChannel, uint32_t negativeInputChannel)
 Set the ACOMP postive and negative input channel. More...
 
void ACOMP_SetLadderConfig (ACOMP_Type *base, const acomp_ladder_config_t *config)
 Set the voltage ladder configuration. More...
 

Data Structure Documentation

struct acomp_config_t

Data Fields

bool enableSyncToBusClk
 If true, Comparator output is synchronized to the bus clock for output to other modules. More...
 
acomp_hysteresis_selection_t hysteresisSelection
 Controls the hysteresis of the comparator. More...
 

Field Documentation

bool acomp_config_t::enableSyncToBusClk

If false, Comparator output is used directly.

acomp_hysteresis_selection_t acomp_config_t::hysteresisSelection
struct acomp_ladder_config_t

Data Fields

uint8_t ladderValue
 Voltage ladder value. More...
 
acomp_ladder_reference_voltage_t referenceVoltage
 Selects the reference voltage(Vref) for the voltage ladder. More...
 

Field Documentation

uint8_t acomp_ladder_config_t::ladderValue

00000 = Vss, 00001 = 1*Vref/31, ..., 11111 = Vref.

acomp_ladder_reference_voltage_t acomp_ladder_config_t::referenceVoltage

Macro Definition Documentation

#define FSL_ACOMP_DRIVER_VERSION   (MAKE_VERSION(2, 1, 0))

Enumeration Type Documentation

Enumerator
kACOMP_LadderRefVoltagePinVDD 

Supply from pin VDD.

kACOMP_LadderRefVoltagePinVDDCMP 

Supply from pin VDDCMP.

Enumerator
kACOMP_InterruptsFallingEdgeEnable 

Enable the falling edge interrupts.

kACOMP_InterruptsRisingEdgeEnable 

Enable the rising edge interrupts.

kACOMP_InterruptsBothEdgesEnable 

Enable the both edges interrupts.

kACOMP_InterruptsDisable 

Disable the interrupts.

Enumerator
kACOMP_HysteresisNoneSelection 

None (the output will switch as the voltages cross).

kACOMP_Hysteresis5MVSelection 

5mV.

kACOMP_Hysteresis10MVSelection 

10mV.

kACOMP_Hysteresis20MVSelection 

20mV.

Function Documentation

void ACOMP_Init ( ACOMP_Type *  base,
const acomp_config_t config 
)
Parameters
baseACOMP peripheral base address.
configPointer to "acomp_config_t" structure.
void ACOMP_Deinit ( ACOMP_Type *  base)
Parameters
baseACOMP peripheral base address.
void ACOMP_GetDefaultConfig ( acomp_config_t config)

This function initializes the converter configuration structure with available settings. The default values are:

* config->enableSyncToBusClk = false;
* config->hysteresisSelection = kACOMP_hysteresisNoneSelection;
*

In default configuration, the ACOMP's output would be used directly and switch as the voltages cross.

Parameters
configPointer to the configuration structure.
void ACOMP_EnableInterrupts ( ACOMP_Type *  base,
acomp_interrupt_enable_t  enable 
)
Parameters
baseACOMP peripheral base address.
enableEnable/Disable interrupt feature.
static bool ACOMP_GetInterruptsStatusFlags ( ACOMP_Type *  base)
inlinestatic
Parameters
baseACOMP peripheral base address.
Returns
Reflect the state ACOMP edge-detect status, true or false.
static void ACOMP_ClearInterruptsStatusFlags ( ACOMP_Type *  base)
inlinestatic
Parameters
baseACOMP peripheral base address.
static bool ACOMP_GetOutputStatusFlags ( ACOMP_Type *  base)
inlinestatic
Parameters
baseACOMP peripheral base address.
Returns
Reflect the state of the comparator output, true or false.
static void ACOMP_SetInputChannel ( ACOMP_Type *  base,
uint32_t  postiveInputChannel,
uint32_t  negativeInputChannel 
)
inlinestatic
Parameters
baseACOMP peripheral base address.
postiveInputChannelThe index of postive input channel.
negativeInputChannelThe index of negative input channel.
void ACOMP_SetLadderConfig ( ACOMP_Type *  base,
const acomp_ladder_config_t config 
)
Parameters
baseACOMP peripheral base address.
configThe structure for voltage ladder. If the config is NULL, voltage ladder would be diasbled, otherwise the voltage ladder would be configured and enabled.