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 CONSEQueueNTIAL 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       PowerCC26XX.h
34  *
35  *  @brief      Power manager interface for CC26XX/CC13XX
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/PowerCC26XX.h>
41  *  @endcode
42  *
43  *  Refer to @ref Power.h for a complete description of APIs.
44  *
45  *  ## Implementation #
46  *  This header file defines the power resources, constraints, events, sleep
47  *  states and transition latencies for CC26XX/CC13XX.
48  *
49  *  ============================================================================
50  */
51 
52 #ifndef ti_drivers_power_PowerCC26XX_
53 #define ti_drivers_power_PowerCC26XX_
54 
55 #include <ti/drivers/dpl/HwiP.h>
56 #include <ti/drivers/dpl/ClockP.h>
57 #include <ti/drivers/Power.h>
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /* \cond */
64 typedef uint8_t PowerCC26XX_Resource; /* Resource identifier */
65 /* \endcond */
66 
67 /*! The latency to reserve for resume from STANDBY (usec). */
68 #define PowerCC26XX_RESUMETIMESTANDBY  750
69 
70 /*! The total latency to reserve for entry to and exit from STANDBY (usec). */
71 #define PowerCC26XX_TOTALTIMESTANDBY   1000
72 
73 /*! The initial delay when waking from STANDBY (usec). */
74 #define PowerCC26XX_WAKEDELAYSTANDBY   240
75 
76 /*! The initial wait time (usec) before checking if RCOSC_LF is stable. */
77 #define PowerCC26XX_INITIALWAITRCOSC_LF 1000
78 
79 /*! The retry wait time (usec) when checking to see if RCOSC_LF is stable. */
80 #define PowerCC26XX_RETRYWAITRCOSC_LF   1000
81 
82 /*! The initial wait time (usec) before checking if XOSC_HF is stable. */
83 #define PowerCC26XX_INITIALWAITXOSC_HF  50
84 
85 /*! The retry wait time (usec) when checking to see if XOSC_HF is stable. */
86 #define PowerCC26XX_RETRYWAITXOSC_HF    50
87 
88 /*! The initial wait time (usec) before checking if XOSC_LF is stable. */
89 #define PowerCC26XX_INITIALWAITXOSC_LF  10000
90 
91 /*! The retry wait time (usec) when checking to see if XOSC_LF is stable. */
92 #define PowerCC26XX_RETRYWAITXOSC_LF    5000
93 
94 /* resource IDs */
95 #define PowerCC26XX_PERIPH_GPT0    0
96 /*!< Resource ID: General Purpose Timer 0 */
97 
98 #define PowerCC26XX_PERIPH_GPT1    1
99 /*!< Resource ID: General Purpose Timer 1 */
100 
101 #define PowerCC26XX_PERIPH_GPT2    2
102 /*!< Resource ID: General Purpose Timer 2 */
103 
104 #define PowerCC26XX_PERIPH_GPT3    3
105 /*!< Resource ID: General Purpose Timer 3 */
106 
107 #define PowerCC26XX_PERIPH_SSI0    4
108 /*!< Resource ID: Synchronous Serial Interface 0 */
109 
110 #define PowerCC26XX_PERIPH_SSI1    5
111 /*!< Resource ID: Synchronous Serial Interface 1 */
112 
113 #define PowerCC26XX_PERIPH_UART0   6  /*!< Resource ID: UART 0 */
114 
115 #define PowerCC26XX_PERIPH_I2C0    7  /*!< Resource ID: I2C 0 */
116 
117 #define PowerCC26XX_PERIPH_TRNG    8
118 /*!< Resource ID: True Random Number Generator */
119 
120 #define PowerCC26XX_PERIPH_GPIO    9  /*!< Resource ID: General Purpose I/Os */
121 
122 #define PowerCC26XX_PERIPH_UDMA    10 /*!< Resource ID: uDMA Controller */
123 
124 #define PowerCC26XX_PERIPH_CRYPTO  11 /*!< Resource ID: AES Security Module */
125 
126 #define PowerCC26XX_PERIPH_I2S     12 /*!< Resource ID: I2S */
127 
128 #define PowerCC26XX_PERIPH_RFCORE  13 /*!< Resource ID: RF Core Module */
129 
130 #define PowerCC26XX_XOSC_HF        14
131 /*!< Resource ID: High Frequency Crystal Oscillator */
132 
133 #define PowerCC26XX_DOMAIN_PERIPH  15
134 /*!< Resource ID: Peripheral Power Domain */
135 
136 #define PowerCC26XX_DOMAIN_SERIAL  16
137 /*!< Resource ID: Serial Power Domain */
138 
139 #define PowerCC26XX_DOMAIN_RFCORE  17
140 /*!< Resource ID: RF Core Power Domain */
141 
142 #define PowerCC26XX_DOMAIN_SYSBUS  18
143 /*!< Resource ID: System Bus Power Domain */
144 
145 /* \cond */
146 #define PowerCC26XX_NUMRESOURCES   19 /* Number of resources in database */
147 /* \endcond */
148 
149 /* \cond */
150 /* resource record bitmasks */
151 #define PowerCC26XX_PERIPH          0x80 /* resource is a peripheral */
152 #define PowerCC26XX_SPECIAL         0x40 /* resource requires special handler */
153 #define PowerCC26XX_DOMAIN          0x00 /* resource is a domain */
154 #define PowerCC26XX_PARENTMASK      0x3F /* parent resource mask */
155 #define PowerCC26XX_NOPARENT        0x3F /* if resource has no parent */
156 /* \endcond */
157 
158 #define PowerCC26XX_STANDBY         0x1 /*!< The STANDBY sleep state */
159 /* \cond */
160 /* internal flags for enabling/disabling resources */
161 #define PowerCC26XX_ENABLE          1
162 #define PowerCC26XX_DISABLE         0
163 /* \endcond */
164 
165 /* constraints */
166 #define PowerCC26XX_RETAIN_VIMS_CACHE_IN_STANDBY  0
167 /*!< Constraint: VIMS RAM must be retained while in STANDBY */
168 
169 #define PowerCC26XX_DISALLOW_SHUTDOWN  1
170 /*!< Constraint: Disallow a transition to the SHUTDOWN state */
171 
172 #define PowerCC26XX_DISALLOW_STANDBY  2
173 /*!< Constraint: Disallow a transition to the STANDBY sleep state */
174 
175 #define PowerCC26XX_DISALLOW_IDLE  3
176 /*!< Constraint: Disallow a transition to the IDLE sleep state */
177 
178 #define PowerCC26XX_NEED_FLASH_IN_IDLE  4
179 /*!< Constraint: Flash memory needs to enabled during IDLE */
180 
181 #define PowerCC26XX_SWITCH_XOSC_HF_MANUALLY 5
182 /*!< Constraint: Prevent power driver from starting an RTOS clock and
183  *   automatically switching to the XOSC_HF when it is ready. The power
184  *   driver will turn on the XOSC_HF and return control to the application.
185  *   The application must poll the status of the XOSC_HF and make sure that it
186  *   is stable before manually switching to it.
187  *   If the constraint is released before the application has switched to the
188  *   XOSC_HF, the application is still responsible for switching to the
189  *   XOSC_HF.
190  *   Failing to do so may cause an undefined internal state in the power
191  *   driver.
192  */
193 
194 #define PowerCC26XX_DISALLOW_XOSC_HF_SWITCHING 6
195 /*!< Constraint: Prevent power driver from switching to XOSC_HF when the crystal is
196  *   ready. The RTOS clock will be rescheduled to try again in the future.
197  *   This is a workaround to prevent the flash from being accessed by a bus master
198  *   other than the CPU while switching to XOSC_HF. This would cause a bus stall.
199  *   This functionality is only implemented on CC26X0, CC26X0R2, and CC13X0 as the
200  *   bug was fixed in hardware on later devices.
201  */
202 
203 /* \cond */
204 #define PowerCC26XX_NUMCONSTRAINTS  7 /* Number of constraints supported */
205 /* \endcond */
206 
207 /* \cond */
208 /* Deprecated constraint names */
209 #define PowerCC26XX_SD_DISALLOW  PowerCC26XX_DISALLOW_SHUTDOWN
210 #define PowerCC26XX_SB_DISALLOW  PowerCC26XX_DISALLOW_STANDBY
211 #define PowerCC26XX_IDLE_PD_DISALLOW  PowerCC26XX_DISALLOW_IDLE
212 #define PowerCC26XX_XOSC_HF_SWITCHING_DISALLOW PowerCC26XX_DISALLOW_XOSC_HF_SWITCHING
213 #define PowerCC26XX_SB_VIMS_CACHE_RETAIN PowerCC26XX_RETAIN_VIMS_CACHE_IN_STANDBY
214 /* \endcond */
215 
216 /*
217  *  Events
218  *
219  *  Each event must be a power of two and must be sequential
220  *  without any gaps.
221  */
222 #define PowerCC26XX_ENTERING_STANDBY    0x1
223 /*!< Power event: The device is entering the STANDBY sleep state */
224 
225 #define PowerCC26XX_ENTERING_SHUTDOWN   0x2
226 /*!< Power event: The device is entering the SHUTDOWN state */
227 
228 #define PowerCC26XX_AWAKE_STANDBY       0x4
229 /*!< Power event: The device is waking up from the STANDBY sleep state */
230 
231 #define PowerCC26XX_AWAKE_STANDBY_LATE  0x8
232 /*!< Power event: The device is waking up from STANDBY (this event is sent later during wakeup, after interrupts are re-enabled) */
233 
234 #define PowerCC26XX_XOSC_HF_SWITCHED    0x10
235 /*!< Power event: The high frequency (HF) clock source has been switched to XOSC_HF */
236 
237 #define PowerCC26XX_JTAG_PD_TURNED_ON   0x20
238 /*!< \warning Note that this power event is only supported by the CC2640R2 device!
239  *
240  * The JTAG subsystem on the CC26xx devices is automatically enabled after receiving
241  * 8 pulses on the TCK pin. This will cause the device to draw more power in all
242  * power modes (Active, Idle, Standby, Shutdown).
243  * The ::PowerCC26XX_JTAG_PD_TURNED_ON power event will
244  * let you know when this has happened outside of a debug session due to noise on the pin.
245  * This allows the application to do a reset of the device when it's convenient in order
246  * disable the JTAG subsystem and conserve power.
247  *
248  * In order to turn off the JTAG_PD the application should subscribe to this event.
249  * In the callback function the application can call Power_shutdown() and
250  * this will force a reset of the device.
251  * Alternatively the the callback function can post another event so that the application can
252  * reset the device when it's more convenient to do so.
253  *
254  * When Power_shutdown() is called when the JTAG subsystem is on,
255  * the device will reset and branch to the flash image again,
256  * only now with the JTAG_PD turned off, thus the excess power is gone.
257  * The wakeup source as read through the SysCtrlResetSourceGet() will in this case
258  * return RSTSRC_WAKEUP_FROM_SHUTDOWN.
259  *
260  * The power driver will, each time before entering standby, check to see if the
261  * JTAG_PD has been turned on after boot. If so, it will notify all subscribers to the
262  * ::PowerCC26XX_JTAG_PD_TURNED_ON event.
263  * If the JTAG_PD was turned on during boot, which is the case when
264  * using the debugger, the notification will NOT be sent even if the event is registered.
265  * This is because when actively developing code with an IDE and emulator, the user typically
266  * wants to be able to debug their code through standby without the device resetting.
267  *
268  * Summary of when the ::PowerCC26XX_JTAG_PD_TURNED_ON notification function will be called.
269  *
270  * | JTAG_PD state        | Notification function registered | Notification function called |
271  * |----------------------|----------------------------------|------------------------
272  * | Off                  | Don't care                       | No
273  * | Turned on during boot| Don't care                       | No
274  * | Turned on after boot | No                               | No
275  * | Turned on after boot | Yes                              | Yes
276  *
277  * \warning If the ::PowerCC26XX_JTAG_PD_TURNED_ON event is registered, and the notification
278  * callback function calls Power_shutdown() it will not be possible to attach
279  * an emulator to a running target. This is becasue the device will reset as soon as the
280  * emulator turns on the JTAG_PD as part of the connect sequence.
281  *
282  *  Code snippet on how to register the notification and the callback function:
283  *  @code
284  *  void jtagPdTurnedOnCallbackFxn()
285  *  {
286  *      // Optionally save any critical application information
287  *      // gracefullyShutdownApplication();
288  *      // Call shutdown, this will reset device, and the application will reboot with JTAG_PD off.
289  *      Power_shutdown(NULL, NULL);
290  *      // Power_shutdown(...) should never return, device will reset.
291  *  }
292  *
293  *  void taskFxn(UArg a0, UArg a1)
294  *  {
295  *      ...
296  *      // Register "JTAG power domain turned on" notification function
297  *      // Everytime the device is about to enter standby, the power driver will check
298  *      // to see if the JTAG_PD has been turned on after boot. If so, the notification
299  *      // function will be called before entering standby...
300  *      Power_registerNotify(&jtagPdTurnedOnNotifyObj, PowerCC26XX_JTAG_PD_TURNED_ON, (Fxn)jtagPdTurnedOnCallbackFxn, NULL);
301  *      ...
302  *  }
303  *  @endcode
304  */
305 
306 
307 /* \cond */
308 #define PowerCC26XX_NUMEVENTS           6  /* Number of events supported */
309 /* \endcond */
310 
311 /* \cond */
312 /*
313  *  Calibration stages
314  */
315 #define PowerCC26XX_SETUP_CALIBRATE     1
316 #define PowerCC26XX_INITIATE_CALIBRATE  2
317 #define PowerCC26XX_DO_CALIBRATE        3
318 /* \endcond */
319 
320 /* \cond */
321 /*! @brief Power resource database record format */
322 typedef struct {
323     uint8_t flags;          /* resource type | first parent */
324     uint16_t driverlibID;   /* corresponding driverlib ID for this resource */
325 } PowerCC26XX_ResourceRecord;
326 /* \endcond */
327 
328 /*! @brief Global configuration structure */
329 typedef struct {
330     /*!
331      *  @brief The Power Policy's initialization function
332      *
333      *  If the policy does not have an initialization function, 'NULL'
334      *  should be specified.
335      */
336     Power_PolicyInitFxn policyInitFxn;
337     /*!
338      *  @brief The Power Policy function
339      *
340      *  When enabled, this function is invoked in the idle loop, to
341      *  opportunistically select and activate sleep states.
342      *
343      *  Two reference policies are provided:
344      *
345      *    PowerCC26XX_doWFI() - a simple policy that invokes CPU wait for
346      *    interrupt (WFI)
347      *
348      *    PowerCC26XX_standbyPolicy() - an agressive policy that considers
349      *    constraints, time until next scheduled work, and sleep state
350      *    latencies, and optionally puts the device into the STANDBY state,
351      *    the IDLE state, or as a minimum, WFI.
352      *
353      *  Custom policies can be written, and specified via this function pointer.
354      *
355      *  In addition to this static selection, the Power Policy can be
356      *  dynamically changed at runtime, via the Power_setPolicy() API.
357      */
358     Power_PolicyFxn policyFxn;
359     /*!
360      *  @brief The function to be used for activating RC Oscillator (RCOSC)
361      *  calibration
362      *
363      *  Calibration is normally enabled, via specification of the function
364      *  PowerCC26XX_calibrate().  This enables high accuracy operation, and
365      *  faster high frequency crystal oscillator (XOSC_HF) startups.
366      *
367      *  To disable RCOSC calibration, the function PowerCC26XX_noCalibrate()
368      *  should be specified.
369      */
370     bool (*calibrateFxn)(unsigned int);
371     /*!
372      *  @brief Time in system ticks that specifies the maximum duration the device
373      *         may spend in standby.
374      *
375      *  When the power driver tries to put the device into standby and determines
376      *  the next wakeup should usually be further into the future than
377      *  maxStandbyDuration system ticks, the power driver will schedule a wakeup
378      *  maxStandbyDuration into the future. When the device wakes up after
379      *  being in standby for maxStandbyDuration ticks, the power driver will
380      *  repeat this process and go back into standby if the state of the system
381      *  allows it.
382      *
383      *  Inserting such periodic wakeups can be used to automatically calibrate
384      *  the RCOSC with a maximum period between calibrations or to force the
385      *  recalculation of the initial VDDR recharge period. This assumes that
386      *  the constraint to prohibit standby is not set and that periods of
387      *  inactivity are long enough for the power driver to put the device
388      *  into standby.
389      *
390      *  The value 0 is invalid. When PowerCC26XX_Config.enableMaxStandbyDuration is
391      *  set to false, any value (including 0) is ignored and the feature is
392      *  disabled.
393      *  This feature should not be used to disallow entering standby;
394      *  the PowerCC26XX_DISALLOW_STANDBY constraint should be used for
395      *  this purpose.
396      */
397     uint32_t maxStandbyDuration;
398      /*!
399      *  @brief Margin in SCLK_LF periods subtracted from previous longest
400      *  VDDR recharge period.
401      *
402      *  As the device comes out of standby, it updated its previous initial
403      *  VDDR recharge period to be closer to the longest recharge period
404      *  experienced during the time spent in standby before waking up.
405      *
406      *  vddrRechargeMargin is subtracted from the longest VDDR recharge
407      *  period in SysCtrlAdjustRechargeAfterPowerDown to ensure there is
408      *  some margin between the new initial and converged VDDR recharge
409      *  period. The converged recharge period at a certain temperature
410      *  is board and device dependent.
411      *
412      *  The default value of 0 disables this feature.
413      */
414     uint16_t vddrRechargeMargin;
415     /*!
416      *  @brief Boolean that enables limiting the duration spent in standby
417      *
418      *  If false, the power driver will put the device into standby as
419      *  appropriate without duration restrictions.
420      *
421      *  If true, the the power driver will force a wakeup every
422      *  PowerCC26XX_Config.maxStandbyDuration system ticks before reevaluating
423      *  the state of the system.
424      *
425      *  This is set to false by default.
426      */
427     bool enableMaxStandbyDuration;
428     /*!
429      *  @brief Boolean specifying if the Power Policy function is enabled
430      *
431      *  If 'true', the policy function will be invoked once for each pass
432      *  of the idle loop.
433      *
434      *  If 'false', the policy will not be invoked.
435      *
436      *  In addition to this static setting, the power policy can be dynamically
437      *  enabled and disabled at runtime, via the Power_enablePolicy() and
438      *  Power_disablePolicy() functions, respectively.
439      */
440     bool enablePolicy;
441     /*!
442      *  @brief Boolean specifying whether the low frequency RC oscillator
443      * (RCOSC_LF) should be calibrated.
444      *
445      *  If RCOSC calibration is enabled (above, via specification of
446      *  an appropriate calibrateFxn), this Boolean specifies whether
447      *  RCOSC_LF should be calibrated.
448      */
449     bool calibrateRCOSC_LF;
450     /*!
451      *  @brief Boolean specifying whether the high frequency RC oscillator
452      * (RCOSC_HF) should be calibrated.
453      *
454      *  If RCOSC calibration is enabled (above, via specification of
455      *  an appropriate calibrateFxn), this Boolean specifies whether
456      *  RCOSC_HF should be calibrated.
457      */
458     bool calibrateRCOSC_HF;
459 } PowerCC26XX_Config;
460 
461 /*!
462  *  @brief  PowerCC26XX_ModuleState
463  *
464  *  Power manager state structure. The application must not access any members
465  *  of this structure!
466  */
467 typedef struct {
468     List_List notifyList;        /*!< Event notification list */
469     uint32_t constraintMask;     /*!< Aggregate constraints mask */
470     ClockP_Struct clockObj;       /*!< Clock object for scheduling wakeups */
471     ClockP_Struct xoscClockObj;   /*!< Clock object for XOSC_HF switching */
472     ClockP_Struct lfClockObj;     /*!< Clock object for LF clock checking */
473     ClockP_Struct calClockStruct; /*!< Clock object for RCOSC calibration */
474     HwiP_Struct hwiStruct;        /*!< Hwi object for RCOSC calibration */
475     int32_t nDeltaFreqCurr;      /*!< RCOSC calibration variable */
476     int32_t nCtrimCurr;          /*!< RCOSC calibration variable */
477     int32_t nCtrimFractCurr;     /*!< RCOSC calibration variable */
478     int32_t nCtrimNew;           /*!< RCOSC calibration variable */
479     int32_t nCtrimFractNew;      /*!< RCOSC calibration variable */
480     int32_t nRtrimNew;           /*!< RCOSC calibration variable */
481     int32_t nRtrimCurr;          /*!< RCOSC calibration variable */
482     int32_t nDeltaFreqNew;       /*!< RCOSC calibration variable */
483     bool bRefine;                /*!< RCOSC calibration variable */
484     uint32_t state;              /*!< Current transition state */
485     bool xoscPending;            /*!< Is XOSC_HF activation in progress? */
486     bool calLF;                  /*!< Calibrate RCOSC_LF? */
487     uint8_t hwiState;            /*!< The AUX ISR calibration state */
488     bool busyCal;                /*!< Already busy calibrating? */
489     uint8_t calStep;             /*!< The current calibration step */
490     bool firstLF;                /*!< Is this the first LF calibration? */
491     bool enablePolicy;           /*!< Is the Power policy enabled? */
492     bool initialized;            /*!< Has Power_init() been called? */
493 #if defined(DeviceFamily_CC26X0R2)
494     bool emulatorAttached;      /*!< Was an emulator detected during boot? */
495 #endif
496     uint8_t constraintCounts[PowerCC26XX_NUMCONSTRAINTS];
497     /*!< Array to maintain constraint reference counts */
498     uint8_t resourceCounts[PowerCC26XX_NUMRESOURCES];
499     /*!< Array to maintain resource dependency reference counts */
500     unsigned int (*resourceHandlers[3])(unsigned int);
501     /*!< Array of special dependency handler functions */
502     Power_PolicyFxn policyFxn;   /*!< The Power policy function */
503 } PowerCC26XX_ModuleState;
504 
505 /*!
506  *  @brief  The RC Oscillator (RCOSC) calibration function
507  *
508  *  The function to be used for performing RCOSC calibation.  This is the
509  *  default calibration function, and is specified via the calibrateFxn
510  *  pointer in the PowerCC26XX_Config structure.
511  *
512  *  @param  arg      used internally
513  *
514  *  @return used internally
515  */
516 bool PowerCC26XX_calibrate(unsigned int arg);
517 
518 /*!
519  *  @brief  The Wait for interrupt (WFI) policy
520  *
521  *  This is a lightweight Power Policy which simply invokes CPU wait for
522  *  interrupt.
523  *
524  *  This policy can be selected statically via the policyFxn pointer in the
525  *  PowerCC26XX_Config structure, or dynamically at runtime, via
526  *  Power_setPolicy().
527  */
528 void PowerCC26XX_doWFI(void);
529 
530 /*!
531  *  @brief  Get the handle of the Clock object used for scheduling device
532  *  wakeups
533  *
534  *  During initialization, the Power Manager creates a Clock object that a
535  *  Power Policy can use to schedule device wakeups.  This function can
536  *  be called by a policy function to get the handle of this pre-allocated
537  *  Clock object.
538  *
539  *  @return     The handle of the Clock object
540  */
541 ClockP_Handle PowerCC26XX_getClockHandle(void);
542 
543 /*!
544  *  @brief  Get the estimated HF crystal oscillator (XOSC_HF) startup delay,
545  *  for a given delay from now, until startup is initiated
546  *
547  *  @param timeUntilWakeupInMs  The estimated time until the next wakeup
548  *                              event, in units of milliseconds
549  *
550  *  @return     The estimated HF crystal oscillator startup latency, in
551  *              units of microseconds.
552  */
553 uint32_t PowerCC26XX_getXoscStartupTime(uint32_t timeUntilWakeupInMs);
554 
555 /*!
556  *  @brief  Explicitly trigger RC oscillator calibration
557  *
558  *  When enabled, RCOSC calibration is normally triggered upon each device
559  *  wakeup from STANDBY.  To trigger more frequent calibration, an application
560  *  can explicitly call this function, to initiate an immediate calibration
561  *  cycle.
562  *
563  *  @return  true if calibration was actually initiated otherwise false
564  */
565 bool PowerCC26XX_injectCalibration(void);
566 
567 /*!
568  *  @brief  Function to specify when RCOSC calibration is to be disabled
569  *
570  *  This function should be specified as the 'calibrateFxn' in the
571  *  PowerCC26XX_Config structure when RCOSC calibration is to be disabled.
572  *
573  *  Note that the reason a function pointer is used here (versus a simple
574  *  Boolean) is so that references to internal calibration subroutines can be
575  *  removed, to eliminate pulling the calibration code into the application
576  *  image; this enables a significant reduction in memory footprint when
577  *  calibration is disabled.
578  *
579  *  @param  arg      used internally
580  *
581  *  @return used internally
582  */
583 bool PowerCC26XX_noCalibrate(unsigned int arg);
584 
585 /*!
586  *  @brief  Check if the XOSC_HF is stable and ready to be switched to
587  *
588  *  @pre    Set PowerCC26XX_SWITCH_XOSC_HF_MANUALLY in the early standby
589  *          wakeup notification.
590  *
591  *  This function should be called when using the
592  *  PowerCC26XX_SWITCH_XOSC_HF_MANUALLY power constraint to ensure that
593  *  the XOSC_HF is stable before switching to it.
594  *
595  *  \sa PowerCC26XX_switchXOSC_HF()
596  */
597 bool PowerCC26XX_isStableXOSC_HF(void);
598 
599 /*!
600  *  @brief  Switch the HF clock source to XOSC_HF
601  *
602  *  @pre    PowerCC26XX_switchXOSC_HF() returns true.
603  *
604  *  This function should only be called when using the
605  *  PowerCC26XX_SWITCH_XOSC_HF_MANUALLY power constraint after ensuring
606  *  the XOSC_HF is stable.
607  *  If the driver cannot switch to the XOSC_HF despite the crystal being
608  *  stable, a clock will be scheduled in the future and the callback will
609  *  try to switch again.
610  *
611  *  \sa PowerCC26XX_isStableXOSC_HF()
612  */
613 void PowerCC26XX_switchXOSC_HF(void);
614 
615 /*!
616  *  @brief  The STANDBY Power Policy
617  *
618  *  This is an agressive Power Policy, which considers active constraints,
619  *  sleep state transition latencies, and time until the next scheduled
620  *  work, and automatically transitions the device into the deepest sleep state
621  *  possible.
622  *
623  *  The first goal is to enter STANDBY; if that is not appropriate
624  *  given current conditions (e.g., the sleep transition latency is greater
625  *  greater than the time until the next scheduled Clock event), then
626  *  the secondary goal is the IDLE state; if that is disallowed (e.g., if
627  *  the PowerCC26XX_DISALLOW_IDLE constraint is declared), then the policy
628  *  will fallback and simply invoke WFI, to clock gate the CPU until the next
629  *  interrupt.
630  *
631  *  In order for this policy to run, it must be selected as the Power
632  *  Policy (either by being specified as the 'policyFxn' in the
633  *  PowerCC26XX_Config structure, or specified at runtime with
634  *  Power_setPolicy()), and the Power Policy must be enabled (either via
635  *  'enablePolicy' in the PowerCC26XX_Config structure, or via a call to
636  *  Power_enablePolicy() at runtime).
637  */
638 void PowerCC26XX_standbyPolicy(void);
639 
640 void PowerCC26XX_schedulerDisable(void);
641 void PowerCC26XX_schedulerRestore(void);
642 
643 #define Power_getPerformanceLevel(void)   0
644 #define Power_setPerformanceLevel(level)  Power_EFAIL
645 
646 #ifdef __cplusplus
647 }
648 #endif
649 
650 #endif /* POWER_CC26XX_ */
651