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_DAC_REGISTERS_H__
78 #define __HW_DAC_REGISTERS_H__
80 #include "MK22F51212.h"
81 #include "fsl_bitaccess.h"
86 * 12-Bit Digital-to-Analog Converter
88 * Registers defined in this header file:
89 * - HW_DAC_DATnL - DAC Data Low Register
90 * - HW_DAC_DATnH - DAC Data High Register
91 * - HW_DAC_SR - DAC Status Register
92 * - HW_DAC_C0 - DAC Control Register
93 * - HW_DAC_C1 - DAC Control Register 1
94 * - HW_DAC_C2 - DAC Control Register 2
96 * - hw_dac_t - Struct containing all module registers.
99 #define HW_DAC_INSTANCE_COUNT (2U) /*!< Number of instances of the DAC module. */
100 #define HW_DAC0 (0U) /*!< Instance number for DAC0. */
101 #define HW_DAC1 (1U) /*!< Instance number for DAC1. */
103 /*******************************************************************************
104 * HW_DAC_DATnL - DAC Data Low Register
105 ******************************************************************************/
108 * @brief HW_DAC_DATnL - DAC Data Low Register (RW)
112 typedef union _hw_dac_datnl
115 struct _hw_dac_datnl_bitfields
117 uint8_t DATA0
: 8; /*!< [7:0] */
122 * @name Constants and macros for entire DAC_DATnL register
125 #define HW_DAC_DATnL_COUNT (16U)
127 #define HW_DAC_DATnL_ADDR(x, n) ((x) + 0x0U + (0x2U * (n)))
129 #define HW_DAC_DATnL(x, n) (*(__IO hw_dac_datnl_t *) HW_DAC_DATnL_ADDR(x, n))
130 #define HW_DAC_DATnL_RD(x, n) (HW_DAC_DATnL(x, n).U)
131 #define HW_DAC_DATnL_WR(x, n, v) (HW_DAC_DATnL(x, n).U = (v))
132 #define HW_DAC_DATnL_SET(x, n, v) (HW_DAC_DATnL_WR(x, n, HW_DAC_DATnL_RD(x, n) | (v)))
133 #define HW_DAC_DATnL_CLR(x, n, v) (HW_DAC_DATnL_WR(x, n, HW_DAC_DATnL_RD(x, n) & ~(v)))
134 #define HW_DAC_DATnL_TOG(x, n, v) (HW_DAC_DATnL_WR(x, n, HW_DAC_DATnL_RD(x, n) ^ (v)))
138 * Constants & macros for individual DAC_DATnL bitfields
142 * @name Register DAC_DATnL, field DATA0[7:0] (RW)
144 * When the DAC buffer is not enabled, DATA[11:0] controls the output voltage
145 * based on the following formula: V out = V in * (1 + DACDAT0[11:0])/4096 When the
146 * DAC buffer is enabled, DATA is mapped to the 16-word buffer.
149 #define BP_DAC_DATnL_DATA0 (0U) /*!< Bit position for DAC_DATnL_DATA0. */
150 #define BM_DAC_DATnL_DATA0 (0xFFU) /*!< Bit mask for DAC_DATnL_DATA0. */
151 #define BS_DAC_DATnL_DATA0 (8U) /*!< Bit field size in bits for DAC_DATnL_DATA0. */
153 /*! @brief Read current value of the DAC_DATnL_DATA0 field. */
154 #define BR_DAC_DATnL_DATA0(x, n) (HW_DAC_DATnL(x, n).U)
156 /*! @brief Format value for bitfield DAC_DATnL_DATA0. */
157 #define BF_DAC_DATnL_DATA0(v) ((uint8_t)((uint8_t)(v) << BP_DAC_DATnL_DATA0) & BM_DAC_DATnL_DATA0)
159 /*! @brief Set the DATA0 field to a new value. */
160 #define BW_DAC_DATnL_DATA0(x, n, v) (HW_DAC_DATnL_WR(x, n, v))
162 /*******************************************************************************
163 * HW_DAC_DATnH - DAC Data High Register
164 ******************************************************************************/
167 * @brief HW_DAC_DATnH - DAC Data High Register (RW)
171 typedef union _hw_dac_datnh
174 struct _hw_dac_datnh_bitfields
176 uint8_t DATA1
: 4; /*!< [3:0] */
177 uint8_t RESERVED0
: 4; /*!< [7:4] */
182 * @name Constants and macros for entire DAC_DATnH register
185 #define HW_DAC_DATnH_COUNT (16U)
187 #define HW_DAC_DATnH_ADDR(x, n) ((x) + 0x1U + (0x2U * (n)))
189 #define HW_DAC_DATnH(x, n) (*(__IO hw_dac_datnh_t *) HW_DAC_DATnH_ADDR(x, n))
190 #define HW_DAC_DATnH_RD(x, n) (HW_DAC_DATnH(x, n).U)
191 #define HW_DAC_DATnH_WR(x, n, v) (HW_DAC_DATnH(x, n).U = (v))
192 #define HW_DAC_DATnH_SET(x, n, v) (HW_DAC_DATnH_WR(x, n, HW_DAC_DATnH_RD(x, n) | (v)))
193 #define HW_DAC_DATnH_CLR(x, n, v) (HW_DAC_DATnH_WR(x, n, HW_DAC_DATnH_RD(x, n) & ~(v)))
194 #define HW_DAC_DATnH_TOG(x, n, v) (HW_DAC_DATnH_WR(x, n, HW_DAC_DATnH_RD(x, n) ^ (v)))
198 * Constants & macros for individual DAC_DATnH bitfields
202 * @name Register DAC_DATnH, field DATA1[3:0] (RW)
204 * When the DAC Buffer is not enabled, DATA[11:0] controls the output voltage
205 * based on the following formula. V out = V in * (1 + DACDAT0[11:0])/4096 When the
206 * DAC buffer is enabled, DATA[11:0] is mapped to the 16-word buffer.
209 #define BP_DAC_DATnH_DATA1 (0U) /*!< Bit position for DAC_DATnH_DATA1. */
210 #define BM_DAC_DATnH_DATA1 (0x0FU) /*!< Bit mask for DAC_DATnH_DATA1. */
211 #define BS_DAC_DATnH_DATA1 (4U) /*!< Bit field size in bits for DAC_DATnH_DATA1. */
213 /*! @brief Read current value of the DAC_DATnH_DATA1 field. */
214 #define BR_DAC_DATnH_DATA1(x, n) (HW_DAC_DATnH(x, n).B.DATA1)
216 /*! @brief Format value for bitfield DAC_DATnH_DATA1. */
217 #define BF_DAC_DATnH_DATA1(v) ((uint8_t)((uint8_t)(v) << BP_DAC_DATnH_DATA1) & BM_DAC_DATnH_DATA1)
219 /*! @brief Set the DATA1 field to a new value. */
220 #define BW_DAC_DATnH_DATA1(x, n, v) (HW_DAC_DATnH_WR(x, n, (HW_DAC_DATnH_RD(x, n) & ~BM_DAC_DATnH_DATA1) | BF_DAC_DATnH_DATA1(v)))
223 /*******************************************************************************
224 * HW_DAC_SR - DAC Status Register
225 ******************************************************************************/
228 * @brief HW_DAC_SR - DAC Status Register (RW)
232 * If DMA is enabled, the flags can be cleared automatically by DMA when the DMA
233 * request is done. Writing 0 to a field clears it whereas writing 1 has no
234 * effect. After reset, DACBFRPTF is set and can be cleared by software, if needed.
235 * The flags are set only when the data buffer status is changed.
237 typedef union _hw_dac_sr
240 struct _hw_dac_sr_bitfields
242 uint8_t DACBFRPBF
: 1; /*!< [0] DAC Buffer Read Pointer Bottom
244 uint8_t DACBFRPTF
: 1; /*!< [1] DAC Buffer Read Pointer Top Position
246 uint8_t DACBFWMF
: 1; /*!< [2] DAC Buffer Watermark Flag */
247 uint8_t RESERVED0
: 5; /*!< [7:3] */
252 * @name Constants and macros for entire DAC_SR register
255 #define HW_DAC_SR_ADDR(x) ((x) + 0x20U)
257 #define HW_DAC_SR(x) (*(__IO hw_dac_sr_t *) HW_DAC_SR_ADDR(x))
258 #define HW_DAC_SR_RD(x) (HW_DAC_SR(x).U)
259 #define HW_DAC_SR_WR(x, v) (HW_DAC_SR(x).U = (v))
260 #define HW_DAC_SR_SET(x, v) (HW_DAC_SR_WR(x, HW_DAC_SR_RD(x) | (v)))
261 #define HW_DAC_SR_CLR(x, v) (HW_DAC_SR_WR(x, HW_DAC_SR_RD(x) & ~(v)))
262 #define HW_DAC_SR_TOG(x, v) (HW_DAC_SR_WR(x, HW_DAC_SR_RD(x) ^ (v)))
266 * Constants & macros for individual DAC_SR bitfields
270 * @name Register DAC_SR, field DACBFRPBF[0] (RW)
272 * In FIFO mode, it is FIFO FULL status bit. It means FIFO read pointer equals
273 * Write Pointer because of Write Pointer increase. If this bit is set, any write
274 * to FIFO from either DMA or CPU is ignored by DAC. It is cleared if there is
275 * any DAC trigger making the DAC read pointer increase. Write to this bit is
276 * ignored in FIFO mode.
279 * - 0 - The DAC buffer read pointer is not equal to C2[DACBFUP].
280 * - 1 - The DAC buffer read pointer is equal to C2[DACBFUP].
283 #define BP_DAC_SR_DACBFRPBF (0U) /*!< Bit position for DAC_SR_DACBFRPBF. */
284 #define BM_DAC_SR_DACBFRPBF (0x01U) /*!< Bit mask for DAC_SR_DACBFRPBF. */
285 #define BS_DAC_SR_DACBFRPBF (1U) /*!< Bit field size in bits for DAC_SR_DACBFRPBF. */
287 /*! @brief Read current value of the DAC_SR_DACBFRPBF field. */
288 #define BR_DAC_SR_DACBFRPBF(x) (BITBAND_ACCESS8(HW_DAC_SR_ADDR(x), BP_DAC_SR_DACBFRPBF))
290 /*! @brief Format value for bitfield DAC_SR_DACBFRPBF. */
291 #define BF_DAC_SR_DACBFRPBF(v) ((uint8_t)((uint8_t)(v) << BP_DAC_SR_DACBFRPBF) & BM_DAC_SR_DACBFRPBF)
293 /*! @brief Set the DACBFRPBF field to a new value. */
294 #define BW_DAC_SR_DACBFRPBF(x, v) (BITBAND_ACCESS8(HW_DAC_SR_ADDR(x), BP_DAC_SR_DACBFRPBF) = (v))
298 * @name Register DAC_SR, field DACBFRPTF[1] (RW)
300 * In FIFO mode, it is FIFO nearly empty flag. It is set when only one data
301 * remains in FIFO. Any DAC trigger does not increase the Read Pointer if this bit is
302 * set to avoid any possible glitch or abrupt change at DAC output. It is
303 * cleared automatically if FIFO is not empty.
306 * - 0 - The DAC buffer read pointer is not zero.
307 * - 1 - The DAC buffer read pointer is zero.
310 #define BP_DAC_SR_DACBFRPTF (1U) /*!< Bit position for DAC_SR_DACBFRPTF. */
311 #define BM_DAC_SR_DACBFRPTF (0x02U) /*!< Bit mask for DAC_SR_DACBFRPTF. */
312 #define BS_DAC_SR_DACBFRPTF (1U) /*!< Bit field size in bits for DAC_SR_DACBFRPTF. */
314 /*! @brief Read current value of the DAC_SR_DACBFRPTF field. */
315 #define BR_DAC_SR_DACBFRPTF(x) (BITBAND_ACCESS8(HW_DAC_SR_ADDR(x), BP_DAC_SR_DACBFRPTF))
317 /*! @brief Format value for bitfield DAC_SR_DACBFRPTF. */
318 #define BF_DAC_SR_DACBFRPTF(v) ((uint8_t)((uint8_t)(v) << BP_DAC_SR_DACBFRPTF) & BM_DAC_SR_DACBFRPTF)
320 /*! @brief Set the DACBFRPTF field to a new value. */
321 #define BW_DAC_SR_DACBFRPTF(x, v) (BITBAND_ACCESS8(HW_DAC_SR_ADDR(x), BP_DAC_SR_DACBFRPTF) = (v))
325 * @name Register DAC_SR, field DACBFWMF[2] (RW)
327 * This bit is set if the remaining FIFO data is less than the watermark
328 * setting. It is cleared automatically by writing data into FIFO by DMA or CPU. Write
329 * to this bit is ignored in FIFO mode.
332 * - 0 - The DAC buffer read pointer has not reached the watermark level.
333 * - 1 - The DAC buffer read pointer has reached the watermark level.
336 #define BP_DAC_SR_DACBFWMF (2U) /*!< Bit position for DAC_SR_DACBFWMF. */
337 #define BM_DAC_SR_DACBFWMF (0x04U) /*!< Bit mask for DAC_SR_DACBFWMF. */
338 #define BS_DAC_SR_DACBFWMF (1U) /*!< Bit field size in bits for DAC_SR_DACBFWMF. */
340 /*! @brief Read current value of the DAC_SR_DACBFWMF field. */
341 #define BR_DAC_SR_DACBFWMF(x) (BITBAND_ACCESS8(HW_DAC_SR_ADDR(x), BP_DAC_SR_DACBFWMF))
343 /*! @brief Format value for bitfield DAC_SR_DACBFWMF. */
344 #define BF_DAC_SR_DACBFWMF(v) ((uint8_t)((uint8_t)(v) << BP_DAC_SR_DACBFWMF) & BM_DAC_SR_DACBFWMF)
346 /*! @brief Set the DACBFWMF field to a new value. */
347 #define BW_DAC_SR_DACBFWMF(x, v) (BITBAND_ACCESS8(HW_DAC_SR_ADDR(x), BP_DAC_SR_DACBFWMF) = (v))
350 /*******************************************************************************
351 * HW_DAC_C0 - DAC Control Register
352 ******************************************************************************/
355 * @brief HW_DAC_C0 - DAC Control Register (RW)
359 typedef union _hw_dac_c0
362 struct _hw_dac_c0_bitfields
364 uint8_t DACBBIEN
: 1; /*!< [0] DAC Buffer Read Pointer Bottom Flag
365 * Interrupt Enable */
366 uint8_t DACBTIEN
: 1; /*!< [1] DAC Buffer Read Pointer Top Flag
367 * Interrupt Enable */
368 uint8_t DACBWIEN
: 1; /*!< [2] DAC Buffer Watermark Interrupt Enable
370 uint8_t LPEN
: 1; /*!< [3] DAC Low Power Control */
371 uint8_t DACSWTRG
: 1; /*!< [4] DAC Software Trigger */
372 uint8_t DACTRGSEL
: 1; /*!< [5] DAC Trigger Select */
373 uint8_t DACRFS
: 1; /*!< [6] DAC Reference Select */
374 uint8_t DACEN
: 1; /*!< [7] DAC Enable */
379 * @name Constants and macros for entire DAC_C0 register
382 #define HW_DAC_C0_ADDR(x) ((x) + 0x21U)
384 #define HW_DAC_C0(x) (*(__IO hw_dac_c0_t *) HW_DAC_C0_ADDR(x))
385 #define HW_DAC_C0_RD(x) (HW_DAC_C0(x).U)
386 #define HW_DAC_C0_WR(x, v) (HW_DAC_C0(x).U = (v))
387 #define HW_DAC_C0_SET(x, v) (HW_DAC_C0_WR(x, HW_DAC_C0_RD(x) | (v)))
388 #define HW_DAC_C0_CLR(x, v) (HW_DAC_C0_WR(x, HW_DAC_C0_RD(x) & ~(v)))
389 #define HW_DAC_C0_TOG(x, v) (HW_DAC_C0_WR(x, HW_DAC_C0_RD(x) ^ (v)))
393 * Constants & macros for individual DAC_C0 bitfields
397 * @name Register DAC_C0, field DACBBIEN[0] (RW)
400 * - 0 - The DAC buffer read pointer bottom flag interrupt is disabled.
401 * - 1 - The DAC buffer read pointer bottom flag interrupt is enabled.
404 #define BP_DAC_C0_DACBBIEN (0U) /*!< Bit position for DAC_C0_DACBBIEN. */
405 #define BM_DAC_C0_DACBBIEN (0x01U) /*!< Bit mask for DAC_C0_DACBBIEN. */
406 #define BS_DAC_C0_DACBBIEN (1U) /*!< Bit field size in bits for DAC_C0_DACBBIEN. */
408 /*! @brief Read current value of the DAC_C0_DACBBIEN field. */
409 #define BR_DAC_C0_DACBBIEN(x) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACBBIEN))
411 /*! @brief Format value for bitfield DAC_C0_DACBBIEN. */
412 #define BF_DAC_C0_DACBBIEN(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_DACBBIEN) & BM_DAC_C0_DACBBIEN)
414 /*! @brief Set the DACBBIEN field to a new value. */
415 #define BW_DAC_C0_DACBBIEN(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACBBIEN) = (v))
419 * @name Register DAC_C0, field DACBTIEN[1] (RW)
422 * - 0 - The DAC buffer read pointer top flag interrupt is disabled.
423 * - 1 - The DAC buffer read pointer top flag interrupt is enabled.
426 #define BP_DAC_C0_DACBTIEN (1U) /*!< Bit position for DAC_C0_DACBTIEN. */
427 #define BM_DAC_C0_DACBTIEN (0x02U) /*!< Bit mask for DAC_C0_DACBTIEN. */
428 #define BS_DAC_C0_DACBTIEN (1U) /*!< Bit field size in bits for DAC_C0_DACBTIEN. */
430 /*! @brief Read current value of the DAC_C0_DACBTIEN field. */
431 #define BR_DAC_C0_DACBTIEN(x) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACBTIEN))
433 /*! @brief Format value for bitfield DAC_C0_DACBTIEN. */
434 #define BF_DAC_C0_DACBTIEN(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_DACBTIEN) & BM_DAC_C0_DACBTIEN)
436 /*! @brief Set the DACBTIEN field to a new value. */
437 #define BW_DAC_C0_DACBTIEN(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACBTIEN) = (v))
441 * @name Register DAC_C0, field DACBWIEN[2] (RW)
444 * - 0 - The DAC buffer watermark interrupt is disabled.
445 * - 1 - The DAC buffer watermark interrupt is enabled.
448 #define BP_DAC_C0_DACBWIEN (2U) /*!< Bit position for DAC_C0_DACBWIEN. */
449 #define BM_DAC_C0_DACBWIEN (0x04U) /*!< Bit mask for DAC_C0_DACBWIEN. */
450 #define BS_DAC_C0_DACBWIEN (1U) /*!< Bit field size in bits for DAC_C0_DACBWIEN. */
452 /*! @brief Read current value of the DAC_C0_DACBWIEN field. */
453 #define BR_DAC_C0_DACBWIEN(x) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACBWIEN))
455 /*! @brief Format value for bitfield DAC_C0_DACBWIEN. */
456 #define BF_DAC_C0_DACBWIEN(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_DACBWIEN) & BM_DAC_C0_DACBWIEN)
458 /*! @brief Set the DACBWIEN field to a new value. */
459 #define BW_DAC_C0_DACBWIEN(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACBWIEN) = (v))
463 * @name Register DAC_C0, field LPEN[3] (RW)
465 * See the 12-bit DAC electrical characteristics of the device data sheet for
466 * details on the impact of the modes below.
469 * - 0 - High-Power mode
470 * - 1 - Low-Power mode
473 #define BP_DAC_C0_LPEN (3U) /*!< Bit position for DAC_C0_LPEN. */
474 #define BM_DAC_C0_LPEN (0x08U) /*!< Bit mask for DAC_C0_LPEN. */
475 #define BS_DAC_C0_LPEN (1U) /*!< Bit field size in bits for DAC_C0_LPEN. */
477 /*! @brief Read current value of the DAC_C0_LPEN field. */
478 #define BR_DAC_C0_LPEN(x) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_LPEN))
480 /*! @brief Format value for bitfield DAC_C0_LPEN. */
481 #define BF_DAC_C0_LPEN(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_LPEN) & BM_DAC_C0_LPEN)
483 /*! @brief Set the LPEN field to a new value. */
484 #define BW_DAC_C0_LPEN(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_LPEN) = (v))
488 * @name Register DAC_C0, field DACSWTRG[4] (WORZ)
490 * Active high. This is a write-only field, which always reads 0. If DAC
491 * software trigger is selected and buffer is enabled, writing 1 to this field will
492 * advance the buffer read pointer once.
495 * - 0 - The DAC soft trigger is not valid.
496 * - 1 - The DAC soft trigger is valid.
499 #define BP_DAC_C0_DACSWTRG (4U) /*!< Bit position for DAC_C0_DACSWTRG. */
500 #define BM_DAC_C0_DACSWTRG (0x10U) /*!< Bit mask for DAC_C0_DACSWTRG. */
501 #define BS_DAC_C0_DACSWTRG (1U) /*!< Bit field size in bits for DAC_C0_DACSWTRG. */
503 /*! @brief Format value for bitfield DAC_C0_DACSWTRG. */
504 #define BF_DAC_C0_DACSWTRG(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_DACSWTRG) & BM_DAC_C0_DACSWTRG)
506 /*! @brief Set the DACSWTRG field to a new value. */
507 #define BW_DAC_C0_DACSWTRG(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACSWTRG) = (v))
511 * @name Register DAC_C0, field DACTRGSEL[5] (RW)
514 * - 0 - The DAC hardware trigger is selected.
515 * - 1 - The DAC software trigger is selected.
518 #define BP_DAC_C0_DACTRGSEL (5U) /*!< Bit position for DAC_C0_DACTRGSEL. */
519 #define BM_DAC_C0_DACTRGSEL (0x20U) /*!< Bit mask for DAC_C0_DACTRGSEL. */
520 #define BS_DAC_C0_DACTRGSEL (1U) /*!< Bit field size in bits for DAC_C0_DACTRGSEL. */
522 /*! @brief Read current value of the DAC_C0_DACTRGSEL field. */
523 #define BR_DAC_C0_DACTRGSEL(x) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACTRGSEL))
525 /*! @brief Format value for bitfield DAC_C0_DACTRGSEL. */
526 #define BF_DAC_C0_DACTRGSEL(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_DACTRGSEL) & BM_DAC_C0_DACTRGSEL)
528 /*! @brief Set the DACTRGSEL field to a new value. */
529 #define BW_DAC_C0_DACTRGSEL(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACTRGSEL) = (v))
533 * @name Register DAC_C0, field DACRFS[6] (RW)
536 * - 0 - The DAC selects DACREF_1 as the reference voltage.
537 * - 1 - The DAC selects DACREF_2 as the reference voltage.
540 #define BP_DAC_C0_DACRFS (6U) /*!< Bit position for DAC_C0_DACRFS. */
541 #define BM_DAC_C0_DACRFS (0x40U) /*!< Bit mask for DAC_C0_DACRFS. */
542 #define BS_DAC_C0_DACRFS (1U) /*!< Bit field size in bits for DAC_C0_DACRFS. */
544 /*! @brief Read current value of the DAC_C0_DACRFS field. */
545 #define BR_DAC_C0_DACRFS(x) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACRFS))
547 /*! @brief Format value for bitfield DAC_C0_DACRFS. */
548 #define BF_DAC_C0_DACRFS(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_DACRFS) & BM_DAC_C0_DACRFS)
550 /*! @brief Set the DACRFS field to a new value. */
551 #define BW_DAC_C0_DACRFS(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACRFS) = (v))
555 * @name Register DAC_C0, field DACEN[7] (RW)
557 * Starts the Programmable Reference Generator operation.
560 * - 0 - The DAC system is disabled.
561 * - 1 - The DAC system is enabled.
564 #define BP_DAC_C0_DACEN (7U) /*!< Bit position for DAC_C0_DACEN. */
565 #define BM_DAC_C0_DACEN (0x80U) /*!< Bit mask for DAC_C0_DACEN. */
566 #define BS_DAC_C0_DACEN (1U) /*!< Bit field size in bits for DAC_C0_DACEN. */
568 /*! @brief Read current value of the DAC_C0_DACEN field. */
569 #define BR_DAC_C0_DACEN(x) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACEN))
571 /*! @brief Format value for bitfield DAC_C0_DACEN. */
572 #define BF_DAC_C0_DACEN(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C0_DACEN) & BM_DAC_C0_DACEN)
574 /*! @brief Set the DACEN field to a new value. */
575 #define BW_DAC_C0_DACEN(x, v) (BITBAND_ACCESS8(HW_DAC_C0_ADDR(x), BP_DAC_C0_DACEN) = (v))
578 /*******************************************************************************
579 * HW_DAC_C1 - DAC Control Register 1
580 ******************************************************************************/
583 * @brief HW_DAC_C1 - DAC Control Register 1 (RW)
587 typedef union _hw_dac_c1
590 struct _hw_dac_c1_bitfields
592 uint8_t DACBFEN
: 1; /*!< [0] DAC Buffer Enable */
593 uint8_t DACBFMD
: 2; /*!< [2:1] DAC Buffer Work Mode Select */
594 uint8_t DACBFWM
: 2; /*!< [4:3] DAC Buffer Watermark Select */
595 uint8_t RESERVED0
: 2; /*!< [6:5] */
596 uint8_t DMAEN
: 1; /*!< [7] DMA Enable Select */
601 * @name Constants and macros for entire DAC_C1 register
604 #define HW_DAC_C1_ADDR(x) ((x) + 0x22U)
606 #define HW_DAC_C1(x) (*(__IO hw_dac_c1_t *) HW_DAC_C1_ADDR(x))
607 #define HW_DAC_C1_RD(x) (HW_DAC_C1(x).U)
608 #define HW_DAC_C1_WR(x, v) (HW_DAC_C1(x).U = (v))
609 #define HW_DAC_C1_SET(x, v) (HW_DAC_C1_WR(x, HW_DAC_C1_RD(x) | (v)))
610 #define HW_DAC_C1_CLR(x, v) (HW_DAC_C1_WR(x, HW_DAC_C1_RD(x) & ~(v)))
611 #define HW_DAC_C1_TOG(x, v) (HW_DAC_C1_WR(x, HW_DAC_C1_RD(x) ^ (v)))
615 * Constants & macros for individual DAC_C1 bitfields
619 * @name Register DAC_C1, field DACBFEN[0] (RW)
622 * - 0 - Buffer read pointer is disabled. The converted data is always the first
623 * word of the buffer.
624 * - 1 - Buffer read pointer is enabled. The converted data is the word that the
625 * read pointer points to. It means converted data can be from any word of
629 #define BP_DAC_C1_DACBFEN (0U) /*!< Bit position for DAC_C1_DACBFEN. */
630 #define BM_DAC_C1_DACBFEN (0x01U) /*!< Bit mask for DAC_C1_DACBFEN. */
631 #define BS_DAC_C1_DACBFEN (1U) /*!< Bit field size in bits for DAC_C1_DACBFEN. */
633 /*! @brief Read current value of the DAC_C1_DACBFEN field. */
634 #define BR_DAC_C1_DACBFEN(x) (BITBAND_ACCESS8(HW_DAC_C1_ADDR(x), BP_DAC_C1_DACBFEN))
636 /*! @brief Format value for bitfield DAC_C1_DACBFEN. */
637 #define BF_DAC_C1_DACBFEN(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C1_DACBFEN) & BM_DAC_C1_DACBFEN)
639 /*! @brief Set the DACBFEN field to a new value. */
640 #define BW_DAC_C1_DACBFEN(x, v) (BITBAND_ACCESS8(HW_DAC_C1_ADDR(x), BP_DAC_C1_DACBFEN) = (v))
644 * @name Register DAC_C1, field DACBFMD[2:1] (RW)
649 * - 10 - One-Time Scan mode
653 #define BP_DAC_C1_DACBFMD (1U) /*!< Bit position for DAC_C1_DACBFMD. */
654 #define BM_DAC_C1_DACBFMD (0x06U) /*!< Bit mask for DAC_C1_DACBFMD. */
655 #define BS_DAC_C1_DACBFMD (2U) /*!< Bit field size in bits for DAC_C1_DACBFMD. */
657 /*! @brief Read current value of the DAC_C1_DACBFMD field. */
658 #define BR_DAC_C1_DACBFMD(x) (HW_DAC_C1(x).B.DACBFMD)
660 /*! @brief Format value for bitfield DAC_C1_DACBFMD. */
661 #define BF_DAC_C1_DACBFMD(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C1_DACBFMD) & BM_DAC_C1_DACBFMD)
663 /*! @brief Set the DACBFMD field to a new value. */
664 #define BW_DAC_C1_DACBFMD(x, v) (HW_DAC_C1_WR(x, (HW_DAC_C1_RD(x) & ~BM_DAC_C1_DACBFMD) | BF_DAC_C1_DACBFMD(v)))
668 * @name Register DAC_C1, field DACBFWM[4:3] (RW)
670 * In normal mode it controls when SR[DACBFWMF] is set. When the DAC buffer read
671 * pointer reaches the word defined by this field, which is 1-4 words away from
672 * the upper limit (DACBUP), SR[DACBFWMF] will be set. This allows user
673 * configuration of the watermark interrupt. In FIFO mode, it is FIFO watermark select
677 * - 00 - In normal mode, 1 word . In FIFO mode, 2 or less than 2 data remaining
678 * in FIFO will set watermark status bit.
679 * - 01 - In normal mode, 2 words . In FIFO mode, Max/4 or less than Max/4 data
680 * remaining in FIFO will set watermark status bit.
681 * - 10 - In normal mode, 3 words . In FIFO mode, Max/2 or less than Max/2 data
682 * remaining in FIFO will set watermark status bit.
683 * - 11 - In normal mode, 4 words . In FIFO mode, Max-2 or less than Max-2 data
684 * remaining in FIFO will set watermark status bit.
687 #define BP_DAC_C1_DACBFWM (3U) /*!< Bit position for DAC_C1_DACBFWM. */
688 #define BM_DAC_C1_DACBFWM (0x18U) /*!< Bit mask for DAC_C1_DACBFWM. */
689 #define BS_DAC_C1_DACBFWM (2U) /*!< Bit field size in bits for DAC_C1_DACBFWM. */
691 /*! @brief Read current value of the DAC_C1_DACBFWM field. */
692 #define BR_DAC_C1_DACBFWM(x) (HW_DAC_C1(x).B.DACBFWM)
694 /*! @brief Format value for bitfield DAC_C1_DACBFWM. */
695 #define BF_DAC_C1_DACBFWM(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C1_DACBFWM) & BM_DAC_C1_DACBFWM)
697 /*! @brief Set the DACBFWM field to a new value. */
698 #define BW_DAC_C1_DACBFWM(x, v) (HW_DAC_C1_WR(x, (HW_DAC_C1_RD(x) & ~BM_DAC_C1_DACBFWM) | BF_DAC_C1_DACBFWM(v)))
702 * @name Register DAC_C1, field DMAEN[7] (RW)
705 * - 0 - DMA is disabled.
706 * - 1 - DMA is enabled. When DMA is enabled, the DMA request will be generated
707 * by original interrupts. The interrupts will not be presented on this
708 * module at the same time.
711 #define BP_DAC_C1_DMAEN (7U) /*!< Bit position for DAC_C1_DMAEN. */
712 #define BM_DAC_C1_DMAEN (0x80U) /*!< Bit mask for DAC_C1_DMAEN. */
713 #define BS_DAC_C1_DMAEN (1U) /*!< Bit field size in bits for DAC_C1_DMAEN. */
715 /*! @brief Read current value of the DAC_C1_DMAEN field. */
716 #define BR_DAC_C1_DMAEN(x) (BITBAND_ACCESS8(HW_DAC_C1_ADDR(x), BP_DAC_C1_DMAEN))
718 /*! @brief Format value for bitfield DAC_C1_DMAEN. */
719 #define BF_DAC_C1_DMAEN(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C1_DMAEN) & BM_DAC_C1_DMAEN)
721 /*! @brief Set the DMAEN field to a new value. */
722 #define BW_DAC_C1_DMAEN(x, v) (BITBAND_ACCESS8(HW_DAC_C1_ADDR(x), BP_DAC_C1_DMAEN) = (v))
725 /*******************************************************************************
726 * HW_DAC_C2 - DAC Control Register 2
727 ******************************************************************************/
730 * @brief HW_DAC_C2 - DAC Control Register 2 (RW)
734 typedef union _hw_dac_c2
737 struct _hw_dac_c2_bitfields
739 uint8_t DACBFUP
: 4; /*!< [3:0] DAC Buffer Upper Limit */
740 uint8_t DACBFRP
: 4; /*!< [7:4] DAC Buffer Read Pointer */
745 * @name Constants and macros for entire DAC_C2 register
748 #define HW_DAC_C2_ADDR(x) ((x) + 0x23U)
750 #define HW_DAC_C2(x) (*(__IO hw_dac_c2_t *) HW_DAC_C2_ADDR(x))
751 #define HW_DAC_C2_RD(x) (HW_DAC_C2(x).U)
752 #define HW_DAC_C2_WR(x, v) (HW_DAC_C2(x).U = (v))
753 #define HW_DAC_C2_SET(x, v) (HW_DAC_C2_WR(x, HW_DAC_C2_RD(x) | (v)))
754 #define HW_DAC_C2_CLR(x, v) (HW_DAC_C2_WR(x, HW_DAC_C2_RD(x) & ~(v)))
755 #define HW_DAC_C2_TOG(x, v) (HW_DAC_C2_WR(x, HW_DAC_C2_RD(x) ^ (v)))
759 * Constants & macros for individual DAC_C2 bitfields
763 * @name Register DAC_C2, field DACBFUP[3:0] (RW)
765 * In normal mode it selects the upper limit of the DAC buffer. The buffer read
766 * pointer cannot exceed it. In FIFO mode it is the FIFO write pointer. User
767 * cannot set Buffer Up limit in FIFO mode. In Normal mode its reset value is MAX.
768 * When IP is configured to FIFO mode, this register becomes Write_Pointer, and its
769 * value is initially set to equal READ_POINTER automatically, and the FIFO
770 * status is empty. It is writable and user can configure it to the same address to
771 * reset FIFO as empty.
774 #define BP_DAC_C2_DACBFUP (0U) /*!< Bit position for DAC_C2_DACBFUP. */
775 #define BM_DAC_C2_DACBFUP (0x0FU) /*!< Bit mask for DAC_C2_DACBFUP. */
776 #define BS_DAC_C2_DACBFUP (4U) /*!< Bit field size in bits for DAC_C2_DACBFUP. */
778 /*! @brief Read current value of the DAC_C2_DACBFUP field. */
779 #define BR_DAC_C2_DACBFUP(x) (HW_DAC_C2(x).B.DACBFUP)
781 /*! @brief Format value for bitfield DAC_C2_DACBFUP. */
782 #define BF_DAC_C2_DACBFUP(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C2_DACBFUP) & BM_DAC_C2_DACBFUP)
784 /*! @brief Set the DACBFUP field to a new value. */
785 #define BW_DAC_C2_DACBFUP(x, v) (HW_DAC_C2_WR(x, (HW_DAC_C2_RD(x) & ~BM_DAC_C2_DACBFUP) | BF_DAC_C2_DACBFUP(v)))
789 * @name Register DAC_C2, field DACBFRP[7:4] (RW)
791 * In normal mode it keeps the current value of the buffer read pointer. FIFO
792 * mode, it is the FIFO read pointer. It is writable in FIFO mode. User can
793 * configure it to same address to reset FIFO as empty.
796 #define BP_DAC_C2_DACBFRP (4U) /*!< Bit position for DAC_C2_DACBFRP. */
797 #define BM_DAC_C2_DACBFRP (0xF0U) /*!< Bit mask for DAC_C2_DACBFRP. */
798 #define BS_DAC_C2_DACBFRP (4U) /*!< Bit field size in bits for DAC_C2_DACBFRP. */
800 /*! @brief Read current value of the DAC_C2_DACBFRP field. */
801 #define BR_DAC_C2_DACBFRP(x) (HW_DAC_C2(x).B.DACBFRP)
803 /*! @brief Format value for bitfield DAC_C2_DACBFRP. */
804 #define BF_DAC_C2_DACBFRP(v) ((uint8_t)((uint8_t)(v) << BP_DAC_C2_DACBFRP) & BM_DAC_C2_DACBFRP)
806 /*! @brief Set the DACBFRP field to a new value. */
807 #define BW_DAC_C2_DACBFRP(x, v) (HW_DAC_C2_WR(x, (HW_DAC_C2_RD(x) & ~BM_DAC_C2_DACBFRP) | BF_DAC_C2_DACBFRP(v)))
810 /*******************************************************************************
811 * hw_dac_t - module struct
812 ******************************************************************************/
814 * @brief All DAC module registers.
817 typedef struct _hw_dac
820 __IO hw_dac_datnl_t DATnL
; /*!< [0x0] DAC Data Low Register */
821 __IO hw_dac_datnh_t DATnH
; /*!< [0x1] DAC Data High Register */
823 __IO hw_dac_sr_t SR
; /*!< [0x20] DAC Status Register */
824 __IO hw_dac_c0_t C0
; /*!< [0x21] DAC Control Register */
825 __IO hw_dac_c1_t C1
; /*!< [0x22] DAC Control Register 1 */
826 __IO hw_dac_c2_t C2
; /*!< [0x23] DAC Control Register 2 */
830 /*! @brief Macro to access all DAC registers. */
831 /*! @param x DAC module instance base address. */
832 /*! @return Reference (not a pointer) to the registers struct. To get a pointer to the struct,
833 * use the '&' operator, like <code>&HW_DAC(DAC0_BASE)</code>. */
834 #define HW_DAC(x) (*(hw_dac_t *)(x))
836 #endif /* __HW_DAC_REGISTERS_H__ */