2 ** ###################################################################
3 ** Compilers: Keil ARM C/C++ Compiler
4 ** Freescale C/C++ for Embedded ARM
6 ** IAR ANSI C/C++ Compiler for ARM
8 ** Reference manual: K22P121M120SF7RM, Rev. 1, March 24, 2014
9 ** Version: rev. 2.5, 2014-05-06
13 ** Extension to the CMSIS register access layer header.
15 ** Copyright (c) 2014 Freescale Semiconductor, Inc.
16 ** All rights reserved.
18 ** Redistribution and use in source and binary forms, with or without modification,
19 ** are permitted provided that the following conditions are met:
21 ** o Redistributions of source code must retain the above copyright notice, this list
22 ** of conditions and the following disclaimer.
24 ** o Redistributions in binary form must reproduce the above copyright notice, this
25 ** list of conditions and the following disclaimer in the documentation and/or
26 ** other materials provided with the distribution.
28 ** o Neither the name of Freescale Semiconductor, Inc. nor the names of its
29 ** contributors may be used to endorse or promote products derived from this
30 ** software without specific prior written permission.
32 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
33 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
36 ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
37 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
38 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
39 ** ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 ** http: www.freescale.com
44 ** mail: support@freescale.com
47 ** - rev. 1.0 (2013-07-23)
49 ** - rev. 1.1 (2013-09-17)
50 ** RM rev. 0.4 update.
51 ** - rev. 2.0 (2013-10-29)
52 ** Register accessor macros added to the memory map.
53 ** Symbols for Processor Expert memory map compatibility added to the memory map.
54 ** Startup file for gcc has been updated according to CMSIS 3.2.
55 ** System initialization updated.
56 ** - rev. 2.1 (2013-10-30)
57 ** Definition of BITBAND macros updated to support peripherals with 32-bit acces disabled.
58 ** - rev. 2.2 (2013-12-20)
59 ** Update according to reference manual rev. 0.6,
60 ** - rev. 2.3 (2014-01-13)
61 ** Update according to reference manual rev. 0.61,
62 ** - rev. 2.4 (2014-02-10)
63 ** The declaration of clock configurations has been moved to separate header file system_MK22F51212.h
64 ** - rev. 2.5 (2014-05-06)
65 ** Update according to reference manual rev. 1.0,
66 ** Update of system and startup files.
67 ** Module access macro module_BASES replaced by module_BASE_PTRS.
69 ** ###################################################################
73 * WARNING! DO NOT EDIT THIS FILE DIRECTLY!
75 * This file was generated automatically and any changes may be lost.
77 #ifndef __HW_CMP_REGISTERS_H__
78 #define __HW_CMP_REGISTERS_H__
80 #include "MK22F51212.h"
81 #include "fsl_bitaccess.h"
86 * High-Speed Comparator (CMP), Voltage Reference (VREF) Digital-to-Analog Converter (DAC), and Analog Mux (ANMUX)
88 * Registers defined in this header file:
89 * - HW_CMP_CR0 - CMP Control Register 0
90 * - HW_CMP_CR1 - CMP Control Register 1
91 * - HW_CMP_FPR - CMP Filter Period Register
92 * - HW_CMP_SCR - CMP Status and Control Register
93 * - HW_CMP_DACCR - DAC Control Register
94 * - HW_CMP_MUXCR - MUX Control Register
96 * - hw_cmp_t - Struct containing all module registers.
99 #define HW_CMP_INSTANCE_COUNT (2U) /*!< Number of instances of the CMP module. */
100 #define HW_CMP0 (0U) /*!< Instance number for CMP0. */
101 #define HW_CMP1 (1U) /*!< Instance number for CMP1. */
103 /*******************************************************************************
104 * HW_CMP_CR0 - CMP Control Register 0
105 ******************************************************************************/
108 * @brief HW_CMP_CR0 - CMP Control Register 0 (RW)
112 typedef union _hw_cmp_cr0
115 struct _hw_cmp_cr0_bitfields
117 uint8_t HYSTCTR
: 2; /*!< [1:0] Comparator hard block hysteresis
119 uint8_t RESERVED0
: 2; /*!< [3:2] */
120 uint8_t FILTER_CNT
: 3; /*!< [6:4] Filter Sample Count */
121 uint8_t RESERVED1
: 1; /*!< [7] */
126 * @name Constants and macros for entire CMP_CR0 register
129 #define HW_CMP_CR0_ADDR(x) ((x) + 0x0U)
131 #define HW_CMP_CR0(x) (*(__IO hw_cmp_cr0_t *) HW_CMP_CR0_ADDR(x))
132 #define HW_CMP_CR0_RD(x) (HW_CMP_CR0(x).U)
133 #define HW_CMP_CR0_WR(x, v) (HW_CMP_CR0(x).U = (v))
134 #define HW_CMP_CR0_SET(x, v) (HW_CMP_CR0_WR(x, HW_CMP_CR0_RD(x) | (v)))
135 #define HW_CMP_CR0_CLR(x, v) (HW_CMP_CR0_WR(x, HW_CMP_CR0_RD(x) & ~(v)))
136 #define HW_CMP_CR0_TOG(x, v) (HW_CMP_CR0_WR(x, HW_CMP_CR0_RD(x) ^ (v)))
140 * Constants & macros for individual CMP_CR0 bitfields
144 * @name Register CMP_CR0, field HYSTCTR[1:0] (RW)
146 * Defines the programmable hysteresis level. The hysteresis values associated
147 * with each level are device-specific. See the Data Sheet of the device for the
157 #define BP_CMP_CR0_HYSTCTR (0U) /*!< Bit position for CMP_CR0_HYSTCTR. */
158 #define BM_CMP_CR0_HYSTCTR (0x03U) /*!< Bit mask for CMP_CR0_HYSTCTR. */
159 #define BS_CMP_CR0_HYSTCTR (2U) /*!< Bit field size in bits for CMP_CR0_HYSTCTR. */
161 /*! @brief Read current value of the CMP_CR0_HYSTCTR field. */
162 #define BR_CMP_CR0_HYSTCTR(x) (HW_CMP_CR0(x).B.HYSTCTR)
164 /*! @brief Format value for bitfield CMP_CR0_HYSTCTR. */
165 #define BF_CMP_CR0_HYSTCTR(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR0_HYSTCTR) & BM_CMP_CR0_HYSTCTR)
167 /*! @brief Set the HYSTCTR field to a new value. */
168 #define BW_CMP_CR0_HYSTCTR(x, v) (HW_CMP_CR0_WR(x, (HW_CMP_CR0_RD(x) & ~BM_CMP_CR0_HYSTCTR) | BF_CMP_CR0_HYSTCTR(v)))
172 * @name Register CMP_CR0, field FILTER_CNT[6:4] (RW)
174 * Represents the number of consecutive samples that must agree prior to the
175 * comparator ouput filter accepting a new output state. For information regarding
176 * filter programming and latency, see the Functional descriptionThe CMP module
177 * can be used to compare two analog input voltages applied to INP and INM. .
180 * - 000 - Filter is disabled. If SE = 1, then COUT is a logic 0. This is not a
181 * legal state, and is not recommended. If SE = 0, COUT = COUTA.
182 * - 001 - One sample must agree. The comparator output is simply sampled.
183 * - 010 - 2 consecutive samples must agree.
184 * - 011 - 3 consecutive samples must agree.
185 * - 100 - 4 consecutive samples must agree.
186 * - 101 - 5 consecutive samples must agree.
187 * - 110 - 6 consecutive samples must agree.
188 * - 111 - 7 consecutive samples must agree.
191 #define BP_CMP_CR0_FILTER_CNT (4U) /*!< Bit position for CMP_CR0_FILTER_CNT. */
192 #define BM_CMP_CR0_FILTER_CNT (0x70U) /*!< Bit mask for CMP_CR0_FILTER_CNT. */
193 #define BS_CMP_CR0_FILTER_CNT (3U) /*!< Bit field size in bits for CMP_CR0_FILTER_CNT. */
195 /*! @brief Read current value of the CMP_CR0_FILTER_CNT field. */
196 #define BR_CMP_CR0_FILTER_CNT(x) (HW_CMP_CR0(x).B.FILTER_CNT)
198 /*! @brief Format value for bitfield CMP_CR0_FILTER_CNT. */
199 #define BF_CMP_CR0_FILTER_CNT(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR0_FILTER_CNT) & BM_CMP_CR0_FILTER_CNT)
201 /*! @brief Set the FILTER_CNT field to a new value. */
202 #define BW_CMP_CR0_FILTER_CNT(x, v) (HW_CMP_CR0_WR(x, (HW_CMP_CR0_RD(x) & ~BM_CMP_CR0_FILTER_CNT) | BF_CMP_CR0_FILTER_CNT(v)))
205 /*******************************************************************************
206 * HW_CMP_CR1 - CMP Control Register 1
207 ******************************************************************************/
210 * @brief HW_CMP_CR1 - CMP Control Register 1 (RW)
214 typedef union _hw_cmp_cr1
217 struct _hw_cmp_cr1_bitfields
219 uint8_t EN
: 1; /*!< [0] Comparator Module Enable */
220 uint8_t OPE
: 1; /*!< [1] Comparator Output Pin Enable */
221 uint8_t COS
: 1; /*!< [2] Comparator Output Select */
222 uint8_t INV
: 1; /*!< [3] Comparator INVERT */
223 uint8_t PMODE
: 1; /*!< [4] Power Mode Select */
224 uint8_t TRIGM
: 1; /*!< [5] Trigger Mode Enable */
225 uint8_t WE
: 1; /*!< [6] Windowing Enable */
226 uint8_t SE
: 1; /*!< [7] Sample Enable */
231 * @name Constants and macros for entire CMP_CR1 register
234 #define HW_CMP_CR1_ADDR(x) ((x) + 0x1U)
236 #define HW_CMP_CR1(x) (*(__IO hw_cmp_cr1_t *) HW_CMP_CR1_ADDR(x))
237 #define HW_CMP_CR1_RD(x) (HW_CMP_CR1(x).U)
238 #define HW_CMP_CR1_WR(x, v) (HW_CMP_CR1(x).U = (v))
239 #define HW_CMP_CR1_SET(x, v) (HW_CMP_CR1_WR(x, HW_CMP_CR1_RD(x) | (v)))
240 #define HW_CMP_CR1_CLR(x, v) (HW_CMP_CR1_WR(x, HW_CMP_CR1_RD(x) & ~(v)))
241 #define HW_CMP_CR1_TOG(x, v) (HW_CMP_CR1_WR(x, HW_CMP_CR1_RD(x) ^ (v)))
245 * Constants & macros for individual CMP_CR1 bitfields
249 * @name Register CMP_CR1, field EN[0] (RW)
251 * Enables the Analog Comparator module. When the module is not enabled, it
252 * remains in the off state, and consumes no power. When the user selects the same
253 * input from analog mux to the positive and negative port, the comparator is
254 * disabled automatically.
257 * - 0 - Analog Comparator is disabled.
258 * - 1 - Analog Comparator is enabled.
261 #define BP_CMP_CR1_EN (0U) /*!< Bit position for CMP_CR1_EN. */
262 #define BM_CMP_CR1_EN (0x01U) /*!< Bit mask for CMP_CR1_EN. */
263 #define BS_CMP_CR1_EN (1U) /*!< Bit field size in bits for CMP_CR1_EN. */
265 /*! @brief Read current value of the CMP_CR1_EN field. */
266 #define BR_CMP_CR1_EN(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_EN))
268 /*! @brief Format value for bitfield CMP_CR1_EN. */
269 #define BF_CMP_CR1_EN(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_EN) & BM_CMP_CR1_EN)
271 /*! @brief Set the EN field to a new value. */
272 #define BW_CMP_CR1_EN(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_EN) = (v))
276 * @name Register CMP_CR1, field OPE[1] (RW)
279 * - 0 - CMPO is not available on the associated CMPO output pin. If the
280 * comparator does not own the pin, this field has no effect.
281 * - 1 - CMPO is available on the associated CMPO output pin. The comparator
282 * output (CMPO) is driven out on the associated CMPO output pin if the
283 * comparator owns the pin. If the comparator does not own the field, this bit has no
287 #define BP_CMP_CR1_OPE (1U) /*!< Bit position for CMP_CR1_OPE. */
288 #define BM_CMP_CR1_OPE (0x02U) /*!< Bit mask for CMP_CR1_OPE. */
289 #define BS_CMP_CR1_OPE (1U) /*!< Bit field size in bits for CMP_CR1_OPE. */
291 /*! @brief Read current value of the CMP_CR1_OPE field. */
292 #define BR_CMP_CR1_OPE(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_OPE))
294 /*! @brief Format value for bitfield CMP_CR1_OPE. */
295 #define BF_CMP_CR1_OPE(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_OPE) & BM_CMP_CR1_OPE)
297 /*! @brief Set the OPE field to a new value. */
298 #define BW_CMP_CR1_OPE(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_OPE) = (v))
302 * @name Register CMP_CR1, field COS[2] (RW)
305 * - 0 - Set the filtered comparator output (CMPO) to equal COUT.
306 * - 1 - Set the unfiltered comparator output (CMPO) to equal COUTA.
309 #define BP_CMP_CR1_COS (2U) /*!< Bit position for CMP_CR1_COS. */
310 #define BM_CMP_CR1_COS (0x04U) /*!< Bit mask for CMP_CR1_COS. */
311 #define BS_CMP_CR1_COS (1U) /*!< Bit field size in bits for CMP_CR1_COS. */
313 /*! @brief Read current value of the CMP_CR1_COS field. */
314 #define BR_CMP_CR1_COS(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_COS))
316 /*! @brief Format value for bitfield CMP_CR1_COS. */
317 #define BF_CMP_CR1_COS(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_COS) & BM_CMP_CR1_COS)
319 /*! @brief Set the COS field to a new value. */
320 #define BW_CMP_CR1_COS(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_COS) = (v))
324 * @name Register CMP_CR1, field INV[3] (RW)
326 * Allows selection of the polarity of the analog comparator function. It is
327 * also driven to the COUT output, on both the device pin and as SCR[COUT], when
331 * - 0 - Does not invert the comparator output.
332 * - 1 - Inverts the comparator output.
335 #define BP_CMP_CR1_INV (3U) /*!< Bit position for CMP_CR1_INV. */
336 #define BM_CMP_CR1_INV (0x08U) /*!< Bit mask for CMP_CR1_INV. */
337 #define BS_CMP_CR1_INV (1U) /*!< Bit field size in bits for CMP_CR1_INV. */
339 /*! @brief Read current value of the CMP_CR1_INV field. */
340 #define BR_CMP_CR1_INV(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_INV))
342 /*! @brief Format value for bitfield CMP_CR1_INV. */
343 #define BF_CMP_CR1_INV(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_INV) & BM_CMP_CR1_INV)
345 /*! @brief Set the INV field to a new value. */
346 #define BW_CMP_CR1_INV(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_INV) = (v))
350 * @name Register CMP_CR1, field PMODE[4] (RW)
352 * See the electrical specifications table in the device Data Sheet for details.
355 * - 0 - Low-Speed (LS) Comparison mode selected. In this mode, CMP has slower
356 * output propagation delay and lower current consumption.
357 * - 1 - High-Speed (HS) Comparison mode selected. In this mode, CMP has faster
358 * output propagation delay and higher current consumption.
361 #define BP_CMP_CR1_PMODE (4U) /*!< Bit position for CMP_CR1_PMODE. */
362 #define BM_CMP_CR1_PMODE (0x10U) /*!< Bit mask for CMP_CR1_PMODE. */
363 #define BS_CMP_CR1_PMODE (1U) /*!< Bit field size in bits for CMP_CR1_PMODE. */
365 /*! @brief Read current value of the CMP_CR1_PMODE field. */
366 #define BR_CMP_CR1_PMODE(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_PMODE))
368 /*! @brief Format value for bitfield CMP_CR1_PMODE. */
369 #define BF_CMP_CR1_PMODE(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_PMODE) & BM_CMP_CR1_PMODE)
371 /*! @brief Set the PMODE field to a new value. */
372 #define BW_CMP_CR1_PMODE(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_PMODE) = (v))
376 * @name Register CMP_CR1, field TRIGM[5] (RW)
378 * CMP and DAC are configured to CMP Trigger mode when CMP_CR1[TRIGM] is set to
379 * 1. In addition, the CMP should be enabled. If the DAC is to be used as a
380 * reference to the CMP, it should also be enabled. CMP Trigger mode depends on an
381 * external timer resource to periodically enable the CMP and 6-bit DAC in order to
382 * generate a triggered compare. Upon setting TRIGM, the CMP and DAC are placed
383 * in a standby state until an external timer resource trigger is received. See
384 * the chip configuration for details about the external timer resource.
387 * - 0 - Trigger mode is disabled.
388 * - 1 - Trigger mode is enabled.
391 #define BP_CMP_CR1_TRIGM (5U) /*!< Bit position for CMP_CR1_TRIGM. */
392 #define BM_CMP_CR1_TRIGM (0x20U) /*!< Bit mask for CMP_CR1_TRIGM. */
393 #define BS_CMP_CR1_TRIGM (1U) /*!< Bit field size in bits for CMP_CR1_TRIGM. */
395 /*! @brief Read current value of the CMP_CR1_TRIGM field. */
396 #define BR_CMP_CR1_TRIGM(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_TRIGM))
398 /*! @brief Format value for bitfield CMP_CR1_TRIGM. */
399 #define BF_CMP_CR1_TRIGM(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_TRIGM) & BM_CMP_CR1_TRIGM)
401 /*! @brief Set the TRIGM field to a new value. */
402 #define BW_CMP_CR1_TRIGM(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_TRIGM) = (v))
406 * @name Register CMP_CR1, field WE[6] (RW)
408 * At any given time, either SE or WE can be set. If a write to this register
409 * attempts to set both, then SE is set and WE is cleared. However, avoid writing
410 * 1s to both field locations because this "11" case is reserved and may change in
411 * future implementations.
414 * - 0 - Windowing mode is not selected.
415 * - 1 - Windowing mode is selected.
418 #define BP_CMP_CR1_WE (6U) /*!< Bit position for CMP_CR1_WE. */
419 #define BM_CMP_CR1_WE (0x40U) /*!< Bit mask for CMP_CR1_WE. */
420 #define BS_CMP_CR1_WE (1U) /*!< Bit field size in bits for CMP_CR1_WE. */
422 /*! @brief Read current value of the CMP_CR1_WE field. */
423 #define BR_CMP_CR1_WE(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_WE))
425 /*! @brief Format value for bitfield CMP_CR1_WE. */
426 #define BF_CMP_CR1_WE(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_WE) & BM_CMP_CR1_WE)
428 /*! @brief Set the WE field to a new value. */
429 #define BW_CMP_CR1_WE(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_WE) = (v))
433 * @name Register CMP_CR1, field SE[7] (RW)
435 * At any given time, either SE or WE can be set. If a write to this register
436 * attempts to set both, then SE is set and WE is cleared. However, avoid writing
437 * 1s to both field locations because this "11" case is reserved and may change in
438 * future implementations.
441 * - 0 - Sampling mode is not selected.
442 * - 1 - Sampling mode is selected.
445 #define BP_CMP_CR1_SE (7U) /*!< Bit position for CMP_CR1_SE. */
446 #define BM_CMP_CR1_SE (0x80U) /*!< Bit mask for CMP_CR1_SE. */
447 #define BS_CMP_CR1_SE (1U) /*!< Bit field size in bits for CMP_CR1_SE. */
449 /*! @brief Read current value of the CMP_CR1_SE field. */
450 #define BR_CMP_CR1_SE(x) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_SE))
452 /*! @brief Format value for bitfield CMP_CR1_SE. */
453 #define BF_CMP_CR1_SE(v) ((uint8_t)((uint8_t)(v) << BP_CMP_CR1_SE) & BM_CMP_CR1_SE)
455 /*! @brief Set the SE field to a new value. */
456 #define BW_CMP_CR1_SE(x, v) (BITBAND_ACCESS8(HW_CMP_CR1_ADDR(x), BP_CMP_CR1_SE) = (v))
459 /*******************************************************************************
460 * HW_CMP_FPR - CMP Filter Period Register
461 ******************************************************************************/
464 * @brief HW_CMP_FPR - CMP Filter Period Register (RW)
468 typedef union _hw_cmp_fpr
471 struct _hw_cmp_fpr_bitfields
473 uint8_t FILT_PER
: 8; /*!< [7:0] Filter Sample Period */
478 * @name Constants and macros for entire CMP_FPR register
481 #define HW_CMP_FPR_ADDR(x) ((x) + 0x2U)
483 #define HW_CMP_FPR(x) (*(__IO hw_cmp_fpr_t *) HW_CMP_FPR_ADDR(x))
484 #define HW_CMP_FPR_RD(x) (HW_CMP_FPR(x).U)
485 #define HW_CMP_FPR_WR(x, v) (HW_CMP_FPR(x).U = (v))
486 #define HW_CMP_FPR_SET(x, v) (HW_CMP_FPR_WR(x, HW_CMP_FPR_RD(x) | (v)))
487 #define HW_CMP_FPR_CLR(x, v) (HW_CMP_FPR_WR(x, HW_CMP_FPR_RD(x) & ~(v)))
488 #define HW_CMP_FPR_TOG(x, v) (HW_CMP_FPR_WR(x, HW_CMP_FPR_RD(x) ^ (v)))
492 * Constants & macros for individual CMP_FPR bitfields
496 * @name Register CMP_FPR, field FILT_PER[7:0] (RW)
498 * Specifies the sampling period, in bus clock cycles, of the comparator output
499 * filter, when CR1[SE]=0. Setting FILT_PER to 0x0 disables the filter. Filter
500 * programming and latency details appear in the Functional descriptionThe CMP
501 * module can be used to compare two analog input voltages applied to INP and INM. .
502 * This field has no effect when CR1[SE]=1. In that case, the external SAMPLE
503 * signal is used to determine the sampling period.
506 #define BP_CMP_FPR_FILT_PER (0U) /*!< Bit position for CMP_FPR_FILT_PER. */
507 #define BM_CMP_FPR_FILT_PER (0xFFU) /*!< Bit mask for CMP_FPR_FILT_PER. */
508 #define BS_CMP_FPR_FILT_PER (8U) /*!< Bit field size in bits for CMP_FPR_FILT_PER. */
510 /*! @brief Read current value of the CMP_FPR_FILT_PER field. */
511 #define BR_CMP_FPR_FILT_PER(x) (HW_CMP_FPR(x).U)
513 /*! @brief Format value for bitfield CMP_FPR_FILT_PER. */
514 #define BF_CMP_FPR_FILT_PER(v) ((uint8_t)((uint8_t)(v) << BP_CMP_FPR_FILT_PER) & BM_CMP_FPR_FILT_PER)
516 /*! @brief Set the FILT_PER field to a new value. */
517 #define BW_CMP_FPR_FILT_PER(x, v) (HW_CMP_FPR_WR(x, v))
520 /*******************************************************************************
521 * HW_CMP_SCR - CMP Status and Control Register
522 ******************************************************************************/
525 * @brief HW_CMP_SCR - CMP Status and Control Register (RW)
529 typedef union _hw_cmp_scr
532 struct _hw_cmp_scr_bitfields
534 uint8_t COUT
: 1; /*!< [0] Analog Comparator Output */
535 uint8_t CFF
: 1; /*!< [1] Analog Comparator Flag Falling */
536 uint8_t CFR
: 1; /*!< [2] Analog Comparator Flag Rising */
537 uint8_t IEF
: 1; /*!< [3] Comparator Interrupt Enable Falling */
538 uint8_t IER
: 1; /*!< [4] Comparator Interrupt Enable Rising */
539 uint8_t RESERVED0
: 1; /*!< [5] */
540 uint8_t DMAEN
: 1; /*!< [6] DMA Enable Control */
541 uint8_t RESERVED1
: 1; /*!< [7] */
546 * @name Constants and macros for entire CMP_SCR register
549 #define HW_CMP_SCR_ADDR(x) ((x) + 0x3U)
551 #define HW_CMP_SCR(x) (*(__IO hw_cmp_scr_t *) HW_CMP_SCR_ADDR(x))
552 #define HW_CMP_SCR_RD(x) (HW_CMP_SCR(x).U)
553 #define HW_CMP_SCR_WR(x, v) (HW_CMP_SCR(x).U = (v))
554 #define HW_CMP_SCR_SET(x, v) (HW_CMP_SCR_WR(x, HW_CMP_SCR_RD(x) | (v)))
555 #define HW_CMP_SCR_CLR(x, v) (HW_CMP_SCR_WR(x, HW_CMP_SCR_RD(x) & ~(v)))
556 #define HW_CMP_SCR_TOG(x, v) (HW_CMP_SCR_WR(x, HW_CMP_SCR_RD(x) ^ (v)))
560 * Constants & macros for individual CMP_SCR bitfields
564 * @name Register CMP_SCR, field COUT[0] (RO)
566 * Returns the current value of the Analog Comparator output, when read. The
567 * field is reset to 0 and will read as CR1[INV] when the Analog Comparator module
568 * is disabled, that is, when CR1[EN] = 0. Writes to this field are ignored.
571 #define BP_CMP_SCR_COUT (0U) /*!< Bit position for CMP_SCR_COUT. */
572 #define BM_CMP_SCR_COUT (0x01U) /*!< Bit mask for CMP_SCR_COUT. */
573 #define BS_CMP_SCR_COUT (1U) /*!< Bit field size in bits for CMP_SCR_COUT. */
575 /*! @brief Read current value of the CMP_SCR_COUT field. */
576 #define BR_CMP_SCR_COUT(x) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_COUT))
580 * @name Register CMP_SCR, field CFF[1] (W1C)
582 * Detects a falling-edge on COUT, when set, during normal operation. CFF is
583 * cleared by writing 1 to it. During Stop modes, CFF is level sensitive .
586 * - 0 - Falling-edge on COUT has not been detected.
587 * - 1 - Falling-edge on COUT has occurred.
590 #define BP_CMP_SCR_CFF (1U) /*!< Bit position for CMP_SCR_CFF. */
591 #define BM_CMP_SCR_CFF (0x02U) /*!< Bit mask for CMP_SCR_CFF. */
592 #define BS_CMP_SCR_CFF (1U) /*!< Bit field size in bits for CMP_SCR_CFF. */
594 /*! @brief Read current value of the CMP_SCR_CFF field. */
595 #define BR_CMP_SCR_CFF(x) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_CFF))
597 /*! @brief Format value for bitfield CMP_SCR_CFF. */
598 #define BF_CMP_SCR_CFF(v) ((uint8_t)((uint8_t)(v) << BP_CMP_SCR_CFF) & BM_CMP_SCR_CFF)
600 /*! @brief Set the CFF field to a new value. */
601 #define BW_CMP_SCR_CFF(x, v) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_CFF) = (v))
605 * @name Register CMP_SCR, field CFR[2] (W1C)
607 * Detects a rising-edge on COUT, when set, during normal operation. CFR is
608 * cleared by writing 1 to it. During Stop modes, CFR is level sensitive .
611 * - 0 - Rising-edge on COUT has not been detected.
612 * - 1 - Rising-edge on COUT has occurred.
615 #define BP_CMP_SCR_CFR (2U) /*!< Bit position for CMP_SCR_CFR. */
616 #define BM_CMP_SCR_CFR (0x04U) /*!< Bit mask for CMP_SCR_CFR. */
617 #define BS_CMP_SCR_CFR (1U) /*!< Bit field size in bits for CMP_SCR_CFR. */
619 /*! @brief Read current value of the CMP_SCR_CFR field. */
620 #define BR_CMP_SCR_CFR(x) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_CFR))
622 /*! @brief Format value for bitfield CMP_SCR_CFR. */
623 #define BF_CMP_SCR_CFR(v) ((uint8_t)((uint8_t)(v) << BP_CMP_SCR_CFR) & BM_CMP_SCR_CFR)
625 /*! @brief Set the CFR field to a new value. */
626 #define BW_CMP_SCR_CFR(x, v) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_CFR) = (v))
630 * @name Register CMP_SCR, field IEF[3] (RW)
632 * Enables the CFF interrupt from the CMP. When this field is set, an interrupt
633 * will be asserted when CFF is set.
636 * - 0 - Interrupt is disabled.
637 * - 1 - Interrupt is enabled.
640 #define BP_CMP_SCR_IEF (3U) /*!< Bit position for CMP_SCR_IEF. */
641 #define BM_CMP_SCR_IEF (0x08U) /*!< Bit mask for CMP_SCR_IEF. */
642 #define BS_CMP_SCR_IEF (1U) /*!< Bit field size in bits for CMP_SCR_IEF. */
644 /*! @brief Read current value of the CMP_SCR_IEF field. */
645 #define BR_CMP_SCR_IEF(x) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_IEF))
647 /*! @brief Format value for bitfield CMP_SCR_IEF. */
648 #define BF_CMP_SCR_IEF(v) ((uint8_t)((uint8_t)(v) << BP_CMP_SCR_IEF) & BM_CMP_SCR_IEF)
650 /*! @brief Set the IEF field to a new value. */
651 #define BW_CMP_SCR_IEF(x, v) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_IEF) = (v))
655 * @name Register CMP_SCR, field IER[4] (RW)
657 * Enables the CFR interrupt from the CMP. When this field is set, an interrupt
658 * will be asserted when CFR is set.
661 * - 0 - Interrupt is disabled.
662 * - 1 - Interrupt is enabled.
665 #define BP_CMP_SCR_IER (4U) /*!< Bit position for CMP_SCR_IER. */
666 #define BM_CMP_SCR_IER (0x10U) /*!< Bit mask for CMP_SCR_IER. */
667 #define BS_CMP_SCR_IER (1U) /*!< Bit field size in bits for CMP_SCR_IER. */
669 /*! @brief Read current value of the CMP_SCR_IER field. */
670 #define BR_CMP_SCR_IER(x) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_IER))
672 /*! @brief Format value for bitfield CMP_SCR_IER. */
673 #define BF_CMP_SCR_IER(v) ((uint8_t)((uint8_t)(v) << BP_CMP_SCR_IER) & BM_CMP_SCR_IER)
675 /*! @brief Set the IER field to a new value. */
676 #define BW_CMP_SCR_IER(x, v) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_IER) = (v))
680 * @name Register CMP_SCR, field DMAEN[6] (RW)
682 * Enables the DMA transfer triggered from the CMP module. When this field is
683 * set, a DMA request is asserted when CFR or CFF is set.
686 * - 0 - DMA is disabled.
687 * - 1 - DMA is enabled.
690 #define BP_CMP_SCR_DMAEN (6U) /*!< Bit position for CMP_SCR_DMAEN. */
691 #define BM_CMP_SCR_DMAEN (0x40U) /*!< Bit mask for CMP_SCR_DMAEN. */
692 #define BS_CMP_SCR_DMAEN (1U) /*!< Bit field size in bits for CMP_SCR_DMAEN. */
694 /*! @brief Read current value of the CMP_SCR_DMAEN field. */
695 #define BR_CMP_SCR_DMAEN(x) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_DMAEN))
697 /*! @brief Format value for bitfield CMP_SCR_DMAEN. */
698 #define BF_CMP_SCR_DMAEN(v) ((uint8_t)((uint8_t)(v) << BP_CMP_SCR_DMAEN) & BM_CMP_SCR_DMAEN)
700 /*! @brief Set the DMAEN field to a new value. */
701 #define BW_CMP_SCR_DMAEN(x, v) (BITBAND_ACCESS8(HW_CMP_SCR_ADDR(x), BP_CMP_SCR_DMAEN) = (v))
704 /*******************************************************************************
705 * HW_CMP_DACCR - DAC Control Register
706 ******************************************************************************/
709 * @brief HW_CMP_DACCR - DAC Control Register (RW)
713 typedef union _hw_cmp_daccr
716 struct _hw_cmp_daccr_bitfields
718 uint8_t VOSEL
: 6; /*!< [5:0] DAC Output Voltage Select */
719 uint8_t VRSEL
: 1; /*!< [6] Supply Voltage Reference Source Select */
720 uint8_t DACEN
: 1; /*!< [7] DAC Enable */
725 * @name Constants and macros for entire CMP_DACCR register
728 #define HW_CMP_DACCR_ADDR(x) ((x) + 0x4U)
730 #define HW_CMP_DACCR(x) (*(__IO hw_cmp_daccr_t *) HW_CMP_DACCR_ADDR(x))
731 #define HW_CMP_DACCR_RD(x) (HW_CMP_DACCR(x).U)
732 #define HW_CMP_DACCR_WR(x, v) (HW_CMP_DACCR(x).U = (v))
733 #define HW_CMP_DACCR_SET(x, v) (HW_CMP_DACCR_WR(x, HW_CMP_DACCR_RD(x) | (v)))
734 #define HW_CMP_DACCR_CLR(x, v) (HW_CMP_DACCR_WR(x, HW_CMP_DACCR_RD(x) & ~(v)))
735 #define HW_CMP_DACCR_TOG(x, v) (HW_CMP_DACCR_WR(x, HW_CMP_DACCR_RD(x) ^ (v)))
739 * Constants & macros for individual CMP_DACCR bitfields
743 * @name Register CMP_DACCR, field VOSEL[5:0] (RW)
745 * Selects an output voltage from one of 64 distinct levels. DACO = (V in /64) *
746 * (VOSEL[5:0] + 1) , so the DACO range is from V in /64 to V in .
749 #define BP_CMP_DACCR_VOSEL (0U) /*!< Bit position for CMP_DACCR_VOSEL. */
750 #define BM_CMP_DACCR_VOSEL (0x3FU) /*!< Bit mask for CMP_DACCR_VOSEL. */
751 #define BS_CMP_DACCR_VOSEL (6U) /*!< Bit field size in bits for CMP_DACCR_VOSEL. */
753 /*! @brief Read current value of the CMP_DACCR_VOSEL field. */
754 #define BR_CMP_DACCR_VOSEL(x) (HW_CMP_DACCR(x).B.VOSEL)
756 /*! @brief Format value for bitfield CMP_DACCR_VOSEL. */
757 #define BF_CMP_DACCR_VOSEL(v) ((uint8_t)((uint8_t)(v) << BP_CMP_DACCR_VOSEL) & BM_CMP_DACCR_VOSEL)
759 /*! @brief Set the VOSEL field to a new value. */
760 #define BW_CMP_DACCR_VOSEL(x, v) (HW_CMP_DACCR_WR(x, (HW_CMP_DACCR_RD(x) & ~BM_CMP_DACCR_VOSEL) | BF_CMP_DACCR_VOSEL(v)))
764 * @name Register CMP_DACCR, field VRSEL[6] (RW)
767 * - 0 - V is selected as resistor ladder network supply reference V. in1 in
768 * - 1 - V is selected as resistor ladder network supply reference V. in2 in
771 #define BP_CMP_DACCR_VRSEL (6U) /*!< Bit position for CMP_DACCR_VRSEL. */
772 #define BM_CMP_DACCR_VRSEL (0x40U) /*!< Bit mask for CMP_DACCR_VRSEL. */
773 #define BS_CMP_DACCR_VRSEL (1U) /*!< Bit field size in bits for CMP_DACCR_VRSEL. */
775 /*! @brief Read current value of the CMP_DACCR_VRSEL field. */
776 #define BR_CMP_DACCR_VRSEL(x) (BITBAND_ACCESS8(HW_CMP_DACCR_ADDR(x), BP_CMP_DACCR_VRSEL))
778 /*! @brief Format value for bitfield CMP_DACCR_VRSEL. */
779 #define BF_CMP_DACCR_VRSEL(v) ((uint8_t)((uint8_t)(v) << BP_CMP_DACCR_VRSEL) & BM_CMP_DACCR_VRSEL)
781 /*! @brief Set the VRSEL field to a new value. */
782 #define BW_CMP_DACCR_VRSEL(x, v) (BITBAND_ACCESS8(HW_CMP_DACCR_ADDR(x), BP_CMP_DACCR_VRSEL) = (v))
786 * @name Register CMP_DACCR, field DACEN[7] (RW)
788 * Enables the DAC. When the DAC is disabled, it is powered down to conserve
792 * - 0 - DAC is disabled.
793 * - 1 - DAC is enabled.
796 #define BP_CMP_DACCR_DACEN (7U) /*!< Bit position for CMP_DACCR_DACEN. */
797 #define BM_CMP_DACCR_DACEN (0x80U) /*!< Bit mask for CMP_DACCR_DACEN. */
798 #define BS_CMP_DACCR_DACEN (1U) /*!< Bit field size in bits for CMP_DACCR_DACEN. */
800 /*! @brief Read current value of the CMP_DACCR_DACEN field. */
801 #define BR_CMP_DACCR_DACEN(x) (BITBAND_ACCESS8(HW_CMP_DACCR_ADDR(x), BP_CMP_DACCR_DACEN))
803 /*! @brief Format value for bitfield CMP_DACCR_DACEN. */
804 #define BF_CMP_DACCR_DACEN(v) ((uint8_t)((uint8_t)(v) << BP_CMP_DACCR_DACEN) & BM_CMP_DACCR_DACEN)
806 /*! @brief Set the DACEN field to a new value. */
807 #define BW_CMP_DACCR_DACEN(x, v) (BITBAND_ACCESS8(HW_CMP_DACCR_ADDR(x), BP_CMP_DACCR_DACEN) = (v))
810 /*******************************************************************************
811 * HW_CMP_MUXCR - MUX Control Register
812 ******************************************************************************/
815 * @brief HW_CMP_MUXCR - MUX Control Register (RW)
819 typedef union _hw_cmp_muxcr
822 struct _hw_cmp_muxcr_bitfields
824 uint8_t MSEL
: 3; /*!< [2:0] Minus Input Mux Control */
825 uint8_t PSEL
: 3; /*!< [5:3] Plus Input Mux Control */
826 uint8_t RESERVED0
: 2; /*!< [7:6] Bit can be programmed to zero only
832 * @name Constants and macros for entire CMP_MUXCR register
835 #define HW_CMP_MUXCR_ADDR(x) ((x) + 0x5U)
837 #define HW_CMP_MUXCR(x) (*(__IO hw_cmp_muxcr_t *) HW_CMP_MUXCR_ADDR(x))
838 #define HW_CMP_MUXCR_RD(x) (HW_CMP_MUXCR(x).U)
839 #define HW_CMP_MUXCR_WR(x, v) (HW_CMP_MUXCR(x).U = (v))
840 #define HW_CMP_MUXCR_SET(x, v) (HW_CMP_MUXCR_WR(x, HW_CMP_MUXCR_RD(x) | (v)))
841 #define HW_CMP_MUXCR_CLR(x, v) (HW_CMP_MUXCR_WR(x, HW_CMP_MUXCR_RD(x) & ~(v)))
842 #define HW_CMP_MUXCR_TOG(x, v) (HW_CMP_MUXCR_WR(x, HW_CMP_MUXCR_RD(x) ^ (v)))
846 * Constants & macros for individual CMP_MUXCR bitfields
850 * @name Register CMP_MUXCR, field MSEL[2:0] (RW)
852 * Determines which input is selected for the minus input of the comparator. For
853 * INx inputs, see CMP, DAC, and ANMUX block diagrams. When an inappropriate
854 * operation selects the same input for both muxes, the comparator automatically
855 * shuts down to prevent itself from becoming a noise generator.
868 #define BP_CMP_MUXCR_MSEL (0U) /*!< Bit position for CMP_MUXCR_MSEL. */
869 #define BM_CMP_MUXCR_MSEL (0x07U) /*!< Bit mask for CMP_MUXCR_MSEL. */
870 #define BS_CMP_MUXCR_MSEL (3U) /*!< Bit field size in bits for CMP_MUXCR_MSEL. */
872 /*! @brief Read current value of the CMP_MUXCR_MSEL field. */
873 #define BR_CMP_MUXCR_MSEL(x) (HW_CMP_MUXCR(x).B.MSEL)
875 /*! @brief Format value for bitfield CMP_MUXCR_MSEL. */
876 #define BF_CMP_MUXCR_MSEL(v) ((uint8_t)((uint8_t)(v) << BP_CMP_MUXCR_MSEL) & BM_CMP_MUXCR_MSEL)
878 /*! @brief Set the MSEL field to a new value. */
879 #define BW_CMP_MUXCR_MSEL(x, v) (HW_CMP_MUXCR_WR(x, (HW_CMP_MUXCR_RD(x) & ~BM_CMP_MUXCR_MSEL) | BF_CMP_MUXCR_MSEL(v)))
883 * @name Register CMP_MUXCR, field PSEL[5:3] (RW)
885 * Determines which input is selected for the plus input of the comparator. For
886 * INx inputs, see CMP, DAC, and ANMUX block diagrams. When an inappropriate
887 * operation selects the same input for both muxes, the comparator automatically
888 * shuts down to prevent itself from becoming a noise generator.
901 #define BP_CMP_MUXCR_PSEL (3U) /*!< Bit position for CMP_MUXCR_PSEL. */
902 #define BM_CMP_MUXCR_PSEL (0x38U) /*!< Bit mask for CMP_MUXCR_PSEL. */
903 #define BS_CMP_MUXCR_PSEL (3U) /*!< Bit field size in bits for CMP_MUXCR_PSEL. */
905 /*! @brief Read current value of the CMP_MUXCR_PSEL field. */
906 #define BR_CMP_MUXCR_PSEL(x) (HW_CMP_MUXCR(x).B.PSEL)
908 /*! @brief Format value for bitfield CMP_MUXCR_PSEL. */
909 #define BF_CMP_MUXCR_PSEL(v) ((uint8_t)((uint8_t)(v) << BP_CMP_MUXCR_PSEL) & BM_CMP_MUXCR_PSEL)
911 /*! @brief Set the PSEL field to a new value. */
912 #define BW_CMP_MUXCR_PSEL(x, v) (HW_CMP_MUXCR_WR(x, (HW_CMP_MUXCR_RD(x) & ~BM_CMP_MUXCR_PSEL) | BF_CMP_MUXCR_PSEL(v)))
915 /*******************************************************************************
916 * hw_cmp_t - module struct
917 ******************************************************************************/
919 * @brief All CMP module registers.
922 typedef struct _hw_cmp
924 __IO hw_cmp_cr0_t CR0
; /*!< [0x0] CMP Control Register 0 */
925 __IO hw_cmp_cr1_t CR1
; /*!< [0x1] CMP Control Register 1 */
926 __IO hw_cmp_fpr_t FPR
; /*!< [0x2] CMP Filter Period Register */
927 __IO hw_cmp_scr_t SCR
; /*!< [0x3] CMP Status and Control Register */
928 __IO hw_cmp_daccr_t DACCR
; /*!< [0x4] DAC Control Register */
929 __IO hw_cmp_muxcr_t MUXCR
; /*!< [0x5] MUX Control Register */
933 /*! @brief Macro to access all CMP registers. */
934 /*! @param x CMP module instance base address. */
935 /*! @return Reference (not a pointer) to the registers struct. To get a pointer to the struct,
936 * use the '&' operator, like <code>&HW_CMP(CMP0_BASE)</code>. */
937 #define HW_CMP(x) (*(hw_cmp_t *)(x))
939 #endif /* __HW_CMP_REGISTERS_H__ */