The MCUXpresso SDK provides a driver for the Analog Converter (ACOMP) module of MCUXpreeso SDK devices.
The ACOMP driver can be divided into 4 function groups.
ACOMP Control Interfaces
The functions in this group can be used to control the ACOMP module. User can invoke ACOMP_GetDefaultConfig() function to configure the default setting, then invoking ACOMP_Init() to initialize the module. All ACOMP feature(except software reset comparators and clock divider) can be enabled by invoking ACOMP_Init() function.
ACOMP Result Interface
There is only one function in this function groups, it is ACOMP_GetResult(). User can get the result of comparator by invoking this function.
ACOMP Interrupt Control Interfaces
The functions in this group can be used to enable/disable interrupts.
ACOMP Status Flag Interfaces
The ACOMP_GetStatusFlags() function in this group can return all status flags. The ACOMP_ClearStatusFlags() can be used to clear status flags, but please note that no all status flags can be cleared by software.
|
#define | FSL_ACOMP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
| ACOMP driver version. More...
|
|
#define | ACOMP_REG_ADDR(startAddr, id) ((uint32_t *)((volatile uint32_t *)(startAddr) + (uint32_t)(id))) |
| The macro to get the address based on start address and acomp id.
|
|
#define | ACOMP_GET_REG_VAL(startAddr, id) (*ACOMP_REG_ADDR((startAddr), (id))) |
| The macro to get register value based on start address and acomp id.
|
|
#define | ACOMP_SET_REG_BIT(startAddr, id, val) (ACOMP_GET_REG_VAL((startAddr), (id)) |= (val)) |
| Sets register's bit field.
|
|
#define | ACOMP_CLEAR_REG_BIT(startAddr, id, val) (ACOMP_GET_REG_VAL((startAddr), (id)) &= ~(val)) |
| Clears register's bit field.
|
|
|
enum | _acomp_interrupt_enable {
kACOMP_Out0InterruptEnable = ACOMP_IMR0_OUT_INT_MASK_MASK,
kACOMP_OutA0InterruptEnable = ACOMP_IMR0_OUTA_INT_MASK_MASK,
kACOMP_Out1InterruptEnable = ACOMP_IMR1_OUT_INT_MASK_MASK << 2U,
kACOMP_OutA1InterruptEnable = ACOMP_IMR1_OUTA_INT_MASK_MASK << 2U
} |
| The enumeration of interrupts, including ACOMP0 synchrnized output interrupt, ACOMP0 asynchrnized output interrupt, ACOMP1 synchrnized output interrupt, and ACOMP1 asynchrnized output interrupt. More...
|
|
enum | _acomp_status_flags {
kACOMP_Acomp0ActiveFlag = 1UL << 0UL,
kACOMP_Acomp0OutInterruptFlag = 1UL << 1UL,
kACOMP_Acomp0OutAInterruptFlag = 1UL << 2UL,
kACOMP_Acomp0RawOutInterruptFlag = 1UL << 3UL,
kACOMP_Acomp0RawOutAInterruptFlag = 1UL << 4UL,
kACOMP_Acomp1ActiveFlag = 1UL << 5UL,
kACOMP_Acomp1OutInterruptFlag = 1UL << 6UL,
kACOMP_Acomp1OutAInterruptFlag = 1UL << 7UL,
kACOMP_Acomp1RawOutInterruptFlag = 1UL << 8UL,
kACOMP_Acomp1RawOutAInterruptFlag = 1UL << 9U
} |
| The enumeration of status flags, including ACOMP0 active staus flag, ACOMP1 active status flag, and so on. More...
|
|
enum | acomp_result_logic_status_t {
kACOMP_ResultLogicLow = 0U,
kACOMP_ResultLogicHigh = 1U
} |
| ACOMP result logical status Type definition. More...
|
|
enum | acomp_comparator_id_t {
kACOMP_Acomp0,
kACOMP_Acomp1
} |
| ACOMP comparator id. More...
|
|
enum | acomp_warm_up_time_t {
kACOMP_WarmUpTime1us = 0U,
kACOMP_WarmUpTime2us,
kACOMP_WarmUpTime4us,
kACOMP_WarmUpTime8us
} |
| The enumeration of wave up time. More...
|
|
enum | acomp_response_mode_t {
kACOMP_SlowResponseMode = 0U,
kACOMP_MediumResponseMode,
kACOMP_FastResponseMode
} |
| The enumeration of response mode. More...
|
|
enum | acomp_interrupt_trigger_type_t {
kACOMP_LowLevelTrig = 0U,
kACOMP_HighLevelTrig = 1U,
kACOMP_FallingEdgeTrig = 2U,
kACOMP_RisingEdgeTrig = 3U
} |
| ACOMP interrupt trigger type definition. More...
|
|
enum | acomp_edge_pulse_trig_source_t {
kACOMP_EdgePulseDis = 0U,
kACOMP_EdgePulseRising,
kACOMP_EdgePulseFalling,
kACOMP_EdgePulseBothEdge
} |
| ACOMP edge pule trigger source type definition. More...
|
|
enum | acomp_pin_out_type_t {
kACOMP_PinOutSyn = 0U,
kACOMP_PinOutAsyn = 1U,
kACOMP_PinOutSynInverted = 2U,
kACOMP_PinOutAsynInverted = 3U,
kACOMP_PinOutDisable = 4U
} |
| ACOMP synchronous/asynchronous output type to pin. More...
|
|
enum | acomp_positive_channel_t {
kACOMP_PosChGPIO42,
kACOMP_PosChGPIO43,
kACOMP_PosChGPIO44,
kACOMP_PosChGPIO45,
kACOMP_PosChGPIO46,
kACOMP_PosChGPIO47,
kACOMP_PosChGPIO48,
kACOMP_PosChGPIO49,
kACOMP_PosChDACA,
kACOMP_PosChDACB
} |
| ACOMP positive channel enumeration. More...
|
|
enum | acomp_negative_channel_t {
kACOMP_NegChGPIO42,
kACOMP_NegChGPIO43,
kACOMP_NegChGPIO44,
kACOMP_NegChGPIO45,
kACOMP_NegChGPIO46,
kACOMP_NegChGPIO47,
kACOMP_NegChGPIO48,
kACOMP_NegChGPIO49,
kACOMP_NegChDACA,
kACOMP_NegChDACB,
kACOMP_NegChVREF1P2,
kACOMP_NegChAVSS,
kACOMP_NegChVIO_0P25,
kACOMP_NegChVIO_0P50,
kACOMP_NegChVIO_0P75,
kACOMP_NegChVIO_1P00
} |
| ACOMP negative channel enumeration. More...
|
|
enum | acomp_input_hysteresis_t {
kACOMP_Hyster0MV,
kACOMP_Hyster10MV,
kACOMP_Hyster20MV,
kACOMP_Hyster30MV,
kACOMP_Hyster40MV,
kACOMP_Hyster50MV,
kACOMP_Hyster60MV,
kACOMP_Hyster70MV
} |
| ACOMP hysteresis level enumeration. More...
|
|
|
void | ACOMP_Init (ACOMP_Type *base, const acomp_config_t *config) |
| Initializes the module, including warm up time, response mode, inactive value and so on. More...
|
|
void | ACOMP_GetDefaultConfig (acomp_config_t *config) |
| Gets the default configuration of ACOMP module. More...
|
|
void | ACOMP_Deinit (ACOMP_Type *base) |
| De-initializes the module. More...
|
|
void | ACOMP_SetInputConfig (ACOMP_Type *base, acomp_comparator_id_t id, const acomp_positive_input_config_t *posInput, const acomp_negative_input_config_t *negInput) |
| Configures selected comparator's inputs, inclduing input channel and hysteresis level. More...
|
|
static void | ACOMP_DoSoftwareReset (ACOMP_Type *base, acomp_comparator_id_t id) |
| Does software reset to the selected ACOMP module. More...
|
|
static void | ACOMP_Enable (ACOMP_Type *base, acomp_comparator_id_t id, bool enable) |
| Enables/Disables ACOMP module. More...
|
|
static void | ACOMP_ResetClockDivider (ACOMP_Type *base) |
| Resets clock divider. More...
|
|
struct acomp_positive_input_config_t |
struct acomp_negative_input_config_t |
bool acomp_config_t::enable |
- true Enable the selected ACOMP.
- false Disable the selected ACOMP.
Enumerator |
---|
kACOMP_Out0InterruptEnable |
ACOMP0 synchrnized output interrupt enable.
|
kACOMP_OutA0InterruptEnable |
ACOMP0 asynchrnized output interrupt enable.
|
kACOMP_Out1InterruptEnable |
ACOMP1 synchrnized output interrupt enable.
|
kACOMP_OutA1InterruptEnable |
ACOMP1 asynchrnized output interrupt enable.
|
Enumerator |
---|
kACOMP_Acomp0ActiveFlag |
ACOMP0 active status flag, if this flag is set it means the ACOMP0 is active.
|
kACOMP_Acomp0OutInterruptFlag |
ACOMP0 Synchronized output interrupt flags, this flag is set when ACOMP0 synchronized output changes from 0 to 1 and the corresponding interrupt is enabled.
|
kACOMP_Acomp0OutAInterruptFlag |
ACOMP0 Asynchronized output interrupt flags, this flag is set when ACOMP0 asynchronized output changes from 0 to 1 and the corresponding interrupt is enabled.
|
kACOMP_Acomp0RawOutInterruptFlag |
ACOMP0 raw synchroized output interrrupt flags.
|
kACOMP_Acomp0RawOutAInterruptFlag |
ACOMP0 raw asynchroized output interrupt flags.
|
kACOMP_Acomp1ActiveFlag |
ACOMP1 active status flag, if this flag is set it means the ACOMP0 is active.
|
kACOMP_Acomp1OutInterruptFlag |
ACOMP1 Synchronized output interrupt flags, this flag is set when ACOMP1 synchronized output changes from 0 to 1 and the corresponding interrupt is enabled.
|
kACOMP_Acomp1OutAInterruptFlag |
ACOMP1 Asynchronized output interrupt flags, this flag is set when ACOMP1 asynchronized output changes from 0 to 1 and the corresponding interrupt is enabled.
|
kACOMP_Acomp1RawOutInterruptFlag |
ACOMP1 raw synchroized output interrrupt flags.
|
kACOMP_Acomp1RawOutAInterruptFlag |
ACOMP1 raw asynchroized output interrupt flags.
|
Enumerator |
---|
kACOMP_ResultLogicLow |
The comparsion result is high logic.
|
kACOMP_ResultLogicHigh |
The comparsion result is low logic.
|
Enumerator |
---|
kACOMP_Acomp0 |
Index for ACOMP0.
|
kACOMP_Acomp1 |
Index for ACOMP1.
|
Enumerator |
---|
kACOMP_WarmUpTime1us |
Set wave-up time as 1us.
|
kACOMP_WarmUpTime2us |
Set wave-up time as 2us.
|
kACOMP_WarmUpTime4us |
Set wave-up time as 4us.
|
kACOMP_WarmUpTime8us |
Set wave-up time as 8us.
|
The response mode will affect the delay from input to output.
Enumerator |
---|
kACOMP_SlowResponseMode |
Slow response mode also called power mode 1.
|
kACOMP_MediumResponseMode |
Medium response mode also called power mode 2.
|
kACOMP_FastResponseMode |
Fast response mode also called power mode 3.
|
Enumerator |
---|
kACOMP_LowLevelTrig |
Low level trigger interrupt.
|
kACOMP_HighLevelTrig |
High level trigger interrupt.
|
kACOMP_FallingEdgeTrig |
Falling edge trigger interrupt.
|
kACOMP_RisingEdgeTrig |
Rising edge trigger interrupt.
|
Enumerator |
---|
kACOMP_EdgePulseDis |
edge pulse function is disable
|
kACOMP_EdgePulseRising |
Rising edge can trigger edge pulse.
|
kACOMP_EdgePulseFalling |
Falling edge can trigger edge pulse.
|
kACOMP_EdgePulseBothEdge |
Both edge can trigger edge pulse.
|
Enumerator |
---|
kACOMP_PinOutSyn |
Enable ACOMP synchronous pin output.
|
kACOMP_PinOutAsyn |
Enable ACOMP asynchronous pin output.
|
kACOMP_PinOutSynInverted |
Enable ACOMP inverted synchronous pin output.
|
kACOMP_PinOutAsynInverted |
Enable ACOMP inverted asynchronous pin output.
|
kACOMP_PinOutDisable |
Diable ACOMP pin output.
|
Enumerator |
---|
kACOMP_PosChGPIO42 |
Gpio42 selection.
|
kACOMP_PosChGPIO43 |
Gpio43 selection.
|
kACOMP_PosChGPIO44 |
Gpio44 selection.
|
kACOMP_PosChGPIO45 |
Gpio45 selection.
|
kACOMP_PosChGPIO46 |
Gpio46 selection.
|
kACOMP_PosChGPIO47 |
Gpio47 selection.
|
kACOMP_PosChGPIO48 |
Gpio48 selection.
|
kACOMP_PosChGPIO49 |
Gpio49 selection.
|
kACOMP_PosChDACA |
DACA selection.
|
kACOMP_PosChDACB |
DACB selection.
|
Enumerator |
---|
kACOMP_NegChGPIO42 |
Gpio42 selection.
|
kACOMP_NegChGPIO43 |
Gpio43 selection.
|
kACOMP_NegChGPIO44 |
Gpio44 selection.
|
kACOMP_NegChGPIO45 |
Gpio45 selection.
|
kACOMP_NegChGPIO46 |
Gpio46 selection.
|
kACOMP_NegChGPIO47 |
Gpio47 selection.
|
kACOMP_NegChGPIO48 |
Gpio48 selection.
|
kACOMP_NegChGPIO49 |
Gpio49 selection.
|
kACOMP_NegChDACA |
DACA selection.
|
kACOMP_NegChDACB |
DACB selection.
|
kACOMP_NegChVREF1P2 |
Vref1p2 selection.
|
kACOMP_NegChAVSS |
AVSS selection.
|
kACOMP_NegChVIO_0P25 |
VIO Scaling factor 0.25.
|
kACOMP_NegChVIO_0P50 |
VIO Scaling factor 0.50.
|
kACOMP_NegChVIO_0P75 |
VIO Scaling factor 0.75.
|
kACOMP_NegChVIO_1P00 |
VIO Scaling factor 1.00.
|
Enumerator |
---|
kACOMP_Hyster0MV |
Hysteresis level = 0mv.
|
kACOMP_Hyster10MV |
Hysteresis level = 10mv.
|
kACOMP_Hyster20MV |
Hysteresis level = 20mv.
|
kACOMP_Hyster30MV |
Hysteresis level = 30mv.
|
kACOMP_Hyster40MV |
Hysteresis level = 40mv.
|
kACOMP_Hyster50MV |
Hysteresis level = 50mv.
|
kACOMP_Hyster60MV |
Hysteresis level = 60mv.
|
kACOMP_Hyster70MV |
Hysteresis level = 70mv.
|
- Parameters
-
base | ACOMP peripheral base address. |
config | The pointer to the structure acomp_config_t. |
* config->enable = false;
* config->posInput = NULL;
* config->negInput = NULL;
*
- Parameters
-
void ACOMP_Deinit |
( |
ACOMP_Type * |
base | ) |
|
- Parameters
-
base | ACOMP peripheral base address. |
- Parameters
-
base | ACOMP peripheral base address. |
id | The selected acomp comparator's id, please refer to acomp_comparator_id_t. |
- Parameters
-
base | ACOMP peripheral base address. |
id | The selected acomp comparator's id, please refer to acomp_comparator_id_t. |
enable | Used to enable/disable module.
- true Enable comparator instance.
- false Disable comparator instance.
|
static void ACOMP_ResetClockDivider |
( |
ACOMP_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | ACOMP peripheral base address. |
- Parameters
-
base | ACOMP peripheral base address. |
id | The selected acomp comparator's id, please refer to acomp_comparator_id_t. |
- Returns
- The result of the selected acomp instance.
static void ACOMP_EnableInterrupts |
( |
ACOMP_Type * |
base, |
|
|
uint32_t |
interruptMask |
|
) |
| |
|
inlinestatic |
Enables interrupts, including acomp0 asynchronized interrupt, acomp0 synchronized interrupt, acomp1 asynchronized interrupt, and acomp1 synchronized interrupt.
- Parameters
-
base | ACOMP peripheral base address. |
interruptMask | The OR'ed value of the interrupts to be enabled, please refer to _acomp_interrupt_enable. |
static void ACOMP_DisableInterrupt |
( |
ACOMP_Type * |
base, |
|
|
uint32_t |
interruptMask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ACOMP peripheral base address. |
interruptMask | The OR'ed value of the interrupts to be disabled, please refer to _acomp_interrupt_enable. |
uint32_t ACOMP_GetStatusFlags |
( |
ACOMP_Type * |
base | ) |
|
Gets status flags, such as ACOMP0 active status flags, ACOMP1 active status flags, and so on.
- Parameters
-
base | ACOMP peripheral base address. |
- Returns
- The OR'ed value ACOMP status flags, please refer to _acomp_status_flags for details.
static void ACOMP_ClearStatusFlags |
( |
ACOMP_Type * |
base, |
|
|
uint32_t |
statusFlagMask |
|
) |
| |
|
inlinestatic |