fsl_src.h 24 KB

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