RTEMS 6.1-rc4
Loading...
Searching...
No Matches
fsl_cmp.h
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright 2016-2019 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_CMP_H_
10#define _FSL_CMP_H_
11
12#include "fsl_common.h"
13
19/*******************************************************************************
20 * Definitions
21 ******************************************************************************/
22
26#define FSL_CMP_DRIVER_VERSION (MAKE_VERSION(2, 0, 2))
33{
36};
37
42{
43 kCMP_OutputRisingEventFlag = CMP_SCR_CFR_MASK,
44 kCMP_OutputFallingEventFlag = CMP_SCR_CFF_MASK,
45 kCMP_OutputAssertEventFlag = CMP_SCR_COUT_MASK,
46};
47
52{
58
63{
67
71typedef struct _cmp_config
72{
73 bool enableCmp;
79#if defined(FSL_FEATURE_CMP_HAS_TRIGGER_MODE) && FSL_FEATURE_CMP_HAS_TRIGGER_MODE
80 bool enableTriggerMode;
81#endif /* FSL_FEATURE_CMP_HAS_TRIGGER_MODE */
83
87typedef struct _cmp_filter_config
88{
89#if defined(FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT) && FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT
90 bool enableSample;
91#endif /* FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT */
92 uint8_t filterCount;
93 uint8_t filterPeriod;
95
99typedef struct _cmp_dac_config
100{
102 uint8_t DACValue;
104
105#if defined(__cplusplus)
106extern "C" {
107#endif
108
109/*******************************************************************************
110 * API
111 ******************************************************************************/
112
131void CMP_Init(CMP_Type *base, const cmp_config_t *config);
132
146void CMP_Deinit(CMP_Type *base);
147
154static inline void CMP_Enable(CMP_Type *base, bool enable)
155{
156 if (enable)
157 {
158 base->CR1 |= CMP_CR1_EN_MASK;
159 }
160 else
161 {
162 base->CR1 &= ~(uint8_t)CMP_CR1_EN_MASK;
163 }
164}
165
182
194void CMP_SetInputChannels(CMP_Type *base, uint8_t positiveChannel, uint8_t negativeChannel);
195
196/* @} */
197
203#if defined(FSL_FEATURE_CMP_HAS_DMA) && FSL_FEATURE_CMP_HAS_DMA
215void CMP_EnableDMA(CMP_Type *base, bool enable);
216#endif /* FSL_FEATURE_CMP_HAS_DMA */
217
218#if defined(FSL_FEATURE_CMP_HAS_WINDOW_MODE) && FSL_FEATURE_CMP_HAS_WINDOW_MODE
225static inline void CMP_EnableWindowMode(CMP_Type *base, bool enable)
226{
227 if (enable)
228 {
229 base->CR1 |= CMP_CR1_WE_MASK;
230 }
231 else
232 {
233 base->CR1 &= (uint8_t)(~CMP_CR1_WE_MASK);
234 }
235}
236#endif /* FSL_FEATURE_CMP_HAS_WINDOW_MODE */
237
238#if defined(FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE) && FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE
245static inline void CMP_EnablePassThroughMode(CMP_Type *base, bool enable)
246{
247 if (enable)
248 {
249 base->MUXCR |= CMP_MUXCR_PSTM_MASK;
250 }
251 else
252 {
253 base->MUXCR &= (uint8_t)(~CMP_MUXCR_PSTM_MASK);
254 }
255}
256#endif /* FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE */
257
265
273
280void CMP_EnableInterrupts(CMP_Type *base, uint32_t mask);
281
288void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask);
289
290/* @} */
291
304uint32_t CMP_GetStatusFlags(CMP_Type *base);
305
312void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask);
313
314/* @} */
315#if defined(__cplusplus)
316}
317#endif
321#endif /* _FSL_CMP_H_ */
uint8_t filterPeriod
Definition: fsl_cmp.h:93
void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask)
Disables the interrupts.
Definition: fsl_cmp.c:311
cmp_hysteresis_mode_t hysteresisMode
Definition: fsl_cmp.h:74
uint32_t CMP_GetStatusFlags(CMP_Type *base)
Gets the status flags.
Definition: fsl_cmp.c:333
void CMP_Deinit(CMP_Type *base)
De-initializes the CMP module.
Definition: fsl_cmp.c:134
struct _cmp_config cmp_config_t
Configures the comparator.
void CMP_SetFilterConfig(CMP_Type *base, const cmp_filter_config_t *config)
Configures the filter.
Definition: fsl_cmp.c:232
bool enableHighSpeed
Definition: fsl_cmp.h:75
void CMP_SetDACConfig(CMP_Type *base, const cmp_dac_config_t *config)
Configures the internal DAC.
Definition: fsl_cmp.c:263
void CMP_Init(CMP_Type *base, const cmp_config_t *config)
Initializes the CMP.
Definition: fsl_cmp.c:70
void CMP_SetInputChannels(CMP_Type *base, uint8_t positiveChannel, uint8_t negativeChannel)
Sets the input channels for the comparator.
Definition: fsl_cmp.c:189
_cmp_reference_voltage_source
CMP Voltage Reference source.
Definition: fsl_cmp.h:63
_cmp_status_flags
Status flags' mask.
Definition: fsl_cmp.h:42
_cmp_interrupt_enable
Interrupt enable/disable mask.
Definition: fsl_cmp.h:33
_cmp_hysteresis_mode
CMP Hysteresis mode.
Definition: fsl_cmp.h:52
void CMP_EnableInterrupts(CMP_Type *base, uint32_t mask)
Enables the interrupts.
Definition: fsl_cmp.c:290
bool useUnfilteredOutput
Definition: fsl_cmp.h:77
struct _cmp_dac_config cmp_dac_config_t
Configures the internal DAC.
cmp_reference_voltage_source_t referenceVoltageSource
Definition: fsl_cmp.h:101
uint8_t DACValue
Definition: fsl_cmp.h:102
enum _cmp_hysteresis_mode cmp_hysteresis_mode_t
CMP Hysteresis mode.
enum _cmp_reference_voltage_source cmp_reference_voltage_source_t
CMP Voltage Reference source.
struct _cmp_filter_config cmp_filter_config_t
Configures the filter.
void CMP_GetDefaultConfig(cmp_config_t *config)
Initializes the CMP user configuration structure.
Definition: fsl_cmp.c:160
bool enableInvertOutput
Definition: fsl_cmp.h:76
void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask)
Clears the status flags.
Definition: fsl_cmp.c:358
uint8_t filterCount
Definition: fsl_cmp.h:92
bool enablePinOut
Definition: fsl_cmp.h:78
bool enableCmp
Definition: fsl_cmp.h:73
@ kCMP_VrefSourceVin2
Definition: fsl_cmp.h:65
@ kCMP_VrefSourceVin1
Definition: fsl_cmp.h:64
@ kCMP_OutputFallingEventFlag
Definition: fsl_cmp.h:44
@ kCMP_OutputAssertEventFlag
Definition: fsl_cmp.h:45
@ kCMP_OutputRisingEventFlag
Definition: fsl_cmp.h:43
@ kCMP_OutputRisingInterruptEnable
Definition: fsl_cmp.h:34
@ kCMP_OutputFallingInterruptEnable
Definition: fsl_cmp.h:35
@ kCMP_HysteresisLevel1
Definition: fsl_cmp.h:54
@ kCMP_HysteresisLevel0
Definition: fsl_cmp.h:53
@ kCMP_HysteresisLevel3
Definition: fsl_cmp.h:56
@ kCMP_HysteresisLevel2
Definition: fsl_cmp.h:55
Definition: MIMXRT1052.h:10267
Configures the comparator.
Definition: fsl_cmp.h:72
Configures the internal DAC.
Definition: fsl_cmp.h:100
Configures the filter.
Definition: fsl_cmp.h:88
Definition: deflate.c:114