The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_K66F/TOOLCHAIN_IAR/fsl_cmp.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_RO359B/TARGET_Freescale/TARGET_MCUXpresso_MCUS/TARGET_MCU_K24F/drivers/fsl_cmp.h@143:86740a56073b
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 143:86740a56073b | 1 | /* |
AnnaBridge | 143:86740a56073b | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
AnnaBridge | 143:86740a56073b | 3 | * Copyright 2016-2017 NXP |
AnnaBridge | 143:86740a56073b | 4 | * |
AnnaBridge | 143:86740a56073b | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 143:86740a56073b | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 143:86740a56073b | 7 | * |
AnnaBridge | 143:86740a56073b | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 143:86740a56073b | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 143:86740a56073b | 10 | * |
AnnaBridge | 143:86740a56073b | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 143:86740a56073b | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 143:86740a56073b | 13 | * other materials provided with the distribution. |
AnnaBridge | 143:86740a56073b | 14 | * |
AnnaBridge | 143:86740a56073b | 15 | * o Neither the name of the copyright holder nor the names of its |
AnnaBridge | 143:86740a56073b | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 143:86740a56073b | 17 | * software without specific prior written permission. |
AnnaBridge | 143:86740a56073b | 18 | * |
AnnaBridge | 143:86740a56073b | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 143:86740a56073b | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 143:86740a56073b | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 143:86740a56073b | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 143:86740a56073b | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 143:86740a56073b | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 143:86740a56073b | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 143:86740a56073b | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 143:86740a56073b | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 143:86740a56073b | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 143:86740a56073b | 29 | */ |
AnnaBridge | 143:86740a56073b | 30 | |
AnnaBridge | 143:86740a56073b | 31 | #ifndef _FSL_CMP_H_ |
AnnaBridge | 143:86740a56073b | 32 | #define _FSL_CMP_H_ |
AnnaBridge | 143:86740a56073b | 33 | |
AnnaBridge | 143:86740a56073b | 34 | #include "fsl_common.h" |
AnnaBridge | 143:86740a56073b | 35 | |
AnnaBridge | 143:86740a56073b | 36 | /*! |
AnnaBridge | 143:86740a56073b | 37 | * @addtogroup cmp |
AnnaBridge | 143:86740a56073b | 38 | * @{ |
AnnaBridge | 143:86740a56073b | 39 | */ |
AnnaBridge | 143:86740a56073b | 40 | |
AnnaBridge | 143:86740a56073b | 41 | |
AnnaBridge | 143:86740a56073b | 42 | /******************************************************************************* |
AnnaBridge | 143:86740a56073b | 43 | * Definitions |
AnnaBridge | 143:86740a56073b | 44 | ******************************************************************************/ |
AnnaBridge | 143:86740a56073b | 45 | |
AnnaBridge | 143:86740a56073b | 46 | /*! @name Driver version */ |
AnnaBridge | 143:86740a56073b | 47 | /*@{*/ |
AnnaBridge | 143:86740a56073b | 48 | /*! @brief CMP driver version 2.0.0. */ |
AnnaBridge | 143:86740a56073b | 49 | #define FSL_CMP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
AnnaBridge | 143:86740a56073b | 50 | /*@}*/ |
AnnaBridge | 143:86740a56073b | 51 | |
AnnaBridge | 143:86740a56073b | 52 | /*! |
AnnaBridge | 143:86740a56073b | 53 | * @brief Interrupt enable/disable mask. |
AnnaBridge | 143:86740a56073b | 54 | */ |
AnnaBridge | 143:86740a56073b | 55 | enum _cmp_interrupt_enable |
AnnaBridge | 143:86740a56073b | 56 | { |
AnnaBridge | 143:86740a56073b | 57 | kCMP_OutputRisingInterruptEnable = CMP_SCR_IER_MASK, /*!< Comparator interrupt enable rising. */ |
AnnaBridge | 143:86740a56073b | 58 | kCMP_OutputFallingInterruptEnable = CMP_SCR_IEF_MASK, /*!< Comparator interrupt enable falling. */ |
AnnaBridge | 143:86740a56073b | 59 | }; |
AnnaBridge | 143:86740a56073b | 60 | |
AnnaBridge | 143:86740a56073b | 61 | /*! |
AnnaBridge | 143:86740a56073b | 62 | * @brief Status flags' mask. |
AnnaBridge | 143:86740a56073b | 63 | */ |
AnnaBridge | 143:86740a56073b | 64 | enum _cmp_status_flags |
AnnaBridge | 143:86740a56073b | 65 | { |
AnnaBridge | 143:86740a56073b | 66 | kCMP_OutputRisingEventFlag = CMP_SCR_CFR_MASK, /*!< Rising-edge on the comparison output has occurred. */ |
AnnaBridge | 143:86740a56073b | 67 | kCMP_OutputFallingEventFlag = CMP_SCR_CFF_MASK, /*!< Falling-edge on the comparison output has occurred. */ |
AnnaBridge | 143:86740a56073b | 68 | kCMP_OutputAssertEventFlag = CMP_SCR_COUT_MASK, /*!< Return the current value of the analog comparator output. */ |
AnnaBridge | 143:86740a56073b | 69 | }; |
AnnaBridge | 143:86740a56073b | 70 | |
AnnaBridge | 143:86740a56073b | 71 | /*! |
AnnaBridge | 143:86740a56073b | 72 | * @brief CMP Hysteresis mode. |
AnnaBridge | 143:86740a56073b | 73 | */ |
AnnaBridge | 143:86740a56073b | 74 | typedef enum _cmp_hysteresis_mode |
AnnaBridge | 143:86740a56073b | 75 | { |
AnnaBridge | 143:86740a56073b | 76 | kCMP_HysteresisLevel0 = 0U, /*!< Hysteresis level 0. */ |
AnnaBridge | 143:86740a56073b | 77 | kCMP_HysteresisLevel1 = 1U, /*!< Hysteresis level 1. */ |
AnnaBridge | 143:86740a56073b | 78 | kCMP_HysteresisLevel2 = 2U, /*!< Hysteresis level 2. */ |
AnnaBridge | 143:86740a56073b | 79 | kCMP_HysteresisLevel3 = 3U, /*!< Hysteresis level 3. */ |
AnnaBridge | 143:86740a56073b | 80 | } cmp_hysteresis_mode_t; |
AnnaBridge | 143:86740a56073b | 81 | |
AnnaBridge | 143:86740a56073b | 82 | /*! |
AnnaBridge | 143:86740a56073b | 83 | * @brief CMP Voltage Reference source. |
AnnaBridge | 143:86740a56073b | 84 | */ |
AnnaBridge | 143:86740a56073b | 85 | typedef enum _cmp_reference_voltage_source |
AnnaBridge | 143:86740a56073b | 86 | { |
AnnaBridge | 143:86740a56073b | 87 | kCMP_VrefSourceVin1 = 0U, /*!< Vin1 is selected as a resistor ladder network supply reference Vin. */ |
AnnaBridge | 143:86740a56073b | 88 | kCMP_VrefSourceVin2 = 1U, /*!< Vin2 is selected as a resistor ladder network supply reference Vin. */ |
AnnaBridge | 143:86740a56073b | 89 | } cmp_reference_voltage_source_t; |
AnnaBridge | 143:86740a56073b | 90 | |
AnnaBridge | 143:86740a56073b | 91 | /*! |
AnnaBridge | 143:86740a56073b | 92 | * @brief Configures the comparator. |
AnnaBridge | 143:86740a56073b | 93 | */ |
AnnaBridge | 143:86740a56073b | 94 | typedef struct _cmp_config |
AnnaBridge | 143:86740a56073b | 95 | { |
AnnaBridge | 143:86740a56073b | 96 | bool enableCmp; /*!< Enable the CMP module. */ |
AnnaBridge | 143:86740a56073b | 97 | cmp_hysteresis_mode_t hysteresisMode; /*!< CMP Hysteresis mode. */ |
AnnaBridge | 143:86740a56073b | 98 | bool enableHighSpeed; /*!< Enable High-speed (HS) comparison mode. */ |
AnnaBridge | 143:86740a56073b | 99 | bool enableInvertOutput; /*!< Enable the inverted comparator output. */ |
AnnaBridge | 143:86740a56073b | 100 | bool useUnfilteredOutput; /*!< Set the compare output(COUT) to equal COUTA(true) or COUT(false). */ |
AnnaBridge | 143:86740a56073b | 101 | bool enablePinOut; /*!< The comparator output is available on the associated pin. */ |
AnnaBridge | 143:86740a56073b | 102 | #if defined(FSL_FEATURE_CMP_HAS_TRIGGER_MODE) && FSL_FEATURE_CMP_HAS_TRIGGER_MODE |
AnnaBridge | 143:86740a56073b | 103 | bool enableTriggerMode; /*!< Enable the trigger mode. */ |
AnnaBridge | 143:86740a56073b | 104 | #endif /* FSL_FEATURE_CMP_HAS_TRIGGER_MODE */ |
AnnaBridge | 143:86740a56073b | 105 | } cmp_config_t; |
AnnaBridge | 143:86740a56073b | 106 | |
AnnaBridge | 143:86740a56073b | 107 | /*! |
AnnaBridge | 143:86740a56073b | 108 | * @brief Configures the filter. |
AnnaBridge | 143:86740a56073b | 109 | */ |
AnnaBridge | 143:86740a56073b | 110 | typedef struct _cmp_filter_config |
AnnaBridge | 143:86740a56073b | 111 | { |
AnnaBridge | 143:86740a56073b | 112 | #if defined(FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT) && FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT |
AnnaBridge | 143:86740a56073b | 113 | bool enableSample; /*!< Using the external SAMPLE as a sampling clock input or using a divided bus clock. */ |
AnnaBridge | 143:86740a56073b | 114 | #endif /* FSL_FEATURE_CMP_HAS_EXTERNAL_SAMPLE_SUPPORT */ |
AnnaBridge | 143:86740a56073b | 115 | uint8_t filterCount; /*!< Filter Sample Count. Available range is 1-7; 0 disables the filter.*/ |
AnnaBridge | 143:86740a56073b | 116 | uint8_t filterPeriod; /*!< Filter Sample Period. The divider to the bus clock. Available range is 0-255. */ |
AnnaBridge | 143:86740a56073b | 117 | } cmp_filter_config_t; |
AnnaBridge | 143:86740a56073b | 118 | |
AnnaBridge | 143:86740a56073b | 119 | /*! |
AnnaBridge | 143:86740a56073b | 120 | * @brief Configures the internal DAC. |
AnnaBridge | 143:86740a56073b | 121 | */ |
AnnaBridge | 143:86740a56073b | 122 | typedef struct _cmp_dac_config |
AnnaBridge | 143:86740a56073b | 123 | { |
AnnaBridge | 143:86740a56073b | 124 | cmp_reference_voltage_source_t referenceVoltageSource; /*!< Supply voltage reference source. */ |
AnnaBridge | 143:86740a56073b | 125 | uint8_t DACValue; /*!< Value for the DAC Output Voltage. Available range is 0-63.*/ |
AnnaBridge | 143:86740a56073b | 126 | } cmp_dac_config_t; |
AnnaBridge | 143:86740a56073b | 127 | |
AnnaBridge | 143:86740a56073b | 128 | #if defined(__cplusplus) |
AnnaBridge | 143:86740a56073b | 129 | extern "C" { |
AnnaBridge | 143:86740a56073b | 130 | #endif |
AnnaBridge | 143:86740a56073b | 131 | |
AnnaBridge | 143:86740a56073b | 132 | /******************************************************************************* |
AnnaBridge | 143:86740a56073b | 133 | * API |
AnnaBridge | 143:86740a56073b | 134 | ******************************************************************************/ |
AnnaBridge | 143:86740a56073b | 135 | |
AnnaBridge | 143:86740a56073b | 136 | /*! |
AnnaBridge | 143:86740a56073b | 137 | * @name Initialization |
AnnaBridge | 143:86740a56073b | 138 | * @{ |
AnnaBridge | 143:86740a56073b | 139 | */ |
AnnaBridge | 143:86740a56073b | 140 | |
AnnaBridge | 143:86740a56073b | 141 | /*! |
AnnaBridge | 143:86740a56073b | 142 | * @brief Initializes the CMP. |
AnnaBridge | 143:86740a56073b | 143 | * |
AnnaBridge | 143:86740a56073b | 144 | * This function initializes the CMP module. The operations included are as follows. |
AnnaBridge | 143:86740a56073b | 145 | * - Enabling the clock for CMP module. |
AnnaBridge | 143:86740a56073b | 146 | * - Configuring the comparator. |
AnnaBridge | 143:86740a56073b | 147 | * - Enabling the CMP module. |
AnnaBridge | 143:86740a56073b | 148 | * Note that for some devices, multiple CMP instances share the same clock gate. In this case, to enable the clock for |
AnnaBridge | 143:86740a56073b | 149 | * any instance enables all CMPs. See the appropriate MCU reference manual for the clock assignment of the CMP. |
AnnaBridge | 143:86740a56073b | 150 | * |
AnnaBridge | 143:86740a56073b | 151 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 152 | * @param config Pointer to the configuration structure. |
AnnaBridge | 143:86740a56073b | 153 | */ |
AnnaBridge | 143:86740a56073b | 154 | void CMP_Init(CMP_Type *base, const cmp_config_t *config); |
AnnaBridge | 143:86740a56073b | 155 | |
AnnaBridge | 143:86740a56073b | 156 | /*! |
AnnaBridge | 143:86740a56073b | 157 | * @brief De-initializes the CMP module. |
AnnaBridge | 143:86740a56073b | 158 | * |
AnnaBridge | 143:86740a56073b | 159 | * This function de-initializes the CMP module. The operations included are as follows. |
AnnaBridge | 143:86740a56073b | 160 | * - Disabling the CMP module. |
AnnaBridge | 143:86740a56073b | 161 | * - Disabling the clock for CMP module. |
AnnaBridge | 143:86740a56073b | 162 | * |
AnnaBridge | 143:86740a56073b | 163 | * This function disables the clock for the CMP. |
AnnaBridge | 143:86740a56073b | 164 | * Note that for some devices, multiple CMP instances share the same clock gate. In this case, before disabling the |
AnnaBridge | 143:86740a56073b | 165 | * clock for the CMP, ensure that all the CMP instances are not used. |
AnnaBridge | 143:86740a56073b | 166 | * |
AnnaBridge | 143:86740a56073b | 167 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 168 | */ |
AnnaBridge | 143:86740a56073b | 169 | void CMP_Deinit(CMP_Type *base); |
AnnaBridge | 143:86740a56073b | 170 | |
AnnaBridge | 143:86740a56073b | 171 | /*! |
AnnaBridge | 143:86740a56073b | 172 | * @brief Enables/disables the CMP module. |
AnnaBridge | 143:86740a56073b | 173 | * |
AnnaBridge | 143:86740a56073b | 174 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 175 | * @param enable Enables or disables the module. |
AnnaBridge | 143:86740a56073b | 176 | */ |
AnnaBridge | 143:86740a56073b | 177 | static inline void CMP_Enable(CMP_Type *base, bool enable) |
AnnaBridge | 143:86740a56073b | 178 | { |
AnnaBridge | 143:86740a56073b | 179 | if (enable) |
AnnaBridge | 143:86740a56073b | 180 | { |
AnnaBridge | 143:86740a56073b | 181 | base->CR1 |= CMP_CR1_EN_MASK; |
AnnaBridge | 143:86740a56073b | 182 | } |
AnnaBridge | 143:86740a56073b | 183 | else |
AnnaBridge | 143:86740a56073b | 184 | { |
AnnaBridge | 143:86740a56073b | 185 | base->CR1 &= ~CMP_CR1_EN_MASK; |
AnnaBridge | 143:86740a56073b | 186 | } |
AnnaBridge | 143:86740a56073b | 187 | } |
AnnaBridge | 143:86740a56073b | 188 | |
AnnaBridge | 143:86740a56073b | 189 | /*! |
AnnaBridge | 143:86740a56073b | 190 | * @brief Initializes the CMP user configuration structure. |
AnnaBridge | 143:86740a56073b | 191 | * |
AnnaBridge | 143:86740a56073b | 192 | * This function initializes the user configuration structure to these default values. |
AnnaBridge | 143:86740a56073b | 193 | * @code |
AnnaBridge | 143:86740a56073b | 194 | * config->enableCmp = true; |
AnnaBridge | 143:86740a56073b | 195 | * config->hysteresisMode = kCMP_HysteresisLevel0; |
AnnaBridge | 143:86740a56073b | 196 | * config->enableHighSpeed = false; |
AnnaBridge | 143:86740a56073b | 197 | * config->enableInvertOutput = false; |
AnnaBridge | 143:86740a56073b | 198 | * config->useUnfilteredOutput = false; |
AnnaBridge | 143:86740a56073b | 199 | * config->enablePinOut = false; |
AnnaBridge | 143:86740a56073b | 200 | * config->enableTriggerMode = false; |
AnnaBridge | 143:86740a56073b | 201 | * @endcode |
AnnaBridge | 143:86740a56073b | 202 | * @param config Pointer to the configuration structure. |
AnnaBridge | 143:86740a56073b | 203 | */ |
AnnaBridge | 143:86740a56073b | 204 | void CMP_GetDefaultConfig(cmp_config_t *config); |
AnnaBridge | 143:86740a56073b | 205 | |
AnnaBridge | 143:86740a56073b | 206 | /*! |
AnnaBridge | 143:86740a56073b | 207 | * @brief Sets the input channels for the comparator. |
AnnaBridge | 143:86740a56073b | 208 | * |
AnnaBridge | 143:86740a56073b | 209 | * This function sets the input channels for the comparator. |
AnnaBridge | 143:86740a56073b | 210 | * Note that two input channels cannot be set the same way in the application. When the user selects the same input |
AnnaBridge | 143:86740a56073b | 211 | * from the analog mux to the positive and negative port, the comparator is disabled automatically. |
AnnaBridge | 143:86740a56073b | 212 | * |
AnnaBridge | 143:86740a56073b | 213 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 214 | * @param positiveChannel Positive side input channel number. Available range is 0-7. |
AnnaBridge | 143:86740a56073b | 215 | * @param negativeChannel Negative side input channel number. Available range is 0-7. |
AnnaBridge | 143:86740a56073b | 216 | */ |
AnnaBridge | 143:86740a56073b | 217 | void CMP_SetInputChannels(CMP_Type *base, uint8_t positiveChannel, uint8_t negativeChannel); |
AnnaBridge | 143:86740a56073b | 218 | |
AnnaBridge | 143:86740a56073b | 219 | /* @} */ |
AnnaBridge | 143:86740a56073b | 220 | |
AnnaBridge | 143:86740a56073b | 221 | /*! |
AnnaBridge | 143:86740a56073b | 222 | * @name Advanced Features |
AnnaBridge | 143:86740a56073b | 223 | * @{ |
AnnaBridge | 143:86740a56073b | 224 | */ |
AnnaBridge | 143:86740a56073b | 225 | |
AnnaBridge | 143:86740a56073b | 226 | #if defined(FSL_FEATURE_CMP_HAS_DMA) && FSL_FEATURE_CMP_HAS_DMA |
AnnaBridge | 143:86740a56073b | 227 | /*! |
AnnaBridge | 143:86740a56073b | 228 | * @brief Enables/disables the DMA request for rising/falling events. |
AnnaBridge | 143:86740a56073b | 229 | * |
AnnaBridge | 143:86740a56073b | 230 | * This function enables/disables the DMA request for rising/falling events. Either event triggers the generation of |
AnnaBridge | 143:86740a56073b | 231 | * the DMA request from CMP if the DMA feature is enabled. Both events are ignored for generating the DMA request from the CMP |
AnnaBridge | 143:86740a56073b | 232 | * if the DMA is disabled. |
AnnaBridge | 143:86740a56073b | 233 | * |
AnnaBridge | 143:86740a56073b | 234 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 235 | * @param enable Enables or disables the feature. |
AnnaBridge | 143:86740a56073b | 236 | */ |
AnnaBridge | 143:86740a56073b | 237 | void CMP_EnableDMA(CMP_Type *base, bool enable); |
AnnaBridge | 143:86740a56073b | 238 | #endif /* FSL_FEATURE_CMP_HAS_DMA */ |
AnnaBridge | 143:86740a56073b | 239 | |
AnnaBridge | 143:86740a56073b | 240 | #if defined(FSL_FEATURE_CMP_HAS_WINDOW_MODE) && FSL_FEATURE_CMP_HAS_WINDOW_MODE |
AnnaBridge | 143:86740a56073b | 241 | /*! |
AnnaBridge | 143:86740a56073b | 242 | * @brief Enables/disables the window mode. |
AnnaBridge | 143:86740a56073b | 243 | * |
AnnaBridge | 143:86740a56073b | 244 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 245 | * @param enable Enables or disables the feature. |
AnnaBridge | 143:86740a56073b | 246 | */ |
AnnaBridge | 143:86740a56073b | 247 | static inline void CMP_EnableWindowMode(CMP_Type *base, bool enable) |
AnnaBridge | 143:86740a56073b | 248 | { |
AnnaBridge | 143:86740a56073b | 249 | if (enable) |
AnnaBridge | 143:86740a56073b | 250 | { |
AnnaBridge | 143:86740a56073b | 251 | base->CR1 |= CMP_CR1_WE_MASK; |
AnnaBridge | 143:86740a56073b | 252 | } |
AnnaBridge | 143:86740a56073b | 253 | else |
AnnaBridge | 143:86740a56073b | 254 | { |
AnnaBridge | 143:86740a56073b | 255 | base->CR1 &= ~CMP_CR1_WE_MASK; |
AnnaBridge | 143:86740a56073b | 256 | } |
AnnaBridge | 143:86740a56073b | 257 | } |
AnnaBridge | 143:86740a56073b | 258 | #endif /* FSL_FEATURE_CMP_HAS_WINDOW_MODE */ |
AnnaBridge | 143:86740a56073b | 259 | |
AnnaBridge | 143:86740a56073b | 260 | #if defined(FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE) && FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE |
AnnaBridge | 143:86740a56073b | 261 | /*! |
AnnaBridge | 143:86740a56073b | 262 | * @brief Enables/disables the pass through mode. |
AnnaBridge | 143:86740a56073b | 263 | * |
AnnaBridge | 143:86740a56073b | 264 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 265 | * @param enable Enables or disables the feature. |
AnnaBridge | 143:86740a56073b | 266 | */ |
AnnaBridge | 143:86740a56073b | 267 | static inline void CMP_EnablePassThroughMode(CMP_Type *base, bool enable) |
AnnaBridge | 143:86740a56073b | 268 | { |
AnnaBridge | 143:86740a56073b | 269 | if (enable) |
AnnaBridge | 143:86740a56073b | 270 | { |
AnnaBridge | 143:86740a56073b | 271 | base->MUXCR |= CMP_MUXCR_PSTM_MASK; |
AnnaBridge | 143:86740a56073b | 272 | } |
AnnaBridge | 143:86740a56073b | 273 | else |
AnnaBridge | 143:86740a56073b | 274 | { |
AnnaBridge | 143:86740a56073b | 275 | base->MUXCR &= ~CMP_MUXCR_PSTM_MASK; |
AnnaBridge | 143:86740a56073b | 276 | } |
AnnaBridge | 143:86740a56073b | 277 | } |
AnnaBridge | 143:86740a56073b | 278 | #endif /* FSL_FEATURE_CMP_HAS_PASS_THROUGH_MODE */ |
AnnaBridge | 143:86740a56073b | 279 | |
AnnaBridge | 143:86740a56073b | 280 | /*! |
AnnaBridge | 143:86740a56073b | 281 | * @brief Configures the filter. |
AnnaBridge | 143:86740a56073b | 282 | * |
AnnaBridge | 143:86740a56073b | 283 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 284 | * @param config Pointer to the configuration structure. |
AnnaBridge | 143:86740a56073b | 285 | */ |
AnnaBridge | 143:86740a56073b | 286 | void CMP_SetFilterConfig(CMP_Type *base, const cmp_filter_config_t *config); |
AnnaBridge | 143:86740a56073b | 287 | |
AnnaBridge | 143:86740a56073b | 288 | /*! |
AnnaBridge | 143:86740a56073b | 289 | * @brief Configures the internal DAC. |
AnnaBridge | 143:86740a56073b | 290 | * |
AnnaBridge | 143:86740a56073b | 291 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 292 | * @param config Pointer to the configuration structure. "NULL" disables the feature. |
AnnaBridge | 143:86740a56073b | 293 | */ |
AnnaBridge | 143:86740a56073b | 294 | void CMP_SetDACConfig(CMP_Type *base, const cmp_dac_config_t *config); |
AnnaBridge | 143:86740a56073b | 295 | |
AnnaBridge | 143:86740a56073b | 296 | /*! |
AnnaBridge | 143:86740a56073b | 297 | * @brief Enables the interrupts. |
AnnaBridge | 143:86740a56073b | 298 | * |
AnnaBridge | 143:86740a56073b | 299 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 300 | * @param mask Mask value for interrupts. See "_cmp_interrupt_enable". |
AnnaBridge | 143:86740a56073b | 301 | */ |
AnnaBridge | 143:86740a56073b | 302 | void CMP_EnableInterrupts(CMP_Type *base, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 303 | |
AnnaBridge | 143:86740a56073b | 304 | /*! |
AnnaBridge | 143:86740a56073b | 305 | * @brief Disables the interrupts. |
AnnaBridge | 143:86740a56073b | 306 | * |
AnnaBridge | 143:86740a56073b | 307 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 308 | * @param mask Mask value for interrupts. See "_cmp_interrupt_enable". |
AnnaBridge | 143:86740a56073b | 309 | */ |
AnnaBridge | 143:86740a56073b | 310 | void CMP_DisableInterrupts(CMP_Type *base, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 311 | |
AnnaBridge | 143:86740a56073b | 312 | /* @} */ |
AnnaBridge | 143:86740a56073b | 313 | |
AnnaBridge | 143:86740a56073b | 314 | /*! |
AnnaBridge | 143:86740a56073b | 315 | * @name Results |
AnnaBridge | 143:86740a56073b | 316 | * @{ |
AnnaBridge | 143:86740a56073b | 317 | */ |
AnnaBridge | 143:86740a56073b | 318 | |
AnnaBridge | 143:86740a56073b | 319 | /*! |
AnnaBridge | 143:86740a56073b | 320 | * @brief Gets the status flags. |
AnnaBridge | 143:86740a56073b | 321 | * |
AnnaBridge | 143:86740a56073b | 322 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 323 | * |
AnnaBridge | 143:86740a56073b | 324 | * @return Mask value for the asserted flags. See "_cmp_status_flags". |
AnnaBridge | 143:86740a56073b | 325 | */ |
AnnaBridge | 143:86740a56073b | 326 | uint32_t CMP_GetStatusFlags(CMP_Type *base); |
AnnaBridge | 143:86740a56073b | 327 | |
AnnaBridge | 143:86740a56073b | 328 | /*! |
AnnaBridge | 143:86740a56073b | 329 | * @brief Clears the status flags. |
AnnaBridge | 143:86740a56073b | 330 | * |
AnnaBridge | 143:86740a56073b | 331 | * @param base CMP peripheral base address. |
AnnaBridge | 143:86740a56073b | 332 | * @param mask Mask value for the flags. See "_cmp_status_flags". |
AnnaBridge | 143:86740a56073b | 333 | */ |
AnnaBridge | 143:86740a56073b | 334 | void CMP_ClearStatusFlags(CMP_Type *base, uint32_t mask); |
AnnaBridge | 143:86740a56073b | 335 | |
AnnaBridge | 143:86740a56073b | 336 | /* @} */ |
AnnaBridge | 143:86740a56073b | 337 | #if defined(__cplusplus) |
AnnaBridge | 143:86740a56073b | 338 | } |
AnnaBridge | 143:86740a56073b | 339 | #endif |
AnnaBridge | 143:86740a56073b | 340 | /*! |
AnnaBridge | 143:86740a56073b | 341 | * @} |
AnnaBridge | 143:86740a56073b | 342 | */ |
AnnaBridge | 143:86740a56073b | 343 | #endif /* _FSL_CMP_H_ */ |