MK64F12_vref.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /*
  2. * Copyright (c) 2014, 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_VREF_REGISTERS_H__
  22. #define __HW_VREF_REGISTERS_H__
  23. #include "regs.h"
  24. /*
  25. * MK64F12 VREF
  26. *
  27. * Voltage Reference
  28. *
  29. * Registers defined in this header file:
  30. * - HW_VREF_TRM - VREF Trim Register
  31. * - HW_VREF_SC - VREF Status and Control Register
  32. *
  33. * - hw_vref_t - Struct containing all module registers.
  34. */
  35. //! @name Module base addresses
  36. //@{
  37. #ifndef REGS_VREF_BASE
  38. #define HW_VREF_INSTANCE_COUNT (1U) //!< Number of instances of the VREF module.
  39. #define REGS_VREF_BASE (0x40074000U) //!< Base address for VREF.
  40. #endif
  41. //@}
  42. //-------------------------------------------------------------------------------------------
  43. // HW_VREF_TRM - VREF Trim Register
  44. //-------------------------------------------------------------------------------------------
  45. #ifndef __LANGUAGE_ASM__
  46. /*!
  47. * @brief HW_VREF_TRM - VREF Trim Register (RW)
  48. *
  49. * Reset value: 0x00U
  50. *
  51. * This register contains bits that contain the trim data for the Voltage
  52. * Reference.
  53. */
  54. typedef union _hw_vref_trm
  55. {
  56. uint8_t U;
  57. struct _hw_vref_trm_bitfields
  58. {
  59. uint8_t TRIM : 6; //!< [5:0] Trim bits
  60. uint8_t CHOPEN : 1; //!< [6] Chop oscillator enable. When set,
  61. //! internal chopping operation is enabled and the internal analog offset will
  62. //! be minimized.
  63. uint8_t RESERVED0 : 1; //!< [7]
  64. } B;
  65. } hw_vref_trm_t;
  66. #endif
  67. /*!
  68. * @name Constants and macros for entire VREF_TRM register
  69. */
  70. //@{
  71. #define HW_VREF_TRM_ADDR (REGS_VREF_BASE + 0x0U)
  72. #ifndef __LANGUAGE_ASM__
  73. #define HW_VREF_TRM (*(__IO hw_vref_trm_t *) HW_VREF_TRM_ADDR)
  74. #define HW_VREF_TRM_RD() (HW_VREF_TRM.U)
  75. #define HW_VREF_TRM_WR(v) (HW_VREF_TRM.U = (v))
  76. #define HW_VREF_TRM_SET(v) (HW_VREF_TRM_WR(HW_VREF_TRM_RD() | (v)))
  77. #define HW_VREF_TRM_CLR(v) (HW_VREF_TRM_WR(HW_VREF_TRM_RD() & ~(v)))
  78. #define HW_VREF_TRM_TOG(v) (HW_VREF_TRM_WR(HW_VREF_TRM_RD() ^ (v)))
  79. #endif
  80. //@}
  81. /*
  82. * Constants & macros for individual VREF_TRM bitfields
  83. */
  84. /*!
  85. * @name Register VREF_TRM, field TRIM[5:0] (RW)
  86. *
  87. * These bits change the resulting VREF by approximately +/- 0.5 mV for each
  88. * step. Min = minimum and max = maximum voltage reference output. For minimum and
  89. * maximum voltage reference output values, refer to the Data Sheet for this chip.
  90. *
  91. * Values:
  92. * - 000000 - Min
  93. * - 111111 - Max
  94. */
  95. //@{
  96. #define BP_VREF_TRM_TRIM (0U) //!< Bit position for VREF_TRM_TRIM.
  97. #define BM_VREF_TRM_TRIM (0x3FU) //!< Bit mask for VREF_TRM_TRIM.
  98. #define BS_VREF_TRM_TRIM (6U) //!< Bit field size in bits for VREF_TRM_TRIM.
  99. #ifndef __LANGUAGE_ASM__
  100. //! @brief Read current value of the VREF_TRM_TRIM field.
  101. #define BR_VREF_TRM_TRIM (HW_VREF_TRM.B.TRIM)
  102. #endif
  103. //! @brief Format value for bitfield VREF_TRM_TRIM.
  104. #define BF_VREF_TRM_TRIM(v) (__REG_VALUE_TYPE((__REG_VALUE_TYPE((v), uint8_t) << BP_VREF_TRM_TRIM), uint8_t) & BM_VREF_TRM_TRIM)
  105. #ifndef __LANGUAGE_ASM__
  106. //! @brief Set the TRIM field to a new value.
  107. #define BW_VREF_TRM_TRIM(v) (HW_VREF_TRM_WR((HW_VREF_TRM_RD() & ~BM_VREF_TRM_TRIM) | BF_VREF_TRM_TRIM(v)))
  108. #endif
  109. //@}
  110. /*!
  111. * @name Register VREF_TRM, field CHOPEN[6] (RW)
  112. *
  113. * This bit is set during factory trimming of the VREF voltage. This bit should
  114. * be written to 1 to achieve the performance stated in the data sheet.
  115. *
  116. * Values:
  117. * - 0 - Chop oscillator is disabled.
  118. * - 1 - Chop oscillator is enabled.
  119. */
  120. //@{
  121. #define BP_VREF_TRM_CHOPEN (6U) //!< Bit position for VREF_TRM_CHOPEN.
  122. #define BM_VREF_TRM_CHOPEN (0x40U) //!< Bit mask for VREF_TRM_CHOPEN.
  123. #define BS_VREF_TRM_CHOPEN (1U) //!< Bit field size in bits for VREF_TRM_CHOPEN.
  124. #ifndef __LANGUAGE_ASM__
  125. //! @brief Read current value of the VREF_TRM_CHOPEN field.
  126. #define BR_VREF_TRM_CHOPEN (BITBAND_ACCESS8(HW_VREF_TRM_ADDR, BP_VREF_TRM_CHOPEN))
  127. #endif
  128. //! @brief Format value for bitfield VREF_TRM_CHOPEN.
  129. #define BF_VREF_TRM_CHOPEN(v) (__REG_VALUE_TYPE((__REG_VALUE_TYPE((v), uint8_t) << BP_VREF_TRM_CHOPEN), uint8_t) & BM_VREF_TRM_CHOPEN)
  130. #ifndef __LANGUAGE_ASM__
  131. //! @brief Set the CHOPEN field to a new value.
  132. #define BW_VREF_TRM_CHOPEN(v) (BITBAND_ACCESS8(HW_VREF_TRM_ADDR, BP_VREF_TRM_CHOPEN) = (v))
  133. #endif
  134. //@}
  135. //-------------------------------------------------------------------------------------------
  136. // HW_VREF_SC - VREF Status and Control Register
  137. //-------------------------------------------------------------------------------------------
  138. #ifndef __LANGUAGE_ASM__
  139. /*!
  140. * @brief HW_VREF_SC - VREF Status and Control Register (RW)
  141. *
  142. * Reset value: 0x00U
  143. *
  144. * This register contains the control bits used to enable the internal voltage
  145. * reference and to select the buffer mode to be used.
  146. */
  147. typedef union _hw_vref_sc
  148. {
  149. uint8_t U;
  150. struct _hw_vref_sc_bitfields
  151. {
  152. uint8_t MODE_LV : 2; //!< [1:0] Buffer Mode selection
  153. uint8_t VREFST : 1; //!< [2] Internal Voltage Reference stable
  154. uint8_t RESERVED0 : 2; //!< [4:3]
  155. uint8_t ICOMPEN : 1; //!< [5] Second order curvature compensation
  156. //! enable
  157. uint8_t REGEN : 1; //!< [6] Regulator enable
  158. uint8_t VREFEN : 1; //!< [7] Internal Voltage Reference enable
  159. } B;
  160. } hw_vref_sc_t;
  161. #endif
  162. /*!
  163. * @name Constants and macros for entire VREF_SC register
  164. */
  165. //@{
  166. #define HW_VREF_SC_ADDR (REGS_VREF_BASE + 0x1U)
  167. #ifndef __LANGUAGE_ASM__
  168. #define HW_VREF_SC (*(__IO hw_vref_sc_t *) HW_VREF_SC_ADDR)
  169. #define HW_VREF_SC_RD() (HW_VREF_SC.U)
  170. #define HW_VREF_SC_WR(v) (HW_VREF_SC.U = (v))
  171. #define HW_VREF_SC_SET(v) (HW_VREF_SC_WR(HW_VREF_SC_RD() | (v)))
  172. #define HW_VREF_SC_CLR(v) (HW_VREF_SC_WR(HW_VREF_SC_RD() & ~(v)))
  173. #define HW_VREF_SC_TOG(v) (HW_VREF_SC_WR(HW_VREF_SC_RD() ^ (v)))
  174. #endif
  175. //@}
  176. /*
  177. * Constants & macros for individual VREF_SC bitfields
  178. */
  179. /*!
  180. * @name Register VREF_SC, field MODE_LV[1:0] (RW)
  181. *
  182. * These bits select the buffer modes for the Voltage Reference module.
  183. *
  184. * Values:
  185. * - 00 - Bandgap on only, for stabilization and startup
  186. * - 01 - High power buffer mode enabled
  187. * - 10 - Low-power buffer mode enabled
  188. * - 11 - Reserved
  189. */
  190. //@{
  191. #define BP_VREF_SC_MODE_LV (0U) //!< Bit position for VREF_SC_MODE_LV.
  192. #define BM_VREF_SC_MODE_LV (0x03U) //!< Bit mask for VREF_SC_MODE_LV.
  193. #define BS_VREF_SC_MODE_LV (2U) //!< Bit field size in bits for VREF_SC_MODE_LV.
  194. #ifndef __LANGUAGE_ASM__
  195. //! @brief Read current value of the VREF_SC_MODE_LV field.
  196. #define BR_VREF_SC_MODE_LV (HW_VREF_SC.B.MODE_LV)
  197. #endif
  198. //! @brief Format value for bitfield VREF_SC_MODE_LV.
  199. #define BF_VREF_SC_MODE_LV(v) (__REG_VALUE_TYPE((__REG_VALUE_TYPE((v), uint8_t) << BP_VREF_SC_MODE_LV), uint8_t) & BM_VREF_SC_MODE_LV)
  200. #ifndef __LANGUAGE_ASM__
  201. //! @brief Set the MODE_LV field to a new value.
  202. #define BW_VREF_SC_MODE_LV(v) (HW_VREF_SC_WR((HW_VREF_SC_RD() & ~BM_VREF_SC_MODE_LV) | BF_VREF_SC_MODE_LV(v)))
  203. #endif
  204. //@}
  205. /*!
  206. * @name Register VREF_SC, field VREFST[2] (RO)
  207. *
  208. * This bit indicates that the bandgap reference within the Voltage Reference
  209. * module has completed its startup and stabilization.
  210. *
  211. * Values:
  212. * - 0 - The module is disabled or not stable.
  213. * - 1 - The module is stable.
  214. */
  215. //@{
  216. #define BP_VREF_SC_VREFST (2U) //!< Bit position for VREF_SC_VREFST.
  217. #define BM_VREF_SC_VREFST (0x04U) //!< Bit mask for VREF_SC_VREFST.
  218. #define BS_VREF_SC_VREFST (1U) //!< Bit field size in bits for VREF_SC_VREFST.
  219. #ifndef __LANGUAGE_ASM__
  220. //! @brief Read current value of the VREF_SC_VREFST field.
  221. #define BR_VREF_SC_VREFST (BITBAND_ACCESS8(HW_VREF_SC_ADDR, BP_VREF_SC_VREFST))
  222. #endif
  223. //@}
  224. /*!
  225. * @name Register VREF_SC, field ICOMPEN[5] (RW)
  226. *
  227. * This bit is set during factory trimming of the VREF voltage. This bit should
  228. * be written to 1 to achieve the performance stated in the data sheet.
  229. *
  230. * Values:
  231. * - 0 - Disabled
  232. * - 1 - Enabled
  233. */
  234. //@{
  235. #define BP_VREF_SC_ICOMPEN (5U) //!< Bit position for VREF_SC_ICOMPEN.
  236. #define BM_VREF_SC_ICOMPEN (0x20U) //!< Bit mask for VREF_SC_ICOMPEN.
  237. #define BS_VREF_SC_ICOMPEN (1U) //!< Bit field size in bits for VREF_SC_ICOMPEN.
  238. #ifndef __LANGUAGE_ASM__
  239. //! @brief Read current value of the VREF_SC_ICOMPEN field.
  240. #define BR_VREF_SC_ICOMPEN (BITBAND_ACCESS8(HW_VREF_SC_ADDR, BP_VREF_SC_ICOMPEN))
  241. #endif
  242. //! @brief Format value for bitfield VREF_SC_ICOMPEN.
  243. #define BF_VREF_SC_ICOMPEN(v) (__REG_VALUE_TYPE((__REG_VALUE_TYPE((v), uint8_t) << BP_VREF_SC_ICOMPEN), uint8_t) & BM_VREF_SC_ICOMPEN)
  244. #ifndef __LANGUAGE_ASM__
  245. //! @brief Set the ICOMPEN field to a new value.
  246. #define BW_VREF_SC_ICOMPEN(v) (BITBAND_ACCESS8(HW_VREF_SC_ADDR, BP_VREF_SC_ICOMPEN) = (v))
  247. #endif
  248. //@}
  249. /*!
  250. * @name Register VREF_SC, field REGEN[6] (RW)
  251. *
  252. * This bit is used to enable the internal 1.75 V regulator to produce a
  253. * constant internal voltage supply in order to reduce the sensitivity to external
  254. * supply noise and variation. If it is desired to keep the regulator enabled in very
  255. * low power modes, refer to the Chip Configuration details for a description on
  256. * how this can be achieved. This bit is set during factory trimming of the VREF
  257. * voltage. This bit should be written to 1 to achieve the performance stated in
  258. * the data sheet.
  259. *
  260. * Values:
  261. * - 0 - Internal 1.75 V regulator is disabled.
  262. * - 1 - Internal 1.75 V regulator is enabled.
  263. */
  264. //@{
  265. #define BP_VREF_SC_REGEN (6U) //!< Bit position for VREF_SC_REGEN.
  266. #define BM_VREF_SC_REGEN (0x40U) //!< Bit mask for VREF_SC_REGEN.
  267. #define BS_VREF_SC_REGEN (1U) //!< Bit field size in bits for VREF_SC_REGEN.
  268. #ifndef __LANGUAGE_ASM__
  269. //! @brief Read current value of the VREF_SC_REGEN field.
  270. #define BR_VREF_SC_REGEN (BITBAND_ACCESS8(HW_VREF_SC_ADDR, BP_VREF_SC_REGEN))
  271. #endif
  272. //! @brief Format value for bitfield VREF_SC_REGEN.
  273. #define BF_VREF_SC_REGEN(v) (__REG_VALUE_TYPE((__REG_VALUE_TYPE((v), uint8_t) << BP_VREF_SC_REGEN), uint8_t) & BM_VREF_SC_REGEN)
  274. #ifndef __LANGUAGE_ASM__
  275. //! @brief Set the REGEN field to a new value.
  276. #define BW_VREF_SC_REGEN(v) (BITBAND_ACCESS8(HW_VREF_SC_ADDR, BP_VREF_SC_REGEN) = (v))
  277. #endif
  278. //@}
  279. /*!
  280. * @name Register VREF_SC, field VREFEN[7] (RW)
  281. *
  282. * This bit is used to enable the bandgap reference within the Voltage Reference
  283. * module. After the VREF is enabled, turning off the clock to the VREF module
  284. * via the corresponding clock gate register will not disable the VREF. VREF must
  285. * be disabled via this VREFEN bit.
  286. *
  287. * Values:
  288. * - 0 - The module is disabled.
  289. * - 1 - The module is enabled.
  290. */
  291. //@{
  292. #define BP_VREF_SC_VREFEN (7U) //!< Bit position for VREF_SC_VREFEN.
  293. #define BM_VREF_SC_VREFEN (0x80U) //!< Bit mask for VREF_SC_VREFEN.
  294. #define BS_VREF_SC_VREFEN (1U) //!< Bit field size in bits for VREF_SC_VREFEN.
  295. #ifndef __LANGUAGE_ASM__
  296. //! @brief Read current value of the VREF_SC_VREFEN field.
  297. #define BR_VREF_SC_VREFEN (BITBAND_ACCESS8(HW_VREF_SC_ADDR, BP_VREF_SC_VREFEN))
  298. #endif
  299. //! @brief Format value for bitfield VREF_SC_VREFEN.
  300. #define BF_VREF_SC_VREFEN(v) (__REG_VALUE_TYPE((__REG_VALUE_TYPE((v), uint8_t) << BP_VREF_SC_VREFEN), uint8_t) & BM_VREF_SC_VREFEN)
  301. #ifndef __LANGUAGE_ASM__
  302. //! @brief Set the VREFEN field to a new value.
  303. #define BW_VREF_SC_VREFEN(v) (BITBAND_ACCESS8(HW_VREF_SC_ADDR, BP_VREF_SC_VREFEN) = (v))
  304. #endif
  305. //@}
  306. //-------------------------------------------------------------------------------------------
  307. // hw_vref_t - module struct
  308. //-------------------------------------------------------------------------------------------
  309. /*!
  310. * @brief All VREF module registers.
  311. */
  312. #ifndef __LANGUAGE_ASM__
  313. #pragma pack(1)
  314. typedef struct _hw_vref
  315. {
  316. __IO hw_vref_trm_t TRM; //!< [0x0] VREF Trim Register
  317. __IO hw_vref_sc_t SC; //!< [0x1] VREF Status and Control Register
  318. } hw_vref_t;
  319. #pragma pack()
  320. //! @brief Macro to access all VREF registers.
  321. //! @return Reference (not a pointer) to the registers struct. To get a pointer to the struct,
  322. //! use the '&' operator, like <code>&HW_VREF</code>.
  323. #define HW_VREF (*(hw_vref_t *) REGS_VREF_BASE)
  324. #endif
  325. #endif // __HW_VREF_REGISTERS_H__
  326. // v22/130726/0.9
  327. // EOF