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.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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