fsl_src.h 22 KB

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