fsl_src.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #ifndef _FSL_SRC_H_
  35. #define _FSL_SRC_H_
  36. #include "fsl_common.h"
  37. /*!
  38. * @addtogroup src
  39. * @{
  40. */
  41. /*******************************************************************************
  42. * Definitions
  43. ******************************************************************************/
  44. /*! @name Driver version */
  45. /*@{*/
  46. /*! @brief SRC driver version 2.0.0. */
  47. #define FSL_SRC_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
  48. /*@}*/
  49. /*!
  50. * @brief SRC reset status flags.
  51. */
  52. enum _src_reset_status_flags
  53. {
  54. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_RESET_OUT) && FSL_FEATURE_SRC_HAS_SRSR_RESET_OUT)
  55. kSRC_ResetOutputEnableFlag = SRC_SRSR_RESET_OUT_MASK, /*!< This bit indicates if RESET status is
  56. driven out on PTE0 pin. */
  57. #endif /* FSL_FEATURE_SRC_HAS_SRSR_RESET_OUT */
  58. #if !(defined(FSL_FEATURE_SRC_HAS_NO_SRSR_WBI) && FSL_FEATURE_SRC_HAS_NO_SRSR_WBI)
  59. kSRC_WarmBootIndicationFlag = SRC_SRSR_WBI_MASK, /*!< WARM boot indication shows that WARM boot
  60. was initiated by software. */
  61. #endif /* FSL_FEATURE_SRC_HAS_NO_SRSR_WBI */
  62. kSRC_TemperatureSensorResetFlag = SRC_SRSR_TSR_MASK, /*!< Indicates whether the reset was the
  63. result of software reset from on-chip
  64. Temperature Sensor. Temperature Sensor
  65. Interrupt need be served before this
  66. bit can be cleaned.*/
  67. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_WDOG3_RST_B) && FSL_FEATURE_SRC_HAS_SRSR_WDOG3_RST_B)
  68. kSRC_Wdog3ResetFlag = SRC_SRSR_WDOG3_RST_B_MASK, /*!< IC Watchdog3 Time-out reset. Indicates
  69. whether the reset was the result of the
  70. watchdog3 time-out event. */
  71. #endif /* FSL_FEATURE_SRC_HAS_SRSR_WDOG3_RST_B */
  72. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_SW) && FSL_FEATURE_SRC_HAS_SRSR_SW)
  73. kSRC_SoftwareResetFlag = SRC_SRSR_SW_MASK, /*!< Indicates a reset has been caused by software
  74. setting of SYSRESETREQ bit in Application
  75. Interrupt and Reset Control Register in the
  76. ARM core. */
  77. #endif /* FSL_FEATURE_SRC_HAS_SRSR_SW */
  78. kSRC_JTAGSoftwareResetFlag = SRC_SRSR_SJC_MASK, /*!< Indicates whether the reset was the result of
  79. setting SJC_GPCCR bit 31. */
  80. kSRC_JTAGGeneratedResetFlag = SRC_SRSR_JTAG_MASK, /*!< Indicates a reset has been caused by JTAG
  81. selection of certain IR codes: EXTEST or
  82. HIGHZ. */
  83. kSRC_WatchdogResetFlag = SRC_SRSR_WDOG_MASK, /*!< Indicates a reset has been caused by the
  84. watchdog timer timing out. This reset source
  85. can be blocked by disabling the watchdog. */
  86. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_IPP_USER_RESET_B) && FSL_FEATURE_SRC_HAS_SRSR_IPP_USER_RESET_B)
  87. kSRC_IppUserResetFlag = SRC_SRSR_IPP_USER_RESET_B_MASK, /*!< Indicates whether the reset was the
  88. result of the ipp_user_reset_b
  89. qualified reset. */
  90. #endif /* FSL_FEATURE_SRC_HAS_SRSR_IPP_USER_RESET_B */
  91. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_SNVS) && FSL_FEATURE_SRC_HAS_SRSR_SNVS)
  92. kSRC_SNVSFailResetFlag = SRC_SRSR_SNVS_MASK, /*!< SNVS hardware failure will always cause a cold
  93. reset. This flag indicates whether the reset
  94. is a result of SNVS hardware failure. */
  95. #endif /* FSL_FEATURE_SRC_HAS_SRSR_SNVS */
  96. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_CSU_RESET_B) && FSL_FEATURE_SRC_HAS_SRSR_CSU_RESET_B)
  97. kSRC_CsuResetFlag = SRC_SRSR_CSU_RESET_B_MASK, /*!< Indicates whether the reset was the result
  98. of the csu_reset_b input. */
  99. #endif /* FSL_FEATURE_SRC_HAS_SRSR_CSU_RESET_B */
  100. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_LOCKUP) && FSL_FEATURE_SRC_HAS_SRSR_LOCKUP)
  101. kSRC_CoreLockupResetFlag = SRC_SRSR_LOCKUP_MASK, /*!< Indicates a reset has been caused by the
  102. ARM core indication of a LOCKUP event. */
  103. #endif /* FSL_FEATURE_SRC_HAS_SRSR_LOCKUP */
  104. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_POR) && FSL_FEATURE_SRC_HAS_SRSR_POR)
  105. kSRC_PowerOnResetFlag = SRC_SRSR_POR_MASK, /*!< Indicates a reset has been caused by the
  106. power-on detection logic. */
  107. #endif /* FSL_FEATURE_SRC_HAS_SRSR_POR */
  108. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_LOCKUP_SYSRESETREQ) && FSL_FEATURE_SRC_HAS_SRSR_LOCKUP_SYSRESETREQ)
  109. kSRC_LockupSysResetFlag = SRC_SRSR_LOCKUP_SYSRESETREQ_MASK, /*!< Indicates a reset has been caused by CPU lockup or software
  110. setting of SYSRESETREQ bit in Application Interrupt and
  111. Reset Control Register of the ARM core. */
  112. #endif /* FSL_FEATURE_SRC_HAS_SRSR_LOCKUP_SYSRESETREQ */
  113. #if (defined(FSL_FEATURE_SRC_HAS_SRSR_IPP_RESET_B) && FSL_FEATURE_SRC_HAS_SRSR_IPP_RESET_B)
  114. kSRC_IppResetPinFlag = SRC_SRSR_IPP_RESET_B_MASK, /*!< Indicates whether reset was the result of
  115. ipp_reset_b pin (Power-up sequence). */
  116. #endif /* FSL_FEATURE_SRC_HAS_SRSR_IPP_RESET_B */
  117. };
  118. #if (defined(FSL_FEATURE_SRC_HAS_SISR) && FSL_FEATURE_SRC_HAS_SISR)
  119. /*!
  120. * @brief SRC interrupt status flag.
  121. */
  122. enum _src_status_flags
  123. {
  124. kSRC_Core0WdogResetReqFlag =
  125. SRC_SISR_CORE0_WDOG_RST_REQ_MASK, /*!< WDOG reset request from core0. Read-only status bit. */
  126. };
  127. #endif /* FSL_FEATURE_SRC_HAS_SISR */
  128. #if (defined(FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH) && FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH)
  129. /*!
  130. * @brief Selection of SoC mix power reset stretch.
  131. *
  132. * This type defines the SoC mix (Audio, ENET, uSDHC, EIM, QSPI, OCRAM, MMDC, etc) power up reset
  133. * stretch mix reset width with the optional count of cycles
  134. */
  135. typedef enum _src_mix_reset_stretch_cycles
  136. {
  137. kSRC_MixResetStretchCycleAlt0 = 0U, /*!< mix reset width is 1 x 88 ipg_cycle cycles. */
  138. kSRC_MixResetStretchCycleAlt1 = 1U, /*!< mix reset width is 2 x 88 ipg_cycle cycles. */
  139. kSRC_MixResetStretchCycleAlt2 = 2U, /*!< mix reset width is 3 x 88 ipg_cycle cycles. */
  140. kSRC_MixResetStretchCycleAlt3 = 3U, /*!< mix reset width is 4 x 88 ipg_cycle cycles. */
  141. } src_mix_reset_stretch_cycles_t;
  142. #endif /* FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH */
  143. #if (defined(FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN) && FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN)
  144. /*!
  145. * @brief Selection of WDOG3 reset option.
  146. */
  147. typedef enum _src_wdog3_reset_option
  148. {
  149. kSRC_Wdog3ResetOptionAlt0 = 0U, /*!< Wdog3_rst_b asserts M4 reset (default). */
  150. kSRC_Wdog3ResetOptionAlt1 = 1U, /*!< Wdog3_rst_b asserts global reset. */
  151. } src_wdog3_reset_option_t;
  152. #endif /* FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN */
  153. /*!
  154. * @brief Selection of WARM reset bypass count.
  155. *
  156. * This type defines the 32KHz clock cycles to count before bypassing the MMDC acknowledge for WARM
  157. * reset. If the MMDC acknowledge is not asserted before this counter is elapsed, a COLD reset will
  158. * be initiated.
  159. */
  160. typedef enum _src_warm_reset_bypass_count
  161. {
  162. kSRC_WarmResetWaitAlways = 0U, /*!< System will wait until MMDC acknowledge is asserted. */
  163. kSRC_WarmResetWaitClk16 = 1U, /*!< Wait 16 32KHz clock cycles before switching the reset. */
  164. kSRC_WarmResetWaitClk32 = 2U, /*!< Wait 32 32KHz clock cycles before switching the reset. */
  165. kSRC_WarmResetWaitClk64 = 3U, /*!< Wait 64 32KHz clock cycles before switching the reset. */
  166. } src_warm_reset_bypass_count_t;
  167. #if defined(__cplusplus)
  168. extern "C" {
  169. #endif
  170. /*******************************************************************************
  171. * API
  172. ******************************************************************************/
  173. #if (defined(FSL_FEATURE_SRC_HAS_SCR_MASK_WDOG3_RST) && FSL_FEATURE_SRC_HAS_SCR_MASK_WDOG3_RST)
  174. /*!
  175. * @brief Enable the WDOG3 reset.
  176. *
  177. * The WDOG3 reset is enabled by default.
  178. *
  179. * @param base SRC peripheral base address.
  180. * @param enable Enable the reset or not.
  181. */
  182. static inline void SRC_EnableWDOG3Reset(SRC_Type *base, bool enable)
  183. {
  184. if (enable)
  185. {
  186. base->SCR = (base->SCR & ~SRC_SCR_MASK_WDOG3_RST_MASK) | SRC_SCR_MASK_WDOG3_RST(0xA);
  187. }
  188. else
  189. {
  190. base->SCR = (base->SCR & ~SRC_SCR_MASK_WDOG3_RST_MASK) | SRC_SCR_MASK_WDOG3_RST(0x5);
  191. }
  192. }
  193. #endif /* FSL_FEATURE_SRC_HAS_SCR_MASK_WDOG3_RST */
  194. #if (defined(FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH) && FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH)
  195. /*!
  196. * @brief Set the mix power up reset stretch mix reset width.
  197. *
  198. * @param base SRC peripheral base address.
  199. * @param option Setting option, see to #src_mix_reset_stretch_cycles_t.
  200. */
  201. static inline void SRC_SetMixResetStretchCycles(SRC_Type *base, src_mix_reset_stretch_cycles_t option)
  202. {
  203. base->SCR = (base->SCR & ~SRC_SCR_MIX_RST_STRCH_MASK) | SRC_SCR_MIX_RST_STRCH(option);
  204. }
  205. #endif /* FSL_FEATURE_SRC_HAS_SCR_MIX_RST_STRCH */
  206. #if (defined(FSL_FEATURE_SRC_HAS_SCR_DBG_RST_MSK_PG) && FSL_FEATURE_SRC_HAS_SCR_DBG_RST_MSK_PG)
  207. /*!
  208. * @brief Debug reset would be asserted after power gating event.
  209. *
  210. * @param base SRC peripheral base address.
  211. * @param enable Enable the reset or not.
  212. */
  213. static inline void SRC_EnableCoreDebugResetAfterPowerGate(SRC_Type *base, bool enable)
  214. {
  215. if (enable)
  216. {
  217. base->SCR &= ~SRC_SCR_DBG_RST_MSK_PG_MASK;
  218. }
  219. else
  220. {
  221. base->SCR |= SRC_SCR_DBG_RST_MSK_PG_MASK;
  222. }
  223. }
  224. #endif /* FSL_FEATURE_SRC_HAS_SCR_DBG_RST_MSK_PG */
  225. #if (defined(FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN) && FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN)
  226. /*!
  227. * @brief Set the Wdog3_rst_b option.
  228. *
  229. * @param base SRC peripheral base address.
  230. * @param option Setting option, see to #src_wdog3_reset_option_t.
  231. */
  232. static inline void SRC_SetWdog3ResetOption(SRC_Type *base, src_wdog3_reset_option_t option)
  233. {
  234. base->SCR = (base->SCR & ~SRC_SCR_WDOG3_RST_OPTN_MASK) | SRC_SCR_WDOG3_RST_OPTN(option);
  235. }
  236. #endif /* FSL_FEATURE_SRC_HAS_SCR_WDOG3_RST_OPTN */
  237. #if (defined(FSL_FEATURE_SRC_HAS_SCR_CORES_DBG_RST) && FSL_FEATURE_SRC_HAS_SCR_CORES_DBG_RST)
  238. /*!
  239. * @brief Software reset for debug of arm platform only.
  240. *
  241. * @param base SRC peripheral base address.
  242. */
  243. static inline void SRC_DoSoftwareResetARMCoreDebug(SRC_Type *base)
  244. {
  245. base->SCR |= SRC_SCR_CORES_DBG_RST_MASK;
  246. }
  247. /*!
  248. * @brief Check if the software reset for debug of arm platform only is done.
  249. *
  250. * @param base SRC peripheral base address.
  251. */
  252. static inline bool SRC_GetSoftwareResetARMCoreDebugDone(SRC_Type *base)
  253. {
  254. return (0U == (base->SCR & SRC_SCR_CORES_DBG_RST_MASK));
  255. }
  256. #endif /* FSL_FEATURE_SRC_HAS_SCR_CORES_DBG_RST */
  257. #if (defined(FSL_FEATURE_SRC_HAS_SCR_MTSR) && FSL_FEATURE_SRC_HAS_SCR_MTSR)
  258. /*!
  259. * @brief Enable the temperature sensor reset.
  260. *
  261. * The temperature sersor reset is enabled by default. When the sensor reset happens, an flag bit
  262. * would be asserted. This flag bit can be cleared only by the hardware reset.
  263. *
  264. * @param base SRC peripheral base address.
  265. * @param enable Enable the reset or not.
  266. */
  267. static inline void SRC_EnableTemperatureSensorReset(SRC_Type *base, bool enable)
  268. {
  269. if (enable) /* Temperature sensor reset is not masked. (default) */
  270. {
  271. base->SCR = (base->SCR & ~SRC_SCR_MTSR_MASK) | SRC_SCR_MTSR(0x2);
  272. }
  273. else /* The on-chip temperature sensor interrupt will not create a reset to the chip. */
  274. {
  275. base->SCR = (base->SCR & ~SRC_SCR_MTSR_MASK) | SRC_SCR_MTSR(0x5);
  276. }
  277. }
  278. #endif /* FSL_FEATURE_SRC_HAS_SCR_MTSR */
  279. #if (defined(FSL_FEATURE_SCR_HAS_SCR_CORE0_DBG_RST) && FSL_FEATURE_SCR_HAS_SCR_CORE0_DBG_RST)
  280. /*!
  281. * @brief Do assert the core0 debug reset.
  282. *
  283. * @param base SRC peripheral base address.
  284. */
  285. static inline void SRC_DoAssertCore0DebugReset(SRC_Type *base)
  286. {
  287. base->SCR |= SRC_SCR_CORE0_DBG_RST_MASK;
  288. }
  289. /*!
  290. * @brief Check if the core0 debug reset is done.
  291. *
  292. * @param base SRC peripheral base address.
  293. */
  294. static inline bool SRC_GetAssertCore0DebugResetDone(SRC_Type *base)
  295. {
  296. return (0U == (base->SCR & SRC_SCR_CORE0_DBG_RST_MASK));
  297. }
  298. #endif /* FSL_FEATURE_SCR_HAS_SCR_CORE0_DBG_RST */
  299. #if (defined(FSL_FEATURE_SRC_HAS_SCR_CORE0_RST) && FSL_FEATURE_SRC_HAS_SCR_CORE0_RST)
  300. /*!
  301. * @brief Do software reset the ARM core0 only.
  302. *
  303. * @param base SRC peripheral base address.
  304. */
  305. static inline void SRC_DoSoftwareResetARMCore0(SRC_Type *base)
  306. {
  307. base->SCR |= SRC_SCR_CORE0_RST_MASK;
  308. }
  309. /*!
  310. * @brief Check if the software for ARM core0 is done.
  311. *
  312. * @param base SRC peripheral base address.
  313. * @return If the reset is done.
  314. */
  315. static inline bool SRC_GetSoftwareResetARMCore0Done(SRC_Type *base)
  316. {
  317. return (0U == (base->SCR & SRC_SCR_CORE0_RST_MASK));
  318. }
  319. #endif /* FSL_FEATURE_SRC_HAS_SCR_CORE0_RST */
  320. #if (defined(FSL_FEATURE_SRC_HAS_SCR_SWRC) && FSL_FEATURE_SRC_HAS_SCR_SWRC)
  321. /*!
  322. * @brief Do software reset for ARM core.
  323. *
  324. * This function can be used to assert the ARM core reset. Once it is called, the reset process will
  325. * begin. After the reset process is finished, the command bit would be self cleared.
  326. *
  327. * @param base SRC peripheral base address.
  328. */
  329. static inline void SRC_DoSoftwareResetARMCore(SRC_Type *base)
  330. {
  331. base->SCR |= SRC_SCR_SWRC_MASK;
  332. }
  333. /*!
  334. * @brief Check if the software for ARM core is done.
  335. *
  336. * @param base SRC peripheral base address.
  337. * @return If the reset is done.
  338. */
  339. static inline bool SRC_GetSoftwareResetARMCoreDone(SRC_Type *base)
  340. {
  341. return (0U == (base->SCR & SRC_SCR_SWRC_MASK));
  342. }
  343. #endif /* FSL_FEATURE_SRC_HAS_SCR_SWRC */
  344. #if (defined(FSL_FEATURE_SRC_HAS_SCR_EIM_RST) && FSL_FEATURE_SRC_HAS_SCR_EIM_RST)
  345. /*!
  346. * @brief Assert the EIM reset.
  347. *
  348. * EIM reset is needed in order to reconfigure the EIM chip select.
  349. * The software reset bit must de-asserted since this is not self-refresh.
  350. *
  351. * @param base SRC peripheral base address.
  352. * @param enable Make the assertion or not.
  353. */
  354. static inline void SRC_AssertEIMReset(SRC_Type *base, bool enable)
  355. {
  356. if (enable)
  357. {
  358. base->SCR |= SRC_SCR_EIM_RST_MASK;
  359. }
  360. else
  361. {
  362. base->SCR &= ~SRC_SCR_EIM_RST_MASK;
  363. }
  364. }
  365. #endif /* FSL_FEATURE_SRC_HAS_SCR_EIM_RST */
  366. /*!
  367. * @brief Enable the WDOG Reset in SRC.
  368. *
  369. * WDOG Reset is enabled in SRC by default. If the WDOG event to SRC is masked, it would not create
  370. * a reset to the chip. During the time the WDOG event is masked, when the WDOG event flag is
  371. * asserted, it would remain asserted regardless of servicing the WDOG module. The only way to clear
  372. * that bit is the hardware reset.
  373. *
  374. * @param base SRC peripheral base address.
  375. * @param enable Enable the reset or not.
  376. */
  377. static inline void SRC_EnableWDOGReset(SRC_Type *base, bool enable)
  378. {
  379. if (enable) /* WDOG Reset is not masked in SRC (default). */
  380. {
  381. base->SCR = (base->SCR & ~SRC_SCR_MWDR_MASK) | SRC_SCR_MWDR(0xA);
  382. }
  383. else /* WDOG Reset is masked in SRC. */
  384. {
  385. base->SCR = (base->SCR & ~SRC_SCR_MWDR_MASK) | SRC_SCR_MWDR(0x5);
  386. }
  387. }
  388. #if !(defined(FSL_FEATURE_SRC_HAS_NO_SCR_WRBC) && FSL_FEATURE_SRC_HAS_NO_SCR_WRBC)
  389. /*!
  390. * @brief Set the delay count of waiting MMDC's acknowledge.
  391. *
  392. * This function would define the 32KHz clock cycles to count before bypassing the MMDC acknowledge
  393. * for WARM reset. If the MMDC acknowledge is not asserted before this counter is elapsed, a COLD
  394. * reset will be initiated.
  395. *
  396. * @param base SRC peripheral base address.
  397. * @param option The option of setting mode, see to #src_warm_reset_bypass_count_t.
  398. */
  399. static inline void SRC_SetWarmResetBypassCount(SRC_Type *base, src_warm_reset_bypass_count_t option)
  400. {
  401. base->SCR = (base->SCR & ~SRC_SCR_WRBC_MASK) | SRC_SCR_WRBC(option);
  402. }
  403. #endif /* FSL_FEATURE_SRC_HAS_NO_SCR_WRBC */
  404. #if (defined(FSL_FEATURE_SRC_HAS_SCR_LOCKUP_RST) && FSL_FEATURE_SRC_HAS_SCR_LOCKUP_RST)
  405. /*!
  406. * @brief Enable the lockup reset.
  407. *
  408. * @param base SRC peripheral base address.
  409. * @param enable Enable the reset or not.
  410. */
  411. static inline void SRC_EnableLockupReset(SRC_Type *base, bool enable)
  412. {
  413. if (enable) /* Enable lockup reset. */
  414. {
  415. base->SCR |= SRC_SCR_LOCKUP_RST_MASK;
  416. }
  417. else /* Disable lockup reset. */
  418. {
  419. base->SCR &= ~SRC_SCR_LOCKUP_RST_MASK;
  420. }
  421. }
  422. #endif /* FSL_FEATURE_SRC_HAS_SCR_LOCKUP_RST */
  423. #if (defined(FSL_FEATURE_SRC_HAS_SCR_LUEN) && FSL_FEATURE_SRC_HAS_SCR_LUEN)
  424. /*!
  425. * @brief Enable the core lockup reset.
  426. *
  427. * When enable the core luckup reset, the system would be reset when core luckup event happens.
  428. *
  429. * @param base SRC peripheral base address.
  430. * @param enable Enable the reset or not.
  431. */
  432. static inline void SRC_EnableCoreLockupReset(SRC_Type *base, bool enable)
  433. {
  434. if (enable) /* Core lockup will cause system reset. */
  435. {
  436. base->SCR |= SRC_SCR_LUEN_MASK;
  437. }
  438. else /* Core lockup will not cause system reset. */
  439. {
  440. base->SCR &= ~SRC_SCR_LUEN_MASK;
  441. }
  442. }
  443. #endif /* FSL_FEATURE_SRC_HAS_SCR_LUEN */
  444. #if !(defined(FSL_FEATURE_SRC_HAS_NO_SCR_WRE) && FSL_FEATURE_SRC_HAS_NO_SCR_WRE)
  445. /*!
  446. * @brief Enable the WARM reset.
  447. *
  448. * Only when the WARM reset is enabled, the WARM reset requests would be served by WARM reset.
  449. * Otherwise, all the WARM reset sources would generate COLD reset.
  450. *
  451. * @param base SRC peripheral base address.
  452. * @param enable Enable the WARM reset or not.
  453. */
  454. static inline void SRC_EnableWarmReset(SRC_Type *base, bool enable)
  455. {
  456. if (enable)
  457. {
  458. base->SCR |= SRC_SCR_WRE_MASK;
  459. }
  460. else
  461. {
  462. base->SCR &= ~SRC_SCR_WRE_MASK;
  463. }
  464. }
  465. #endif /* FSL_FEATURE_SRC_HAS_NO_SCR_WRE */
  466. #if (defined(FSL_FEATURE_SRC_HAS_SISR) && FSL_FEATURE_SRC_HAS_SISR)
  467. /*!
  468. * @brief Get interrupt status flags.
  469. *
  470. * @param base SRC peripheral base address.
  471. * @return Mask value of status flags. See to $_src_status_flags.
  472. */
  473. static inline uint32_t SRC_GetStatusFlags(SRC_Type *base)
  474. {
  475. return base->SISR;
  476. }
  477. #endif /* FSL_FEATURE_SRC_HAS_SISR */
  478. /*!
  479. * @brief Get the boot mode register 1 value.
  480. *
  481. * The Boot Mode register contains bits that reflect the status of BOOT_CFGx pins of the chip.
  482. * See to chip-specific document for detail information about value.
  483. *
  484. * @param base SRC peripheral base address.
  485. * @return status of BOOT_CFGx pins of the chip.
  486. */
  487. static inline uint32_t SRC_GetBootModeWord1(SRC_Type *base)
  488. {
  489. return base->SBMR1;
  490. }
  491. /*!
  492. * @brief Get the boot mode register 2 value.
  493. *
  494. * The Boot Mode register contains bits that reflect the status of BOOT_MODEx Pins and fuse values
  495. * that controls boot of the chip. See to chip-specific document for detail information about value.
  496. *
  497. * @param base SRC peripheral base address.
  498. * @return status of BOOT_MODEx Pins and fuse values that controls boot of the chip.
  499. */
  500. static inline uint32_t SRC_GetBootModeWord2(SRC_Type *base)
  501. {
  502. return base->SBMR2;
  503. }
  504. #if !(defined(FSL_FEATURE_SRC_HAS_NO_SRSR_WBI) && FSL_FEATURE_SRC_HAS_NO_SRSR_WBI)
  505. /*!
  506. * @brief Set the warm boot indication flag.
  507. *
  508. * WARM boot indication shows that WARM boot was initiated by software. This indicates to the
  509. * software that it saved the needed information in the memory before initiating the WARM reset.
  510. * In this case, software will set this bit to '1', before initiating the WARM reset. The warm_boot
  511. * bit should be used as indication only after a warm_reset sequence. Software should clear this bit
  512. * after warm_reset to indicate that the next warm_reset is not performed with warm_boot.
  513. *
  514. * @param base SRC peripheral base address.
  515. * @param enable Assert the flag or not.
  516. */
  517. static inline void SRC_SetWarmBootIndication(SRC_Type *base, bool enable)
  518. {
  519. if (enable)
  520. {
  521. base->SRSR = (base->SRSR & ~SRC_SRSR_W1C_BITS_MASK) | SRC_SRSR_WBI_MASK;
  522. }
  523. else
  524. {
  525. base->SRSR = (base->SRSR & ~SRC_SRSR_W1C_BITS_MASK) & ~SRC_SRSR_WBI_MASK;
  526. }
  527. }
  528. #endif /* FSL_FEATURE_SRC_HAS_NO_SRSR_WBI */
  529. /*!
  530. * @brief Get the status flags of SRC.
  531. *
  532. * @param base SRC peripheral base address.
  533. * @return Mask value of status flags, see to #_src_reset_status_flags.
  534. */
  535. static inline uint32_t SRC_GetResetStatusFlags(SRC_Type *base)
  536. {
  537. return base->SRSR;
  538. }
  539. /*!
  540. * @brief Clear the status flags of SRC.
  541. *
  542. * @param base SRC peripheral base address.
  543. * @param Mask value of status flags to be cleared, see to #_src_reset_status_flags.
  544. */
  545. void SRC_ClearResetStatusFlags(SRC_Type *base, uint32_t flags);
  546. /*!
  547. * @brief Set value to general purpose registers.
  548. *
  549. * General purpose registers (GPRx) would hold the value during reset process. Wakeup function could
  550. * be kept in these register. For example, the GPR1 holds the entry function for waking-up from
  551. * Partial SLEEP mode while the GPR2 holds the argument. Other GPRx register would store the
  552. * arbitray values.
  553. *
  554. * @param base SRC peripheral base address.
  555. * @param index The index of GPRx register array. Note index 0 reponses the GPR1 register.
  556. * @param value Setting value for GPRx register.
  557. */
  558. static inline void SRC_SetGeneralPurposeRegister(SRC_Type *base, uint32_t index, uint32_t value)
  559. {
  560. assert(index < SRC_GPR_COUNT);
  561. base->GPR[index] = value;
  562. }
  563. /*!
  564. * @brief Get the value from general purpose registers.
  565. *
  566. * @param base SRC peripheral base address.
  567. * @param index The index of GPRx register array. Note index 0 reponses the GPR1 register.
  568. * @return The setting value for GPRx register.
  569. */
  570. static inline uint32_t SRC_GetGeneralPurposeRegister(SRC_Type *base, uint32_t index)
  571. {
  572. assert(index < SRC_GPR_COUNT);
  573. return base->GPR[index];
  574. }
  575. #if defined(__cplusplus)
  576. }
  577. #endif
  578. /*!
  579. * @}
  580. */
  581. #endif /* _FSL_SRC_H_ */