power.h brief Power Manager
anchor ti_drivers_Power_Overview
Overview
The Power Manager facilitates the transition of the MCU from active states to sleep states and vice versa. It provides other drivers the ability to set and release dependencies on hardware resources, and keeps reference counts on each resource to know when to enable or disable the resource. It provides drivers the ability to register callback functions to be invoked upon specific power events. In addition, drivers and applications can set or release constraints to prevent the MCU from transitioning into specific active or sleep states. Refer to the device specific power driver header file device specific information.
Usage
This documentation provides a basic usage summary and a set of examples in the form of commented code fragments. Detailed descriptions of the APIs are provided in subsequent sections.
Synopsis
- Note
- The following example demonstrates usage of some of the Power driver APIs.This example is intended for reference only and is not intended for application use. You should refer to the device specific Power driver header for valid API usage and arguments.
#include <ti/drivers/Power.h>
}
}
}
}
Examples
- Note
- The following examples are intended for reference only and are not intended for application use. You should refer to the device specific Power driver header file for more usage information.
Enabling Power Policy
#include <ti/drivers/Power.h>
Disabling Power Policy
#include <ti/drivers/Power.h>
bool flag;
if (flag == false) {
}
Using Power Constraints
#include <ti/drivers/Power.h>
uint32_t mask;
int16_t status;
}
}
Using Power Dependency
#include <ti/drivers/Power.h>
int16_t count;
int16_t status;
}
}
if (count > 0) {
}
}
Using Power Notify
The application must define a Power_NotifyFxn function and allocate memory for the Power_NotifyObj object.
#include <ti/drivers/Power.h>
static int postNotifyFxn(unsigned int eventType, uintptr_t eventArg,
uintptr_t clientArg);
The application must register for the event. Here, we use pseudo event names. You should refer to the device specific power driver header file for eventTypes. Inside the infinite loop, we wait for a semaphore to be post from our notification callback.
void thread(void)
{
int16_t status;
unsigned int eventTypes = LOW_POWER_EXIT | LOW_POWER_ENTER;
uintptr_t clientArg = semaphoreHandle;
postNotifyFxn, clientArg);
while (1)
{
sem_wait(semaphoreHandle);
break;
}
}
The application may implement the power notify function to fit their needs. The Power_NotifyFxn should always return Power_NOTIFYDONE or Power_NOTIFYERROR.
static int postNotifyFxn(unsigned int eventType, uintptr_t eventArg,
uintptr_t clientArg)
{
sem_t semaphoreHandle = (sem_t) clientArg;
if (eventType == LOW_POWER_EXIT) {
sem_post(semaphoreHandle);
}
if (eventType == LOW_POWER_ENTER) {
}
}
Power transitions
#include <ti/drivers/Power.h>
uint32_t totalLatency, resumeLatency;
int16_t status;
switch (status)
{
break;
break;
break;
break;
}
Configuration
- Note
- The Power Manager APIs and configuration parameters are described here. For a detailed description of terms and concepts, and usage by different types of software components (peripheral drivers, power policies, and applications) please see the SimpleLink SDK Power Management User's Guide.
◆ Power_LatencyType
Enumerator |
---|
Power_TOTAL_LATENCY | |
Power_RESUME_LATENCY | |