1 /*
2  * Copyright 2020, NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 #ifndef _FSL_POWER_H_
8 #define _FSL_POWER_H_
9 
10 #include <stdint.h>
11 #include "fsl_common.h"
12 #include "fsl_device_registers.h"
13 
14 /*!
15  * @addtogroup power
16  * @{
17  */
18 /*******************************************************************************
19  * Definitions
20  ******************************************************************************/
21 
22 /*! @name Driver version */
23 /*@{*/
24 /*! @brief power driver version 1.0.0. */
25 #define FSL_POWER_DRIVER_VERSION (MAKE_VERSION(1, 0, 0))
26 /*@}*/
27 
28 /**
29  * @brief Low Power Modes configuration
30  */
31 typedef enum _power_mode_config
32 {
33     kPmu_Sleep          = 0U,
34     kPmu_Deep_Sleep     = 1U,
35     kPmu_PowerDown      = 2U,
36     kPmu_Deep_PowerDown = 3U,
37 } power_mode_cfg_t;
38 
39 /**
40  * @brief Device Reset Causes
41  */
42 typedef enum _power_reset_cause
43 {
44     kRESET_CAUSE_POR            = 0UL, /*!< Power On Reset */
45     kRESET_CAUSE_PADRESET       = 1UL, /*!< Hardware Pin Reset */
46     kRESET_CAUSE_BODRESET       = 2UL, /*!< Brown-out Detector reset (either BODVBAT or BODCORE) */
47     kRESET_CAUSE_ARMSYSTEMRESET = 3UL, /*!< ARM System Reset */
48     kRESET_CAUSE_WDTRESET       = 4UL, /*!< Watchdog Timer Reset */
49     kRESET_CAUSE_SWRRESET       = 5UL, /*!< Software Reset */
50     kRESET_CAUSE_CDOGRESET      = 6UL, /*!< Code Watchdog Reset */
51     /* Reset causes in DEEP-POWER-DOWN low power mode */
52     kRESET_CAUSE_DPDRESET_WAKEUPIO = 7UL, /*!< Any of the 5 wake-up pins */
53     kRESET_CAUSE_DPDRESET_RTC      = 8UL, /*!< Real Time Clock (RTC) */
54     kRESET_CAUSE_DPDRESET_OSTIMER  = 9UL, /*!< OS Event Timer (OSTIMER) */
55     kRESET_CAUSE_DPDRESET_WAKEUPIO_RTC =
56         10UL, /*!< Any of the 5 wake-up pins and RTC (the 2 events occured within 1 nano-second of each other) */
57     kRESET_CAUSE_DPDRESET_WAKEUPIO_OSTIMER =
58         11UL, /*!< Any of the 5 wake-up pins and OSTIMER (the 2 events occured within 1 nano-second of each other) */
59     kRESET_CAUSE_DPDRESET_RTC_OSTIMER =
60         12UL, /*!< Real Time Clock or OS Event Timer (the 2 events occured within 1 nano-second of each other) */
61     kRESET_CAUSE_DPDRESET_WAKEUPIO_RTC_OSTIMER = 13UL, /*!< Any of the 5 wake-up pins or RTC or OS Event Timer (the 3
62                                                           events occured within 1 nano-second of each other) */
63     /* Miscallenous */
64     kRESET_CAUSE_NOT_RELEVANT =
65         14UL, /*!< No reset cause (for example, this code is used when waking up from DEEP-SLEEP low power mode) */
66     kRESET_CAUSE_NOT_DETERMINISTIC = 15UL, /*!< Unknown Reset Cause. Should be treated like "Hardware Pin Reset" from an
67                                               application point of view. */
68 } power_reset_cause_t;
69 
70 /**
71  * @brief Device Boot Modes
72  */
73 typedef enum _power_boot_mode
74 {
75     kBOOT_MODE_POWER_UP =
76         0UL, /*!< All non Low Power Mode wake up (Power On Reset, Pin Reset, BoD Reset, ARM System Reset ... ) */
77     kBOOT_MODE_LP_DEEP_SLEEP      = 1UL, /*!< Wake up from DEEP-SLEEP Low Power mode */
78     kBOOT_MODE_LP_POWER_DOWN      = 2UL, /*!< Wake up from POWER-DOWN Low Power mode */
79     kBOOT_MODE_LP_DEEP_POWER_DOWN = 4UL, /*!< Wake up from DEEP-POWER-DOWN Low Power mode */
80 } power_boot_mode_t;
81 
82 /**
83  * @brief Device wake up pins events
84  */
85 typedef enum _power_wakeup_pin_t
86 {
87     kWAKEUP_PIN_NONE     = 0UL,        /*!< No wake up pin event */
88     kWAKEUP_PIN_0        = (1UL << 0), /*!< Wake up pin 0 event */
89     kWAKEUP_PIN_1        = (1UL << 1), /*!< Wake up pin 1 event */
90     kWAKEUP_PIN_2        = (1UL << 2), /*!< Wake up pin 2 event */
91     kWAKEUP_PIN_3        = (1UL << 3), /*!< Wake up pin 3 event */
92     kWAKEUP_PIN_4        = (1UL << 4), /*!< Wake up pin 4 event */
93     kWAKEUP_PIN_MULTIPLE = 0x1FUL, /*!< More than 1 wake up pins events occured (within 1 nano-second of each other) */
94 } power_wakeup_pin_t;
95 
96 /**
97  * @brief analog components power modes control during low power modes
98  */
99 typedef enum _power_pd_bit
100 {
101     /* Power Down Vector 0 */
102     kPDRUNCFG_PD_DCDC       = (1UL << 0),
103     kPDRUNCFG_PD_BIAS       = (1UL << 1),
104     kPDRUNCFG_PD_BODCORE    = (1UL << 2),
105     kPDRUNCFG_PD_BODVDDMAIN = (1UL << 3),
106     kPDRUNCFG_PD_FRO1M      = (1UL << 4),
107     kPDRUNCFG_PD_FRO192M    = (1UL << 5),
108     kPDRUNCFG_PD_FRO32K     = (1UL << 6),
109     kPDRUNCFG_PD_XTAL32K    = (1UL << 7),
110     kPDRUNCFG_PD_XTALHF     = (1UL << 8),
111     kPDRUNCFG_PD_PLL0       = (1UL << 9),
112     kPDRUNCFG_PD_PLL1       = (1UL << 10),
113     kPDRUNCFG_PD_USBFSPHY   = (1UL << 11),
114     // kPDRUNCFG_PD_          = (1UL << 12), /*!< RESERVED */
115     kPDRUNCFG_PD_COMP = (1UL << 13),
116     // kPDRUNCFG_PD_          = (1UL << 14), /*!< RESERVED */
117     // kPDRUNCFG_PD_          = (1UL << 15), /*!< RESERVED */
118     kPDRUNCFG_PD_LDOMEM = (1UL << 16),
119     // kPDRUNCFG_PD_          = (1UL << 17), /*!< RESERVED */
120     kPDRUNCFG_PD_LDOEFUSEPROG = (1UL << 18),
121     // kPDRUNCFG_PD_          = (1UL << 19), /*!< RESERVED */
122     kPDRUNCFG_PD_LDOXTALHF  = (1UL << 20),
123     kPDRUNCFG_PD_LDOFLASHNV = (1UL << 21),
124     // kPDRUNCFG_PD_          = (1UL << 22), /*!< RESERVED */
125     kPDRUNCFG_PD_PLL0_SSCG = (1UL << 23),
126     kPDRUNCFG_PD_ROM       = (1UL << 24),
127     kPDRUNCFG_PD_HSCMP0    = (1UL << 25),
128     kPDRUNCFG_PD_HSCMP1    = (1UL << 26),
129     kPDRUNCFG_PD_HSCMP2    = (1UL << 27),
130     kPDRUNCFG_PD_OPAMP0    = (1UL << 28),
131     kPDRUNCFG_PD_OPAMP1    = (1UL << 29),
132     kPDRUNCFG_PD_OPAMP2    = (1UL << 30),
133     kPDRUNCFG_PD_VREF      = (1UL << 31),
134 
135     /* Power Down Vector 1 */
136     kPDRUNCFG_PD_CMPBIAS    = (1UL << 0) | (1UL << 31),
137     kPDRUNCFG_PD_HSCMP0_DAC = (1UL << 1) | (1UL << 31),
138     kPDRUNCFG_PD_HSCMP1_DAC = (1UL << 2) | (1UL << 31),
139     kPDRUNCFG_PD_HSCMP2_DAC = (1UL << 3) | (1UL << 31),
140     kPDRUNCFG_PD_DAC0       = (1UL << 4) | (1UL << 31),
141     kPDRUNCFG_PD_DAC1       = (1UL << 5) | (1UL << 31),
142     kPDRUNCFG_PD_DAC2       = (1UL << 6) | (1UL << 31),
143     kPDRUNCFG_STOP_DAC0     = (1UL << 7) | (1UL << 31),
144     kPDRUNCFG_STOP_DAC1     = (1UL << 8) | (1UL << 31),
145     kPDRUNCFG_STOP_DAC2     = (1UL << 9) | (1UL << 31),
146 
147     /*
148        This enum member has no practical meaning,it is used to avoid MISRA issue,
149        user should not trying to use it.
150        */
151     kPDRUNCFG_ForceUnsigned = 0x80000000U,
152 } pd_bit_t;
153 
154 /**
155  * @brief SRAM instances bit masks
156  */
157 typedef enum _power_sram_bit
158 {
159     kPOWER_SRAM_RAM_X0        = (1UL << 0),  /*!< RAM_X0 */
160     kPOWER_SRAM_RAM_00        = (1UL << 1),  /*!< RAM_00 */
161     kPOWER_SRAM_RAM_01        = (1UL << 2),  /*!< RAM_01 */
162     kPOWER_SRAM_RAM_02        = (1UL << 3),  /*!< RAM_02 */
163     kPOWER_SRAM_RAM_03        = (1UL << 4),  /*!< RAM_03 */
164     kPOWER_SRAM_RAM_10        = (1UL << 5),  /*!< RAM_10 */
165     kPOWER_SRAM_RAM_20        = (1UL << 6),  /*!< RAM_20 */
166     kPOWER_SRAM_RAM_30        = (1UL << 7),  /*!< RAM_30 */
167     kPOWER_SRAM_RAM_40        = (1UL << 8),  /*!< RAM_40 */
168     kPOWER_SRAM_RAM_41        = (1UL << 9),  /*!< RAM_41 */
169     kPOWER_SRAM_RAM_42        = (1UL << 10), /*!< RAM_42 */
170     kPOWER_SRAM_RAM_43        = (1UL << 11), /*!< RAM_43 */
171     kPOWER_SRAM_FLASHCACHE    = (1UL << 12), /*!< Reserved. Flash Cache SRAM instance */
172     kPOWER_SRAM_FLEXSPICACHE  = (1UL << 13), /*!< Reserved. FlexSPI Cache SRAM instance */
173     kPOWER_SRAM_FLEXSPIH2PREG = (1UL << 14), /*!< Reserved. FlexSPI Dual Port Register Files instances */
174 
175     kPOWER_SRAM_DSLP_MASK = 0x7FFFUL, /*!< Reserved. DEEP-SLEEP SRAM instances */
176     kPOWER_SRAM_PDWN_MASK = 0xFFFUL,  /*!< Reserved. POWER-DOWN SRAM instances */
177 
178 #if (defined(LPC55S36_SERIES) || defined(LPC5536_SERIES) || defined(LPC5534_SERIES))
179     kPOWER_SRAM_DPWD_MASK = 0xFE6UL, /*!< Reserved. DEEP-POWER-DOWN SRAM instances (RAM_X0, RAM_02 and RAM_03 excluded:
180                                         they are used by ROM Boot code) */
181 #else
182     kPOWER_SRAM_DPWD_MASK = 0xF3FUL, /*!< Reserved. DEEP-POWER-DOWN SRAM instances (RAM_20 & RAM_30 excluded).*/
183 #endif
184 
185     /*
186        This enum member has no practical meaning,it is used to avoid MISRA issue,
187        user should not trying to use it.
188        */
189     kPOWER_SRAM_ForceUnsigned = 0x80000000U,
190 } power_sram_bit_t;
191 
192 /**
193  * @brief SRAM instances indexes
194  */
195 typedef enum _power_sram_index
196 {
197     kPOWER_SRAM_IDX_RAM_X0        = 0UL,  /*!< RAM_X0 */
198     kPOWER_SRAM_IDX_RAM_00        = 1UL,  /*!< RAM_00 */
199     kPOWER_SRAM_IDX_RAM_01        = 2UL,  /*!< RAM_01 */
200     kPOWER_SRAM_IDX_RAM_02        = 3UL,  /*!< RAM_02 */
201     kPOWER_SRAM_IDX_RAM_03        = 4UL,  /*!< RAM_03 */
202     kPOWER_SRAM_IDX_RAM_10        = 5UL,  /*!< RAM_10 */
203     kPOWER_SRAM_IDX_RAM_20        = 6UL,  /*!< RAM_20 */
204     kPOWER_SRAM_IDX_RAM_30        = 7UL,  /*!< RAM_30 */
205     kPOWER_SRAM_IDX_RAM_40        = 8UL,  /*!< RAM_40 */
206     kPOWER_SRAM_IDX_RAM_41        = 9UL,  /*!< RAM_41 */
207     kPOWER_SRAM_IDX_RAM_42        = 10UL, /*!< RAM_42 */
208     kPOWER_SRAM_IDX_RAM_43        = 11UL, /*!< RAM_43 */
209     kPOWER_SRAM_IDX_FLASHCACHE    = 12UL, /*!< Reserved. Flash Cache SRAM instance */
210     kPOWER_SRAM_IDX_FLEXSPICACHE  = 13UL, /*!< Reserved. FlexSPI Cache SRAM instance */
211     kPOWER_SRAM_IDX_FLEXSPIH2PREG = 14UL, /*!< Reserved. FlexSPI Dual Port Register Files instances */
212 } power_sram_index_t;
213 
214 /*@brief SRAM Power Mode */
215 typedef enum _power_sram_pwr_mode
216 {
217     kPOWER_SRAMPwrActive     = 0U, /*!< Active */
218     kPOWER_SRAMPwrLightSleep = 1U, /*!< RESERVED, DO NOT USE (Light Sleep) */
219     kPOWER_SRAMPwrDeepSleep  = 2U, /*!< Deep Sleep : SRAM content retained */
220     kPOWER_SRAMPwrShutDown   = 3U, /*!< Shutdown: SRAM content lost */
221 } power_sram_pwr_mode_t;
222 
223 /*@brief BOD VDDMAIN level */
224 typedef enum _power_bod_vddmain_level
225 {
226     kPOWER_BodVddmainLevel1000mv = 0,  /*!< VDDMAIN Brown out detector level 1V */
227     kPOWER_BodVddmainLevel1100mv = 1,  /*!< VDDMAIN Brown out detector level 1.1V */
228     kPOWER_BodVddmainLevel1200mv = 2,  /*!< VDDMAIN Brown out detector level 1.2V */
229     kPOWER_BodVddmainLevel1300mv = 3,  /*!< VDDMAIN Brown out detector level 1.3V */
230     kPOWER_BodVddmainLevel1400mv = 4,  /*!< VDDMAIN Brown out detector level 1.4V */
231     kPOWER_BodVddmainLevel1500mv = 5,  /*!< VDDMAIN Brown out detector level 1.5V */
232     kPOWER_BodVddmainLevel1600mv = 6,  /*!< VDDMAIN Brown out detector level 1.6V */
233     kPOWER_BodVddmainLevel1650mv = 7,  /*!< VDDMAIN Brown out detector level 1.65V */
234     kPOWER_BodVddmainLevel1700mv = 8,  /*!< VDDMAIN Brown out detector level 1.7V */
235     kPOWER_BodVddmainLevel1750mv = 9,  /*!< VDDMAIN Brown out detector level 1.75V */
236     kPOWER_BodVddmainLevel1800mv = 10, /*!< VDDMAIN Brown out detector level 1.8V */
237     kPOWER_BodVddmainLevel1900mv = 11, /*!< VDDMAIN Brown out detector level 1.9V */
238     kPOWER_BodVddmainLevel2000mv = 12, /*!< VDDMAIN Brown out detector level 2V */
239     kPOWER_BodVddmainLevel2100mv = 13, /*!< VDDMAIN Brown out detector level 2.1V */
240     kPOWER_BodVddmainLevel2200mv = 14, /*!< VDDMAIN Brown out detector level 2.2V */
241     kPOWER_BodVddmainLevel2300mv = 15, /*!< VDDMAIN Brown out detector level 2.3V */
242     kPOWER_BodVddmainLevel2400mv = 16, /*!< VDDMAIN Brown out detector level 2.4V */
243     kPOWER_BodVddmainLevel2500mv = 17, /*!< VDDMAIN Brown out detector level 2.5V */
244     kPOWER_BodVddmainLevel2600mv = 18, /*!< VDDMAIN Brown out detector level 2.6V */
245     kPOWER_BodVddmainLevel2700mv = 19, /*!< VDDMAIN Brown out detector level 2.7V */
246     kPOWER_BodVddmainLevel2800mv = 20, /*!< VDDMAIN Brown out detector level 2.80 V */
247     kPOWER_BodVddmainLevel2900mv = 21, /*!< VDDMAIN Brown out detector level 2.9V */
248     kPOWER_BodVddmainLevel3000mv = 22, /*!< VDDMAIN Brown out detector level 3.0V */
249     kPOWER_BodVddmainLevel3100mv = 23, /*!< VDDMAIN Brown out detector level 3.1V */
250     kPOWER_BodVddmainLevel3200mv = 24, /*!< VDDMAIN Brown out detector level 3.2V */
251     kPOWER_BodVddmainLevel3300mv = 25, /*!< VDDMAIN Brown out detector level 3.3V */
252 } power_bod_vddmain_level_t;
253 
254 /*@brief BOD core level */
255 typedef enum _power_bod_core_level
256 {
257     kPOWER_BodCoreLevel600mv = 0, /*!< core Brown out detector level 600mV */
258     kPOWER_BodCoreLevel650mv = 1, /*!< core Brown out detector level 650mV */
259     kPOWER_BodCoreLevel700mv = 2, /*!< core Brown out detector level 700mV */
260     kPOWER_BodCoreLevel750mv = 3, /*!< core Brown out detector level 750mV */
261     kPOWER_BodCoreLevel800mv = 4, /*!< core Brown out detector level 800mV */
262     kPOWER_BodCoreLevel850mv = 5, /*!< core Brown out detector level 850mV */
263     kPOWER_BodCoreLevel900mv = 6, /*!< core Brown out detector level 900mV */
264     kPOWER_BodCoreLevel950mv = 7, /*!< core Brown out detector level 950mV */
265 } power_bod_core_level_t;
266 
267 /*@brief BODs (VDDMAIN & Core) Hysteresis control */
268 typedef enum _power_bod_hyst
269 {
270     kPOWER_BodHystLevel25mv  = 0U, /*!< BOD Hysteresis control level 25mv */
271     kPOWER_BodHystLevel50mv  = 1U, /*!< BOD Hysteresis control level 50mv */
272     kPOWER_BodHystLevel75mv  = 2U, /*!< BOD Hysteresis control level 75mv */
273     kPOWER_BodHystLevel100mv = 3U, /*!< BOD Hysteresis control level 100mv */
274 } power_bod_hyst_t;
275 
276 /*@brief Core Power Source */
277 typedef enum _power_core_pwr_source
278 {
279     kPOWER_CoreSrcDCDC      = 0U, /*!< DCDC */
280     kPOWER_CoreSrcLDOCoreHP = 1U, /*!< LDO Core High Power Mode */
281     kPOWER_CoreSrcLDOCoreLP = 2U, /*!< LDO Core Low Power Mode (DO NOT USE : Reserved for test purposes) */
282     kPOWER_CoreSrcExternal  = 3U, /*!< External (DO NOT USE : Reserved for test purposes) */
283 } power_core_pwr_source_t;
284 
285 /*@brief Core Regulators Power State */
286 typedef enum _power_core_pwr_state
287 {
288     kPOWER_CorePwrDisable = 0U, /*!< Disable */
289     kPOWER_CorePwrEnable  = 1U, /*!< Enable */
290 } power_core_pwr_state_t;
291 
292 /*@brief Generic Power Library APIs Status codes */
293 typedef enum _power_status
294 {
295     kPOWER_Status_Success = 0U, /*!< OK */
296     kPOWER_Status_Fail    = 1U, /*!< Generic error code */
297 } power_status_t;
298 
299 /**
300  * @brief Low Power Modes Wake up sources
301  */
302 /* Wake up source vector 0 */
303 #define WAKEUP_SYS              (1UL << 0) /*!< [SLEEP, DEEP SLEEP                             ] */ /* WWDT0_IRQ and BOD_IRQ*/
304 #define WAKEUP_SDMA0            (1UL << 1)  /*!< [SLEEP, DEEP SLEEP                             ] */
305 #define WAKEUP_GPIO_GLOBALINT0  (1UL << 2)  /*!< [SLEEP, DEEP SLEEP, POWER DOWN                 ] */
306 #define WAKEUP_GPIO_GLOBALINT1  (1UL << 3)  /*!< [SLEEP, DEEP SLEEP, POWER DOWN                 ] */
307 #define WAKEUP_GPIO_INT0_0      (1UL << 4)  /*!< [SLEEP, DEEP SLEEP                             ] */
308 #define WAKEUP_GPIO_INT0_1      (1UL << 5)  /*!< [SLEEP, DEEP SLEEP                             ] */
309 #define WAKEUP_GPIO_INT0_2      (1UL << 6)  /*!< [SLEEP, DEEP SLEEP                             ] */
310 #define WAKEUP_GPIO_INT0_3      (1UL << 7)  /*!< [SLEEP, DEEP SLEEP                             ] */
311 #define WAKEUP_UTICK            (1UL << 8)  /*!< [SLEEP, DEEP SLEEP                             ] */
312 #define WAKEUP_MRT              (1UL << 9)  /*!< [SLEEP,                                        ] */
313 #define WAKEUP_CTIMER0          (1UL << 10) /*!< [SLEEP, DEEP SLEEP                             ] */
314 #define WAKEUP_CTIMER1          (1UL << 11) /*!< [SLEEP, DEEP SLEEP                             ] */
315 #define WAKEUP_SCT              (1UL << 12) /*!< [SLEEP,                                        ] */
316 #define WAKEUP_CTIMER3          (1UL << 13) /*!< [SLEEP, DEEP SLEEP                             ] */
317 #define WAKEUP_FLEXCOMM0        (1UL << 14) /*!< [SLEEP, DEEP SLEEP                             ] */
318 #define WAKEUP_FLEXCOMM1        (1UL << 15) /*!< [SLEEP, DEEP SLEEP                             ] */
319 #define WAKEUP_FLEXCOMM2        (1UL << 16) /*!< [SLEEP, DEEP SLEEP                             ] */
320 #define WAKEUP_FLEXCOMM3        (1UL << 17) /*!< [SLEEP, DEEP SLEEP, POWER DOWN                 ] */
321 #define WAKEUP_FLEXCOMM4        (1UL << 18) /*!< [SLEEP, DEEP SLEEP                             ] */
322 #define WAKEUP_FLEXCOMM5        (1UL << 19) /*!< [SLEEP, DEEP SLEEP                             ] */
323 #define WAKEUP_FLEXCOMM6        (1UL << 20) /*!< [SLEEP, DEEP SLEEP                             ] */
324 #define WAKEUP_FLEXCOMM7        (1UL << 21) /*!< [SLEEP, DEEP SLEEP                             ] */
325 #define WAKEUP_ADC0             (1UL << 22) /*!< [SLEEP,                                        ] */
326 #define WAKEUP_ADC1             (1UL << 23) /*!< [SLEEP,                                        ] */
327 #define WAKEUP_ACMP             (1UL << 24) /*!< [SLEEP, DEEP SLEEP, POWER DOWN                 ] */
328 #define WAKEUP_DMIC             (1UL << 25) /*!< [SLEEP,                                        ] */
329 #define WAKEUP_HWVAD            (1UL << 26) /*!< [SLEEP, DEEP SLEEP,                            ] */
330 #define WAKEUP_USB0_NEEDCLK     (1UL << 27) /*!< [SLEEP, DEEP SLEEP                             ] */
331 #define WAKEUP_USB0             (1UL << 28) /*!< [SLEEP, DEEP SLEEP                             ] */
332 #define WAKEUP_RTC_ALARM_WAKEUP (1UL << 29) /*!< [SLEEP, DEEP SLEEP, POWER DOWN, DEEP POWER DOWN] */
333 #define WAKEUP_EZH_ARCH_B       (1UL << 30) /*!< [SLEEP,                                        ] */
334 #define WAKEUP_WAKEUP_MAILBOX   (1UL << 31) /*!< [SLEEP, DEEP SLEEP,                            ] */
335 
336 /* Wake up source vector 1 */
337 #define WAKEUP_GPIO_INT0_4    (1UL << 0) /*!< [SLEEP, DEEP SLEEP                             ] */
338 #define WAKEUP_GPIO_INT0_5    (1UL << 1) /*!< [SLEEP, DEEP SLEEP                             ] */
339 #define WAKEUP_GPIO_INT0_6    (1UL << 2) /*!< [SLEEP, DEEP SLEEP                             ] */
340 #define WAKEUP_GPIO_INT0_7    (1UL << 3) /*!< [SLEEP, DEEP SLEEP                             ] */
341 #define WAKEUP_CTIMER2        (1UL << 4) /*!< [SLEEP, DEEP SLEEP                             ] */
342 #define WAKEUP_CTIMER4        (1UL << 5) /*!< [SLEEP, DEEP SLEEP                             ] */
343 #define WAKEUP_OS_EVENT_TIMER (1UL << 6) /*!< [SLEEP, DEEP SLEEP, POWER DOWN, DEEP POWER DOWN] */
344 #define WAKEUP_FLEXSPI        (1UL << 7) /*!< [SLEEP,                                        ] */
345 // reserved                        (1UL << 8)
346 // reserved                        (1UL << 9)
347 // reserved                        (1UL << 10)
348 #define WAKEUP_CAN0_0    (1UL << 11) /*!< [SLEEP,                                        ] */
349 #define WAKEUP_CAN0_1    (1UL << 12) /*!< [SLEEP,                                        ] */
350 #define WAKEUP_SPIFILTER (1UL << 13) /*!< [SLEEP,                                        ] */
351 // reserved                        (1UL << 14)
352 // reserved                        (1UL << 15)
353 // reserved                        (1UL << 16)
354 #define WAKEUP_SEC_HYPERVISOR_CALL (1UL << 17) /*!< [SLEEP,                                        ] */
355 #define WAKEUP_SEC_GPIO_INT0_0     (1UL << 18) /*!< [SLEEP, DEEP SLEEP                             ] */
356 #define WAKEUP_SEC_GPIO_INT0_1     (1UL << 19) /*!< [SLEEP, DEEP SLEEP                             ] */
357 // reserved                        (1UL << 20)
358 #define WAKEUP_SEC_VIO  (1UL << 21) /*!< [SLEEP,                                        ] */
359 #define WAKEUP_CSS_IRQ0 (1UL << 22) /*!< [SLEEP,                                        ] */
360 #define WAKEUP_PKC      (1UL << 23) /*!< [SLEEP,                                        ] */
361 #define WAKEUP_PUF      (1UL << 24) /*!< [SLEEP,                                        ] */
362 #define WAKEUP_PQ       (1UL << 25) /*!< [SLEEP,                                        ] */
363 #define WAKEUP_SDMA1    (1UL << 26) /*!< [SLEEP, DEEP SLEEP                             ] */
364 #define WAKEUP_LSPI_HS  (1UL << 27) /*!< [SLEEP, DEEP SLEEP                             ] */
365 #define WAKEUP_CODE_WDG (1UL << 28) /*!< [SLEEP,                                        ] */
366 // reserved                        (1UL << 29)
367 #define WAKEUP_I3C (1UL << 30) /*!< [SLEEP, DEEP SLEEP                             ] */
368 // reserved                        (1UL << 31)
369 
370 /* Wake up source vector 2 */
371 #define WAKEUP_NEUTRON  (1UL << 0) /*!< [SLEEP,                                        ] */
372 #define WAKEUP_CSS_IRQ1 (1UL << 1) /*!< [SLEEP,                                        ] */
373 // reserved                         (1UL << 2)
374 #define WAKEUP_ANA_GLITCH_DETECT (1UL << 3)
375 // reserved                        (1UL << 4)
376 // reserved                        (1UL << 5)
377 // reserved                        (1UL << 6)
378 // reserved                        (1UL << 7)
379 // reserved                        (1UL << 8)
380 // reserved                        (1UL << 9)
381 #define WAKEUP_DAC0                  (1UL << 10) /*!< [SLEEP, DEEP SLEEP                             ] */
382 #define WAKEUP_DAC1                  (1UL << 11) /*!< [SLEEP, DEEP SLEEP                             ] */
383 #define WAKEUP_DAC2                  (1UL << 12) /*!< [SLEEP, DEEP SLEEP                             ] */
384 #define WAKEUP_HS_COMP0              (1UL << 13) /*!< [SLEEP,                                        ] */
385 #define WAKEUP_HS_COMP1              (1UL << 14) /*!< [SLEEP,                                        ] */
386 #define WAKEUP_HS_COMP2              (1UL << 15) /*!< [SLEEP,                                        ] */
387 #define WAKEUP_FLEXPWM0_CAPTURE      (1UL << 16) /*!< [SLEEP,                                        ] */
388 #define WAKEUP_FLEXPWM0_FAULT        (1UL << 17) /*!< [SLEEP,                                        ] */
389 #define WAKEUP_FLEXPWM0_RELOAD_ERROR (1UL << 18) /*!< [SLEEP,                                        ] */
390 #define WAKEUP_FLEXPWM0_COMPARE0     (1UL << 19) /*!< [SLEEP,                                        ] */
391 #define WAKEUP_FLEXPWM0_RELOAD0      (1UL << 20) /*!< [SLEEP,                                        ] */
392 #define WAKEUP_FLEXPWM0_COMPARE1     (1UL << 21) /*!< [SLEEP,                                        ] */
393 #define WAKEUP_FLEXPWM0_RELOAD1      (1UL << 22) /*!< [SLEEP,                                        ] */
394 #define WAKEUP_FLEXPWM0_COMPARE2     (1UL << 23) /*!< [SLEEP,                                        ] */
395 #define WAKEUP_FLEXPWM0_RELOAD2      (1UL << 24) /*!< [SLEEP,                                        ] */
396 #define WAKEUP_FLEXPWM0_COMPARE3     (1UL << 25) /*!< [SLEEP,                                        ] */
397 #define WAKEUP_FLEXPWM0_RELOAD3      (1UL << 26) /*!< [SLEEP,                                        ] */
398 #define WAKEUP_FLEXPWM1_CAPTURE      (1UL << 27) /*!< [SLEEP,                                        ] */
399 #define WAKEUP_FLEXPWM1_FAULT        (1UL << 28) /*!< [SLEEP,                                        ] */
400 #define WAKEUP_FLEXPWM1_RELOAD_ERROR (1UL << 29) /*!< [SLEEP,                                        ] */
401 #define WAKEUP_FLEXPWM1_COMPARE0     (1UL << 30) /*!< [SLEEP,                                        ] */
402 #define WAKEUP_FLEXPWM1_RELOAD0      (1UL << 31) /*!< [SLEEP,                                        ] */
403 
404 /* Wake up source vector 3 */
405 #define WAKEUP_FLEXPWM1_COMPARE1 (1UL << 0)  /*!< [SLEEP,                                        ] */
406 #define WAKEUP_FLEXPWM1_RELOAD1  (1UL << 1)  /*!< [SLEEP,                                        ] */
407 #define WAKEUP_FLEXPWM1_COMPARE2 (1UL << 2)  /*!< [SLEEP,                                        ] */
408 #define WAKEUP_FLEXPWM1_RELOAD2  (1UL << 3)  /*!< [SLEEP,                                        ] */
409 #define WAKEUP_FLEXPWM1_COMPARE3 (1UL << 4)  /*!< [SLEEP,                                        ] */
410 #define WAKEUP_FLEXPWM1_RELOAD3  (1UL << 5)  /*!< [SLEEP,                                        ] */
411 #define WAKEUP_ENC0_COMPARE      (1UL << 6)  /*!< [SLEEP,                                        ] */
412 #define WAKEUP_ENC0_HOME         (1UL << 7)  /*!< [SLEEP,                                        ] */
413 #define WAKEUP_ENC0_WDG          (1UL << 8)  /*!< [SLEEP,                                        ] */
414 #define WAKEUP_ENC0_IDX          (1UL << 9)  /*!< [SLEEP,                                        ] */
415 #define WAKEUP_ENC1_COMPARE      (1UL << 10) /*!< [SLEEP,                                        ] */
416 #define WAKEUP_ENC1_HOME         (1UL << 11) /*!< [SLEEP,                                        ] */
417 #define WAKEUP_ENC1_WDG          (1UL << 12) /*!< [SLEEP,                                        ] */
418 #define WAKEUP_ENC1_IDX          (1UL << 13) /*!< [SLEEP,                                        ] */
419 #define WAKEUP_ITRC              (1UL << 14) /*!< [SLEEP, DEEP SLEEP, POWER DOWN                 ] */
420 #define WAKEUP_CF_DSP24L_IRQ0    (1UL << 15) /*!< [SLEEP,                                        ] */
421 #define WAKEUP_CF_DSP24L_IRQ1    (1UL << 16) /*!< [SLEEP,                                        ] */
422 #define WAKEUP_FTM0              (1UL << 17) /*!< [SLEEP,                                        ] */
423 // reserved                        (1UL << 18)
424 // reserved                        (1UL << 19)
425 // reserved                        (1UL << 20)
426 // reserved                        (1UL << 21)
427 // reserved                        (1UL << 22)
428 // reserved                        (1UL << 23)
429 // reserved                        (1UL << 24)
430 // reserved                        (1UL << 25)
431 // reserved                        (1UL << 26)
432 // reserved                        (1UL << 27)
433 // reserved                        (1UL << 28)
434 // reserved                        (1UL << 29)
435 // reserved                        (1UL << 30)
436 // reserved                        (1UL << 31)
437 
438 /**
439  * @brief Sleep Postpone (DEEP-SLEEP)
440  */
441 #define LOWPOWER_HWWAKE_FORCED (1UL << 0) /*!< Force peripheral clocking to stay on during deep-sleep mode. */
442 #define LOWPOWER_HWWAKE_PERIPHERALS                                                                                \
443     (1UL << 1) /*!< Wake for Flexcomms. Any Flexcomm FIFO reaching the level specified by its own TXLVL will cause \
444                   peripheral clocking to wake up temporarily while the related status is asserted */
445 #define LOWPOWER_HWWAKE_DMIC                                                                                   \
446     (1UL << 2) /*!< Wake for DMIC. DMIC being busy will cause peripheral clocking to remain running until DMIC \
447                   completes. Used in conjonction with LOWPOWER_HWWAKE_PERIPHERALS */
448 #define LOWPOWER_HWWAKE_SDMA0                                                                                 \
449     (1UL << 3) /*!< Wake for DMA0. DMA0 being busy will cause peripheral clocking to remain running until DMA \
450                   completes. Used in conjonction with LOWPOWER_HWWAKE_PERIPHERALS or LOWPOWER_HWWAKE_DAC */
451 #define LOWPOWER_HWWAKE_SDMA1                                                                                 \
452     (1UL << 5) /*!< Wake for DMA1. DMA0 being busy will cause peripheral clocking to remain running until DMA \
453                   completes. Used in conjonction with LOWPOWER_HWWAKE_PERIPHERALS or LOWPOWER_HWWAKE_DAC */
454 #define LOWPOWER_HWWAKE_DAC                                                                                        \
455     (1UL << 6) /*!< Wake for DAC0, DAC1, DAC2. Any DAC0/1/2 FIFO reaching the level specified by the configuration \
456                  will generate an asynchronous SDMA0 request, and SDMA0 will wake up the bus                       \
457                    clock temporarily to transfer data to DAC0/1/2.*/
458 #define LOWPOWER_HWWAKE_ENABLE_FRO192M                                                                                 \
459     (1UL << 31) /*!< Need to be set if FRO192M is disable - via PDCTRL0 - in Deep Sleep mode and any of                \
460                    LOWPOWER_HWWAKE_PERIPHERALS, LOWPOWER_HWWAKE_SDMA0, LOWPOWER_HWWAKE_SDMA1 or LOWPOWER_HWWAKE_DAC is \
461                    set */
462 
463 /**
464  * @brief CPU State retention (POWER-DOWN)
465  */
466 #define LOWPOWER_CPURETCTRL_ENA_DISABLE 0 /*!< In POWER DOWN mode, CPU Retention is disabled */
467 #define LOWPOWER_CPURETCTRL_ENA_ENABLE  1 /*!< In POWER DOWN mode, CPU Retention is enabled  */
468 
469 /**
470  * @brief Wake up I/O sources (DEEP POWER-DOWN)
471  */
472 #define LOWPOWER_WAKEUPIOSRC_PIO0_INDEX 0 /*!< Pin P1( 1) */
473 #define LOWPOWER_WAKEUPIOSRC_PIO1_INDEX 2 /*!< Pin P0(28) */
474 #define LOWPOWER_WAKEUPIOSRC_PIO2_INDEX 4 /*!< Pin P1(18) */
475 #define LOWPOWER_WAKEUPIOSRC_PIO3_INDEX 6 /*!< Pin P1(30) */
476 #define LOWPOWER_WAKEUPIOSRC_PIO4_INDEX 8 /*!< Pin P0(26) */
477 
478 #define LOWPOWER_WAKEUPIOSRC_DISABLE        0 /*!< Wake up is disable                      */
479 #define LOWPOWER_WAKEUPIOSRC_RISING         1 /*!< Wake up on rising edge                  */
480 #define LOWPOWER_WAKEUPIOSRC_FALLING        2 /*!< Wake up on falling edge                 */
481 #define LOWPOWER_WAKEUPIOSRC_RISING_FALLING 3 /*!< Wake up on both rising or falling edges */
482 
483 #define LOWPOWER_WAKEUPIOSRC_PIO0MODE_INDEX 10 /*!< Pin P1( 1) */
484 #define LOWPOWER_WAKEUPIOSRC_PIO1MODE_INDEX 12 /*!< Pin P0(28) */
485 #define LOWPOWER_WAKEUPIOSRC_PIO2MODE_INDEX 14 /*!< Pin P1(18) */
486 #define LOWPOWER_WAKEUPIOSRC_PIO3MODE_INDEX 16 /*!< Pin P1(30) */
487 #define LOWPOWER_WAKEUPIOSRC_PIO4MODE_INDEX 18 /*!< Pin P0(26) */
488 
489 #define LOWPOWER_WAKEUPIOSRC_IO_MODE_PLAIN    0 /*!< Wake up Pad is plain input */
490 #define LOWPOWER_WAKEUPIOSRC_IO_MODE_PULLDOWN 1 /*!< Wake up Pad is pull-down   */
491 #define LOWPOWER_WAKEUPIOSRC_IO_MODE_PULLUP   2 /*!< Wake up Pad is pull-up     */
492 #define LOWPOWER_WAKEUPIOSRC_IO_MODE_REPEATER 3 /*!< Wake up Pad is in repeater */
493 
494 #define LOWPOWER_WAKEUPIO_PIO0_DISABLEPULLUPDOWN_INDEX \
495     20 /*!< Wake-up I/O 0 pull-up/down disable/enable control index */
496 #define LOWPOWER_WAKEUPIO_PIO1_DISABLEPULLUPDOWN_INDEX \
497     21 /*!< Wake-up I/O 1 pull-up/down disable/enable control index */
498 #define LOWPOWER_WAKEUPIO_PIO2_DISABLEPULLUPDOWN_INDEX \
499     22 /*!< Wake-up I/O 2 pull-up/down disable/enable control index */
500 #define LOWPOWER_WAKEUPIO_PIO3_DISABLEPULLUPDOWN_INDEX \
501     23 /*!< Wake-up I/O 3 pull-up/down disable/enable control index */
502 #define LOWPOWER_WAKEUPIO_PIO4_DISABLEPULLUPDOWN_INDEX \
503     24 /*!< Wake-up I/O 4 pull-up/down disable/enable control index */
504 
505 #define LOWPOWER_WAKEUPIO_PIO0_DISABLEPULLUPDOWN_MASK \
506     (1UL << LOWPOWER_WAKEUPIO_PIO0_DISABLEPULLUPDOWN_INDEX) /*!< Wake-up I/O 0 pull-up/down disable/enable mask */
507 #define LOWPOWER_WAKEUPIO_PIO1_DISABLEPULLUPDOWN_MASK \
508     (1UL << LOWPOWER_WAKEUPIO_PIO1_DISABLEPULLUPDOWN_INDEX) /*!< Wake-up I/O 1 pull-up/down disable/enable mask */
509 #define LOWPOWER_WAKEUPIO_PIO2_DISABLEPULLUPDOWN_MASK \
510     (1UL << LOWPOWER_WAKEUPIO_PIO2_DISABLEPULLUPDOWN_INDEX) /*!< Wake-up I/O 2 pull-up/down disable/enable mask */
511 #define LOWPOWER_WAKEUPIO_PIO3_DISABLEPULLUPDOWN_MASK \
512     (1UL << LOWPOWER_WAKEUPIO_PIO3_DISABLEPULLUPDOWN_INDEX) /*!< Wake-up I/O 3 pull-up/down disable/enable mask */
513 #define LOWPOWER_WAKEUPIO_PIO4_DISABLEPULLUPDOWN_MASK \
514     (1UL << LOWPOWER_WAKEUPIO_PIO4_DISABLEPULLUPDOWN_INDEX) /*!< Wake-up I/O 4 pull-up/down disable/enable mask */
515 
516 #define LOWPOWER_WAKEUPIO_PIO0_PULLUPDOWN_INDEX 25 /*!< Wake-up I/O 0 pull-up/down configuration index */
517 #define LOWPOWER_WAKEUPIO_PIO1_PULLUPDOWN_INDEX 26 /*!< Wake-up I/O 1 pull-up/down configuration index */
518 #define LOWPOWER_WAKEUPIO_PIO2_PULLUPDOWN_INDEX 27 /*!< Wake-up I/O 2 pull-up/down configuration index */
519 #define LOWPOWER_WAKEUPIO_PIO3_PULLUPDOWN_INDEX 28 /*!< Wake-up I/O 3 pull-up/down configuration index */
520 #define LOWPOWER_WAKEUPIO_PIO4_PULLUPDOWN_INDEX 29 /*!< Wake-up I/O 4 pull-up/down configuration index */
521 
522 #define LOWPOWER_WAKEUPIO_PIO0_PULLUPDOWN_MASK \
523     (1UL << LOWPOWER_WAKEUPIO_PIO0_PULLUPDOWN_INDEX) /*!< Wake-up I/O 0 pull-up/down mask */
524 #define LOWPOWER_WAKEUPIO_PIO1_PULLUPDOWN_MASK \
525     (1UL << LOWPOWER_WAKEUPIO_PIO1_PULLUPDOWN_INDEX) /*!< Wake-up I/O 1 pull-up/down mask */
526 #define LOWPOWER_WAKEUPIO_PIO2_PULLUPDOWN_MASK \
527     (1UL << LOWPOWER_WAKEUPIO_PIO2_PULLUPDOWN_INDEX) /*!< Wake-up I/O 2 pull-up/down mask */
528 #define LOWPOWER_WAKEUPIO_PIO3_PULLUPDOWN_MASK \
529     (1UL << LOWPOWER_WAKEUPIO_PIO3_PULLUPDOWN_INDEX) /*!< Wake-up I/O 3 pull-up/down mask */
530 #define LOWPOWER_WAKEUPIO_PIO4_PULLUPDOWN_MASK \
531     (1UL << LOWPOWER_WAKEUPIO_PIO4_PULLUPDOWN_INDEX) /*!< Wake-up I/O 4 pull-up/down mask */
532 
533 #define LOWPOWER_WAKEUPIO_PULLDOWN 0 /*!< Select pull-down */
534 #define LOWPOWER_WAKEUPIO_PULLUP   1 /*!< Select pull-up   */
535 
536 #define LOWPOWER_WAKEUPIO_CFG_SRC_IOCON                                                                      \
537     0 /*!< Wake-up pins configuration (in/out, pull up/down plain input ...) is coming from IOCON (valid for \
538          DEEP-SLEEP and POWER-DOWN) */
539 #define LOWPOWER_WAKEUPIO_CFG_SRC_PMC                                                                          \
540     1 /*!< Wake-up pins configuration (in/out, pull up/down plain input ...) is coming from PMC and set up via \
541            the second parameter (wakeup_io_ctrl) of POWER_SetWakeUpPins API (valid for DEEP-SLEEP and POWER-DOWN) */
542 
543 #ifdef __cplusplus
544 extern "C" {
545 #endif
546 /*******************************************************************************
547  * API
548  ******************************************************************************/
549 
550 /*!
551  * @brief API to enable PDRUNCFG bit in the Syscon. Note that enabling the bit powers down the peripheral
552  *
553  * @param en    peripheral for which to enable the PDRUNCFG bit
554  * @return none
555  */
POWER_EnablePD(pd_bit_t en)556 static inline void POWER_EnablePD(pd_bit_t en)
557 {
558     if (((en & (1UL << 31)) != 0UL) && (en != (1UL << 31)))
559     {
560         /* PDRUNCFGSET1 */
561         PMC->PDRUNCFGSET1 = (uint32_t)(en & ~(1UL << 31));
562     }
563     else
564     {
565         /* PDRUNCFGSET0 */
566         PMC->PDRUNCFGSET0 = (uint32_t)en;
567     }
568 }
569 
570 /*!
571  * @brief API to disable PDRUNCFG bit in the Syscon. Note that disabling the bit powers up the peripheral
572  *
573  * @param en    peripheral for which to disable the PDRUNCFG bit
574  * @return none
575  */
POWER_DisablePD(pd_bit_t en)576 static inline void POWER_DisablePD(pd_bit_t en)
577 {
578     if (((en & (1UL << 31)) != 0UL) && (en != (1UL << 31)))
579     {
580         /* PDRUNCFGCLR1 */
581         PMC->PDRUNCFGCLR1 = (uint32_t)(en & ~(1UL << 31));
582     }
583     else
584     {
585         /* PDRUNCFGCLR0 */
586         PMC->PDRUNCFGCLR0 = (uint32_t)en;
587     }
588 }
589 
590 /**
591  * @brief   SoC Power Management Controller initialization
592  * @return  power_status_t
593  */
594 power_status_t POWER_PowerInit(void);
595 
596 /**
597  * @brief   Selects the core logic supply source
598  * @param   pwr_source : Defines which regulator will be used to power the part core logic (internally)
599  * @return  power_status_t
600  */
601 power_status_t POWER_SetCorePowerSource(power_core_pwr_source_t pwr_source);
602 
603 /**
604  * @brief   Returns the current core logic supply source.
605  * @return  power_core_pwr_source_t
606  */
607 power_core_pwr_source_t POWER_GetCorePowerSource(void);
608 
609 /**
610  * @brief   Allows to control the state (enabled or disabled) of the core logic internal regulators (DCDC, LDO_CORE)
611  * @param   pwr_source : Defines which regulator will be enabled or disabled
612  * @param   pwr_state : Defines the state of the internal regulator indicated by pwr_source
613  * @return  power_status_t
614  */
615 power_status_t POWER_CorePowerSourceControl(power_core_pwr_source_t pwr_source, power_core_pwr_state_t pwr_state);
616 
617 /**
618  * @brief   Allows to configure SRAM instances (low) power modes when the part is in ACTIVE mode.
619  * @param   sram_inst : Defines the SRAM instance(s) to be configured.
620  * @param   pwr_mode : Defines the SRAM low power mode to be applied to all SRAM instances given by sram_inst
621  * @return  power_status_t
622  */
623 power_status_t POWER_SRAMPowerModeControl(power_sram_bit_t sram_inst, power_sram_pwr_mode_t pwr_mode);
624 
625 /**
626  * @brief
627  * @param   p_sram_index :
628  * @return  power_sram_pwr_mode_t
629  */
630 power_sram_pwr_mode_t POWER_GetSRAMPowerMode(power_sram_index_t sram_index);
631 
632 /**
633  * @brief   Configures and enters in SLEEP low power mode
634  * @return  Nothing
635  */
636 void POWER_EnterSleep(void);
637 
638 /**
639  * @brief   Configures and enters in DEEP-SLEEP low power mode
640  * @param   exclude_from_pd: defines which analog peripherals shall NOT be powered down (it is a 2 x 32-bit vectors,
641  aligned with "pd_bit_t" definition)
642  * @param   sram_retention_ctrl:defines which SRAM instances will be put in "retention" mode during deep-sleep (aligned
643  with "power_sram_bit_t" definition)
644  * @param   wakeup_interrupts: defines which peripheral interrupts can be a wake-up source during deep-sleep (it is a 4
645  x 32-bit vectors, aligned with "WAKEUP_" #defines)
646  * @param   hardware_wake_ctrl: configure DMA services during deep-sleep without waking up entire device (see
647  "LOWPOWER_HWWAKE_*" #defines).
648 
649  * @return  Nothing
650  *
651  *          !!! IMPORTANT NOTES :
652  *           1 - CPU & System CLock frequency is switched to FRO12MHz and is NOT restored back by the API.
653  */
654 void POWER_EnterDeepSleep(uint32_t exclude_from_pd[2],
655                           uint32_t sram_retention_ctrl,
656                           uint32_t wakeup_interrupts[4],
657                           uint32_t hardware_wake_ctrl);
658 
659 /**
660  * @brief   Configures and enters in POWERDOWN low power mode
661  * @param   exclude_from_pd: defines which analog peripherals shall NOT be powered down (it is a 1 x 32-bit vector,
662  aligned with "pd_bit_t" definition)
663  * @param   sram_retention_ctrl:defines which SRAM instances will be put in "retention" mode during power-down (aligned
664  with "power_sram_bit_t" definition)
665  * @param   wakeup_interrupts: defines which peripheral interrupts can be a wake-up source during power-down (it is a 2
666  x 32-bit vectors, aligned with "WAKEUP_" #defines)
667  * @param   cpu_retention_addr: Must be:
668              - Word aligned (address ending by 0x0, 0x4, 0x8 and 0xC).
669              - Between 0x2000_0000 and 0x2000_09FC (inside RAM_00) or
670              - Between 0x2000_1000 and 0x2000_19FC (inside RAM_01) or
671              - Between 0x2000_2000 and 0x2000_29FC (inside RAM_02) or
672              - Between 0x2000_3000 and 0x2000_39FC (inside RAM_03)
673              - The CPU state will be stored in SRAM from "cpu_retention_addr" to "cpu_retention_addr + 1540".
674                Therefore, any data present in this area before calling the function will be lost.
675 
676  * @return  Nothing
677  *
678  *          !!! IMPORTANT NOTES :
679  *           1 - CPU0 & System Clock frequency is switched to FRO12MHz and is NOT restored back by the API.
680  *           2 - It is the responsability of the user to make sure that SRAM instance containing the application
681  *               software stack and variables WILL BE preserved during low power (via parameter "sram_retention_ctrl")
682  */
683 void POWER_EnterPowerDown(uint32_t exclude_from_pd[1],
684                           uint32_t sram_retention_ctrl,
685                           uint32_t wakeup_interrupts[4],
686                           uint32_t cpu_retention_addr);
687 
688 /**
689  * @brief   Configures and enters in DEEPPOWERDOWN low power mode
690  * @param   exclude_from_pd: defines which analog peripherals shall NOT be powered down (it is a 1 x 32-bit vector,
691  aligned with "pd_bit_t" definition)
692  * @param   sram_retention_ctrl: defines which SRAM instances will be put in "retention" mode during deep power-down
693  (aligned with "power_sram_bit_t" definition)
694  * @param   wakeup_interrupts: defines which peripheral interrupts can be a wake-up source during deep power-down (it is
695  a 2 x 32-bit vectors, aligned with "WAKEUP_" #defines)
696  * @param   wakeup_io_ctrl: configure the 5 wake-up pins that can wake-up the part from deep power-down mode (see
697  "LOWPOWER_WAKEUPIOSRC_*" #defines)
698 
699  * @return  Nothing
700  *
701  *          !!! IMPORTANT NOTES :
702  *           1 - CPU0 & System Clock frequency is switched to FRO12MHz and is NOT restored back by the API.
703  *           2 - The HARD FAULT handler should execute from SRAM. (The Hard fault handler should initiate a full chip
704  reset)
705  */
706 void POWER_EnterDeepPowerDown(uint32_t exclude_from_pd[1],
707                               uint32_t sram_retention_ctrl,
708                               uint32_t wakeup_interrupts[2],
709                               uint32_t wakeup_io_ctrl);
710 
711 /**
712  * @brief   Configures the 5 wake-up pins to wake up the part in DEEP-SLEEP and POWER-DOWN low power modes.
713  * @param   wakeup_io_cfg_src : for all wake-up pins : indicates if the config is from IOCON (0) or from PMC (1).
714  * @param   wakeup_io_ctrl: the 5 wake-up pins configurations (see "LOWPOWER_WAKEUPIOSRC_*" #defines)
715 
716  * @return  Nothing
717  *
718  *          !!! IMPORTANT NOTES :
719  *           1 - To be called just before POWER_EnterDeepSleep() or POWER_EnterPowerDown().
720  */
721 void POWER_SetWakeUpPins(uint32_t wakeup_io_cfg_src, uint32_t wakeup_io_ctrl);
722 
723 /**
724  * @brief   Return some key information related to the device reset causes / wake-up sources, for all power modes.
725  * @param   reset_cause   : the device reset cause, according to the definition of power_reset_cause_t type.
726  * @param   boot_mode     : the device boot mode, according to the definition of power_boot_mode_t type.
727  * @param   wakeup_pin_cause: the wake-up pin sources, according to the definition of power_wakeup_pin_t  type.
728 
729  * @return  Nothing
730  *
731  */
732 void POWER_GetWakeUpCause(power_reset_cause_t *reset_cause,
733                           power_boot_mode_t *boot_mode,
734                           power_wakeup_pin_t *wakeup_pin_cause);
735 
736 /**
737  * @brief   Configures the device internal power control settings
738  * @param   system_freq_hz: operating frequency required (in Hertz).
739  * @return  Nothing
740  *
741  *          prepare on-chip power regulators (DC-DC Converter / Core and Always-on
742  *          Low Drop-Out regulators)  to deliver the amount of power needed for the
743  *          requested performance level, as defined by the CPU operating frequency.
744  */
745 void POWER_SetVoltageForFreq(uint32_t system_freq_hz);
746 
747 #ifdef __cplusplus
748 }
749 #endif
750 
751 #endif /* _FSL_POWER_H_ */
752