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