12#include "fsl_common.h"
26#define FSL_ACMP_DRIVER_VERSION (MAKE_VERSION(2U, 0U, 6U))
30#define CMP_C0_CFx_MASK (CMP_C0_CFR_MASK | CMP_C0_CFF_MASK)
31#define CMP_C1_CHNn_MASK 0xFF0000U
32#define CMP_C2_CHnF_MASK 0xFF0000U
50#if defined(FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT) && (FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT == 1U)
59typedef enum _acmp_offset_mode
61 kACMP_OffsetLevel0 = 0U,
62 kACMP_OffsetLevel1 = 1U,
86#if defined(FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT) && (FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT == 1U)
88typedef enum _acmp_port_input
90 kACMP_PortInputFromDAC = 0U,
91 kACMP_PortInputFromMux = 1U,
102#if defined(FSL_FEATURE_ACMP_HAS_C1_DMODE_BIT) && (FSL_FEATURE_ACMP_HAS_C1_DMODE_BIT == 1U)
104typedef enum _acmp_dac_work_mode
106 kACMP_DACWorkLowSpeedMode = 0U,
107 kACMP_DACWorkHighSpeedMode = 1U,
108} acmp_dac_work_mode_t;
114#if defined(FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT) && (FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT == 1U)
115 acmp_offset_mode_t offsetMode;
132#if defined(FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT) && (FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT == 1U)
133 acmp_port_input_t positivePortInput;
136#if defined(FSL_FEATURE_ACMP_HAS_C1_INNSEL_BIT) && (FSL_FEATURE_ACMP_HAS_C1_INNSEL_BIT == 1U)
137 acmp_port_input_t negativePortInput;
156#if defined(FSL_FEATURE_ACMP_HAS_C1_DACOE_BIT) && (FSL_FEATURE_ACMP_HAS_C1_DACOE_BIT == 1U)
160#if defined(FSL_FEATURE_ACMP_HAS_C1_DMODE_BIT) && (FSL_FEATURE_ACMP_HAS_C1_DMODE_BIT == 1U)
161 acmp_dac_work_mode_t workMode;
176#if defined(FSL_FEATURE_ACMP_HAS_C3_REG) && (FSL_FEATURE_ACMP_HAS_C3_REG == 1U)
179typedef enum _acmp_discrete_clock_source
181 kACMP_DiscreteClockSlow = 0U,
182 kACMP_DiscreteClockFast = 1U,
183} acmp_discrete_clock_source_t;
190typedef enum _acmp_discrete_sample_time
192 kACMP_DiscreteSampleTimeAs1T = 0U,
193 kACMP_DiscreteSampleTimeAs2T = 1U,
194 kACMP_DiscreteSampleTimeAs4T = 2U,
195 kACMP_DiscreteSampleTimeAs8T = 3U,
196 kACMP_DiscreteSampleTimeAs16T = 4U,
197 kACMP_DiscreteSampleTimeAs32T = 5U,
198 kACMP_DiscreteSampleTimeAs64T = 6U,
199 kACMP_DiscreteSampleTimeAs256T = 7U,
200} acmp_discrete_sample_time_t;
206typedef enum _acmp_discrete_phase_time
208 kACMP_DiscretePhaseTimeAlt0 = 0U,
209 kACMP_DiscretePhaseTimeAlt1 = 1U,
210 kACMP_DiscretePhaseTimeAlt2 = 2U,
211 kACMP_DiscretePhaseTimeAlt3 = 3U,
212 kACMP_DiscretePhaseTimeAlt4 = 4U,
213 kACMP_DiscretePhaseTimeAlt5 = 5U,
214 kACMP_DiscretePhaseTimeAlt6 = 6U,
215 kACMP_DiscretePhaseTimeAlt7 = 7U,
216} acmp_discrete_phase_time_t;
219typedef struct _acmp_discrete_mode_config
221 bool enablePositiveChannelDiscreteMode;
223 bool enableNegativeChannelDiscreteMode;
225 bool enableResistorDivider;
227 acmp_discrete_clock_source_t clockSource;
229 acmp_discrete_sample_time_t sampleTime;
230 acmp_discrete_phase_time_t phase1Time;
231 acmp_discrete_phase_time_t phase2Time;
232} acmp_discrete_mode_config_t;
236#if defined(__cplusplus)
300#if defined(FSL_FEATURE_ACMP_HAS_C0_LINKEN_BIT) && (FSL_FEATURE_ACMP_HAS_C0_LINKEN_BIT == 1U)
309void ACMP_EnableLinkToDAC(
CMP_Type *base,
bool enable);
429static inline uint32_t ACMP_GetRoundRobinStatusFlags(
CMP_Type *base)
431 return (((base->C2) & CMP_C2_CHnF_MASK) >> CMP_C2_CH0F_SHIFT);
451static inline uint32_t ACMP_GetRoundRobinResult(
CMP_Type *base)
453 return ((base->C2 & CMP_C2_ACOn_MASK) >> CMP_C2_ACOn_SHIFT);
504#if defined(FSL_FEATURE_ACMP_HAS_C3_REG) && (FSL_FEATURE_ACMP_HAS_C3_REG == 1U)
518void ACMP_SetDiscreteModeConfig(
CMP_Type *base,
const acmp_discrete_mode_config_t *
config);
525void ACMP_GetDefaultDiscreteModeConfig(acmp_discrete_mode_config_t *
config);
530#if defined(__cplusplus)
struct _acmp_channel_config acmp_channel_config_t
Configuration for channel.
_acmp_interrupt_enable
Interrupt enable/disable mask.
Definition: fsl_acmp.h:36
void ACMP_SetFilterConfig(CMP_Type *base, const acmp_filter_config_t *config)
Configures the filter.
Definition: fsl_acmp.c:315
acmp_hysteresis_mode_t hysteresisMode
Definition: fsl_acmp.h:117
bool enableSample
Definition: fsl_acmp.h:145
void ACMP_Enable(CMP_Type *base, bool enable)
Enables or disables the ACMP.
Definition: fsl_acmp.c:172
uint32_t ACMP_GetStatusFlags(CMP_Type *base)
Gets status flags.
Definition: fsl_acmp.c:560
void ACMP_SetRoundRobinPreState(CMP_Type *base, uint32_t mask)
Defines the pre-set state of channels in round robin mode.
Definition: fsl_acmp.c:454
bool enableHighSpeed
Definition: fsl_acmp.h:118
void ACMP_SetChannelConfig(CMP_Type *base, const acmp_channel_config_t *config)
Sets the channel configuration.
Definition: fsl_acmp.c:230
uint32_t minusMuxInput
Definition: fsl_acmp.h:139
enum _acmp_reference_voltage_source acmp_reference_voltage_source_t
CMP Voltage Reference source.
uint32_t checkerChannelMask
Definition: fsl_acmp.h:170
_acmp_reference_voltage_source
CMP Voltage Reference source.
Definition: fsl_acmp.h:81
_acmp_hysteresis_mode
Comparator hard block hysteresis control.
Definition: fsl_acmp.h:72
bool enableInvertOutput
Definition: fsl_acmp.h:119
bool enablePinOut
Definition: fsl_acmp.h:121
uint32_t DACValue
Definition: fsl_acmp.h:154
struct _acmp_filter_config acmp_filter_config_t
Configuration for filter.
void ACMP_Init(CMP_Type *base, const acmp_config_t *config)
Initializes the ACMP.
Definition: fsl_acmp.c:70
struct _acmp_config acmp_config_t
Configuration for ACMP.
void ACMP_EnableDMA(CMP_Type *base, bool enable)
Enables or disables DMA.
Definition: fsl_acmp.c:260
uint32_t filterPeriod
Definition: fsl_acmp.h:147
enum _acmp_hysteresis_mode acmp_hysteresis_mode_t
Comparator hard block hysteresis control.
uint32_t fixedChannelNumber
Definition: fsl_acmp.h:169
struct _acmp_dac_config acmp_dac_config_t
Configuration for DAC.
void ACMP_ClearRoundRobinStatusFlags(CMP_Type *base, uint32_t mask)
Clears the channel input changed flags in round robin mode.
Definition: fsl_acmp.c:471
void ACMP_DisableInterrupts(CMP_Type *base, uint32_t mask)
Disables interrupts.
Definition: fsl_acmp.c:523
void ACMP_Deinit(CMP_Type *base)
Deinitializes the ACMP.
Definition: fsl_acmp.c:120
uint32_t delayModulus
Definition: fsl_acmp.h:173
uint32_t plusMuxInput
Definition: fsl_acmp.h:135
_acmp_status_flags
Status flag mask.
Definition: fsl_acmp.h:44
void ACMP_SetDACConfig(CMP_Type *base, const acmp_dac_config_t *config)
Configures the internal DAC.
Definition: fsl_acmp.c:348
bool useUnfilteredOutput
Definition: fsl_acmp.h:120
_acmp_fixed_port
Fixed mux port.
Definition: fsl_acmp.h:97
void ACMP_EnableInterrupts(CMP_Type *base, uint32_t mask)
Enables interrupts.
Definition: fsl_acmp.c:486
acmp_reference_voltage_source_t referenceVoltageSource
Definition: fsl_acmp.h:153
void ACMP_EnableWindowMode(CMP_Type *base, bool enable)
Enables or disables window mode.
Definition: fsl_acmp.c:281
acmp_fixed_port_t fixedPort
Definition: fsl_acmp.h:168
uint32_t sampleClockCount
Definition: fsl_acmp.h:172
void ACMP_ClearStatusFlags(CMP_Type *base, uint32_t mask)
Clears status flags.
Definition: fsl_acmp.c:590
enum _acmp_fixed_port acmp_fixed_port_t
Fixed mux port.
struct _acmp_round_robin_config acmp_round_robin_config_t
Configuration for round robin mode.
void ACMP_GetDefaultConfig(acmp_config_t *config)
Gets the default configuration for ACMP.
Definition: fsl_acmp.c:148
void ACMP_SetRoundRobinConfig(CMP_Type *base, const acmp_round_robin_config_t *config)
Configures the round robin mode.
Definition: fsl_acmp.c:407
uint32_t filterCount
Definition: fsl_acmp.h:146
@ kACMP_RoundRobinInterruptEnable
Definition: fsl_acmp.h:39
@ kACMP_OutputFallingInterruptEnable
Definition: fsl_acmp.h:38
@ kACMP_OutputRisingInterruptEnable
Definition: fsl_acmp.h:37
@ kACMP_VrefSourceVin2
Definition: fsl_acmp.h:83
@ kACMP_VrefSourceVin1
Definition: fsl_acmp.h:82
@ kACMP_HysteresisLevel2
Definition: fsl_acmp.h:75
@ kACMP_HysteresisLevel1
Definition: fsl_acmp.h:74
@ kACMP_HysteresisLevel0
Definition: fsl_acmp.h:73
@ kACMP_HysteresisLevel3
Definition: fsl_acmp.h:76
@ kACMP_OutputAssertEventFlag
Definition: fsl_acmp.h:47
@ kACMP_OutputFallingEventFlag
Definition: fsl_acmp.h:46
@ kACMP_OutputRisingEventFlag
Definition: fsl_acmp.h:45
@ kACMP_FixedPlusPort
Definition: fsl_acmp.h:98
@ kACMP_FixedMinusPort
Definition: fsl_acmp.h:99
Definition: MIMXRT1052.h:10267
Configuration for channel.
Definition: fsl_acmp.h:131
Configuration for ACMP.
Definition: fsl_acmp.h:113
Configuration for DAC.
Definition: fsl_acmp.h:152
Configuration for filter.
Definition: fsl_acmp.h:144
Configuration for round robin mode.
Definition: fsl_acmp.h:167
Definition: deflate.c:114