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_EWM_REGISTERS_H__
78 #define __HW_EWM_REGISTERS_H__
80 #include "MK22F51212.h"
81 #include "fsl_bitaccess.h"
86 * External Watchdog Monitor
88 * Registers defined in this header file:
89 * - HW_EWM_CTRL - Control Register
90 * - HW_EWM_SERV - Service Register
91 * - HW_EWM_CMPL - Compare Low Register
92 * - HW_EWM_CMPH - Compare High Register
93 * - HW_EWM_CLKPRESCALER - Clock Prescaler Register
95 * - hw_ewm_t - Struct containing all module registers.
98 #define HW_EWM_INSTANCE_COUNT (1U) /*!< Number of instances of the EWM module. */
100 /*******************************************************************************
101 * HW_EWM_CTRL - Control Register
102 ******************************************************************************/
105 * @brief HW_EWM_CTRL - Control Register (RW)
109 * The CTRL register is cleared by any reset. INEN, ASSIN and EWMEN bits can be
110 * written once after a CPU reset. Modifying these bits more than once, generates
111 * a bus transfer error.
113 typedef union _hw_ewm_ctrl
116 struct _hw_ewm_ctrl_bitfields
118 uint8_t EWMEN
: 1; /*!< [0] EWM enable. */
119 uint8_t ASSIN
: 1; /*!< [1] EWM_in's Assertion State Select. */
120 uint8_t INEN
: 1; /*!< [2] Input Enable. */
121 uint8_t INTEN
: 1; /*!< [3] Interrupt Enable. */
122 uint8_t RESERVED0
: 4; /*!< [7:4] */
127 * @name Constants and macros for entire EWM_CTRL register
130 #define HW_EWM_CTRL_ADDR(x) ((x) + 0x0U)
132 #define HW_EWM_CTRL(x) (*(__IO hw_ewm_ctrl_t *) HW_EWM_CTRL_ADDR(x))
133 #define HW_EWM_CTRL_RD(x) (HW_EWM_CTRL(x).U)
134 #define HW_EWM_CTRL_WR(x, v) (HW_EWM_CTRL(x).U = (v))
135 #define HW_EWM_CTRL_SET(x, v) (HW_EWM_CTRL_WR(x, HW_EWM_CTRL_RD(x) | (v)))
136 #define HW_EWM_CTRL_CLR(x, v) (HW_EWM_CTRL_WR(x, HW_EWM_CTRL_RD(x) & ~(v)))
137 #define HW_EWM_CTRL_TOG(x, v) (HW_EWM_CTRL_WR(x, HW_EWM_CTRL_RD(x) ^ (v)))
141 * Constants & macros for individual EWM_CTRL bitfields
145 * @name Register EWM_CTRL, field EWMEN[0] (RW)
147 * This bit when set, enables the EWM module. This resets the EWM counter to
148 * zero and deasserts the EWM_out signal. Clearing EWMEN bit disables the EWM, and
149 * therefore it cannot be enabled until a reset occurs, due to the write-once
150 * nature of this bit.
153 #define BP_EWM_CTRL_EWMEN (0U) /*!< Bit position for EWM_CTRL_EWMEN. */
154 #define BM_EWM_CTRL_EWMEN (0x01U) /*!< Bit mask for EWM_CTRL_EWMEN. */
155 #define BS_EWM_CTRL_EWMEN (1U) /*!< Bit field size in bits for EWM_CTRL_EWMEN. */
157 /*! @brief Read current value of the EWM_CTRL_EWMEN field. */
158 #define BR_EWM_CTRL_EWMEN(x) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_EWMEN))
160 /*! @brief Format value for bitfield EWM_CTRL_EWMEN. */
161 #define BF_EWM_CTRL_EWMEN(v) ((uint8_t)((uint8_t)(v) << BP_EWM_CTRL_EWMEN) & BM_EWM_CTRL_EWMEN)
163 /*! @brief Set the EWMEN field to a new value. */
164 #define BW_EWM_CTRL_EWMEN(x, v) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_EWMEN) = (v))
168 * @name Register EWM_CTRL, field ASSIN[1] (RW)
170 * Default assert state of the EWM_in signal is logic zero. Setting ASSIN bit
171 * inverts the assert state to a logic one.
174 #define BP_EWM_CTRL_ASSIN (1U) /*!< Bit position for EWM_CTRL_ASSIN. */
175 #define BM_EWM_CTRL_ASSIN (0x02U) /*!< Bit mask for EWM_CTRL_ASSIN. */
176 #define BS_EWM_CTRL_ASSIN (1U) /*!< Bit field size in bits for EWM_CTRL_ASSIN. */
178 /*! @brief Read current value of the EWM_CTRL_ASSIN field. */
179 #define BR_EWM_CTRL_ASSIN(x) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_ASSIN))
181 /*! @brief Format value for bitfield EWM_CTRL_ASSIN. */
182 #define BF_EWM_CTRL_ASSIN(v) ((uint8_t)((uint8_t)(v) << BP_EWM_CTRL_ASSIN) & BM_EWM_CTRL_ASSIN)
184 /*! @brief Set the ASSIN field to a new value. */
185 #define BW_EWM_CTRL_ASSIN(x, v) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_ASSIN) = (v))
189 * @name Register EWM_CTRL, field INEN[2] (RW)
191 * This bit when set, enables the EWM_in port.
194 #define BP_EWM_CTRL_INEN (2U) /*!< Bit position for EWM_CTRL_INEN. */
195 #define BM_EWM_CTRL_INEN (0x04U) /*!< Bit mask for EWM_CTRL_INEN. */
196 #define BS_EWM_CTRL_INEN (1U) /*!< Bit field size in bits for EWM_CTRL_INEN. */
198 /*! @brief Read current value of the EWM_CTRL_INEN field. */
199 #define BR_EWM_CTRL_INEN(x) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_INEN))
201 /*! @brief Format value for bitfield EWM_CTRL_INEN. */
202 #define BF_EWM_CTRL_INEN(v) ((uint8_t)((uint8_t)(v) << BP_EWM_CTRL_INEN) & BM_EWM_CTRL_INEN)
204 /*! @brief Set the INEN field to a new value. */
205 #define BW_EWM_CTRL_INEN(x, v) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_INEN) = (v))
209 * @name Register EWM_CTRL, field INTEN[3] (RW)
211 * This bit when set and EWM_out is asserted, an interrupt request is generated.
212 * To de-assert interrupt request, user should clear this bit by writing 0.
215 #define BP_EWM_CTRL_INTEN (3U) /*!< Bit position for EWM_CTRL_INTEN. */
216 #define BM_EWM_CTRL_INTEN (0x08U) /*!< Bit mask for EWM_CTRL_INTEN. */
217 #define BS_EWM_CTRL_INTEN (1U) /*!< Bit field size in bits for EWM_CTRL_INTEN. */
219 /*! @brief Read current value of the EWM_CTRL_INTEN field. */
220 #define BR_EWM_CTRL_INTEN(x) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_INTEN))
222 /*! @brief Format value for bitfield EWM_CTRL_INTEN. */
223 #define BF_EWM_CTRL_INTEN(v) ((uint8_t)((uint8_t)(v) << BP_EWM_CTRL_INTEN) & BM_EWM_CTRL_INTEN)
225 /*! @brief Set the INTEN field to a new value. */
226 #define BW_EWM_CTRL_INTEN(x, v) (BITBAND_ACCESS8(HW_EWM_CTRL_ADDR(x), BP_EWM_CTRL_INTEN) = (v))
229 /*******************************************************************************
230 * HW_EWM_SERV - Service Register
231 ******************************************************************************/
234 * @brief HW_EWM_SERV - Service Register (WORZ)
238 * The SERV register provides the interface from the CPU to the EWM module. It
239 * is write-only and reads of this register return zero.
241 typedef union _hw_ewm_serv
244 struct _hw_ewm_serv_bitfields
246 uint8_t SERVICE
: 8; /*!< [7:0] */
251 * @name Constants and macros for entire EWM_SERV register
254 #define HW_EWM_SERV_ADDR(x) ((x) + 0x1U)
256 #define HW_EWM_SERV(x) (*(__O hw_ewm_serv_t *) HW_EWM_SERV_ADDR(x))
257 #define HW_EWM_SERV_RD(x) (HW_EWM_SERV(x).U)
258 #define HW_EWM_SERV_WR(x, v) (HW_EWM_SERV(x).U = (v))
262 * Constants & macros for individual EWM_SERV bitfields
266 * @name Register EWM_SERV, field SERVICE[7:0] (WORZ)
268 * The EWM service mechanism requires the CPU to write two values to the SERV
269 * register: a first data byte of 0xB4, followed by a second data byte of 0x2C. The
270 * EWM service is illegal if either of the following conditions is true. The
271 * first or second data byte is not written correctly. The second data byte is not
272 * written within a fixed number of peripheral bus cycles of the first data byte.
273 * This fixed number of cycles is called EWM_service_time.
276 #define BP_EWM_SERV_SERVICE (0U) /*!< Bit position for EWM_SERV_SERVICE. */
277 #define BM_EWM_SERV_SERVICE (0xFFU) /*!< Bit mask for EWM_SERV_SERVICE. */
278 #define BS_EWM_SERV_SERVICE (8U) /*!< Bit field size in bits for EWM_SERV_SERVICE. */
280 /*! @brief Format value for bitfield EWM_SERV_SERVICE. */
281 #define BF_EWM_SERV_SERVICE(v) ((uint8_t)((uint8_t)(v) << BP_EWM_SERV_SERVICE) & BM_EWM_SERV_SERVICE)
283 /*! @brief Set the SERVICE field to a new value. */
284 #define BW_EWM_SERV_SERVICE(x, v) (HW_EWM_SERV_WR(x, v))
287 /*******************************************************************************
288 * HW_EWM_CMPL - Compare Low Register
289 ******************************************************************************/
292 * @brief HW_EWM_CMPL - Compare Low Register (RW)
296 * The CMPL register is reset to zero after a CPU reset. This provides no
297 * minimum time for the CPU to service the EWM counter. This register can be written
298 * only once after a CPU reset. Writing this register more than once generates a
299 * bus transfer error.
301 typedef union _hw_ewm_cmpl
304 struct _hw_ewm_cmpl_bitfields
306 uint8_t COMPAREL
: 8; /*!< [7:0] */
311 * @name Constants and macros for entire EWM_CMPL register
314 #define HW_EWM_CMPL_ADDR(x) ((x) + 0x2U)
316 #define HW_EWM_CMPL(x) (*(__IO hw_ewm_cmpl_t *) HW_EWM_CMPL_ADDR(x))
317 #define HW_EWM_CMPL_RD(x) (HW_EWM_CMPL(x).U)
318 #define HW_EWM_CMPL_WR(x, v) (HW_EWM_CMPL(x).U = (v))
319 #define HW_EWM_CMPL_SET(x, v) (HW_EWM_CMPL_WR(x, HW_EWM_CMPL_RD(x) | (v)))
320 #define HW_EWM_CMPL_CLR(x, v) (HW_EWM_CMPL_WR(x, HW_EWM_CMPL_RD(x) & ~(v)))
321 #define HW_EWM_CMPL_TOG(x, v) (HW_EWM_CMPL_WR(x, HW_EWM_CMPL_RD(x) ^ (v)))
325 * Constants & macros for individual EWM_CMPL bitfields
329 * @name Register EWM_CMPL, field COMPAREL[7:0] (RW)
331 * To prevent runaway code from changing this field, software should write to
332 * this field after a CPU reset even if the (default) minimum service time is
336 #define BP_EWM_CMPL_COMPAREL (0U) /*!< Bit position for EWM_CMPL_COMPAREL. */
337 #define BM_EWM_CMPL_COMPAREL (0xFFU) /*!< Bit mask for EWM_CMPL_COMPAREL. */
338 #define BS_EWM_CMPL_COMPAREL (8U) /*!< Bit field size in bits for EWM_CMPL_COMPAREL. */
340 /*! @brief Read current value of the EWM_CMPL_COMPAREL field. */
341 #define BR_EWM_CMPL_COMPAREL(x) (HW_EWM_CMPL(x).U)
343 /*! @brief Format value for bitfield EWM_CMPL_COMPAREL. */
344 #define BF_EWM_CMPL_COMPAREL(v) ((uint8_t)((uint8_t)(v) << BP_EWM_CMPL_COMPAREL) & BM_EWM_CMPL_COMPAREL)
346 /*! @brief Set the COMPAREL field to a new value. */
347 #define BW_EWM_CMPL_COMPAREL(x, v) (HW_EWM_CMPL_WR(x, v))
350 /*******************************************************************************
351 * HW_EWM_CMPH - Compare High Register
352 ******************************************************************************/
355 * @brief HW_EWM_CMPH - Compare High Register (RW)
359 * The CMPH register is reset to 0xFF after a CPU reset. This provides a maximum
360 * of 256 clocks time, for the CPU to service the EWM counter. This register can
361 * be written only once after a CPU reset. Writing this register more than once
362 * generates a bus transfer error. The valid values for CMPH are up to 0xFE
363 * because the EWM counter never expires when CMPH = 0xFF. The expiration happens only
364 * if EWM counter is greater than CMPH.
366 typedef union _hw_ewm_cmph
369 struct _hw_ewm_cmph_bitfields
371 uint8_t COMPAREH
: 8; /*!< [7:0] */
376 * @name Constants and macros for entire EWM_CMPH register
379 #define HW_EWM_CMPH_ADDR(x) ((x) + 0x3U)
381 #define HW_EWM_CMPH(x) (*(__IO hw_ewm_cmph_t *) HW_EWM_CMPH_ADDR(x))
382 #define HW_EWM_CMPH_RD(x) (HW_EWM_CMPH(x).U)
383 #define HW_EWM_CMPH_WR(x, v) (HW_EWM_CMPH(x).U = (v))
384 #define HW_EWM_CMPH_SET(x, v) (HW_EWM_CMPH_WR(x, HW_EWM_CMPH_RD(x) | (v)))
385 #define HW_EWM_CMPH_CLR(x, v) (HW_EWM_CMPH_WR(x, HW_EWM_CMPH_RD(x) & ~(v)))
386 #define HW_EWM_CMPH_TOG(x, v) (HW_EWM_CMPH_WR(x, HW_EWM_CMPH_RD(x) ^ (v)))
390 * Constants & macros for individual EWM_CMPH bitfields
394 * @name Register EWM_CMPH, field COMPAREH[7:0] (RW)
396 * To prevent runaway code from changing this field, software should write to
397 * this field after a CPU reset even if the (default) maximum service time is
401 #define BP_EWM_CMPH_COMPAREH (0U) /*!< Bit position for EWM_CMPH_COMPAREH. */
402 #define BM_EWM_CMPH_COMPAREH (0xFFU) /*!< Bit mask for EWM_CMPH_COMPAREH. */
403 #define BS_EWM_CMPH_COMPAREH (8U) /*!< Bit field size in bits for EWM_CMPH_COMPAREH. */
405 /*! @brief Read current value of the EWM_CMPH_COMPAREH field. */
406 #define BR_EWM_CMPH_COMPAREH(x) (HW_EWM_CMPH(x).U)
408 /*! @brief Format value for bitfield EWM_CMPH_COMPAREH. */
409 #define BF_EWM_CMPH_COMPAREH(v) ((uint8_t)((uint8_t)(v) << BP_EWM_CMPH_COMPAREH) & BM_EWM_CMPH_COMPAREH)
411 /*! @brief Set the COMPAREH field to a new value. */
412 #define BW_EWM_CMPH_COMPAREH(x, v) (HW_EWM_CMPH_WR(x, v))
415 /*******************************************************************************
416 * HW_EWM_CLKPRESCALER - Clock Prescaler Register
417 ******************************************************************************/
420 * @brief HW_EWM_CLKPRESCALER - Clock Prescaler Register (RW)
424 * This CLKPRESCALER register is reset to 0x00 after a CPU reset. This register
425 * can be written only once after a CPU reset. Writing this register more than
426 * once generates a bus transfer error. Write the required prescaler value before
427 * enabling the EWM. The implementation of this register is chip-specific. See the
428 * Chip Configuration details.
430 typedef union _hw_ewm_clkprescaler
433 struct _hw_ewm_clkprescaler_bitfields
435 uint8_t CLK_DIV
: 8; /*!< [7:0] */
437 } hw_ewm_clkprescaler_t
;
440 * @name Constants and macros for entire EWM_CLKPRESCALER register
443 #define HW_EWM_CLKPRESCALER_ADDR(x) ((x) + 0x5U)
445 #define HW_EWM_CLKPRESCALER(x) (*(__IO hw_ewm_clkprescaler_t *) HW_EWM_CLKPRESCALER_ADDR(x))
446 #define HW_EWM_CLKPRESCALER_RD(x) (HW_EWM_CLKPRESCALER(x).U)
447 #define HW_EWM_CLKPRESCALER_WR(x, v) (HW_EWM_CLKPRESCALER(x).U = (v))
448 #define HW_EWM_CLKPRESCALER_SET(x, v) (HW_EWM_CLKPRESCALER_WR(x, HW_EWM_CLKPRESCALER_RD(x) | (v)))
449 #define HW_EWM_CLKPRESCALER_CLR(x, v) (HW_EWM_CLKPRESCALER_WR(x, HW_EWM_CLKPRESCALER_RD(x) & ~(v)))
450 #define HW_EWM_CLKPRESCALER_TOG(x, v) (HW_EWM_CLKPRESCALER_WR(x, HW_EWM_CLKPRESCALER_RD(x) ^ (v)))
454 * Constants & macros for individual EWM_CLKPRESCALER bitfields
458 * @name Register EWM_CLKPRESCALER, field CLK_DIV[7:0] (RW)
460 * Selected low power source for running the EWM counter can be prescaled as
461 * below. Prescaled clock frequency = low power clock source frequency/ ( 1+ CLK_DIV
465 #define BP_EWM_CLKPRESCALER_CLK_DIV (0U) /*!< Bit position for EWM_CLKPRESCALER_CLK_DIV. */
466 #define BM_EWM_CLKPRESCALER_CLK_DIV (0xFFU) /*!< Bit mask for EWM_CLKPRESCALER_CLK_DIV. */
467 #define BS_EWM_CLKPRESCALER_CLK_DIV (8U) /*!< Bit field size in bits for EWM_CLKPRESCALER_CLK_DIV. */
469 /*! @brief Read current value of the EWM_CLKPRESCALER_CLK_DIV field. */
470 #define BR_EWM_CLKPRESCALER_CLK_DIV(x) (HW_EWM_CLKPRESCALER(x).U)
472 /*! @brief Format value for bitfield EWM_CLKPRESCALER_CLK_DIV. */
473 #define BF_EWM_CLKPRESCALER_CLK_DIV(v) ((uint8_t)((uint8_t)(v) << BP_EWM_CLKPRESCALER_CLK_DIV) & BM_EWM_CLKPRESCALER_CLK_DIV)
475 /*! @brief Set the CLK_DIV field to a new value. */
476 #define BW_EWM_CLKPRESCALER_CLK_DIV(x, v) (HW_EWM_CLKPRESCALER_WR(x, v))
479 /*******************************************************************************
480 * hw_ewm_t - module struct
481 ******************************************************************************/
483 * @brief All EWM module registers.
486 typedef struct _hw_ewm
488 __IO hw_ewm_ctrl_t CTRL
; /*!< [0x0] Control Register */
489 __O hw_ewm_serv_t SERV
; /*!< [0x1] Service Register */
490 __IO hw_ewm_cmpl_t CMPL
; /*!< [0x2] Compare Low Register */
491 __IO hw_ewm_cmph_t CMPH
; /*!< [0x3] Compare High Register */
492 uint8_t _reserved0
[1];
493 __IO hw_ewm_clkprescaler_t CLKPRESCALER
; /*!< [0x5] Clock Prescaler Register */
497 /*! @brief Macro to access all EWM registers. */
498 /*! @param x EWM module instance base address. */
499 /*! @return Reference (not a pointer) to the registers struct. To get a pointer to the struct,
500 * use the '&' operator, like <code>&HW_EWM(EWM_BASE)</code>. */
501 #define HW_EWM(x) (*(hw_ewm_t *)(x))
503 #endif /* __HW_EWM_REGISTERS_H__ */