Power manager interface for CC26XX/CC13XX.
============================================================================
The Power header file should be included in an application as follows:
Refer to Power.h for a complete description of APIs.
This header file defines the power resources, constraints, events, sleep states and transition latencies for CC26XX/CC13XX.
#include <ti/drivers/dpl/HwiP.h>
#include <ti/drivers/dpl/ClockP.h>
#include <ti/drivers/Power.h>
#include <ti/devices/DeviceFamily.h>
Go to the source code of this file.
Data Structures | |
struct | PowerCC26XX_Config |
Global configuration structure. More... | |
struct | PowerCC26XX_ModuleState |
PowerCC26XX_ModuleState. More... | |
Functions | |
bool | PowerCC26XX_calibrate (unsigned int arg) |
The RC Oscillator (RCOSC) calibration function. More... | |
void | PowerCC26XX_doWFI (void) |
The Wait for interrupt (WFI) policy. More... | |
ClockP_Handle | PowerCC26XX_getClockHandle (void) |
Get the handle of the Clock object used for scheduling device wakeups. More... | |
uint32_t | PowerCC26XX_getXoscStartupTime (uint32_t timeUntilWakeupInMs) |
Get the estimated HF crystal oscillator (XOSC_HF) startup delay, for a given delay from now, until startup is initiated. More... | |
bool | PowerCC26XX_injectCalibration (void) |
Explicitly trigger RC oscillator calibration. More... | |
bool | PowerCC26XX_noCalibrate (unsigned int arg) |
Function to specify when RCOSC calibration is to be disabled. More... | |
bool | PowerCC26XX_isStableXOSC_HF (void) |
Check if the XOSC_HF is stable and ready to be switched to. More... | |
void | PowerCC26XX_switchXOSC_HF (void) |
Switch the HF clock source to XOSC_HF. More... | |
void | PowerCC26XX_standbyPolicy (void) |
The STANDBY Power Policy. More... | |
void | PowerCC26XX_schedulerDisable (void) |
void | PowerCC26XX_schedulerRestore (void) |
#define PowerCC26XX_RESUMETIMESTANDBY 750 |
The latency to reserve for resume from STANDBY (usec).
#define PowerCC26XX_TOTALTIMESTANDBY 1000 |
The total latency to reserve for entry to and exit from STANDBY (usec).
#define PowerCC26XX_WAKEDELAYSTANDBY 240 |
The initial delay when waking from STANDBY (usec).
#define PowerCC26XX_INITIALWAITRCOSC_LF 1000 |
The initial wait time (usec) before checking if RCOSC_LF is stable.
#define PowerCC26XX_RETRYWAITRCOSC_LF 1000 |
The retry wait time (usec) when checking to see if RCOSC_LF is stable.
#define PowerCC26XX_INITIALWAITXOSC_HF 50 |
The initial wait time (usec) before checking if XOSC_HF is stable.
#define PowerCC26XX_RETRYWAITXOSC_HF 50 |
The retry wait time (usec) when checking to see if XOSC_HF is stable.
#define PowerCC26XX_INITIALWAITXOSC_LF 10000 |
The initial wait time (usec) before checking if XOSC_LF is stable.
#define PowerCC26XX_RETRYWAITXOSC_LF 5000 |
The retry wait time (usec) when checking to see if XOSC_LF is stable.
#define PowerCC26XX_PERIPH_GPT0 0 |
Resource ID: General Purpose Timer 0
#define PowerCC26XX_PERIPH_GPT1 1 |
Resource ID: General Purpose Timer 1
#define PowerCC26XX_PERIPH_GPT2 2 |
Resource ID: General Purpose Timer 2
#define PowerCC26XX_PERIPH_GPT3 3 |
Resource ID: General Purpose Timer 3
#define PowerCC26XX_PERIPH_SSI0 4 |
Resource ID: Synchronous Serial Interface 0
#define PowerCC26XX_PERIPH_SPI0 PowerCC26XX_PERIPH_SSI0 |
Resource ID: SPI0
#define PowerCC26XX_PERIPH_UART0 5 |
Resource ID: UART 0
#define PowerCC26XX_PERIPH_I2C0 6 |
Resource ID: I2C 0
#define PowerCC26XX_PERIPH_TRNG 7 |
Resource ID: True Random Number Generator
#define PowerCC26XX_PERIPH_GPIO 8 |
Resource ID: General Purpose I/Os
#define PowerCC26XX_PERIPH_UDMA 9 |
Resource ID: uDMA Controller
#define PowerCC26XX_PERIPH_CRYPTO 10 |
Resource ID: AES Security Module
#define PowerCC26XX_PERIPH_I2S 11 |
Resource ID: I2S
#define PowerCC26XX_PERIPH_RFCORE 12 |
Resource ID: RF Core Module
#define PowerCC26XX_XOSC_HF 13 |
Resource ID: High Frequency Crystal Oscillator
#define PowerCC26XX_DOMAIN_PERIPH 14 |
Resource ID: Peripheral Power Domain
#define PowerCC26XX_DOMAIN_SERIAL 15 |
Resource ID: Serial Power Domain
#define PowerCC26XX_DOMAIN_RFCORE 16 |
Resource ID: RF Core Power Domain
#define PowerCC26XX_DOMAIN_SYSBUS 17 |
Resource ID: System Bus Power Domain
#define PowerCC26XX_PERIPH_PKA 18 |
Resource ID: PKA Module
#define PowerCC26XX_PERIPH_UART1 19 |
Resource ID: UART1
#define PowerCC26XX_PERIPH_SSI1 20 |
Resource ID: Synchronous Serial Interface 1
#define PowerCC26XX_PERIPH_SPI1 PowerCC26XX_PERIPH_SSI1 |
Resource ID: SPI1
#define PowerCC26XX_PERIPH_UART2 21 |
Resource ID: UART2
#define PowerCC26XX_PERIPH_UART3 22 |
Resource ID: UART3
#define PowerCC26XX_PERIPH_SPI2 23 |
Resource ID: SPI2
#define PowerCC26XX_PERIPH_SSI2 PowerCC26XX_PERIPH_SPI2 |
Included for compatibilty. Please use PowerCC26XX_PERIPH_SPI2
#define PowerCC26XX_PERIPH_SPI3 24 |
Resource ID: SPI3
#define PowerCC26XX_PERIPH_SSI3 PowerCC26XX_PERIPH_SPI3 |
Included for compatibility. Please use PowerCC26XX_PERIPH_SPI3
#define PowerCC26XX_PERIPH_I2C1 25 |
Resource ID: I2C1
#define PowerCC26XX_STANDBY 0x1 |
The STANDBY sleep state
#define PowerCC26XX_RETAIN_VIMS_CACHE_IN_STANDBY 0 |
Constraint: VIMS RAM must be retained while in STANDBY
#define PowerCC26XX_DISALLOW_SHUTDOWN 1 |
Constraint: Disallow a transition to the SHUTDOWN state
#define PowerCC26XX_DISALLOW_STANDBY 2 |
Constraint: Disallow a transition to the STANDBY sleep state
#define PowerCC26XX_DISALLOW_IDLE 3 |
Constraint: Disallow a transition to the IDLE sleep state
#define PowerCC26XX_NEED_FLASH_IN_IDLE 4 |
Constraint: Flash memory needs to enabled during IDLE
#define PowerCC26XX_SWITCH_XOSC_HF_MANUALLY 5 |
Constraint: Prevent power driver from starting an RTOS clock and automatically switching to the XOSC_HF when it is ready. The power driver will turn on the XOSC_HF and return control to the application. The application must poll the status of the XOSC_HF and make sure that it is stable before manually switching to it. If the constraint is released before the application has switched to the XOSC_HF, the application is still responsible for switching to the XOSC_HF. Failing to do so may cause an undefined internal state in the power driver.
#define PowerCC26XX_DISALLOW_XOSC_HF_SWITCHING 6 |
Constraint: Prevent power driver from switching to XOSC_HF when the crystal is ready. The RTOS clock will be rescheduled to try again in the future. This is a workaround to prevent the flash from being accessed by a bus controller other than the CPU while switching to XOSC_HF. This would cause a bus stall. This functionality is only implemented on CC26X0, CC26X0R2, and CC13X0 as the bug was fixed in hardware on later devices.
#define PowerCC26XX_ENTERING_STANDBY 0x1 |
Power event: The device is entering the STANDBY sleep state
#define PowerCC26XX_ENTERING_SHUTDOWN 0x2 |
Power event: The device is entering the SHUTDOWN state
#define PowerCC26XX_AWAKE_STANDBY 0x4 |
Power event: The device is waking up from the STANDBY sleep state
#define PowerCC26XX_AWAKE_STANDBY_LATE 0x8 |
Power event: The device is waking up from STANDBY (this event is sent later during wakeup, after interrupts are re-enabled)
#define PowerCC26XX_XOSC_HF_SWITCHED 0x10 |
Power event: The high frequency (HF) clock source has been switched to XOSC_HF
#define PowerCC26XX_SCLK_LF_SWITCHED 0x20 |
Power event: The low frequency (LF) clock source has been switched from RCOSC_HF derived to the source configured in CCFG.
Only the XOSC_LF requires a significant amount of time to turn on and switch. The other LF clock sources will often have switched and trigger a notification before the OS schedules the first task after enabling interrupts. It may be necessary to register the notification in main, before interrupts are enabled to guarantee the event will not be missed by the application.
#define PowerCC26XX_JTAG_PD_TURNED_ON 0x40 |
The JTAG subsystem on the CC26xx devices is automatically enabled after receiving 8 pulses on the TCK pin. This will cause the device to draw more power in all power modes (Active, Idle, Standby, Shutdown). The PowerCC26XX_JTAG_PD_TURNED_ON power event will let you know when this has happened outside of a debug session due to noise on the pin. This allows the application to do a reset of the device when it's convenient in order disable the JTAG subsystem and conserve power.
In order to turn off the JTAG_PD the application should subscribe to this event. In the callback function the application can call Power_shutdown() and this will force a reset of the device. Alternatively the the callback function can post another event so that the application can reset the device when it's more convenient to do so.
When Power_shutdown() is called when the JTAG subsystem is on, the device will reset and branch to the flash image again, only now with the JTAG_PD turned off, thus the excess power is gone. The wakeup source as read through the SysCtrlResetSourceGet() will in this case return RSTSRC_WAKEUP_FROM_SHUTDOWN.
The power driver will, each time before entering standby, check to see if the JTAG_PD has been turned on after boot. If so, it will notify all subscribers to the PowerCC26XX_JTAG_PD_TURNED_ON event. If the JTAG_PD was turned on during boot, which is the case when using the debugger, the notification will NOT be sent even if the event is registered. This is because when actively developing code with an IDE and emulator, the user typically wants to be able to debug their code through standby without the device resetting.
Summary of when the PowerCC26XX_JTAG_PD_TURNED_ON notification function will be called.
JTAG_PD state | Notification function registered | Notification function called |
---|---|---|
Off | Don't care | No |
Turned on during boot | Don't care | No |
Turned on after boot | No | No |
Turned on after boot | Yes | Yes |
Code snippet on how to register the notification and the callback function:
#define Power_getPerformanceLevel | ( | void | ) | 0 |
#define Power_setPerformanceLevel | ( | level | ) | Power_EFAIL |
bool PowerCC26XX_calibrate | ( | unsigned int | arg | ) |
The RC Oscillator (RCOSC) calibration function.
The function to be used for performing RCOSC calibation. This is the default calibration function, and is specified via the calibrateFxn pointer in the PowerCC26XX_Config structure.
arg | used internally |
void PowerCC26XX_doWFI | ( | void | ) |
The Wait for interrupt (WFI) policy.
This is a lightweight Power Policy which simply invokes CPU wait for interrupt.
This policy can be selected statically via the policyFxn pointer in the PowerCC26XX_Config structure, or dynamically at runtime, via Power_setPolicy().
ClockP_Handle PowerCC26XX_getClockHandle | ( | void | ) |
Get the handle of the Clock object used for scheduling device wakeups.
During initialization, the Power Manager creates a Clock object that a Power Policy can use to schedule device wakeups. This function can be called by a policy function to get the handle of this pre-allocated Clock object.
uint32_t PowerCC26XX_getXoscStartupTime | ( | uint32_t | timeUntilWakeupInMs | ) |
Get the estimated HF crystal oscillator (XOSC_HF) startup delay, for a given delay from now, until startup is initiated.
timeUntilWakeupInMs | The estimated time until the next wakeup event, in units of milliseconds |
bool PowerCC26XX_injectCalibration | ( | void | ) |
Explicitly trigger RC oscillator calibration.
When enabled, RCOSC calibration is normally triggered upon each device wakeup from STANDBY. To trigger more frequent calibration, an application can explicitly call this function, to initiate an immediate calibration cycle.
bool PowerCC26XX_noCalibrate | ( | unsigned int | arg | ) |
Function to specify when RCOSC calibration is to be disabled.
This function should be specified as the 'calibrateFxn' in the PowerCC26XX_Config structure when RCOSC calibration is to be disabled.
Note that the reason a function pointer is used here (versus a simple Boolean) is so that references to internal calibration subroutines can be removed, to eliminate pulling the calibration code into the application image; this enables a significant reduction in memory footprint when calibration is disabled.
arg | used internally |
bool PowerCC26XX_isStableXOSC_HF | ( | void | ) |
Check if the XOSC_HF is stable and ready to be switched to.
This function should be called when using the PowerCC26XX_SWITCH_XOSC_HF_MANUALLY power constraint to ensure that the XOSC_HF is stable before switching to it.
void PowerCC26XX_switchXOSC_HF | ( | void | ) |
Switch the HF clock source to XOSC_HF.
This function should only be called when using the PowerCC26XX_SWITCH_XOSC_HF_MANUALLY power constraint after ensuring the XOSC_HF is stable. If the driver cannot switch to the XOSC_HF despite the crystal being stable, a clock will be scheduled in the future and the callback will try to switch again.
void PowerCC26XX_standbyPolicy | ( | void | ) |
The STANDBY Power Policy.
This is an agressive Power Policy, which considers active constraints, sleep state transition latencies, and time until the next scheduled work, and automatically transitions the device into the deepest sleep state possible.
The first goal is to enter STANDBY; if that is not appropriate given current conditions (e.g., the sleep transition latency is greater greater than the time until the next scheduled Clock event), then the secondary goal is the IDLE state; if that is disallowed (e.g., if the PowerCC26XX_DISALLOW_IDLE constraint is declared), then the policy will fallback and simply invoke WFI, to clock gate the CPU until the next interrupt.
In order for this policy to run, it must be selected as the Power Policy (either by being specified as the 'policyFxn' in the PowerCC26XX_Config structure, or specified at runtime with Power_setPolicy()), and the Power Policy must be enabled (either via 'enablePolicy' in the PowerCC26XX_Config structure, or via a call to Power_enablePolicy() at runtime).
void PowerCC26XX_schedulerDisable | ( | void | ) |
void PowerCC26XX_schedulerRestore | ( | void | ) |