1 /*
2  * Copyright (c) 2015-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /** ============================================================================
33  *  @file       PowerCC32XX.h
34  *
35  *  @brief      Power manager interface for the CC32XX
36  *
37  *  The Power header file should be included in an application as follows:
38  *  @code
39  *  #include <ti/drivers/Power.h>
40  *  #include <ti/drivers/power/PowerCC32XX.h>
41  *  @endcode
42  *
43  *  Refer to @ref Power.h for a complete description of APIs.
44  *
45  *  ## Implementation #
46  *  This module defines the power resources, constraints, events, sleep
47  *  states and transition latencies for CC32XX.
48  *
49  *  A reference power policy is provided which can transition the MCU from the
50  *  active state to one of two sleep states: Low-Power Deep Sleep (LPDS) or
51  *  Sleep. The policy looks at the estimated idle time remaining, and the
52  *  active constraints, and determine which sleep state to transition to. The
53  *  policy will give first preference to choosing LPDS, but if that is not
54  *  appropriate (e.g., not enough idle time), it will choose Sleep.
55  *
56  *  ============================================================================
57  */
58 
59 #ifndef ti_drivers_power_PowerCC32XX__include
60 #define ti_drivers_power_PowerCC32XX__include
61 
62 #include <stdint.h>
63 #include <ti/drivers/utils/List.h>
64 #include <ti/drivers/Power.h>
65 
66 /* driverlib header files */
67 #include <ti/devices/cc32xx/inc/hw_types.h>
68 #include <ti/devices/cc32xx/driverlib/rom.h>
69 #include <ti/devices/cc32xx/driverlib/rom_map.h>
70 #include <ti/devices/cc32xx/driverlib/pin.h>
71 
72 #ifdef __cplusplus
73 extern "C" {
74 #endif
75 
76 /* latency values were measured with a logic analyzer, and rounded up */
77 
78 /*! The latency to reserve for resuming from LPDS (usec) */
79 #define PowerCC32XX_RESUMETIMELPDS          2500
80 
81 /*! The total latency to reserve for entry to and exit from LPDS (usec) */
82 #define PowerCC32XX_TOTALTIMELPDS           20000
83 
84 /*! The total latency to reserve for entry to and exit from Shutdown (usec) */
85 #define PowerCC32XX_TOTALTIMESHUTDOWN       500000
86 
87 /* Power resources */
88 #define PowerCC32XX_PERIPH_CAMERA       0
89 /*!< Resource ID: Camera */
90 
91 #define PowerCC32XX_PERIPH_I2S          1
92 /*!< Resource ID: I2S */
93 
94 #define PowerCC32XX_PERIPH_SDHOST       2
95 /*!< Resource ID: SDHost */
96 
97 #define PowerCC32XX_PERIPH_GSPI         3
98 /*!< Resource ID: General Purpose SPI (GSPI) */
99 
100 #define PowerCC32XX_PERIPH_LSPI         4
101 /*!< Resource ID: LSPI */
102 
103 #define PowerCC32XX_PERIPH_UDMA         5
104 /*!< Resource ID: uDMA Controller */
105 
106 #define PowerCC32XX_PERIPH_GPIOA0       6
107 /*!< Resource ID: General Purpose I/O Port A0 */
108 
109 #define PowerCC32XX_PERIPH_GPIOA1       7
110 /*!< Resource ID: General Purpose I/O Port A1 */
111 
112 #define PowerCC32XX_PERIPH_GPIOA2       8
113 /*!< Resource ID: General Purpose I/O Port A2 */
114 
115 #define PowerCC32XX_PERIPH_GPIOA3       9
116 /*!< Resource ID: General Purpose I/O Port A3 */
117 
118 #define PowerCC32XX_PERIPH_GPIOA4       10
119 /*!< Resource ID: General Purpose I/O Port A4 */
120 
121 #define PowerCC32XX_PERIPH_WDT          11
122 /*!< Resource ID: Watchdog module */
123 
124 #define PowerCC32XX_PERIPH_UARTA0       12
125 /*!< Resource ID: UART 0 */
126 
127 #define PowerCC32XX_PERIPH_UARTA1       13
128 /*!< Resource ID: UART 1 */
129 
130 #define PowerCC32XX_PERIPH_TIMERA0      14
131 /*!< Resource ID: General Purpose Timer A0 */
132 
133 #define PowerCC32XX_PERIPH_TIMERA1      15
134 /*!< Resource ID: General Purpose Timer A1 */
135 
136 #define PowerCC32XX_PERIPH_TIMERA2      16
137 /*!< Resource ID: General Purpose Timer A2 */
138 
139 #define PowerCC32XX_PERIPH_TIMERA3      17
140 /*!< Resource ID: General Purpose Timer A3 */
141 
142 #define PowerCC32XX_PERIPH_DTHE         18
143 /*!< Resource ID: Cryptography Accelerator (DTHE) */
144 
145 #define PowerCC32XX_PERIPH_SSPI         19
146 /*!< Resource ID: Serial Flash SPI (SSPI) */
147 
148 #define PowerCC32XX_PERIPH_I2CA0        20
149 /*!< Resource ID: I2C */
150 
151 /* \cond */
152 #define PowerCC32XX_NUMRESOURCES        21 /* Number of resources in database */
153 /* \endcond */
154 
155 /*
156  *  Power constraints on the CC32XX device
157  */
158 #define PowerCC32XX_DISALLOW_LPDS       0
159 /*!< Constraint: Disallow entry to Low Power Deep Sleep (LPDS) */
160 
161 #define PowerCC32XX_DISALLOW_SHUTDOWN   1
162 /*!< Constraint: Disallow entry to Shutdown */
163 
164 /* \cond */
165 #define PowerCC32XX_NUMCONSTRAINTS      2   /*!< number of constraints */
166 /* \endcond */
167 
168 /*
169  *  Power events on the CC32XX device
170  *
171  *  Each event must be a power of two, and the event IDs must be sequential
172  *  without any gaps.
173  */
174 #define PowerCC32XX_ENTERING_LPDS       0x1
175 /*!< Power event: The device is entering the LPDS sleep state */
176 
177 #define PowerCC32XX_ENTERING_SHUTDOWN   0x2
178 /*!< Power event: The device is entering the Shutdown state */
179 
180 #define PowerCC32XX_AWAKE_LPDS          0x4
181 /*!< Power event: The device is waking from the LPDS sleep state */
182 
183 /* \cond */
184 #define PowerCC32XX_NUMEVENTS           3    /*!< number of events */
185 /* \endcond */
186 
187 /* Power sleep states */
188 #define PowerCC32XX_LPDS                0x1 /*!< The LPDS sleep state */
189 
190 /* \cond */
191 /* Use by NVIC Register structure */
192 #define PowerCC32XX_numNVICSetEnableRegs    6
193 #define PowerCC32XX_numNVICIntPriority      49
194 /* \endcond */
195 
196 /* \cond */
197 /* Number of pins that can be parked in LPDS */
198 #define PowerCC32XX_NUMPINS             34
199 /* \endcond */
200 
201 /*! @brief  Used to specify parking of a pin during LPDS */
202 typedef struct {
203     uint32_t pin;
204     /*!< The pin to be parked */
205     uint32_t parkState;
206     /*!< The state to park the pin (an enumerated PowerCC32XX_ParkState) */
207 } PowerCC32XX_ParkInfo;
208 
209 /*! @brief Power global configuration */
210 typedef struct {
211     /*! Initialization function for the power policy */
212     Power_PolicyInitFxn policyInitFxn;
213     /*! The power policy function */
214     Power_PolicyFxn policyFxn;
215     /*!
216      *  @brief  Hook function called before entering LPDS
217      *
218      *  This function is called after any notifications are complete,
219      *  and before any pins are parked, just before entry to LPDS.
220      */
221     void (*enterLPDSHookFxn)(void);
222     /*!
223      *  @brief  Hook function called when resuming from LPDS
224      *
225      *  This function is called early in the wake sequence, before any
226      *  notification functions are run.
227      */
228     void (*resumeLPDSHookFxn)(void);
229     /*! Determines whether to run the power policy function */
230     bool enablePolicy;
231     /*! Enable GPIO as a wakeup source for LPDS */
232     bool enableGPIOWakeupLPDS;
233     /*! Enable GPIO as a wakeup source for shutdown */
234     bool enableGPIOWakeupShutdown;
235     /*! Enable Network activity as a wakeup source for LPDS */
236     bool enableNetworkWakeupLPDS;
237     /*!
238      *  @brief  The GPIO source for wakeup from LPDS
239      *
240      *  Only one GPIO {2,4,11,13,17,24,26} can be specified as a wake source
241      *  for LPDS.  The GPIO must be specified as one of the following (as
242      *  defined in driverlib/prcm.h): PRCM_LPDS_GPIO2, PRCM_LPDS_GPIO4,
243      *  PRCM_LPDS_GPIO11, PRCM_LPDS_GPIO13, PRCM_LPDS_GPIO17, PRCM_LPDS_GPIO24,
244      *  PRCM_LPDS_GPIO26
245      */
246     uint32_t wakeupGPIOSourceLPDS;
247     /*!
248      *  @brief  The GPIO trigger type for wakeup from LPDS
249      *
250      *  Value can be one of the following (defined in driverlib/prcm.h):
251      *  PRCM_LPDS_LOW_LEVEL, PRCM_LPDS_HIGH_LEVEL,
252      *  PRCM_LPDS_FALL_EDGE, PRCM_LPDS_RISE_EDGE
253      */
254     uint32_t wakeupGPIOTypeLPDS;
255     /*!
256      *  @brief  Function to be called when the configured GPIO triggers wakeup
257      *  from LPDS
258      *
259      *  During LPDS the internal GPIO module is powered off, and special
260      *  periphery logic is used instead to detect the trigger and wake the
261      *  device.  No GPIO interrupt service routine will be triggered in this
262      *  case (even if an ISR is configured, and used normally to detect GPIO
263      *  interrupts when not in LPDS).  This function can be used in lieu of a
264      *  GPIO ISR, to take specific action upon LPDS wakeup.
265      *
266      *  A value of NULL indicates no GPIO wakeup function will be called.
267      *
268      *  An argument for this wakeup function can be specified via
269      *  wakeupGPIOFxnLPDSArg.
270      *
271      *  @note This wakeup function will be called as one of the last steps
272      *  in Power_sleep(), after all notifications have been sent out, and after
273      *  pins have been restored to their previous (non-parked) states.
274      */
275     void (*wakeupGPIOFxnLPDS)(uint_least8_t argument);
276     /*!
277      *  @brief  The argument to be passed to wakeupGPIOFxnLPDS()
278      */
279     uint_least8_t wakeupGPIOFxnLPDSArg;
280     /*!
281      *  @brief  The GPIO sources for wakeup from shutdown
282      *
283      *  Only one GPIO {2,4,11,13,17,24,26} can be specified as a wake source
284      *  for Shutdown.  The GPIO must be specified as one of the following (as
285      *  defined in driverlib/prcm.h): PRCM_HIB_GPIO2, PRCM_HIB_GPIO4,
286      *  PRCM_HIB_GPIO11, PRCM_HIB_GPIO13, PRCM_HIB_GPIO17, PRCM_HIB_GPIO24,
287      *  PRCM_HIB_GPIO26
288      */
289     uint32_t wakeupGPIOSourceShutdown;
290     /*!
291      *  @brief  The GPIO trigger type for wakeup from shutdown
292      *
293      *  Value can be one of the following (defined in driverlib/prcm.h):
294      *  PRCM_HIB_LOW_LEVEL, PRCM_HIB_HIGH_LEVEL,
295      *  PRCM_HIB_FALL_EDGE, PRCM_HIB_RISE_EDGE
296      */
297     uint32_t wakeupGPIOTypeShutdown;
298     /*!
299      *  @brief  SRAM retention mask for LPDS
300      *
301      *  Value can be a mask of the following (defined in driverlib/prcm.h):
302      *  PRCM_SRAM_COL_1, PRCM_SRAM_COL_2, PRCM_SRAM_COL_3,
303      *  PRCM_SRAM_COL_4
304      */
305     uint32_t ramRetentionMaskLPDS;
306     /*!
307      *  @brief  Keep debug interface active during LPDS
308      *
309      *  This Boolean controls whether the debug interface will be left active
310      *  when LPDS is entered.  For best power savings this flag should be set
311      *  to false.  Setting the flag to true will enable better debug
312      *  capability, but will prevent full LPDS, and will result in increased
313      *  power consumption.
314      */
315     bool keepDebugActiveDuringLPDS;
316     /*!
317      *  @brief  IO retention mask for Shutdown
318      *
319      *  Value can be a mask of the following (defined in driverlib/prcm.h):
320      *  PRCM_IO_RET_GRP_0, PRCM_IO_RET_GRP_1, PRCM_IO_RET_GRP_2
321      *  PRCM_IO_RET_GRP_3
322      */
323     uint32_t ioRetentionShutdown;
324     /*!
325      *  @brief  Pointer to an array of pins to be parked during LPDS
326      *
327      *  A value of NULL will disable parking of any pins during LPDS
328      */
329     PowerCC32XX_ParkInfo * pinParkDefs;
330     /*!
331      *  @brief  Number of pins to be parked during LPDS
332      */
333     uint32_t numPins;
334 } PowerCC32XX_ConfigV1;
335 
336 /*!
337  *  @cond NODOC
338  *  NVIC registers that need to be saved before entering LPDS.
339  */
340 typedef struct {
341     uint32_t vectorTable;
342     uint32_t auxCtrl;
343     uint32_t intCtrlState;
344     uint32_t appInt;
345     uint32_t sysCtrl;
346     uint32_t configCtrl;
347     uint32_t sysPri1;
348     uint32_t sysPri2;
349     uint32_t sysPri3;
350     uint32_t sysHcrs;
351     uint32_t systickCtrl;
352     uint32_t systickReload;
353     uint32_t systickCalib;
354     uint32_t intSetEn[PowerCC32XX_numNVICSetEnableRegs];
355     uint32_t intPriority[PowerCC32XX_numNVICIntPriority];
356 } PowerCC32XX_NVICRegisters;
357 /*! @endcond */
358 
359 /*!
360  *  @cond NODOC
361  *  MCU core registers that need to be save before entering LPDS.
362  */
363 typedef struct {
364     uint32_t msp;
365     uint32_t psp;
366     uint32_t psr;
367     uint32_t primask;
368     uint32_t faultmask;
369     uint32_t basepri;
370     uint32_t control;
371 } PowerCC32XX_MCURegisters;
372 /*! @endcond */
373 
374 /*!
375  *  @cond NODOC
376  *  Structure of context registers to save before entering LPDS.
377  */
378 typedef struct {
379     PowerCC32XX_MCURegisters m4Regs;
380     PowerCC32XX_NVICRegisters nvicRegs;
381 } PowerCC32XX_SaveRegisters;
382 /*! @endcond */
383 
384 /*! @brief Enumeration of states a pin can be parked in */
385 typedef enum {
386     /*! No pull resistor, leave pin in a HIZ state */
387     PowerCC32XX_NO_PULL_HIZ = PIN_TYPE_STD,
388     /*! Pull-up resistor for standard pin type */
389     PowerCC32XX_WEAK_PULL_UP_STD = PIN_TYPE_STD_PU,
390     /*! Pull-down resistor for standard pin type */
391     PowerCC32XX_WEAK_PULL_DOWN_STD = PIN_TYPE_STD_PD,
392     /*! Pull-up resistor for open drain pin type */
393     PowerCC32XX_WEAK_PULL_UP_OPENDRAIN = PIN_TYPE_OD_PU,
394     /*! Pull-down resistor for open drain pin type */
395     PowerCC32XX_WEAK_PULL_DOWN_OPENDRAIN = PIN_TYPE_OD_PD,
396     /*! Drive pin to a low logic state */
397     PowerCC32XX_DRIVE_LOW,
398     /*! Drive pin to a high logic state */
399     PowerCC32XX_DRIVE_HIGH,
400     /*! Take no action; do not park the pin */
401     PowerCC32XX_DONT_PARK
402 } PowerCC32XX_ParkState;
403 
404 /*! @brief Enumeration of pins that can be parked */
405 typedef enum {
406     /*! PIN_01 */
407     PowerCC32XX_PIN01 = PIN_01,
408     /*! PIN_02 */
409     PowerCC32XX_PIN02 = PIN_02,
410     /*! PIN_03 */
411     PowerCC32XX_PIN03 = PIN_03,
412     /*! PIN_04 */
413     PowerCC32XX_PIN04 = PIN_04,
414     /*! PIN_05 */
415     PowerCC32XX_PIN05 = PIN_05,
416     /*! PIN_06 */
417     PowerCC32XX_PIN06 = PIN_06,
418     /*! PIN_07 */
419     PowerCC32XX_PIN07 = PIN_07,
420     /*! PIN_08 */
421     PowerCC32XX_PIN08 = PIN_08,
422     /*! PIN_11 */
423     PowerCC32XX_PIN11 = PIN_11,
424     /*! PIN_12 */
425     PowerCC32XX_PIN12 = PIN_12,
426     /*! PIN_13 */
427     PowerCC32XX_PIN13 = PIN_13,
428     /*! PIN_14 */
429     PowerCC32XX_PIN14 = PIN_14,
430     /*! PIN_15 */
431     PowerCC32XX_PIN15 = PIN_15,
432     /*! PIN_16 */
433     PowerCC32XX_PIN16 = PIN_16,
434     /*! PIN_17 */
435     PowerCC32XX_PIN17 = PIN_17,
436     /*! PIN_18 */
437     PowerCC32XX_PIN18 = PIN_18,
438     /*! PIN_19 */
439     PowerCC32XX_PIN19 = PIN_19,
440     /*! PIN_20 */
441     PowerCC32XX_PIN20 = PIN_20,
442     /*! PIN_21 */
443     PowerCC32XX_PIN21 = PIN_21,
444     /*! PIN_29 */
445     PowerCC32XX_PIN29 = 0x1C,
446     /*! PIN_30 */
447     PowerCC32XX_PIN30 = 0x1D,
448     /*! PIN_45 */
449     PowerCC32XX_PIN45 = PIN_45,
450     /*! PIN_50 */
451     PowerCC32XX_PIN50 = PIN_50,
452     /*! PIN_52 */
453     PowerCC32XX_PIN52 = PIN_52,
454     /*! PIN_53 */
455     PowerCC32XX_PIN53 = PIN_53,
456     /*! PIN_55 */
457     PowerCC32XX_PIN55 = PIN_55,
458     /*! PIN_57 */
459     PowerCC32XX_PIN57 = PIN_57,
460     /*! PIN_58 */
461     PowerCC32XX_PIN58 = PIN_58,
462     /*! PIN_59 */
463     PowerCC32XX_PIN59 = PIN_59,
464     /*! PIN_60 */
465     PowerCC32XX_PIN60 = PIN_60,
466     /*! PIN_61 */
467     PowerCC32XX_PIN61 = PIN_61,
468     /*! PIN_62 */
469     PowerCC32XX_PIN62 = PIN_62,
470     /*! PIN_63 */
471     PowerCC32XX_PIN63 = PIN_63,
472     /*! PIN_64 */
473     PowerCC32XX_PIN64 = PIN_64
474 } PowerCC32XX_Pin;
475 
476 /*!
477  *  @brief  Specify the wakeup sources for LPDS and Shutdown
478  *
479  *  The wakeup sources for LPDS and Shutdown can be dynamically changed
480  *  at runtime, via PowerCC32XX_configureWakeup().  The application
481  *  should fill a structure of this type, and pass it as the parameter
482  *  to PowerCC32XX_configureWakeup() to specify the new wakeup settings.
483  */
484 typedef struct {
485     /*! Enable GPIO as a wakeup source for LPDS */
486     bool enableGPIOWakeupLPDS;
487     /*! Enable GPIO as a wakeup source for shutdown */
488     bool enableGPIOWakeupShutdown;
489     /*! Enable Network activity as a wakeup source for LPDS */
490     bool enableNetworkWakeupLPDS;
491     /*!
492      *  @brief  The GPIO source for wakeup from LPDS
493      *
494      *  Only one GPIO {2,4,11,13,17,24,26} can be specified as a wake source
495      *  for LPDS.  The GPIO must be specified as one of the following (as
496      *  defined in driverlib/prcm.h): PRCM_LPDS_GPIO2, PRCM_LPDS_GPIO4,
497      *  PRCM_LPDS_GPIO11, PRCM_LPDS_GPIO13, PRCM_LPDS_GPIO17, PRCM_LPDS_GPIO24,
498      *  PRCM_LPDS_GPIO26
499      */
500     uint32_t wakeupGPIOSourceLPDS;
501     /*!
502      *  @brief  The GPIO trigger type for wakeup from LPDS
503      *
504      *  Value can be one of the following (defined in driverlib/prcm.h):
505      *  PRCM_LPDS_LOW_LEVEL, PRCM_LPDS_HIGH_LEVEL,
506      *  PRCM_LPDS_FALL_EDGE, PRCM_LPDS_RISE_EDGE
507      */
508     uint32_t wakeupGPIOTypeLPDS;
509     /*!
510      *  @brief  Function to be called when the configured GPIO triggers wakeup
511      *  from LPDS
512      *
513      *  During LPDS the internal GPIO module is powered off, and special
514      *  periphery logic is used instead to detect the trigger and wake the
515      *  device.  No GPIO interrupt service routine will be triggered in this
516      *  case (even if an ISR is configured, and used normally to detect GPIO
517      *  interrupts when not in LPDS).  This function can be used in lieu of a
518      *  GPIO ISR, to take specific action upon LPDS wakeup.
519      *
520      *  A value of NULL indicates no GPIO wakeup function will be called.
521      *
522      *  An argument for this wakeup function can be specified via
523      *  wakeupGPIOFxnLPDSArg.
524      *
525      *  Note that this wakeup function will be called as one of the last steps
526      *  in Power_sleep(), after all notifications have been sent out, and after
527      *  pins have been restored to their previous (non-parked) states.
528      */
529     void (*wakeupGPIOFxnLPDS)(uint_least8_t argument);
530     /*!
531      *  @brief  The argument to be passed to wakeupGPIOFxnLPDS()
532      */
533     uint_least8_t wakeupGPIOFxnLPDSArg;
534     /*!
535      *  @brief  The GPIO sources for wakeup from shutdown
536      *
537      *  Only one GPIO {2,4,11,13,17,24,26} can be specified as a wake source
538      *  for Shutdown.  The GPIO must be specified as one of the following (as
539      *  defined in driverlib/prcm.h): PRCM_HIB_GPIO2, PRCM_HIB_GPIO4,
540      *  PRCM_HIB_GPIO11, PRCM_HIB_GPIO13, PRCM_HIB_GPIO17, PRCM_HIB_GPIO24,
541      *  PRCM_HIB_GPIO26
542      */
543     uint32_t wakeupGPIOSourceShutdown;
544     /*!
545      *  @brief  The GPIO trigger type for wakeup from shutdown
546      *
547      *  Value can be one of the following (defined in driverlib/prcm.h):
548      *  PRCM_HIB_LOW_LEVEL, PRCM_HIB_HIGH_LEVEL,
549      *  PRCM_HIB_FALL_EDGE, PRCM_HIB_RISE_EDGE
550      */
551     uint32_t wakeupGPIOTypeShutdown;
552 } PowerCC32XX_Wakeup;
553 
554 /*!
555  *  @cond NODOC
556  *  Internal structure defining Power module state.
557  */
558 typedef struct {
559     List_List notifyList;
560     uint32_t constraintMask;
561     uint32_t state;
562     uint16_t dbRecords[PowerCC32XX_NUMRESOURCES];
563     bool enablePolicy;
564     bool initialized;
565     uint8_t refCount[PowerCC32XX_NUMRESOURCES];
566     uint8_t constraintCounts[PowerCC32XX_NUMCONSTRAINTS];
567     Power_PolicyFxn policyFxn;
568     uint32_t pinType[PowerCC32XX_NUMPINS];
569     uint16_t pinDir[PowerCC32XX_NUMPINS];
570     uint8_t pinMode[PowerCC32XX_NUMPINS];
571     uint16_t stateAntPin29;
572     uint16_t stateAntPin30;
573     uint32_t pinLockMask;
574     PowerCC32XX_Wakeup wakeupConfig;
575 } PowerCC32XX_ModuleState;
576 /*! @endcond */
577 
578 /*!
579  *  @brief  Function configures wakeup for LPDS and shutdown
580  *
581  *  This function allows the app to configure the GPIO source and
582  *  type for waking up from LPDS and shutdown and the network host
583  *  as a wakeup source for LPDS.  This overwrites any previous
584  *  wakeup settings.
585  *
586  *  @param[in]  wakeup      Settings applied to wakeup configuration
587  */
588 void PowerCC32XX_configureWakeup(PowerCC32XX_Wakeup *wakeup);
589 
590 /*! OS-specific power policy initialization function */
591 void PowerCC32XX_initPolicy(void);
592 
593 /*!
594  *  @brief  Function to get wakeup configuration settings
595  *
596  *  This function allows an app to query the current LPDS and shutdown
597  *  wakeup configuration settings.
598  *
599  *  @param[in]  wakeup      A #PowerCC32XX_Wakeup structure to be written into
600  */
601 void PowerCC32XX_getWakeup(PowerCC32XX_Wakeup *wakeup);
602 
603 /*! CC32XX-specific function to query the LPDS park state for a pin */
604 PowerCC32XX_ParkState PowerCC32XX_getParkState(PowerCC32XX_Pin pin);
605 
606 /*! CC32XX-specific function to restore the LPDS park state for a pin */
607 void PowerCC32XX_restoreParkState(PowerCC32XX_Pin pin,
608     PowerCC32XX_ParkState state);
609 
610 /*! CC32XX-specific function to dynamically set the LPDS park state for a pin */
611 void PowerCC32XX_setParkState(PowerCC32XX_Pin pin, uint32_t level);
612 
613 /*!
614  *  @brief  Function to disable IO retention and unlock pin groups following
615  *  exit from Shutdown.
616  *
617  *  #PowerCC32XX_ConfigV1.ioRetentionShutdown can be used to specify locking
618  *  and retention of pin groups during Shutdown. Upon exit from Shutdown, and
619  *  when appropriate, an application can call this function, to
620  *  correspondingly disable IO retention, and unlock the specified pin groups.
621  *
622  *  @param[in]  groupFlags     A logical OR of one or more of the following
623  *  flags (defined in driverlib/prcm.h):
624  *  @li @p PRCM_IO_RET_GRP_0 - all pins except sFlash and JTAG interface
625  *  @li @p PRCM_IO_RET_GRP_1 - sFlash interface pins 11,12,13,14
626  *  @li @p PRCM_IO_RET_GRP_2 - JTAG TDI and TDO interface pins 16,17
627  *  @li @p PRCM_IO_RET_GRP_3 - JTAG TCK and TMS interface pins 19,20
628  */
629 void PowerCC32XX_disableIORetention(unsigned long groupFlags);
630 
631 /*!
632  *  @brief A reference power policy is provided which can transition the MCU
633  *  from the active state to one of two sleep states: Low-Power Deep Sleep
634  *  (LPDS) or Sleep.
635  *
636  *  The policy looks at the estimated idle time remaining, and the
637  *  active constraints, and determine which sleep state to transition to. The
638  *  policy will give first preference to choosing LPDS, but if that is not
639  *  appropriate (e.g., not enough idle time), it will choose Sleep.
640  */
641 void PowerCC32XX_sleepPolicy(void);
642 
643 /*!
644  *  @brief  Software reset of a resource
645  *
646  *  This function performs a software reset of a resource.
647  *
648  *  Resource identifiers are device specific, and defined in the
649  *  device-specific Power include file.  For example, the resources for
650  *  CC32XX are defined in PowerCC32XX.h.
651  *
652  *  @param[in]  resourceId      resource id
653  *
654  *  @retval  #Power_SOK on success,
655  *  @retval  #Power_EINVALIDINPUT if the reseourceId is invalid.
656  *
657  */
658  int_fast16_t PowerCC32XX_reset(uint_fast16_t resourceId);
659 
660 /* \cond */
661 #define Power_getPerformanceLevel(void)   0
662 #define Power_setPerformanceLevel(level)  Power_EFAIL
663 /* \endcond */
664 
665 #ifdef __cplusplus
666 }
667 #endif
668 
669 #endif /* ti_drivers_power_PowerCC32XX__include */
670