xWRL6432 MMWAVE-L-SDK  05.04.00.01
Power_Latency_Type

Introduction


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.
// Import Power Driver definitions
#include <ti/drivers/Power.h>
// One-time initialization of Power manager
// Set power dependency on a resource
status = Power_setDependency(resourceId);
if (status != Power_SOK) {
// Error occurred
}
// Set a power constraint
status = Power_setConstraint(constraintId);
if (status != Power_SOK) {
// Error occurred
}
// Other application code
// Release a previously set power constraint
status = Power_releaseConstraint(constraintId);
if (status != Power_SOK) {
// Error occurred
}
status = Power_releaseDependency(resourceId);
if (status != Power_SOK) {
// Error occurred
}

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

// Import Power Driver definitions
#include <ti/drivers/Power.h>
// One-time initialization of Power manager
// Enable power policy

Disabling Power Policy

// Import Power Driver definitions
#include <ti/drivers/Power.h>
bool flag;
// One-time initialization of Power manager
// Disable power policy
if (flag == false) {
// Power policy was already disabled
}

Using Power Constraints

// Import Power Driver definitions
#include <ti/drivers/Power.h>
uint32_t mask;
int16_t status;
// One-time initialization of Power manager
// Set a power constraint
status = Power_setConstraint(constraintId);
if (status != Power_SOK) {
// Error occurred setting constraint
}
// Read mask of currently set power constraints
// Release previously set constraint
status = Power_releaseConstraint(constraintId);
if (status != Power_SOK) {
// Error occurred releasing constraint
}

Using Power Dependency

// Import Power Driver definitions
#include <ti/drivers/Power.h>
int16_t count;
int16_t status;
// One-time initialization of Power manager
// Set a power dependency
status = Power_setDependency(resourceId);
if (status != Power_SOK) {
// Error occurred setting dependency
}
// Get the dependency count of the resource
count = Power_getDependencyCount(resourceId);
if (count == Power_EINVALIDINPUT) {
// Invalid resourceId used
}
if (count > 0) {
// At least 1 dependency exists for the resource.
// Regardless, we may safely release the dependency when we
// no longer need the resource.
}
// Release a power dependency
status = Power_releaseDependency(resourceId);
if (status != Power_SOK) {
// Error occurred releasing dependency
}

Using Power Notify

The application must define a Power_NotifyFxn function and allocate memory for the Power_NotifyObj object.

// Import Power Driver definitions
#include <ti/drivers/Power.h>
// Application Power_NotifyObj object
Power_NotifyObj powerNotifyObj;
// Application Power_NotifyFxn function prototype
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.

// Application thread
void thread(void)
{
int16_t status;
unsigned int eventTypes = LOW_POWER_EXIT | LOW_POWER_ENTER;
uintptr_t clientArg = semaphoreHandle;
status = Power_registerNotify(&powerNotifyObj, eventTypes,
postNotifyFxn, clientArg);
while (1)
{
sem_wait(semaphoreHandle);
// Do something
// Unregister for the notification. After this call,
// our postNotifyFxn() will never be called again unless
// we use Power_registerNotify() again.
Power_unregisterNotify(&powerNotifyObj);
break;
}
}

The application may implement the power notify function to fit their needs. The Power_NotifyFxn should always return Power_NOTIFYDONE or Power_NOTIFYERROR.

// Application Power_NotifyFxn function implementation
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);
return (Power_NOTIFYDONE);
}
if (eventType == LOW_POWER_ENTER) {
// Store something in RAM
return (Power_NOTIFYDONE);
}
// We received an unexpected event type
}

Power transitions

// Import Power Driver definitions
#include <ti/drivers/Power.h>
uint32_t totalLatency, resumeLatency;
int16_t status;
// One-time initialization of Power manager
// Get the current power transition state
switch (status)
{
// No transitions in progress
break;
// Transition to sleep in progress
break;
// Transition from sleep in progress
break;
// Performance level change in progress
break;
}
// Get the Power_TOTAL and Power_RESUME transition latency for a
// device specific sleepState. Latency is in microseconds.
totalLatency = Power_getTransitionLatency(sleepState, Power_TOTAL);
resumeLatency = Power_getTransitionLatency(sleepState, Power_RESUME);

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.

Enumerations

enum  Power_LatencyType { Power_TOTAL_LATENCY, Power_RESUME_LATENCY }
 

Enumeration Type Documentation

◆ Power_LatencyType

Enumerator
Power_TOTAL_LATENCY 
Power_RESUME_LATENCY 
Power_NotifyObj
Power notify object structure.
Definition: power.h:459
Power_unregisterNotify
void Power_unregisterNotify(Power_NotifyObj *pNotifyObj)
Unregister previously registered notifications.
Power_getTransitionState
uint_fast16_t Power_getTransitionState(void)
Get the current transition state of the Power Manager.
Power_setDependency
int_fast16_t Power_setDependency(uint_fast16_t resourceId)
Declare a dependency upon a resource.
Power_releaseDependency
int_fast16_t Power_releaseDependency(uint_fast16_t resourceId)
Release a previously declared dependency.
Power_NOTIFYERROR
#define Power_NOTIFYERROR
Definition: power.h:388
Power_getConstraintMask
uint_fast32_t Power_getConstraintMask(void)
Get the constraints that have been declared with Power.
Power_releaseConstraint
int_fast16_t Power_releaseConstraint(uint_fast16_t constraintId)
Release a previously declared constraint.
Power_enablePolicy
void Power_enablePolicy(void)
Enable the configured power policy to run when the CPU is idle.
Power_EXITING_SLEEP
#define Power_EXITING_SLEEP
Definition: power.h:409
Power_EINVALIDINPUT
#define Power_EINVALIDINPUT
Definition: power.h:396
Power_ACTIVE
#define Power_ACTIVE
Definition: power.h:405
Power_NOTIFYDONE
#define Power_NOTIFYDONE
Definition: power.h:387
Power_init
int_fast16_t Power_init(void)
Power initialization function.
Power_ENTERING_SLEEP
#define Power_ENTERING_SLEEP
Definition: power.h:408
Power_getDependencyCount
int_fast16_t Power_getDependencyCount(uint_fast16_t resourceId)
Get the current dependency count for a resource.
Power_getTransitionLatency
uint32_t Power_getTransitionLatency(Power_SleepState sleepState, Power_LatencyType type)
Get the hardware transition latency for a sleep state.
Power_setConstraint
int_fast16_t Power_setConstraint(uint_fast16_t constraintId)
Declare an operational constraint.
Power_registerNotify
int_fast16_t Power_registerNotify(Power_NotifyObj *pNotifyObj, uint_fast16_t eventTypes, Power_NotifyFxn notifyFxn, uintptr_t clientArg)
Register a function to be called upon a specific power event.
Power_CHANGING_PERF_LEVEL
#define Power_CHANGING_PERF_LEVEL
Definition: power.h:412
Power_SOK
#define Power_SOK
Definition: power.h:394
Power_disablePolicy
bool Power_disablePolicy(void)
Disable the configured power policy from running when the CPU is idle.