regsepit.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*
  2. * Copyright (c) 2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESS OR IMPLIED
  6. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  7. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  8. * SHALL FREESCALE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  9. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
  10. * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  11. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  12. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  13. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  14. * OF SUCH DAMAGE.
  15. */
  16. /*
  17. * WARNING! DO NOT EDIT THIS FILE DIRECTLY!
  18. *
  19. * This file was generated automatically and any changes may be lost.
  20. */
  21. #ifndef __HW_EPIT_REGISTERS_H__
  22. #define __HW_EPIT_REGISTERS_H__
  23. #include "regs.h"
  24. /*
  25. * i.MX6UL EPIT
  26. *
  27. * EPIT
  28. *
  29. * Registers defined in this header file:
  30. * - HW_EPIT_CR - Control register
  31. * - HW_EPIT_SR - Status register
  32. * - HW_EPIT_LR - Load register
  33. * - HW_EPIT_CMPR - Compare register
  34. * - HW_EPIT_CNR - Counter register
  35. *
  36. * - hw_epit_t - Struct containing all module registers.
  37. */
  38. //! @name Module base addresses
  39. //@{
  40. #ifndef REGS_EPIT_BASE
  41. #define HW_EPIT_INSTANCE_COUNT (2) //!< Number of instances of the EPIT module.
  42. #define HW_EPIT1 (1) //!< Instance number for EPIT1.
  43. #define HW_EPIT2 (2) //!< Instance number for EPIT2.
  44. #define REGS_EPIT1_BASE (0x020d0000) //!< Base address for EPIT instance number 1.
  45. #define REGS_EPIT2_BASE (0x020d4000) //!< Base address for EPIT instance number 2.
  46. //! @brief Get the base address of EPIT by instance number.
  47. //! @param x EPIT instance number, from 1 through 2.
  48. #define REGS_EPIT_BASE(x) ( (x) == HW_EPIT1 ? REGS_EPIT1_BASE : (x) == HW_EPIT2 ? REGS_EPIT2_BASE : 0x00d00000)
  49. //! @brief Get the instance number given a base address.
  50. //! @param b Base address for an instance of EPIT.
  51. #define REGS_EPIT_INSTANCE(b) ( (b) == REGS_EPIT1_BASE ? HW_EPIT1 : (b) == REGS_EPIT2_BASE ? HW_EPIT2 : 0)
  52. #endif
  53. //@}
  54. //-------------------------------------------------------------------------------------------
  55. // HW_EPIT_CR - Control register
  56. //-------------------------------------------------------------------------------------------
  57. #ifndef __LANGUAGE_ASM__
  58. /*!
  59. * @brief HW_EPIT_CR - Control register (RW)
  60. *
  61. * Reset value: 0x00000000
  62. *
  63. * The EPIT control register (EPIT_CR) is used to configure the operating settings of the EPIT. It
  64. * contains the clock division prescaler value and also the interrupt enable bit. Additionally, it
  65. * contains other control bits which are described below. Peripheral Bus Write access to EPIT
  66. * Control Register (EPIT_CR) results in one cycle of the wait state, while other valid peripheral
  67. * bus accesses are with 0 wait state.
  68. */
  69. typedef union _hw_epit_cr
  70. {
  71. reg32_t U;
  72. struct _hw_epit_cr_bitfields
  73. {
  74. unsigned EN : 1; //!< [0] This bit enables the EPIT.
  75. unsigned ENMOD : 1; //!< [1] EPIT enable mode.
  76. unsigned OCIEN : 1; //!< [2] Output compare interrupt enable.
  77. unsigned RLD : 1; //!< [3] Counter reload control.
  78. unsigned PRESCALAR : 12; //!< [15:4] Counter clock prescaler value.
  79. unsigned SWR : 1; //!< [16] Software reset.
  80. unsigned IOVW : 1; //!< [17] EPIT counter overwrite enable.
  81. unsigned DBGEN : 1; //!< [18] This bit is used to keep the EPIT functional in debug mode.
  82. unsigned WAITEN : 1; //!< [19] This read/write control bit enables the operation of the EPIT during wait mode.
  83. unsigned RESERVED0 : 1; //!< [20] Reserved.
  84. unsigned STOPEN : 1; //!< [21] EPIT stop mode enable.
  85. unsigned OM : 2; //!< [23:22] EPIT output mode.This bit field determines the mode of EPIT output on the output pin.
  86. unsigned CLKSRC : 2; //!< [25:24] Select clock source
  87. unsigned RESERVED1 : 6; //!< [31:26] Reserved.
  88. } B;
  89. } hw_epit_cr_t;
  90. #endif
  91. /*!
  92. * @name Constants and macros for entire EPIT_CR register
  93. */
  94. //@{
  95. #define HW_EPIT_CR_ADDR(x) (REGS_EPIT_BASE(x) + 0x0)
  96. #ifndef __LANGUAGE_ASM__
  97. #define HW_EPIT_CR(x) (*(volatile hw_epit_cr_t *) HW_EPIT_CR_ADDR(x))
  98. #define HW_EPIT_CR_RD(x) (HW_EPIT_CR(x).U)
  99. #define HW_EPIT_CR_WR(x, v) (HW_EPIT_CR(x).U = (v))
  100. #define HW_EPIT_CR_SET(x, v) (HW_EPIT_CR_WR(x, HW_EPIT_CR_RD(x) | (v)))
  101. #define HW_EPIT_CR_CLR(x, v) (HW_EPIT_CR_WR(x, HW_EPIT_CR_RD(x) & ~(v)))
  102. #define HW_EPIT_CR_TOG(x, v) (HW_EPIT_CR_WR(x, HW_EPIT_CR_RD(x) ^ (v)))
  103. #endif
  104. //@}
  105. /*
  106. * constants & macros for individual EPIT_CR bitfields
  107. */
  108. /*! @name Register EPIT_CR, field EN[0] (RW)
  109. *
  110. * This bit enables the EPIT. EPIT counter and prescaler value when EPIT is enabled (EN = 1), is
  111. * dependent upon ENMOD and RLD bit as described for ENMOD bit. It is recommended that all registers
  112. * be properly programmed before setting this bit. This bit is reset by a hardware reset. A software
  113. * reset does not affect this bit.
  114. *
  115. * Values:
  116. * - 0 - EPIT is disabled
  117. * - 1 - EPIT is enabled
  118. */
  119. //@{
  120. #define BP_EPIT_CR_EN (0) //!< Bit position for EPIT_CR_EN.
  121. #define BM_EPIT_CR_EN (0x00000001) //!< Bit mask for EPIT_CR_EN.
  122. //! @brief Get value of EPIT_CR_EN from a register value.
  123. #define BG_EPIT_CR_EN(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_EN) >> BP_EPIT_CR_EN)
  124. //! @brief Format value for bitfield EPIT_CR_EN.
  125. #define BF_EPIT_CR_EN(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_EN) & BM_EPIT_CR_EN)
  126. #ifndef __LANGUAGE_ASM__
  127. //! @brief Set the EN field to a new value.
  128. #define BW_EPIT_CR_EN(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_EN) | BF_EPIT_CR_EN(v)))
  129. #endif
  130. //@}
  131. /*! @name Register EPIT_CR, field ENMOD[1] (RW)
  132. *
  133. * EPIT enable mode. When EPIT is disabled (EN=0), both main counter and prescaler counter freeze
  134. * their count at current count values. ENMOD bit is a r/w bit that determines the counter value
  135. * when the EPIT is enabled again by setting EN bit. If ENMOD bit is set, then main counter is
  136. * loaded with the load value (If RLD=1)/ 0xFFFF_FFFF (If RLD=0) and prescaler counter is reset,
  137. * when EPIT is enabled (EN=1). If ENMOD is programmed to 0 then both main counter and prescaler
  138. * counter restart counting from their frozen values when EPIT is enabled (EN=1). If EPIT is
  139. * programmed to be disabled in a low-power mode (STOP/WAIT/DEBUG), then both the main counter and
  140. * the prescaler counter freeze at their current count values when EPIT enters low-power mode. When
  141. * EPIT exits the low-power mode, both main counter and prescaler counter start counting from their
  142. * frozen values irrespective of the ENMOD bit. This bit is reset by a hardware reset. A software
  143. * reset does not affect this bit.
  144. *
  145. * Values:
  146. * - 0 - Counter starts counting from the value it had when it was disabled.
  147. * - 1 - Counter starts count from load value (RLD=1) or 0xFFFF_FFFF (If RLD=0)
  148. */
  149. //@{
  150. #define BP_EPIT_CR_ENMOD (1) //!< Bit position for EPIT_CR_ENMOD.
  151. #define BM_EPIT_CR_ENMOD (0x00000002) //!< Bit mask for EPIT_CR_ENMOD.
  152. //! @brief Get value of EPIT_CR_ENMOD from a register value.
  153. #define BG_EPIT_CR_ENMOD(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_ENMOD) >> BP_EPIT_CR_ENMOD)
  154. //! @brief Format value for bitfield EPIT_CR_ENMOD.
  155. #define BF_EPIT_CR_ENMOD(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_ENMOD) & BM_EPIT_CR_ENMOD)
  156. #ifndef __LANGUAGE_ASM__
  157. //! @brief Set the ENMOD field to a new value.
  158. #define BW_EPIT_CR_ENMOD(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_ENMOD) | BF_EPIT_CR_ENMOD(v)))
  159. #endif
  160. //@}
  161. /*! @name Register EPIT_CR, field OCIEN[2] (RW)
  162. *
  163. * Output compare interrupt enable. This bit enables the generation of interrupt on occurrence of
  164. * compare event.
  165. *
  166. * Values:
  167. * - 0 - Compare interrupt disabled
  168. * - 1 - Compare interrupt enabled
  169. */
  170. //@{
  171. #define BP_EPIT_CR_OCIEN (2) //!< Bit position for EPIT_CR_OCIEN.
  172. #define BM_EPIT_CR_OCIEN (0x00000004) //!< Bit mask for EPIT_CR_OCIEN.
  173. //! @brief Get value of EPIT_CR_OCIEN from a register value.
  174. #define BG_EPIT_CR_OCIEN(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_OCIEN) >> BP_EPIT_CR_OCIEN)
  175. //! @brief Format value for bitfield EPIT_CR_OCIEN.
  176. #define BF_EPIT_CR_OCIEN(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_OCIEN) & BM_EPIT_CR_OCIEN)
  177. #ifndef __LANGUAGE_ASM__
  178. //! @brief Set the OCIEN field to a new value.
  179. #define BW_EPIT_CR_OCIEN(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_OCIEN) | BF_EPIT_CR_OCIEN(v)))
  180. #endif
  181. //@}
  182. /*! @name Register EPIT_CR, field RLD[3] (RW)
  183. *
  184. * Counter reload control. This bit is cleared by hardware reset. It decides the counter
  185. * functionality, whether to run in free-running mode or set-and-forget mode.
  186. *
  187. * Values:
  188. * - 0 - When the counter reaches zero it rolls over to 0xFFFF_FFFF (free-running mode)
  189. * - 1 - When the counter reaches zero it reloads from the modulus register (set-and-forget mode)
  190. */
  191. //@{
  192. #define BP_EPIT_CR_RLD (3) //!< Bit position for EPIT_CR_RLD.
  193. #define BM_EPIT_CR_RLD (0x00000008) //!< Bit mask for EPIT_CR_RLD.
  194. //! @brief Get value of EPIT_CR_RLD from a register value.
  195. #define BG_EPIT_CR_RLD(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_RLD) >> BP_EPIT_CR_RLD)
  196. //! @brief Format value for bitfield EPIT_CR_RLD.
  197. #define BF_EPIT_CR_RLD(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_RLD) & BM_EPIT_CR_RLD)
  198. #ifndef __LANGUAGE_ASM__
  199. //! @brief Set the RLD field to a new value.
  200. #define BW_EPIT_CR_RLD(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_RLD) | BF_EPIT_CR_RLD(v)))
  201. #endif
  202. //@}
  203. /*! @name Register EPIT_CR, field PRESCALAR[15:4] (RW)
  204. *
  205. * Counter clock prescaler value. This bit field determines the prescaler value by which the clock
  206. * is divided before it goes to the counter
  207. *
  208. * Values:
  209. * - 0x000 - Divide by 1
  210. * - 0x001 - Divide by 2...
  211. * - 0xFFF - Divide by 4096
  212. */
  213. //@{
  214. #define BP_EPIT_CR_PRESCALAR (4) //!< Bit position for EPIT_CR_PRESCALAR.
  215. #define BM_EPIT_CR_PRESCALAR (0x0000fff0) //!< Bit mask for EPIT_CR_PRESCALAR.
  216. //! @brief Get value of EPIT_CR_PRESCALAR from a register value.
  217. #define BG_EPIT_CR_PRESCALAR(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_PRESCALAR) >> BP_EPIT_CR_PRESCALAR)
  218. //! @brief Format value for bitfield EPIT_CR_PRESCALAR.
  219. #define BF_EPIT_CR_PRESCALAR(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_PRESCALAR) & BM_EPIT_CR_PRESCALAR)
  220. #ifndef __LANGUAGE_ASM__
  221. //! @brief Set the PRESCALAR field to a new value.
  222. #define BW_EPIT_CR_PRESCALAR(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_PRESCALAR) | BF_EPIT_CR_PRESCALAR(v)))
  223. #endif
  224. //@}
  225. /*! @name Register EPIT_CR, field SWR[16] (RW)
  226. *
  227. * Software reset. The EPIT is reset when this bit is set to 1. It is a self clearing bit. This bit
  228. * is set when the block is in reset state and is cleared when the reset procedure is over. Setting
  229. * this bit resets all the registers to their reset values, except for the EN, ENMOD, STOPEN, WAITEN
  230. * and DBGEN bits in this control register
  231. *
  232. * Values:
  233. * - 0 - EPIT is out of reset
  234. * - 1 - EPIT is undergoing reset
  235. */
  236. //@{
  237. #define BP_EPIT_CR_SWR (16) //!< Bit position for EPIT_CR_SWR.
  238. #define BM_EPIT_CR_SWR (0x00010000) //!< Bit mask for EPIT_CR_SWR.
  239. //! @brief Get value of EPIT_CR_SWR from a register value.
  240. #define BG_EPIT_CR_SWR(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_SWR) >> BP_EPIT_CR_SWR)
  241. //! @brief Format value for bitfield EPIT_CR_SWR.
  242. #define BF_EPIT_CR_SWR(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_SWR) & BM_EPIT_CR_SWR)
  243. #ifndef __LANGUAGE_ASM__
  244. //! @brief Set the SWR field to a new value.
  245. #define BW_EPIT_CR_SWR(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_SWR) | BF_EPIT_CR_SWR(v)))
  246. #endif
  247. //@}
  248. /*! @name Register EPIT_CR, field IOVW[17] (RW)
  249. *
  250. * EPIT counter overwrite enable. This bit controls the counter data when the modulus register is
  251. * written. When this bit is set, all writes to the load register overwrites the counter contents
  252. * and the counter starts subsequently counting down from the programmed value.
  253. *
  254. * Values:
  255. * - 0 - Write to load register does not result in counter value being overwritten.
  256. * - 1 - Write to load register results in immediate overwriting of counter value.
  257. */
  258. //@{
  259. #define BP_EPIT_CR_IOVW (17) //!< Bit position for EPIT_CR_IOVW.
  260. #define BM_EPIT_CR_IOVW (0x00020000) //!< Bit mask for EPIT_CR_IOVW.
  261. //! @brief Get value of EPIT_CR_IOVW from a register value.
  262. #define BG_EPIT_CR_IOVW(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_IOVW) >> BP_EPIT_CR_IOVW)
  263. //! @brief Format value for bitfield EPIT_CR_IOVW.
  264. #define BF_EPIT_CR_IOVW(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_IOVW) & BM_EPIT_CR_IOVW)
  265. #ifndef __LANGUAGE_ASM__
  266. //! @brief Set the IOVW field to a new value.
  267. #define BW_EPIT_CR_IOVW(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_IOVW) | BF_EPIT_CR_IOVW(v)))
  268. #endif
  269. //@}
  270. /*! @name Register EPIT_CR, field DBGEN[18] (RW)
  271. *
  272. * This bit is used to keep the EPIT functional in debug mode. When this bit is cleared, the input
  273. * clock is gated off in debug mode.This bit is reset by hardware reset. A software reset does not
  274. * affect this bit.
  275. *
  276. * Values:
  277. * - 0 - Inactive in debug mode
  278. * - 1 - Active in debug mode
  279. */
  280. //@{
  281. #define BP_EPIT_CR_DBGEN (18) //!< Bit position for EPIT_CR_DBGEN.
  282. #define BM_EPIT_CR_DBGEN (0x00040000) //!< Bit mask for EPIT_CR_DBGEN.
  283. //! @brief Get value of EPIT_CR_DBGEN from a register value.
  284. #define BG_EPIT_CR_DBGEN(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_DBGEN) >> BP_EPIT_CR_DBGEN)
  285. //! @brief Format value for bitfield EPIT_CR_DBGEN.
  286. #define BF_EPIT_CR_DBGEN(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_DBGEN) & BM_EPIT_CR_DBGEN)
  287. #ifndef __LANGUAGE_ASM__
  288. //! @brief Set the DBGEN field to a new value.
  289. #define BW_EPIT_CR_DBGEN(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_DBGEN) | BF_EPIT_CR_DBGEN(v)))
  290. #endif
  291. //@}
  292. /*! @name Register EPIT_CR, field WAITEN[19] (RW)
  293. *
  294. * This read/write control bit enables the operation of the EPIT during wait mode. This bit is reset
  295. * by a hardware reset. A software reset does not affect this bit.
  296. *
  297. * Values:
  298. * - 0 - EPIT is disabled in wait mode
  299. * - 1 - EPIT is enabled in wait mode
  300. */
  301. //@{
  302. #define BP_EPIT_CR_WAITEN (19) //!< Bit position for EPIT_CR_WAITEN.
  303. #define BM_EPIT_CR_WAITEN (0x00080000) //!< Bit mask for EPIT_CR_WAITEN.
  304. //! @brief Get value of EPIT_CR_WAITEN from a register value.
  305. #define BG_EPIT_CR_WAITEN(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_WAITEN) >> BP_EPIT_CR_WAITEN)
  306. //! @brief Format value for bitfield EPIT_CR_WAITEN.
  307. #define BF_EPIT_CR_WAITEN(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_WAITEN) & BM_EPIT_CR_WAITEN)
  308. #ifndef __LANGUAGE_ASM__
  309. //! @brief Set the WAITEN field to a new value.
  310. #define BW_EPIT_CR_WAITEN(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_WAITEN) | BF_EPIT_CR_WAITEN(v)))
  311. #endif
  312. //@}
  313. /*! @name Register EPIT_CR, field STOPEN[21] (RW)
  314. *
  315. * EPIT stop mode enable. This read/write control bit enables the operation of the EPIT during stop
  316. * mode. This bit is reset by a hardware reset and unaffected by software reset.
  317. *
  318. * Values:
  319. * - 0 - EPIT is disabled in stop mode
  320. * - 1 - EPIT is enabled in stop mode
  321. */
  322. //@{
  323. #define BP_EPIT_CR_STOPEN (21) //!< Bit position for EPIT_CR_STOPEN.
  324. #define BM_EPIT_CR_STOPEN (0x00200000) //!< Bit mask for EPIT_CR_STOPEN.
  325. //! @brief Get value of EPIT_CR_STOPEN from a register value.
  326. #define BG_EPIT_CR_STOPEN(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_STOPEN) >> BP_EPIT_CR_STOPEN)
  327. //! @brief Format value for bitfield EPIT_CR_STOPEN.
  328. #define BF_EPIT_CR_STOPEN(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_STOPEN) & BM_EPIT_CR_STOPEN)
  329. #ifndef __LANGUAGE_ASM__
  330. //! @brief Set the STOPEN field to a new value.
  331. #define BW_EPIT_CR_STOPEN(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_STOPEN) | BF_EPIT_CR_STOPEN(v)))
  332. #endif
  333. //@}
  334. /*! @name Register EPIT_CR, field OM[23:22] (RW)
  335. *
  336. * EPIT output mode.This bit field determines the mode of EPIT output on the output pin.
  337. *
  338. * Values:
  339. * - 00 - EPIT output is disconnected from pad
  340. * - 01 - Toggle output pin
  341. * - 10 - Clear output pin
  342. * - 11 - Set output pin
  343. */
  344. //@{
  345. #define BP_EPIT_CR_OM (22) //!< Bit position for EPIT_CR_OM.
  346. #define BM_EPIT_CR_OM (0x00c00000) //!< Bit mask for EPIT_CR_OM.
  347. //! @brief Get value of EPIT_CR_OM from a register value.
  348. #define BG_EPIT_CR_OM(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_OM) >> BP_EPIT_CR_OM)
  349. //! @brief Format value for bitfield EPIT_CR_OM.
  350. #define BF_EPIT_CR_OM(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_OM) & BM_EPIT_CR_OM)
  351. #ifndef __LANGUAGE_ASM__
  352. //! @brief Set the OM field to a new value.
  353. #define BW_EPIT_CR_OM(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_OM) | BF_EPIT_CR_OM(v)))
  354. #endif
  355. //@}
  356. /*! @name Register EPIT_CR, field CLKSRC[25:24] (RW)
  357. *
  358. * Select clock source These bits determine which clock input is to be selected for running the
  359. * counter. This field value should only be changed when the EPIT is disabled by clearing the EN bit
  360. * in this register. For other programming requirements while changing clock source, refer to .
  361. *
  362. * Values:
  363. * - 00 - Clock is off
  364. * - 01 - Peripheral clock
  365. * - 10 - High-frequency reference clock
  366. * - 11 - Low-frequency reference clock
  367. */
  368. //@{
  369. #define BP_EPIT_CR_CLKSRC (24) //!< Bit position for EPIT_CR_CLKSRC.
  370. #define BM_EPIT_CR_CLKSRC (0x03000000) //!< Bit mask for EPIT_CR_CLKSRC.
  371. //! @brief Get value of EPIT_CR_CLKSRC from a register value.
  372. #define BG_EPIT_CR_CLKSRC(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CR_CLKSRC) >> BP_EPIT_CR_CLKSRC)
  373. //! @brief Format value for bitfield EPIT_CR_CLKSRC.
  374. #define BF_EPIT_CR_CLKSRC(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CR_CLKSRC) & BM_EPIT_CR_CLKSRC)
  375. #ifndef __LANGUAGE_ASM__
  376. //! @brief Set the CLKSRC field to a new value.
  377. #define BW_EPIT_CR_CLKSRC(x, v) (HW_EPIT_CR_WR(x, (HW_EPIT_CR_RD(x) & ~BM_EPIT_CR_CLKSRC) | BF_EPIT_CR_CLKSRC(v)))
  378. #endif
  379. //@}
  380. //-------------------------------------------------------------------------------------------
  381. // HW_EPIT_SR - Status register
  382. //-------------------------------------------------------------------------------------------
  383. #ifndef __LANGUAGE_ASM__
  384. /*!
  385. * @brief HW_EPIT_SR - Status register (RW)
  386. *
  387. * Reset value: 0x00000000
  388. *
  389. * The EPIT status register (EPIT_SR) has a single status bit for the output compare event. The bit
  390. * is a write 1 to clear bit.
  391. */
  392. typedef union _hw_epit_sr
  393. {
  394. reg32_t U;
  395. struct _hw_epit_sr_bitfields
  396. {
  397. unsigned OCIF : 1; //!< [0] Output compare interrupt flag.
  398. unsigned RESERVED0 : 31; //!< [31:1] Reserved.
  399. } B;
  400. } hw_epit_sr_t;
  401. #endif
  402. /*!
  403. * @name Constants and macros for entire EPIT_SR register
  404. */
  405. //@{
  406. #define HW_EPIT_SR_ADDR(x) (REGS_EPIT_BASE(x) + 0x4)
  407. #ifndef __LANGUAGE_ASM__
  408. #define HW_EPIT_SR(x) (*(volatile hw_epit_sr_t *) HW_EPIT_SR_ADDR(x))
  409. #define HW_EPIT_SR_RD(x) (HW_EPIT_SR(x).U)
  410. #define HW_EPIT_SR_WR(x, v) (HW_EPIT_SR(x).U = (v))
  411. #define HW_EPIT_SR_SET(x, v) (HW_EPIT_SR_WR(x, HW_EPIT_SR_RD(x) | (v)))
  412. #define HW_EPIT_SR_CLR(x, v) (HW_EPIT_SR_WR(x, HW_EPIT_SR_RD(x) & ~(v)))
  413. #define HW_EPIT_SR_TOG(x, v) (HW_EPIT_SR_WR(x, HW_EPIT_SR_RD(x) ^ (v)))
  414. #endif
  415. //@}
  416. /*
  417. * constants & macros for individual EPIT_SR bitfields
  418. */
  419. /*! @name Register EPIT_SR, field OCIF[0] (W1C)
  420. *
  421. * Output compare interrupt flag. This bit is the interrupt flag that is set when the content of
  422. * counter equals the content of the compare register (EPIT_CMPR). The bit is a write 1 to clear
  423. * bit.
  424. *
  425. * Values:
  426. * - 0 - Compare event has not occurred
  427. * - 1 - Compare event occurred
  428. */
  429. //@{
  430. #define BP_EPIT_SR_OCIF (0) //!< Bit position for EPIT_SR_OCIF.
  431. #define BM_EPIT_SR_OCIF (0x00000001) //!< Bit mask for EPIT_SR_OCIF.
  432. //! @brief Get value of EPIT_SR_OCIF from a register value.
  433. #define BG_EPIT_SR_OCIF(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_SR_OCIF) >> BP_EPIT_SR_OCIF)
  434. //! @brief Format value for bitfield EPIT_SR_OCIF.
  435. #define BF_EPIT_SR_OCIF(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_SR_OCIF) & BM_EPIT_SR_OCIF)
  436. #ifndef __LANGUAGE_ASM__
  437. //! @brief Set the OCIF field to a new value.
  438. #define BW_EPIT_SR_OCIF(x, v) (HW_EPIT_SR_WR(x, (HW_EPIT_SR_RD(x) & ~BM_EPIT_SR_OCIF) | BF_EPIT_SR_OCIF(v)))
  439. #endif
  440. //@}
  441. //-------------------------------------------------------------------------------------------
  442. // HW_EPIT_LR - Load register
  443. //-------------------------------------------------------------------------------------------
  444. #ifndef __LANGUAGE_ASM__
  445. /*!
  446. * @brief HW_EPIT_LR - Load register (RW)
  447. *
  448. * Reset value: 0xffffffff
  449. *
  450. * The EPIT load register (EPIT_LR) contains the value that is to be loaded into the counter when
  451. * EPIT counter reaches zero if the RLD bit in EPIT_CR is set. If the IOVW bit in the EPIT_CR is set
  452. * then a write to this register overwrites the value of the EPIT counter register in addition to
  453. * updating this registers value. This overwrite feature is active even if the RLD bit is not set.
  454. */
  455. typedef union _hw_epit_lr
  456. {
  457. reg32_t U;
  458. struct _hw_epit_lr_bitfields
  459. {
  460. unsigned LOAD : 32; //!< [31:0] Load value.
  461. } B;
  462. } hw_epit_lr_t;
  463. #endif
  464. /*!
  465. * @name Constants and macros for entire EPIT_LR register
  466. */
  467. //@{
  468. #define HW_EPIT_LR_ADDR(x) (REGS_EPIT_BASE(x) + 0x8)
  469. #ifndef __LANGUAGE_ASM__
  470. #define HW_EPIT_LR(x) (*(volatile hw_epit_lr_t *) HW_EPIT_LR_ADDR(x))
  471. #define HW_EPIT_LR_RD(x) (HW_EPIT_LR(x).U)
  472. #define HW_EPIT_LR_WR(x, v) (HW_EPIT_LR(x).U = (v))
  473. #define HW_EPIT_LR_SET(x, v) (HW_EPIT_LR_WR(x, HW_EPIT_LR_RD(x) | (v)))
  474. #define HW_EPIT_LR_CLR(x, v) (HW_EPIT_LR_WR(x, HW_EPIT_LR_RD(x) & ~(v)))
  475. #define HW_EPIT_LR_TOG(x, v) (HW_EPIT_LR_WR(x, HW_EPIT_LR_RD(x) ^ (v)))
  476. #endif
  477. //@}
  478. /*
  479. * constants & macros for individual EPIT_LR bitfields
  480. */
  481. /*! @name Register EPIT_LR, field LOAD[31:0] (RW)
  482. *
  483. * Load value. Value that is loaded into the counter at the start of each count cycle.
  484. */
  485. //@{
  486. #define BP_EPIT_LR_LOAD (0) //!< Bit position for EPIT_LR_LOAD.
  487. #define BM_EPIT_LR_LOAD (0xffffffff) //!< Bit mask for EPIT_LR_LOAD.
  488. //! @brief Get value of EPIT_LR_LOAD from a register value.
  489. #define BG_EPIT_LR_LOAD(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_LR_LOAD) >> BP_EPIT_LR_LOAD)
  490. //! @brief Format value for bitfield EPIT_LR_LOAD.
  491. #define BF_EPIT_LR_LOAD(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_LR_LOAD) & BM_EPIT_LR_LOAD)
  492. #ifndef __LANGUAGE_ASM__
  493. //! @brief Set the LOAD field to a new value.
  494. #define BW_EPIT_LR_LOAD(x, v) (HW_EPIT_LR_WR(x, (HW_EPIT_LR_RD(x) & ~BM_EPIT_LR_LOAD) | BF_EPIT_LR_LOAD(v)))
  495. #endif
  496. //@}
  497. //-------------------------------------------------------------------------------------------
  498. // HW_EPIT_CMPR - Compare register
  499. //-------------------------------------------------------------------------------------------
  500. #ifndef __LANGUAGE_ASM__
  501. /*!
  502. * @brief HW_EPIT_CMPR - Compare register (RW)
  503. *
  504. * Reset value: 0x00000000
  505. *
  506. * The EPIT compare register (EPIT_CMPR) holds the value that determines when a compare event is
  507. * generated.
  508. */
  509. typedef union _hw_epit_cmpr
  510. {
  511. reg32_t U;
  512. struct _hw_epit_cmpr_bitfields
  513. {
  514. unsigned COMPARE : 32; //!< [31:0] Compare Value.
  515. } B;
  516. } hw_epit_cmpr_t;
  517. #endif
  518. /*!
  519. * @name Constants and macros for entire EPIT_CMPR register
  520. */
  521. //@{
  522. #define HW_EPIT_CMPR_ADDR(x) (REGS_EPIT_BASE(x) + 0xc)
  523. #ifndef __LANGUAGE_ASM__
  524. #define HW_EPIT_CMPR(x) (*(volatile hw_epit_cmpr_t *) HW_EPIT_CMPR_ADDR(x))
  525. #define HW_EPIT_CMPR_RD(x) (HW_EPIT_CMPR(x).U)
  526. #define HW_EPIT_CMPR_WR(x, v) (HW_EPIT_CMPR(x).U = (v))
  527. #define HW_EPIT_CMPR_SET(x, v) (HW_EPIT_CMPR_WR(x, HW_EPIT_CMPR_RD(x) | (v)))
  528. #define HW_EPIT_CMPR_CLR(x, v) (HW_EPIT_CMPR_WR(x, HW_EPIT_CMPR_RD(x) & ~(v)))
  529. #define HW_EPIT_CMPR_TOG(x, v) (HW_EPIT_CMPR_WR(x, HW_EPIT_CMPR_RD(x) ^ (v)))
  530. #endif
  531. //@}
  532. /*
  533. * constants & macros for individual EPIT_CMPR bitfields
  534. */
  535. /*! @name Register EPIT_CMPR, field COMPARE[31:0] (RW)
  536. *
  537. * Compare Value. When the counter value equals this bit field value a compare event is generated.
  538. */
  539. //@{
  540. #define BP_EPIT_CMPR_COMPARE (0) //!< Bit position for EPIT_CMPR_COMPARE.
  541. #define BM_EPIT_CMPR_COMPARE (0xffffffff) //!< Bit mask for EPIT_CMPR_COMPARE.
  542. //! @brief Get value of EPIT_CMPR_COMPARE from a register value.
  543. #define BG_EPIT_CMPR_COMPARE(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CMPR_COMPARE) >> BP_EPIT_CMPR_COMPARE)
  544. //! @brief Format value for bitfield EPIT_CMPR_COMPARE.
  545. #define BF_EPIT_CMPR_COMPARE(v) ((__REG_VALUE_TYPE((v), reg32_t) << BP_EPIT_CMPR_COMPARE) & BM_EPIT_CMPR_COMPARE)
  546. #ifndef __LANGUAGE_ASM__
  547. //! @brief Set the COMPARE field to a new value.
  548. #define BW_EPIT_CMPR_COMPARE(x, v) (HW_EPIT_CMPR_WR(x, (HW_EPIT_CMPR_RD(x) & ~BM_EPIT_CMPR_COMPARE) | BF_EPIT_CMPR_COMPARE(v)))
  549. #endif
  550. //@}
  551. //-------------------------------------------------------------------------------------------
  552. // HW_EPIT_CNR - Counter register
  553. //-------------------------------------------------------------------------------------------
  554. #ifndef __LANGUAGE_ASM__
  555. /*!
  556. * @brief HW_EPIT_CNR - Counter register (RO)
  557. *
  558. * Reset value: 0xffffffff
  559. *
  560. * The EPIT counter register (EPIT_CNR) contains the current count value and can be read at any time
  561. * without disturbing the counter. This is a read-only register and any attempt to write into it
  562. * generates a transfer error. But if the IOVW bit in EPIT_CR is set, the value of this register can
  563. * be overwritten with a write to EPIT_LR. This change is reflected when this register is
  564. * subsequently read.
  565. */
  566. typedef union _hw_epit_cnr
  567. {
  568. reg32_t U;
  569. struct _hw_epit_cnr_bitfields
  570. {
  571. unsigned COUNT : 32; //!< [31:0] Counter value.
  572. } B;
  573. } hw_epit_cnr_t;
  574. #endif
  575. /*!
  576. * @name Constants and macros for entire EPIT_CNR register
  577. */
  578. //@{
  579. #define HW_EPIT_CNR_ADDR(x) (REGS_EPIT_BASE(x) + 0x10)
  580. #ifndef __LANGUAGE_ASM__
  581. #define HW_EPIT_CNR(x) (*(volatile hw_epit_cnr_t *) HW_EPIT_CNR_ADDR(x))
  582. #define HW_EPIT_CNR_RD(x) (HW_EPIT_CNR(x).U)
  583. #endif
  584. //@}
  585. /*
  586. * constants & macros for individual EPIT_CNR bitfields
  587. */
  588. /*! @name Register EPIT_CNR, field COUNT[31:0] (RO)
  589. *
  590. * Counter value. This contains the current value of the counter.
  591. */
  592. //@{
  593. #define BP_EPIT_CNR_COUNT (0) //!< Bit position for EPIT_CNR_COUNT.
  594. #define BM_EPIT_CNR_COUNT (0xffffffff) //!< Bit mask for EPIT_CNR_COUNT.
  595. //! @brief Get value of EPIT_CNR_COUNT from a register value.
  596. #define BG_EPIT_CNR_COUNT(r) ((__REG_VALUE_TYPE((r), reg32_t) & BM_EPIT_CNR_COUNT) >> BP_EPIT_CNR_COUNT)
  597. //@}
  598. //-------------------------------------------------------------------------------------------
  599. // hw_epit_t - module struct
  600. //-------------------------------------------------------------------------------------------
  601. /*!
  602. * @brief All EPIT module registers.
  603. */
  604. #ifndef __LANGUAGE_ASM__
  605. #pragma pack(1)
  606. typedef struct _hw_epit
  607. {
  608. volatile hw_epit_cr_t CR; //!< Control register
  609. volatile hw_epit_sr_t SR; //!< Status register
  610. volatile hw_epit_lr_t LR; //!< Load register
  611. volatile hw_epit_cmpr_t CMPR; //!< Compare register
  612. volatile hw_epit_cnr_t CNR; //!< Counter register
  613. } hw_epit_t;
  614. #pragma pack()
  615. //! @brief Macro to access all EPIT registers.
  616. //! @param x EPIT instance number.
  617. //! @return Reference (not a pointer) to the registers struct. To get a pointer to the struct,
  618. //! use the '&' operator, like <code>&HW_EPIT(0)</code>.
  619. #define HW_EPIT(x) (*(hw_epit_t *) REGS_EPIT_BASE(x))
  620. #endif
  621. #endif // __HW_EPIT_REGISTERS_H__
  622. // v18/121106/1.2.2
  623. // EOF