rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Enumerator | Variables
Acmp

Data Structures

struct  _acmp_config
 Configuration for ACMP. More...
 
struct  _acmp_channel_config
 Configuration for channel. More...
 
struct  _acmp_filter_config
 Configuration for filter. More...
 
struct  _acmp_dac_config
 Configuration for DAC. More...
 
struct  _acmp_round_robin_config
 Configuration for round robin mode. More...
 
struct  _acmp_discrete_mode_config
 Configuration for discrete mode. More...
 

Variables

acmp_offset_mode_t _acmp_config::offsetMode
 
acmp_hysteresis_mode_t _acmp_config::hysteresisMode
 
bool _acmp_config::enableHighSpeed
 
bool _acmp_config::enableInvertOutput
 
bool _acmp_config::useUnfilteredOutput
 
bool _acmp_config::enablePinOut
 
acmp_port_input_t _acmp_channel_config::positivePortInput
 
uint32_t _acmp_channel_config::plusMuxInput
 
acmp_port_input_t _acmp_channel_config::negativePortInput
 
uint32_t _acmp_channel_config::minusMuxInput
 
bool _acmp_filter_config::enableSample
 
uint32_t _acmp_filter_config::filterCount
 
uint32_t _acmp_filter_config::filterPeriod
 
acmp_reference_voltage_source_t _acmp_dac_config::referenceVoltageSource
 
uint32_t _acmp_dac_config::DACValue
 
bool _acmp_dac_config::enableOutput
 
acmp_dac_work_mode_t _acmp_dac_config::workMode
 
acmp_fixed_port_t _acmp_round_robin_config::fixedPort
 
uint32_t _acmp_round_robin_config::fixedChannelNumber
 
uint32_t _acmp_round_robin_config::checkerChannelMask
 
uint32_t _acmp_round_robin_config::sampleClockCount
 
uint32_t _acmp_round_robin_config::delayModulus
 
bool _acmp_discrete_mode_config::enablePositiveChannelDiscreteMode
 
bool _acmp_discrete_mode_config::enableNegativeChannelDiscreteMode
 
bool _acmp_discrete_mode_config::enableResistorDivider
 
acmp_discrete_clock_source_t _acmp_discrete_mode_config::clockSource
 
acmp_discrete_sample_time_t _acmp_discrete_mode_config::sampleTime
 
acmp_discrete_phase_time_t _acmp_discrete_mode_config::phase1Time
 
acmp_discrete_phase_time_t _acmp_discrete_mode_config::phase2Time
 

Driver version

enum  _acmp_interrupt_enable { kACMP_OutputRisingInterruptEnable = (1U << 0U) , kACMP_OutputFallingInterruptEnable = (1U << 1U) , kACMP_RoundRobinInterruptEnable = (1U << 2U) }
 Interrupt enable/disable mask. More...
 
enum  _acmp_status_flags { kACMP_OutputRisingEventFlag = CMP_C0_CFR_MASK , kACMP_OutputFallingEventFlag = CMP_C0_CFF_MASK , kACMP_OutputAssertEventFlag = CMP_C0_COUT_MASK }
 Status flag mask. More...
 
enum  _acmp_offset_mode { kACMP_OffsetLevel0 = 0U , kACMP_OffsetLevel1 = 1U }
 Comparator hard block offset control. More...
 
enum  _acmp_hysteresis_mode { kACMP_HysteresisLevel0 = 0U , kACMP_HysteresisLevel1 = 1U , kACMP_HysteresisLevel2 = 2U , kACMP_HysteresisLevel3 = 3U }
 Comparator hard block hysteresis control. More...
 
enum  _acmp_reference_voltage_source { kACMP_VrefSourceVin1 = 0U , kACMP_VrefSourceVin2 = 1U }
 CMP Voltage Reference source. More...
 
enum  _acmp_port_input { kACMP_PortInputFromDAC = 0U , kACMP_PortInputFromMux = 1U }
 Port input source. More...
 
enum  _acmp_fixed_port { kACMP_FixedPlusPort = 0U , kACMP_FixedMinusPort = 1U }
 Fixed mux port. More...
 
enum  _acmp_dac_work_mode { kACMP_DACWorkLowSpeedMode = 0U , kACMP_DACWorkHighSpeedMode = 1U }
 Internal DAC's work mode. More...
 
enum  _acmp_discrete_clock_source { kACMP_DiscreteClockSlow = 0U , kACMP_DiscreteClockFast = 1U }
 Discrete mode clock selection. More...
 
enum  _acmp_discrete_sample_time {
  kACMP_DiscreteSampleTimeAs1T = 0U , kACMP_DiscreteSampleTimeAs2T = 1U , kACMP_DiscreteSampleTimeAs4T = 2U , kACMP_DiscreteSampleTimeAs8T = 3U ,
  kACMP_DiscreteSampleTimeAs16T = 4U , kACMP_DiscreteSampleTimeAs32T = 5U , kACMP_DiscreteSampleTimeAs64T = 6U , kACMP_DiscreteSampleTimeAs256T = 7U
}
 ACMP discrete sample selection. These values configures the analog comparator sampling timing (speicified by the discrete mode clock period T which is selected by acmp_discrete_clock_source_t) in discrete mode. More...
 
enum  _acmp_discrete_phase_time {
  kACMP_DiscretePhaseTimeAlt0 = 0U , kACMP_DiscretePhaseTimeAlt1 = 1U , kACMP_DiscretePhaseTimeAlt2 = 2U , kACMP_DiscretePhaseTimeAlt3 = 3U ,
  kACMP_DiscretePhaseTimeAlt4 = 4U , kACMP_DiscretePhaseTimeAlt5 = 5U , kACMP_DiscretePhaseTimeAlt6 = 6U , kACMP_DiscretePhaseTimeAlt7 = 7U
}
 ACMP discrete phase time selection. There are two phases for sampling input signals, phase 1 and phase 2. More...
 
typedef enum _acmp_offset_mode acmp_offset_mode_t
 Comparator hard block offset control.
 
typedef enum _acmp_hysteresis_mode acmp_hysteresis_mode_t
 Comparator hard block hysteresis control.
 
typedef enum _acmp_reference_voltage_source acmp_reference_voltage_source_t
 CMP Voltage Reference source.
 
typedef enum _acmp_port_input acmp_port_input_t
 Port input source.
 
typedef enum _acmp_fixed_port acmp_fixed_port_t
 Fixed mux port.
 
typedef enum _acmp_dac_work_mode acmp_dac_work_mode_t
 Internal DAC's work mode.
 
typedef struct _acmp_config acmp_config_t
 Configuration for ACMP.
 
typedef struct _acmp_channel_config acmp_channel_config_t
 Configuration for channel.
 
typedef struct _acmp_filter_config acmp_filter_config_t
 Configuration for filter.
 
typedef struct _acmp_dac_config acmp_dac_config_t
 Configuration for DAC.
 
typedef struct _acmp_round_robin_config acmp_round_robin_config_t
 Configuration for round robin mode.
 
typedef enum _acmp_discrete_clock_source acmp_discrete_clock_source_t
 Discrete mode clock selection.
 
typedef enum _acmp_discrete_sample_time acmp_discrete_sample_time_t
 ACMP discrete sample selection. These values configures the analog comparator sampling timing (speicified by the discrete mode clock period T which is selected by acmp_discrete_clock_source_t) in discrete mode.
 
typedef enum _acmp_discrete_phase_time acmp_discrete_phase_time_t
 ACMP discrete phase time selection. There are two phases for sampling input signals, phase 1 and phase 2.
 
typedef struct _acmp_discrete_mode_config acmp_discrete_mode_config_t
 Configuration for discrete mode.
 

Initialization and deinitialization

void ACMP_Init (CMP_Type *base, const acmp_config_t *config)
 Initializes the ACMP.
 
void ACMP_Deinit (CMP_Type *base)
 Deinitializes the ACMP.
 
void ACMP_GetDefaultConfig (acmp_config_t *config)
 Gets the default configuration for ACMP.
 

Basic Operations

void ACMP_Enable (CMP_Type *base, bool enable)
 Enables or disables the ACMP.
 
void ACMP_EnableLinkToDAC (CMP_Type *base, bool enable)
 Enables the link from CMP to DAC enable.
 
void ACMP_SetChannelConfig (CMP_Type *base, const acmp_channel_config_t *config)
 Sets the channel configuration.
 

Advanced Operations

void ACMP_EnableDMA (CMP_Type *base, bool enable)
 Enables or disables DMA.
 
void ACMP_EnableWindowMode (CMP_Type *base, bool enable)
 Enables or disables window mode.
 
void ACMP_SetFilterConfig (CMP_Type *base, const acmp_filter_config_t *config)
 Configures the filter.
 
void ACMP_SetDACConfig (CMP_Type *base, const acmp_dac_config_t *config)
 Configures the internal DAC.
 
void ACMP_SetRoundRobinConfig (CMP_Type *base, const acmp_round_robin_config_t *config)
 Configures the round robin mode.
 
void ACMP_SetRoundRobinPreState (CMP_Type *base, uint32_t mask)
 Defines the pre-set state of channels in round robin mode.
 
static uint32_t ACMP_GetRoundRobinStatusFlags (CMP_Type *base)
 Gets the channel input changed flags in round robin mode.
 
void ACMP_ClearRoundRobinStatusFlags (CMP_Type *base, uint32_t mask)
 Clears the channel input changed flags in round robin mode.
 
static uint32_t ACMP_GetRoundRobinResult (CMP_Type *base)
 Gets the round robin result.
 

Interrupts

void ACMP_EnableInterrupts (CMP_Type *base, uint32_t mask)
 Enables interrupts.
 
void ACMP_DisableInterrupts (CMP_Type *base, uint32_t mask)
 Disables interrupts.
 

Status

uint32_t ACMP_GetStatusFlags (CMP_Type *base)
 Gets status flags.
 
void ACMP_ClearStatusFlags (CMP_Type *base, uint32_t mask)
 Clears status flags.
 

Discrete mode

void ACMP_SetDiscreteModeConfig (CMP_Type *base, const acmp_discrete_mode_config_t *config)
 Configure the discrete mode.
 
void ACMP_GetDefaultDiscreteModeConfig (acmp_discrete_mode_config_t *config)
 Get the default configuration for discrete mode setting.
 

Detailed Description

Typedef Documentation

◆ acmp_channel_config_t

Configuration for channel.

The comparator's port can be input from channel mux or DAC. If port input is from channel mux, detailed channel number for the mux should be configured.

◆ acmp_config_t

typedef struct _acmp_config acmp_config_t

Configuration for ACMP.

◆ acmp_dac_config_t

Configuration for DAC.

◆ acmp_dac_work_mode_t

Internal DAC's work mode.

◆ acmp_discrete_clock_source_t

Discrete mode clock selection.

◆ acmp_discrete_mode_config_t

Configuration for discrete mode.

◆ acmp_discrete_phase_time_t

ACMP discrete phase time selection. There are two phases for sampling input signals, phase 1 and phase 2.

◆ acmp_discrete_sample_time_t

ACMP discrete sample selection. These values configures the analog comparator sampling timing (speicified by the discrete mode clock period T which is selected by acmp_discrete_clock_source_t) in discrete mode.

◆ acmp_filter_config_t

Configuration for filter.

◆ acmp_fixed_port_t

Fixed mux port.

◆ acmp_hysteresis_mode_t

Comparator hard block hysteresis control.

See chip data sheet to get the actual hysteresis value with each level.

◆ acmp_offset_mode_t

Comparator hard block offset control.

If OFFSET level is 1, then there is no hysteresis in the case of positive port input crossing negative port input in the positive direction (or negative port input crossing positive port input in the negative direction). Hysteresis still exists for positive port input crossing negative port input in the falling direction. If OFFSET level is 0, then the hysteresis selected by acmp_hysteresis_mode_t is valid for both directions.

◆ acmp_port_input_t

Port input source.

◆ acmp_reference_voltage_source_t

CMP Voltage Reference source.

◆ acmp_round_robin_config_t

Configuration for round robin mode.

Enumeration Type Documentation

◆ _acmp_dac_work_mode

Internal DAC's work mode.

Enumerator
kACMP_DACWorkLowSpeedMode 

DAC is selected to work in low speed and low power mode.

kACMP_DACWorkHighSpeedMode 

DAC is selected to work in high speed high power mode.

Definition at line 104 of file fsl_acmp.h.

105{
106 kACMP_DACWorkLowSpeedMode = 0U, /*!< DAC is selected to work in low speed and low power mode. */
107 kACMP_DACWorkHighSpeedMode = 1U, /*!< DAC is selected to work in high speed high power mode. */
enum _acmp_dac_work_mode acmp_dac_work_mode_t
Internal DAC's work mode.
@ kACMP_DACWorkHighSpeedMode
Definition fsl_acmp.h:107
@ kACMP_DACWorkLowSpeedMode
Definition fsl_acmp.h:106

◆ _acmp_discrete_clock_source

Discrete mode clock selection.

Enumerator
kACMP_DiscreteClockSlow 

Slow clock (32kHz) is used as the discrete mode clock.

kACMP_DiscreteClockFast 

Fast clock (16-20MHz) is used as the discrete mode clock.

Definition at line 179 of file fsl_acmp.h.

180{
181 kACMP_DiscreteClockSlow = 0U, /*!< Slow clock (32kHz) is used as the discrete mode clock. */
182 kACMP_DiscreteClockFast = 1U, /*!< Fast clock (16-20MHz) is used as the discrete mode clock. */
enum _acmp_discrete_clock_source acmp_discrete_clock_source_t
Discrete mode clock selection.
@ kACMP_DiscreteClockSlow
Definition fsl_acmp.h:181
@ kACMP_DiscreteClockFast
Definition fsl_acmp.h:182

◆ _acmp_discrete_phase_time

ACMP discrete phase time selection. There are two phases for sampling input signals, phase 1 and phase 2.

Enumerator
kACMP_DiscretePhaseTimeAlt0 

The phase x active in one sampling selection 0.

kACMP_DiscretePhaseTimeAlt1 

The phase x active in one sampling selection 1.

kACMP_DiscretePhaseTimeAlt2 

The phase x active in one sampling selection 2.

kACMP_DiscretePhaseTimeAlt3 

The phase x active in one sampling selection 3.

kACMP_DiscretePhaseTimeAlt4 

The phase x active in one sampling selection 4.

kACMP_DiscretePhaseTimeAlt5 

The phase x active in one sampling selection 5.

kACMP_DiscretePhaseTimeAlt6 

The phase x active in one sampling selection 6.

kACMP_DiscretePhaseTimeAlt7 

The phase x active in one sampling selection 7.

Definition at line 206 of file fsl_acmp.h.

207{
208 kACMP_DiscretePhaseTimeAlt0 = 0U, /*!< The phase x active in one sampling selection 0. */
209 kACMP_DiscretePhaseTimeAlt1 = 1U, /*!< The phase x active in one sampling selection 1. */
210 kACMP_DiscretePhaseTimeAlt2 = 2U, /*!< The phase x active in one sampling selection 2. */
211 kACMP_DiscretePhaseTimeAlt3 = 3U, /*!< The phase x active in one sampling selection 3. */
212 kACMP_DiscretePhaseTimeAlt4 = 4U, /*!< The phase x active in one sampling selection 4. */
213 kACMP_DiscretePhaseTimeAlt5 = 5U, /*!< The phase x active in one sampling selection 5. */
214 kACMP_DiscretePhaseTimeAlt6 = 6U, /*!< The phase x active in one sampling selection 6. */
215 kACMP_DiscretePhaseTimeAlt7 = 7U, /*!< The phase x active in one sampling selection 7. */
enum _acmp_discrete_phase_time acmp_discrete_phase_time_t
ACMP discrete phase time selection. There are two phases for sampling input signals,...
@ kACMP_DiscretePhaseTimeAlt2
Definition fsl_acmp.h:210
@ kACMP_DiscretePhaseTimeAlt0
Definition fsl_acmp.h:208
@ kACMP_DiscretePhaseTimeAlt1
Definition fsl_acmp.h:209
@ kACMP_DiscretePhaseTimeAlt7
Definition fsl_acmp.h:215
@ kACMP_DiscretePhaseTimeAlt3
Definition fsl_acmp.h:211
@ kACMP_DiscretePhaseTimeAlt4
Definition fsl_acmp.h:212
@ kACMP_DiscretePhaseTimeAlt6
Definition fsl_acmp.h:214
@ kACMP_DiscretePhaseTimeAlt5
Definition fsl_acmp.h:213

◆ _acmp_discrete_sample_time

ACMP discrete sample selection. These values configures the analog comparator sampling timing (speicified by the discrete mode clock period T which is selected by acmp_discrete_clock_source_t) in discrete mode.

Enumerator
kACMP_DiscreteSampleTimeAs1T 

The sampling time equals to 1xT.

kACMP_DiscreteSampleTimeAs2T 

The sampling time equals to 2xT.

kACMP_DiscreteSampleTimeAs4T 

The sampling time equals to 4xT.

kACMP_DiscreteSampleTimeAs8T 

The sampling time equals to 8xT.

kACMP_DiscreteSampleTimeAs16T 

The sampling time equals to 16xT.

kACMP_DiscreteSampleTimeAs32T 

The sampling time equals to 32xT.

kACMP_DiscreteSampleTimeAs64T 

The sampling time equals to 64xT.

kACMP_DiscreteSampleTimeAs256T 

The sampling time equals to 256xT.

Definition at line 190 of file fsl_acmp.h.

191{
192 kACMP_DiscreteSampleTimeAs1T = 0U, /*!< The sampling time equals to 1xT. */
193 kACMP_DiscreteSampleTimeAs2T = 1U, /*!< The sampling time equals to 2xT. */
194 kACMP_DiscreteSampleTimeAs4T = 2U, /*!< The sampling time equals to 4xT. */
195 kACMP_DiscreteSampleTimeAs8T = 3U, /*!< The sampling time equals to 8xT. */
196 kACMP_DiscreteSampleTimeAs16T = 4U, /*!< The sampling time equals to 16xT. */
197 kACMP_DiscreteSampleTimeAs32T = 5U, /*!< The sampling time equals to 32xT. */
198 kACMP_DiscreteSampleTimeAs64T = 6U, /*!< The sampling time equals to 64xT. */
199 kACMP_DiscreteSampleTimeAs256T = 7U, /*!< The sampling time equals to 256xT. */
enum _acmp_discrete_sample_time acmp_discrete_sample_time_t
ACMP discrete sample selection. These values configures the analog comparator sampling timing (speici...
@ kACMP_DiscreteSampleTimeAs64T
Definition fsl_acmp.h:198
@ kACMP_DiscreteSampleTimeAs2T
Definition fsl_acmp.h:193
@ kACMP_DiscreteSampleTimeAs256T
Definition fsl_acmp.h:199
@ kACMP_DiscreteSampleTimeAs1T
Definition fsl_acmp.h:192
@ kACMP_DiscreteSampleTimeAs16T
Definition fsl_acmp.h:196
@ kACMP_DiscreteSampleTimeAs8T
Definition fsl_acmp.h:195
@ kACMP_DiscreteSampleTimeAs4T
Definition fsl_acmp.h:194
@ kACMP_DiscreteSampleTimeAs32T
Definition fsl_acmp.h:197

◆ _acmp_fixed_port

Fixed mux port.

Enumerator
kACMP_FixedPlusPort 

Only the inputs to the Minus port are swept in each round.

kACMP_FixedMinusPort 

Only the inputs to the Plus port are swept in each round.

Definition at line 96 of file fsl_acmp.h.

97{
98 kACMP_FixedPlusPort = 0U, /*!< Only the inputs to the Minus port are swept in each round. */
99 kACMP_FixedMinusPort = 1U, /*!< Only the inputs to the Plus port are swept in each round. */
enum _acmp_fixed_port acmp_fixed_port_t
Fixed mux port.
@ kACMP_FixedPlusPort
Definition fsl_acmp.h:98
@ kACMP_FixedMinusPort
Definition fsl_acmp.h:99

◆ _acmp_hysteresis_mode

Comparator hard block hysteresis control.

See chip data sheet to get the actual hysteresis value with each level.

Enumerator
kACMP_HysteresisLevel0 

Offset is level 0 and Hysteresis is level 0.

kACMP_HysteresisLevel1 

Offset is level 0 and Hysteresis is level 1.

kACMP_HysteresisLevel2 

Offset is level 0 and Hysteresis is level 2.

kACMP_HysteresisLevel3 

Offset is level 0 and Hysteresis is level 3.

Definition at line 71 of file fsl_acmp.h.

72{
73 kACMP_HysteresisLevel0 = 0U, /*!< Offset is level 0 and Hysteresis is level 0. */
74 kACMP_HysteresisLevel1 = 1U, /*!< Offset is level 0 and Hysteresis is level 1. */
75 kACMP_HysteresisLevel2 = 2U, /*!< Offset is level 0 and Hysteresis is level 2. */
76 kACMP_HysteresisLevel3 = 3U, /*!< Offset is level 0 and Hysteresis is level 3. */
enum _acmp_hysteresis_mode acmp_hysteresis_mode_t
Comparator hard block hysteresis control.
@ 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

◆ _acmp_interrupt_enable

Interrupt enable/disable mask.

Enumerator
kACMP_OutputRisingInterruptEnable 

Enable the interrupt when comparator outputs rising.

kACMP_OutputFallingInterruptEnable 

Enable the interrupt when comparator outputs falling.

kACMP_RoundRobinInterruptEnable 

Enable the Round-Robin interrupt.

Definition at line 35 of file fsl_acmp.h.

36{
37 kACMP_OutputRisingInterruptEnable = (1U << 0U), /*!< Enable the interrupt when comparator outputs rising. */
38 kACMP_OutputFallingInterruptEnable = (1U << 1U), /*!< Enable the interrupt when comparator outputs falling. */
39 kACMP_RoundRobinInterruptEnable = (1U << 2U), /*!< Enable the Round-Robin interrupt. */
40};
@ kACMP_RoundRobinInterruptEnable
Definition fsl_acmp.h:39
@ kACMP_OutputFallingInterruptEnable
Definition fsl_acmp.h:38
@ kACMP_OutputRisingInterruptEnable
Definition fsl_acmp.h:37

◆ _acmp_offset_mode

Comparator hard block offset control.

If OFFSET level is 1, then there is no hysteresis in the case of positive port input crossing negative port input in the positive direction (or negative port input crossing positive port input in the negative direction). Hysteresis still exists for positive port input crossing negative port input in the falling direction. If OFFSET level is 0, then the hysteresis selected by acmp_hysteresis_mode_t is valid for both directions.

Enumerator
kACMP_OffsetLevel0 

The comparator hard block output has level 0 offset internally.

kACMP_OffsetLevel1 

The comparator hard block output has level 1 offset internally.

Definition at line 59 of file fsl_acmp.h.

60{
61 kACMP_OffsetLevel0 = 0U, /*!< The comparator hard block output has level 0 offset internally. */
62 kACMP_OffsetLevel1 = 1U, /*!< The comparator hard block output has level 1 offset internally. */
enum _acmp_offset_mode acmp_offset_mode_t
Comparator hard block offset control.
@ kACMP_OffsetLevel0
Definition fsl_acmp.h:61
@ kACMP_OffsetLevel1
Definition fsl_acmp.h:62

◆ _acmp_port_input

Port input source.

Enumerator
kACMP_PortInputFromDAC 

Port input from the 8-bit DAC output.

kACMP_PortInputFromMux 

Port input from the analog 8-1 mux.

Definition at line 88 of file fsl_acmp.h.

89{
90 kACMP_PortInputFromDAC = 0U, /*!< Port input from the 8-bit DAC output. */
91 kACMP_PortInputFromMux = 1U, /*!< Port input from the analog 8-1 mux. */
enum _acmp_port_input acmp_port_input_t
Port input source.
@ kACMP_PortInputFromDAC
Definition fsl_acmp.h:90
@ kACMP_PortInputFromMux
Definition fsl_acmp.h:91

◆ _acmp_reference_voltage_source

CMP Voltage Reference source.

Enumerator
kACMP_VrefSourceVin1 

Vin1 is selected as resistor ladder network supply reference Vin.

kACMP_VrefSourceVin2 

Vin2 is selected as resistor ladder network supply reference Vin.

Definition at line 80 of file fsl_acmp.h.

81{
82 kACMP_VrefSourceVin1 = 0U, /*!< Vin1 is selected as resistor ladder network supply reference Vin. */
83 kACMP_VrefSourceVin2 = 1U, /*!< Vin2 is selected as resistor ladder network supply reference Vin. */
enum _acmp_reference_voltage_source acmp_reference_voltage_source_t
CMP Voltage Reference source.
@ kACMP_VrefSourceVin2
Definition fsl_acmp.h:83
@ kACMP_VrefSourceVin1
Definition fsl_acmp.h:82

◆ _acmp_status_flags

Status flag mask.

Enumerator
kACMP_OutputRisingEventFlag 

Rising-edge on compare output has occurred.

kACMP_OutputFallingEventFlag 

Falling-edge on compare output has occurred.

kACMP_OutputAssertEventFlag 

Return the current value of the analog comparator output.

Definition at line 43 of file fsl_acmp.h.

44{
45 kACMP_OutputRisingEventFlag = CMP_C0_CFR_MASK, /*!< Rising-edge on compare output has occurred. */
46 kACMP_OutputFallingEventFlag = CMP_C0_CFF_MASK, /*!< Falling-edge on compare output has occurred. */
47 kACMP_OutputAssertEventFlag = CMP_C0_COUT_MASK, /*!< Return the current value of the analog comparator output. */
48};
@ kACMP_OutputAssertEventFlag
Definition fsl_acmp.h:47
@ kACMP_OutputFallingEventFlag
Definition fsl_acmp.h:46
@ kACMP_OutputRisingEventFlag
Definition fsl_acmp.h:45

Function Documentation

◆ ACMP_ClearRoundRobinStatusFlags()

void ACMP_ClearRoundRobinStatusFlags ( CMP_Type *  base,
uint32_t  mask 
)

Clears the channel input changed flags in round robin mode.

Parameters
baseACMP peripheral base address.
maskMask of channel index. Available range is channel0:0x01 to channel7:0x80.

brief Clears the channel input changed flags in round robin mode.

param base ACMP peripheral base address. param mask Mask of channel index. Available range is channel0:0x01 to channel7:0x80.

Definition at line 470 of file fsl_acmp.c.

471{
472 /* CMPx_C2 */
473 uint32_t tmp32 = (base->C2 & (~CMP_C2_CHnF_MASK));
474
475 tmp32 |= (mask << CMP_C2_CH0F_SHIFT);
476 base->C2 = tmp32;
477}

◆ ACMP_ClearStatusFlags()

void ACMP_ClearStatusFlags ( CMP_Type *  base,
uint32_t  mask 
)

Clears status flags.

Parameters
baseACMP peripheral base address.
maskStatus flags mask. See "_acmp_status_flags".

brief Clears status flags.

param base ACMP peripheral base address. param mask Status flags mask. See "_acmp_status_flags".

Definition at line 589 of file fsl_acmp.c.

590{
591 /* CMPx_C0 */
592 uint32_t tmp32 = (base->C0 & (~(CMP_C0_CFR_MASK | CMP_C0_CFF_MASK)));
593
594 /* Clear flag according to mask. */
596 {
597 tmp32 |= CMP_C0_CFR_MASK;
598 }
600 {
601 tmp32 |= CMP_C0_CFF_MASK;
602 }
603 base->C0 = tmp32;
604}

Referenced by comp_lld_get_status().

Here is the caller graph for this function:

◆ ACMP_Deinit()

void ACMP_Deinit ( CMP_Type *  base)

Deinitializes the ACMP.

Parameters
baseACMP peripheral base address.

brief Deinitializes the ACMP.

param base ACMP peripheral base address.

Definition at line 120 of file fsl_acmp.c.

121{
122 /* Disable the module. */
123 ACMP_Enable(base, false);
124
125#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
126 /* Disable clock gate. */
128#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
129}
static uint32_t ACMP_GetInstance(CMP_Type *base)
Get the ACMP instance from the peripheral base address.
Definition fsl_acmp.c:45
static const clock_ip_name_t s_acmpClock[]
Definition fsl_acmp.c:39
void ACMP_Enable(CMP_Type *base, bool enable)
Enables or disables the ACMP.
Definition fsl_acmp.c:172
static void CLOCK_DisableClock(clock_ip_name_t name)
Disable the clock for specific IP.
Definition fsl_clock.h:653

Referenced by comp_lld_stop().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ACMP_DisableInterrupts()

void ACMP_DisableInterrupts ( CMP_Type *  base,
uint32_t  mask 
)

Disables interrupts.

Parameters
baseACMP peripheral base address.
maskInterrupts mask. See "_acmp_interrupt_enable".

brief Disables interrupts.

param base ACMP peripheral base address. param mask Interrupts mask. See "_acmp_interrupt_enable".

Definition at line 522 of file fsl_acmp.c.

523{
524 uint32_t tmp32;
525
526 /* CMPx_C0
527 * Set control bit. Avoid clearing status flags at the same time.
528 * Clear CMP interrupt enable flag.
529 */
530 tmp32 = base->C0;
532 {
533 tmp32 &= ~(CMP_C0_IER_MASK | CMP_C0_CFx_MASK);
534 }
536 {
537 tmp32 &= ~(CMP_C0_IEF_MASK | CMP_C0_CFx_MASK);
538 }
539 base->C0 = tmp32;
540
541 /* CMPx_C2
542 * Clear round robin interrupt enable flag.
543 */
545 {
546 tmp32 = base->C2;
547 /* Set control bit. Avoid clearing status flags at the same time. */
548 tmp32 &= ~(CMP_C2_RRIE_MASK | CMP_C2_CHnF_MASK);
549 base->C2 = tmp32;
550 }
551}

Referenced by comp_lld_disable().

Here is the caller graph for this function:

◆ ACMP_Enable()

void ACMP_Enable ( CMP_Type *  base,
bool  enable 
)

Enables or disables the ACMP.

Parameters
baseACMP peripheral base address.
enableTrue to enable the ACMP.

brief Enables or disables the ACMP.

param base ACMP peripheral base address. param enable True to enable the ACMP.

Definition at line 172 of file fsl_acmp.c.

173{
174 /* CMPx_C0
175 * Set control bit. Avoid clearing status flags at the same time.
176 */
177 if (enable)
178 {
179 base->C0 = ((base->C0 | CMP_C0_EN_MASK) & ~CMP_C0_CFx_MASK);
180 }
181 else
182 {
183 base->C0 &= ~(CMP_C0_EN_MASK | CMP_C0_CFx_MASK);
184 }
185}
static void enable(const char *param)
Definition settings.cpp:441

Referenced by ACMP_Deinit(), ACMP_Init(), comp_lld_disable(), and comp_lld_enable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ACMP_EnableDMA()

void ACMP_EnableDMA ( CMP_Type *  base,
bool  enable 
)

Enables or disables DMA.

Parameters
baseACMP peripheral base address.
enableTrue to enable DMA.

brief Enables or disables DMA.

param base ACMP peripheral base address. param enable True to enable DMA.

Definition at line 260 of file fsl_acmp.c.

261{
262 /* CMPx_C0
263 * Set control bit. Avoid clearing status flags at the same time.
264 */
265 if (enable)
266 {
267 base->C0 = ((base->C0 | CMP_C0_DMAEN_MASK) & ~CMP_C0_CFx_MASK);
268 }
269 else
270 {
271 base->C0 &= ~(CMP_C0_DMAEN_MASK | CMP_C0_CFx_MASK);
272 }
273}
Here is the call graph for this function:

◆ ACMP_EnableInterrupts()

void ACMP_EnableInterrupts ( CMP_Type *  base,
uint32_t  mask 
)

Enables interrupts.

Parameters
baseACMP peripheral base address.
maskInterrupts mask. See "_acmp_interrupt_enable".

brief Enables interrupts.

param base ACMP peripheral base address. param mask Interrupts mask. See "_acmp_interrupt_enable".

Definition at line 485 of file fsl_acmp.c.

486{
487 uint32_t tmp32;
488
489 /* CMPx_C0
490 * Set control bit. Avoid clearing status flags at the same time.
491 * Set CMP interrupt enable flag.
492 */
493 tmp32 = base->C0 & ~CMP_C0_CFx_MASK; /* To protect the W1C flags. */
495 {
496 tmp32 = ((tmp32 | CMP_C0_IER_MASK) & ~CMP_C0_CFx_MASK);
497 }
499 {
500 tmp32 = ((tmp32 | CMP_C0_IEF_MASK) & ~CMP_C0_CFx_MASK);
501 }
502 base->C0 = tmp32;
503
504 /* CMPx_C2
505 * Set round robin interrupt enable flag.
506 */
508 {
509 tmp32 = base->C2;
510 /* Set control bit. Avoid clearing status flags at the same time. */
511 tmp32 = ((tmp32 | CMP_C2_RRIE_MASK) & ~CMP_C2_CHnF_MASK);
512 base->C2 = tmp32;
513 }
514}

Referenced by comp_lld_enable().

Here is the caller graph for this function:

◆ ACMP_EnableLinkToDAC()

void ACMP_EnableLinkToDAC ( CMP_Type *  base,
bool  enable 
)

Enables the link from CMP to DAC enable.

When this bit is set, the DAC enable/disable is controlled by the bit CMP_C0[EN] instead of CMP_C1[DACEN].

Parameters
baseACMP peripheral base address.
enableEnable the feature or not.

brief Enables the link from CMP to DAC enable.

When this bit is set, the DAC enable/disable is controlled by the bit CMP_C0[EN] instead of CMP_C1[DACEN].

param base ACMP peripheral base address. param enable Enable the feature or not.

Definition at line 196 of file fsl_acmp.c.

197{
198 /* CMPx_C0_LINKEN
199 * Set control bit. Avoid clearing status flags at the same time.
200 */
201 if (enable)
202 {
203 base->C0 = ((base->C0 | CMP_C0_LINKEN_MASK) & ~CMP_C0_CFx_MASK);
204 }
205 else
206 {
207 base->C0 &= ~(CMP_C0_LINKEN_MASK | CMP_C0_CFx_MASK);
208 }
209}
Here is the call graph for this function:

◆ ACMP_EnableWindowMode()

void ACMP_EnableWindowMode ( CMP_Type *  base,
bool  enable 
)

Enables or disables window mode.

Parameters
baseACMP peripheral base address.
enableTrue to enable window mode.

brief Enables or disables window mode.

param base ACMP peripheral base address. param enable True to enable window mode.

Definition at line 281 of file fsl_acmp.c.

282{
283 /* CMPx_C0
284 * Set control bit. Avoid clearing status flags at the same time.
285 */
286 if (enable)
287 {
288 base->C0 = ((base->C0 | CMP_C0_WE_MASK) & ~CMP_C0_CFx_MASK);
289 }
290 else
291 {
292 base->C0 &= ~(CMP_C0_WE_MASK | CMP_C0_CFx_MASK);
293 }
294}
Here is the call graph for this function:

◆ ACMP_GetDefaultConfig()

void ACMP_GetDefaultConfig ( acmp_config_t config)

Gets the default configuration for ACMP.

This function initializes the user configuration structure to default value. The default value are:

Example:

config->enableHighSpeed = false;
config->enableInvertOutput = false;
config->useUnfilteredOutput = false;
config->enablePinOut = false;
config->enableHysteresisBothDirections = false;
config->hysteresisMode = kACMP_hysteresisMode0;
static constexpr persistent_config_s * config
Parameters
configPointer to ACMP configuration structure.

brief Gets the default configuration for ACMP.

This function initializes the user configuration structure to default value. The default value are:

Example: code config->enableHighSpeed = false; config->enableInvertOutput = false; config->useUnfilteredOutput = false; config->enablePinOut = false; config->enableHysteresisBothDirections = false; config->hysteresisMode = kACMP_hysteresisMode0; endcode

param config Pointer to ACMP configuration structure.

Definition at line 148 of file fsl_acmp.c.

149{
150 assert(NULL != config);
151
152 /* Initializes the configure structure to zero. */
153 memset(config, 0, sizeof(*config));
154
155 /* Fill default configuration */
156 config->enableHighSpeed = false;
157 config->enableInvertOutput = false;
158 config->useUnfilteredOutput = false;
159 config->enablePinOut = false;
160#if defined(FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT) && (FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT == 1U)
161 config->offsetMode = kACMP_OffsetLevel0;
162#endif /* FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT */
163 config->hysteresisMode = kACMP_HysteresisLevel0;
164}

Referenced by comp_lld_start().

Here is the caller graph for this function:

◆ ACMP_GetDefaultDiscreteModeConfig()

void ACMP_GetDefaultDiscreteModeConfig ( acmp_discrete_mode_config_t config)

Get the default configuration for discrete mode setting.

Parameters
configPointer to configuration structure to be restored with the setting values.

brief Get the default configuration for discrete mode setting.

param config Pointer to configuration structure to be restored with the setting values.

Definition at line 645 of file fsl_acmp.c.

646{
647 assert(NULL != config);
648
649 /* Initializes the configure structure to zero. */
650 memset(config, 0, sizeof(*config));
651
652 config->enablePositiveChannelDiscreteMode = false;
653 config->enableNegativeChannelDiscreteMode = false;
654 config->enableResistorDivider = false;
655 config->clockSource = kACMP_DiscreteClockSlow;
659}

◆ ACMP_GetRoundRobinResult()

static uint32_t ACMP_GetRoundRobinResult ( CMP_Type *  base)
inlinestatic

Gets the round robin result.

Note that the set-pre-state has different circuit with get-round-robin-result in the SOC even though they are same bits. So ACMP_GetRoundRobinResult() can't return the same value as the value are set by ACMP_SetRoundRobinPreState.

Parameters
baseACMP peripheral base address.
Returns
Mask of round robin channel result. Available range is channel0:0x01 to channel7:0x80.

Definition at line 451 of file fsl_acmp.h.

452{
453 return ((base->C2 & CMP_C2_ACOn_MASK) >> CMP_C2_ACOn_SHIFT);
454}

◆ ACMP_GetRoundRobinStatusFlags()

static uint32_t ACMP_GetRoundRobinStatusFlags ( CMP_Type *  base)
inlinestatic

Gets the channel input changed flags in round robin mode.

Parameters
baseACMP peripheral base address.
Returns
Mask of channel input changed asserted flags. Available range is channel0:0x01 to channel7:0x80.

Definition at line 429 of file fsl_acmp.h.

430{
431 return (((base->C2) & CMP_C2_CHnF_MASK) >> CMP_C2_CH0F_SHIFT);
432}

◆ ACMP_GetStatusFlags()

uint32_t ACMP_GetStatusFlags ( CMP_Type *  base)

Gets status flags.

Parameters
baseACMP peripheral base address.
Returns
Status flags asserted mask. See "_acmp_status_flags".

brief Gets status flags.

param base ACMP peripheral base address. return Status flags asserted mask. See "_acmp_status_flags".

Definition at line 559 of file fsl_acmp.c.

560{
561 uint32_t status = 0U;
562 uint32_t tmp32 = base->C0;
563
564 /* CMPx_C0
565 * Check if each flag is set.
566 */
567 if (CMP_C0_CFR_MASK == (tmp32 & CMP_C0_CFR_MASK))
568 {
570 }
571 if (CMP_C0_CFF_MASK == (tmp32 & CMP_C0_CFF_MASK))
572 {
574 }
575 if (CMP_C0_COUT_MASK == (tmp32 & CMP_C0_COUT_MASK))
576 {
578 }
579
580 return status;
581}

Referenced by comp_lld_get_status().

Here is the caller graph for this function:

◆ ACMP_Init()

void ACMP_Init ( CMP_Type *  base,
const acmp_config_t config 
)

Initializes the ACMP.

The default configuration can be got by calling ACMP_GetDefaultConfig().

Parameters
baseACMP peripheral base address.
configPointer to ACMP configuration structure.

brief Initializes the ACMP.

The default configuration can be got by calling ACMP_GetDefaultConfig().

param base ACMP peripheral base address. param config Pointer to ACMP configuration structure.

Definition at line 70 of file fsl_acmp.c.

71{
72 assert(NULL != config);
73
74 uint32_t tmp32;
75
76#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL) && FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL)
77 /* Open clock gate. */
79#endif /* FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL */
80
81 /* Disable the module before configuring it. */
82 ACMP_Enable(base, false);
83
84 /* CMPx_C0
85 * Set control bit. Avoid clearing status flags at the same time.
86 */
87 tmp32 = (base->C0 & (~(CMP_C0_PMODE_MASK | CMP_C0_INVT_MASK | CMP_C0_COS_MASK | CMP_C0_OPE_MASK |
88 CMP_C0_HYSTCTR_MASK | CMP_C0_CFx_MASK)));
89#if defined(FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT) && (FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT == 1U)
90 tmp32 &= ~CMP_C0_OFFSET_MASK;
91#endif /* FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT */
92 if (config->enableHighSpeed)
93 {
94 tmp32 |= CMP_C0_PMODE_MASK;
95 }
96 if (config->enableInvertOutput)
97 {
98 tmp32 |= CMP_C0_INVT_MASK;
99 }
100 if (config->useUnfilteredOutput)
101 {
102 tmp32 |= CMP_C0_COS_MASK;
103 }
104 if (config->enablePinOut)
105 {
106 tmp32 |= CMP_C0_OPE_MASK;
107 }
108 tmp32 |= CMP_C0_HYSTCTR(config->hysteresisMode);
109#if defined(FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT) && (FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT == 1U)
110 tmp32 |= CMP_C0_OFFSET(config->offsetMode);
111#endif /* FSL_FEATURE_ACMP_HAS_C0_OFFSET_BIT */
112 base->C0 = tmp32;
113}
static void CLOCK_EnableClock(clock_ip_name_t name)
Enable the clock for specific IP.
Definition fsl_clock.h:641

Referenced by comp_lld_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ACMP_SetChannelConfig()

void ACMP_SetChannelConfig ( CMP_Type *  base,
const acmp_channel_config_t config 
)

Sets the channel configuration.

Note that the plus/minus mux's setting is only valid when the positive/negative port's input isn't from DAC but from channel mux.

Example:

acmp_channel_config_t configStruct = {0};
configStruct.minusMuxInput = 1U;
ACMP_SetChannelConfig(CMP0, &configStruct);
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
acmp_port_input_t positivePortInput
Definition fsl_acmp.h:133
acmp_port_input_t negativePortInput
Definition fsl_acmp.h:137
Configuration for channel.
Definition fsl_acmp.h:131
Parameters
baseACMP peripheral base address.
configPointer to channel configuration structure.

brief Sets the channel configuration.

Note that the plus/minus mux's setting is only valid when the positive/negative port's input isn't from DAC but from channel mux.

Example: code acmp_channel_config_t configStruct = {0}; configStruct.positivePortInput = kACMP_PortInputFromDAC; configStruct.negativePortInput = kACMP_PortInputFromMux; configStruct.minusMuxInput = 1U; ACMP_SetChannelConfig(CMP0, &configStruct); endcode

param base ACMP peripheral base address. param config Pointer to channel configuration structure.

Definition at line 230 of file fsl_acmp.c.

231{
232 assert(NULL != config);
233
234 uint32_t tmp32 = (base->C1 & (~(CMP_C1_PSEL_MASK | CMP_C1_MSEL_MASK)));
235
236/* CMPx_C1
237 * Set the input of CMP's positive port.
238 */
239#if (defined(FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT) && (FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT == 1U))
240 tmp32 &= ~CMP_C1_INPSEL_MASK;
241 tmp32 |= CMP_C1_INPSEL(config->positivePortInput);
242#endif /* FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT */
243
244#if (defined(FSL_FEATURE_ACMP_HAS_C1_INNSEL_BIT) && (FSL_FEATURE_ACMP_HAS_C1_INNSEL_BIT == 1U))
245 tmp32 &= ~CMP_C1_INNSEL_MASK;
246 tmp32 |= CMP_C1_INNSEL(config->negativePortInput);
247#endif /* FSL_FEATURE_ACMP_HAS_C1_INPSEL_BIT */
248
249 tmp32 |= CMP_C1_PSEL(config->plusMuxInput) | CMP_C1_MSEL(config->minusMuxInput);
250
251 base->C1 = tmp32;
252}

Referenced by comp_lld_channel_enable().

Here is the caller graph for this function:

◆ ACMP_SetDACConfig()

void ACMP_SetDACConfig ( CMP_Type *  base,
const acmp_dac_config_t config 
)

Configures the internal DAC.

Example:

acmp_dac_config_t configStruct = {0};
configStruct.DACValue = 20U;
configStruct.enableOutput = false;
ACMP_SetDACConfig(CMP0, &configStruct);
uint32_t DACValue
Definition fsl_acmp.h:154
void ACMP_SetDACConfig(CMP_Type *base, const acmp_dac_config_t *config)
Configures the internal DAC.
Definition fsl_acmp.c:348
acmp_reference_voltage_source_t referenceVoltageSource
Definition fsl_acmp.h:153
acmp_dac_work_mode_t workMode
Definition fsl_acmp.h:161
Configuration for DAC.
Definition fsl_acmp.h:152
Parameters
baseACMP peripheral base address.
configPointer to DAC configuration structure. "NULL" is for disabling the feature.

brief Configures the internal DAC.

Example: code acmp_dac_config_t configStruct = {0}; configStruct.referenceVoltageSource = kACMP_VrefSourceVin1; configStruct.DACValue = 20U; configStruct.enableOutput = false; configStruct.workMode = kACMP_DACWorkLowSpeedMode; ACMP_SetDACConfig(CMP0, &configStruct); endcode

param base ACMP peripheral base address. param config Pointer to DAC configuration structure. "NULL" is for disabling the feature.

Definition at line 348 of file fsl_acmp.c.

349{
350 uint32_t tmp32;
351
352 /* CMPx_C1
353 * NULL configuration means to disable the feature.
354 */
355 if (NULL == config)
356 {
357 base->C1 &= ~CMP_C1_DACEN_MASK;
358 return;
359 }
360
361 tmp32 = (base->C1 & (~(CMP_C1_VRSEL_MASK | CMP_C1_VOSEL_MASK)));
362 /* Set configuration and enable the feature. */
363 tmp32 |= (CMP_C1_VRSEL(config->referenceVoltageSource) | CMP_C1_VOSEL(config->DACValue) | CMP_C1_DACEN_MASK);
364
365#if defined(FSL_FEATURE_ACMP_HAS_C1_DACOE_BIT) && (FSL_FEATURE_ACMP_HAS_C1_DACOE_BIT == 1U)
366 tmp32 &= ~CMP_C1_DACOE_MASK;
367 if (config->enableOutput)
368 {
369 tmp32 |= CMP_C1_DACOE_MASK;
370 }
371#endif /* FSL_FEATURE_ACMP_HAS_C1_DACOE_BIT */
372
373#if defined(FSL_FEATURE_ACMP_HAS_C1_DMODE_BIT) && (FSL_FEATURE_ACMP_HAS_C1_DMODE_BIT == 1U)
374 switch (config->workMode)
375 {
377 tmp32 &= ~CMP_C1_DMODE_MASK;
378 break;
380 tmp32 |= CMP_C1_DMODE_MASK;
381 break;
382 default:
383 break;
384 }
385#endif /* FSL_FEATURE_ACMP_HAS_C1_DMODE_BIT */
386
387 base->C1 = tmp32;
388}

Referenced by comp_lld_set_dac_value().

Here is the caller graph for this function:

◆ ACMP_SetDiscreteModeConfig()

void ACMP_SetDiscreteModeConfig ( CMP_Type *  base,
const acmp_discrete_mode_config_t config 
)

Configure the discrete mode.

Configure the discrete mode when supporting 3V domain with 1.8V core.

Parameters
baseACMP peripheral base address.
configPointer to configuration structure. See "acmp_discrete_mode_config_t".

brief Configure the discrete mode.

Configure the discrete mode when supporting 3V domain with 1.8V core.

param base ACMP peripheral base address. param config Pointer to configuration structure. See "acmp_discrete_mode_config_t".

Definition at line 615 of file fsl_acmp.c.

616{
617 uint32_t tmp32 = 0U;
618
619 if (!config->enablePositiveChannelDiscreteMode)
620 {
621 tmp32 |= CMP_C3_PCHCTEN_MASK;
622 }
623 if (!config->enableNegativeChannelDiscreteMode)
624 {
625 tmp32 |= CMP_C3_NCHCTEN_MASK;
626 }
627 if (config->enableResistorDivider)
628 {
629 tmp32 |= CMP_C3_RDIVE_MASK;
630 }
631
632 tmp32 |= CMP_C3_DMCS(config->clockSource) /* Select the clock. */
633 | CMP_C3_ACSAT(config->sampleTime) /* Sample time period. */
634 | CMP_C3_ACPH1TC(config->phase1Time) /* Phase 1 sample time. */
635 | CMP_C3_ACPH2TC(config->phase2Time); /* Phase 2 sample time. */
636
637 base->C3 = tmp32;
638}

◆ ACMP_SetFilterConfig()

void ACMP_SetFilterConfig ( CMP_Type *  base,
const acmp_filter_config_t config 
)

Configures the filter.

The filter can be enabled when the filter count is bigger than 1, the filter period is greater than 0 and the sample clock is from divided bus clock or the filter is bigger than 1 and the sample clock is from external clock. Detailed usage can be got from the reference manual.

Example:

acmp_filter_config_t configStruct = {0};
configStruct.filterCount = 5U;
configStruct.filterPeriod = 200U;
configStruct.enableSample = false;
ACMP_SetFilterConfig(CMP0, &configStruct);
void ACMP_SetFilterConfig(CMP_Type *base, const acmp_filter_config_t *config)
Configures the filter.
Definition fsl_acmp.c:315
uint32_t filterPeriod
Definition fsl_acmp.h:147
uint32_t filterCount
Definition fsl_acmp.h:146
Configuration for filter.
Definition fsl_acmp.h:144
Parameters
baseACMP peripheral base address.
configPointer to filter configuration structure.

brief Configures the filter.

The filter can be enabled when the filter count is bigger than 1, the filter period is greater than 0 and the sample clock is from divided bus clock or the filter is bigger than 1 and the sample clock is from external clock. Detailed usage can be got from the reference manual.

Example: code acmp_filter_config_t configStruct = {0}; configStruct.filterCount = 5U; configStruct.filterPeriod = 200U; configStruct.enableSample = false; ACMP_SetFilterConfig(CMP0, &configStruct); endcode

param base ACMP peripheral base address. param config Pointer to filter configuration structure.

Definition at line 315 of file fsl_acmp.c.

316{
317 assert(NULL != config);
318
319 /* CMPx_C0
320 * Set control bit. Avoid clearing status flags at the same time.
321 */
322 uint32_t tmp32 = (base->C0 & (~(CMP_C0_FILTER_CNT_MASK | CMP_C0_FPR_MASK | CMP_C0_SE_MASK | CMP_C0_CFx_MASK)));
323
324 if (config->enableSample)
325 {
326 tmp32 |= CMP_C0_SE_MASK;
327 }
328 tmp32 |= (CMP_C0_FILTER_CNT(config->filterCount) | CMP_C0_FPR(config->filterPeriod));
329 base->C0 = tmp32;
330}

Referenced by comp_lld_start().

Here is the caller graph for this function:

◆ ACMP_SetRoundRobinConfig()

void ACMP_SetRoundRobinConfig ( CMP_Type *  base,
const acmp_round_robin_config_t config 
)

Configures the round robin mode.

Example:

acmp_round_robin_config_t configStruct = {0};
configStruct.fixedChannelNumber = 3U;
configStruct.checkerChannelMask = 0xF7U;
configStruct.sampleClockCount = 0U;
configStruct.delayModulus = 0U;
ACMP_SetRoundRobinConfig(CMP0, &configStruct);
acmp_fixed_port_t fixedPort
Definition fsl_acmp.h:168
void ACMP_SetRoundRobinConfig(CMP_Type *base, const acmp_round_robin_config_t *config)
Configures the round robin mode.
Definition fsl_acmp.c:406
Configuration for round robin mode.
Definition fsl_acmp.h:167
Parameters
baseACMP peripheral base address.
configPointer to round robin mode configuration structure. "NULL" is for disabling the feature.

brief Configures the round robin mode.

Example: code acmp_round_robin_config_t configStruct = {0}; configStruct.fixedPort = kACMP_FixedPlusPort; configStruct.fixedChannelNumber = 3U; configStruct.checkerChannelMask = 0xF7U; configStruct.sampleClockCount = 0U; configStruct.delayModulus = 0U; ACMP_SetRoundRobinConfig(CMP0, &configStruct); endcode param base ACMP peripheral base address. param config Pointer to round robin mode configuration structure. "NULL" is for disabling the feature.

Definition at line 406 of file fsl_acmp.c.

407{
408 uint32_t tmp32;
409
410 /* CMPx_C2
411 * Set control bit. Avoid clearing status flags at the same time.
412 * NULL configuration means to disable the feature.
413 */
414 if (NULL == config)
415 {
416 tmp32 = CMP_C2_CHnF_MASK;
417#if defined(FSL_FEATURE_ACMP_HAS_C2_RRE_BIT) && (FSL_FEATURE_ACMP_HAS_C2_RRE_BIT == 1U)
418 tmp32 |= CMP_C2_RRE_MASK;
419#endif /* FSL_FEATURE_ACMP_HAS_C2_RRE_BIT */
420 base->C2 &= ~(tmp32);
421 return;
422 }
423
424 /* CMPx_C1
425 * Set all channel's round robin checker enable mask.
426 */
427 tmp32 = (base->C1 & ~(CMP_C1_CHNn_MASK));
428 tmp32 |= ((config->checkerChannelMask) << CMP_C1_CHN0_SHIFT);
429 base->C1 = tmp32;
430
431 /* CMPx_C2
432 * Set configuration and enable the feature.
433 */
434 tmp32 = (base->C2 &
435 (~(CMP_C2_FXMP_MASK | CMP_C2_FXMXCH_MASK | CMP_C2_NSAM_MASK | CMP_C2_INITMOD_MASK | CMP_C2_CHnF_MASK)));
436 tmp32 |= (CMP_C2_FXMP(config->fixedPort) | CMP_C2_FXMXCH(config->fixedChannelNumber) |
437 CMP_C2_NSAM(config->sampleClockCount) | CMP_C2_INITMOD(config->delayModulus));
438#if defined(FSL_FEATURE_ACMP_HAS_C2_RRE_BIT) && (FSL_FEATURE_ACMP_HAS_C2_RRE_BIT == 1U)
439 tmp32 |= CMP_C2_RRE_MASK;
440#endif /* FSL_FEATURE_ACMP_HAS_C2_RRE_BIT */
441 base->C2 = tmp32;
442}

◆ ACMP_SetRoundRobinPreState()

void ACMP_SetRoundRobinPreState ( CMP_Type *  base,
uint32_t  mask 
)

Defines the pre-set state of channels in round robin mode.

Note: The pre-state has different circuit with get-round-robin-result in the SOC even though they are same bits. So get-round-robin-result can't return the same value as the value are set by pre-state.

Parameters
baseACMP peripheral base address.
maskMask of round robin channel index. Available range is channel0:0x01 to channel7:0x80.

brief Defines the pre-set state of channels in round robin mode.

Note: The pre-state has different circuit with get-round-robin-result in the SOC even though they are same bits. So get-round-robin-result can't return the same value as the value are set by pre-state.

param base ACMP peripheral base address. param mask Mask of round robin channel index. Available range is channel0:0x01 to channel7:0x80.

Definition at line 453 of file fsl_acmp.c.

454{
455 /* CMPx_C2
456 * Set control bit. Avoid clearing status flags at the same time.
457 */
458 uint32_t tmp32 = (base->C2 & ~(CMP_C2_ACOn_MASK | CMP_C2_CHnF_MASK));
459
460 tmp32 |= (mask << CMP_C2_ACOn_SHIFT);
461 base->C2 = tmp32;
462}

Variable Documentation

◆ checkerChannelMask

uint32_t _acmp_round_robin_config::checkerChannelMask

Mask of checker channel index. Available range is channel0:0x01 to channel7:0x80 for round-robin checker.

Definition at line 170 of file fsl_acmp.h.

◆ clockSource

acmp_discrete_clock_source_t _acmp_discrete_mode_config::clockSource

Select the clock source in order to generate the requiried timing for comparator to work in discrete mode.

Definition at line 227 of file fsl_acmp.h.

◆ DACValue

uint32_t _acmp_dac_config::DACValue

Value for DAC Output Voltage. Available range is 0-63.

Definition at line 154 of file fsl_acmp.h.

Referenced by comp_lld_set_dac_value().

◆ delayModulus

uint32_t _acmp_round_robin_config::delayModulus

Comparator and DAC initialization delay modulus.

Definition at line 173 of file fsl_acmp.h.

◆ enableHighSpeed

bool _acmp_config::enableHighSpeed

Enable High Speed (HS) comparison mode.

Definition at line 118 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ enableInvertOutput

bool _acmp_config::enableInvertOutput

Enable inverted comparator output.

Definition at line 119 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ enableNegativeChannelDiscreteMode

bool _acmp_discrete_mode_config::enableNegativeChannelDiscreteMode

Negative Channel Continuous Mode Enable. By default, the continuous mode is used.

Definition at line 223 of file fsl_acmp.h.

◆ enableOutput

bool _acmp_dac_config::enableOutput

Enable the DAC output.

Definition at line 157 of file fsl_acmp.h.

◆ enablePinOut

bool _acmp_config::enablePinOut

The comparator output is available on the associated pin.

Definition at line 121 of file fsl_acmp.h.

◆ enablePositiveChannelDiscreteMode

bool _acmp_discrete_mode_config::enablePositiveChannelDiscreteMode

Positive Channel Continuous Mode Enable. By default, the continuous mode is used.

Definition at line 221 of file fsl_acmp.h.

◆ enableResistorDivider

bool _acmp_discrete_mode_config::enableResistorDivider

Resistor Divider Enable is used to enable the resistor divider for the inputs when they come from 3v domain and their values are above 1.8v.

Definition at line 225 of file fsl_acmp.h.

◆ enableSample

bool _acmp_filter_config::enableSample

Using external SAMPLE as sampling clock input, or using divided bus clock.

Definition at line 145 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ filterCount

uint32_t _acmp_filter_config::filterCount

Filter Sample Count. Available range is 1-7, 0 would cause the filter disabled.

Definition at line 146 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ filterPeriod

uint32_t _acmp_filter_config::filterPeriod

Filter Sample Period. The divider to bus clock. Available range is 0-255.

Definition at line 147 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ fixedChannelNumber

uint32_t _acmp_round_robin_config::fixedChannelNumber

Indicates which channel is fixed in the fixed mux port.

Definition at line 169 of file fsl_acmp.h.

◆ fixedPort

acmp_fixed_port_t _acmp_round_robin_config::fixedPort

Fixed mux port.

Definition at line 168 of file fsl_acmp.h.

◆ hysteresisMode

acmp_hysteresis_mode_t _acmp_config::hysteresisMode

Hysteresis mode.

Definition at line 117 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ minusMuxInput

uint32_t _acmp_channel_config::minusMuxInput

Minus mux input channel(0~7).

Definition at line 139 of file fsl_acmp.h.

Referenced by comp_lld_channel_enable().

◆ negativePortInput

acmp_port_input_t _acmp_channel_config::negativePortInput

Input source of the comparator's negative port.

Definition at line 137 of file fsl_acmp.h.

Referenced by comp_lld_channel_enable().

◆ offsetMode

acmp_offset_mode_t _acmp_config::offsetMode

Offset mode.

Definition at line 115 of file fsl_acmp.h.

◆ phase1Time

acmp_discrete_phase_time_t _acmp_discrete_mode_config::phase1Time

Select the ACMP phase 1 sampling time.

Definition at line 230 of file fsl_acmp.h.

◆ phase2Time

acmp_discrete_phase_time_t _acmp_discrete_mode_config::phase2Time

Select the ACMP phase 2 sampling time.

Definition at line 231 of file fsl_acmp.h.

◆ plusMuxInput

uint32_t _acmp_channel_config::plusMuxInput

Plus mux input channel(0~7).

Definition at line 135 of file fsl_acmp.h.

Referenced by comp_lld_channel_enable().

◆ positivePortInput

acmp_port_input_t _acmp_channel_config::positivePortInput

Input source of the comparator's positive port.

Definition at line 133 of file fsl_acmp.h.

Referenced by comp_lld_channel_enable().

◆ referenceVoltageSource

acmp_reference_voltage_source_t _acmp_dac_config::referenceVoltageSource

Supply voltage reference source.

Definition at line 153 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ sampleClockCount

uint32_t _acmp_round_robin_config::sampleClockCount

Specifies how many round-robin clock cycles(0~3) later the sample takes place.

Definition at line 172 of file fsl_acmp.h.

◆ sampleTime

acmp_discrete_sample_time_t _acmp_discrete_mode_config::sampleTime

Select the ACMP total sampling time period.

Definition at line 229 of file fsl_acmp.h.

◆ useUnfilteredOutput

bool _acmp_config::useUnfilteredOutput

Set compare output(COUT) to equal COUTA(true) or COUT(false).

Definition at line 120 of file fsl_acmp.h.

Referenced by comp_lld_start().

◆ workMode

acmp_dac_work_mode_t _acmp_dac_config::workMode

Definition at line 161 of file fsl_acmp.h.