xWRL6432 MMWAVE-L-SDK  05.04.00.01
power.h File Reference

Go to the source code of this file.

Data Structures

struct  Power_NotifyObj
 Power notify object structure. More...
 

Macros

#define Power_NOTIFYDONE   (0)
 
#define Power_NOTIFYERROR   (-1)
 
#define Power_SOK   (0)
 
#define Power_EFAIL   (-1)
 
#define Power_EINVALIDINPUT   (-2)
 
#define Power_EINVALIDPOINTER   (-3)
 
#define Power_ECHANGE_NOT_ALLOWED   (-4)
 
#define Power_EBUSY   (-5)
 
#define Power_ACTIVE   (1U)
 
#define Power_ENTERING_DEEPSLEEP   (2U)
 
#define Power_EXITING_DEEPSLEEP   (3U)
 
#define Power_ENTERING_SLEEP   (4U)
 
#define Power_EXITING_SLEEP   (5U)
 
#define Power_ENTERING_IDLE   (6U)
 
#define Power_EXITING_IDLE   (7U)
 
#define Power_CHANGING_PERF_LEVEL   (8U)
 

Typedefs

typedef void(* Power_PolicyInitFxn) (void)
 Power policy initialization function pointer. More...
 
typedef void(* Power_PolicyFxn) (unsigned long long sleepTimeus)
 Power policy function pointer. More...
 
typedef int_fast16_t(* Power_NotifyFxn) (uint_fast16_t eventType, uintptr_t eventArg, uintptr_t clientArg)
 Power notify callback function used with the Power_registerNotify() More...
 

Enumerations

enum  Power_LatencyType { Power_TOTAL_LATENCY, Power_RESUME_LATENCY }
 
enum  Power_SleepState { POWER_LPDS, POWER_SLEEP, POWER_IDLE, POWER_NONE }
 

Functions

bool Power_disablePolicy (void)
 Disable the configured power policy from running when the CPU is idle. More...
 
void Power_enablePolicy (void)
 Enable the configured power policy to run when the CPU is idle. More...
 
uint_fast32_t Power_getConstraintMask (void)
 Get the constraints that have been declared with Power. More...
 
int_fast16_t Power_getDependencyCount (uint_fast16_t resourceId)
 Get the current dependency count for a resource. More...
 
uint_fast16_t Power_getPerformanceLevel (void)
 Get the current performance level. More...
 
uint32_t Power_getTransitionLatency (Power_SleepState sleepState, Power_LatencyType type)
 Get the hardware transition latency for a sleep state. More...
 
void Power_setTransitionLatency (Power_SleepState sleepState, Power_LatencyType type, uint32_t latencyTime)
 
uint32_t Power_getThresholds (Power_SleepState sleepState)
 
void Power_setThresholds (Power_SleepState sleepState, uint32_t latencyTime)
 
Power_SleepState Power_getLowPowModeTaken ()
 
void Power_setLowPowModeTaken (Power_SleepState mode)
 
uint_fast16_t Power_getTransitionState (void)
 Get the current transition state of the Power Manager. More...
 
void Power_idleFunc (unsigned long long sleepTimeus)
 Power function to be added to the application idle loop. More...
 
int_fast16_t Power_init (void)
 Power initialization function. More...
 
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. More...
 
int_fast16_t Power_releaseConstraint (uint_fast16_t constraintId)
 Release a previously declared constraint. More...
 
int_fast16_t Power_releaseDependency (uint_fast16_t resourceId)
 Release a previously declared dependency. More...
 
int_fast16_t Power_setConstraint (uint_fast16_t constraintId)
 Declare an operational constraint. More...
 
int_fast16_t Power_setDependency (uint_fast16_t resourceId)
 Declare a dependency upon a resource. More...
 
int_fast16_t Power_setPerformanceLevel (uint_fast16_t level)
 Set the MCU performance level. More...
 
void Power_setPolicy (Power_PolicyFxn policy)
 Set a new Power policy. More...
 
int_fast16_t Power_sleep (uint_fast16_t sleepState)
 Transition the device into a sleep state. More...
 
void Power_unregisterNotify (Power_NotifyObj *pNotifyObj)
 Unregister previously registered notifications. More...
 

Typedef Documentation

◆ Power_PolicyInitFxn

typedef void(* Power_PolicyInitFxn) (void)

Power policy initialization function pointer.

◆ Power_PolicyFxn

typedef void(* Power_PolicyFxn) (unsigned long long sleepTimeus)

Power policy function pointer.

◆ Power_NotifyFxn

typedef int_fast16_t(* Power_NotifyFxn) (uint_fast16_t eventType, uintptr_t eventArg, uintptr_t clientArg)

Power notify callback function used with the Power_registerNotify()

Parameters
[in]eventTypeThe eventTypes parameter identifies the type of power event for which the notify callback function was called.
[in]eventArgAn optional eventType specific argument.
[in]clientArgPointer to a custom argument.
Return values
Power_NOTIFYDONEif the client processed the notification successfully
Power_NOTIFYERRORif an error occurred during notification.
See also
Power_registerNotify()
Power_unregisterNotify()
Power_NotifyObj
Using power notify

Function Documentation

◆ Power_disablePolicy()

bool Power_disablePolicy ( void  )

Disable the configured power policy from running when the CPU is idle.

Calling this function clears the flag that controls whether the configured power policy function is invoked on each pass through the Idle loop. This function call will override both a 'true' setting of the "enablePolicy" setting in the Power Manager configuration object, as well as a previous runtime call to the Power_enablePolicy() function.

Returns
The old value of "enablePolicy".
See also
Power_enablePolicy()
Enabling power policy
Disabling power policy

◆ Power_enablePolicy()

void Power_enablePolicy ( void  )

Enable the configured power policy to run when the CPU is idle.

Calling this function sets a flag that will cause the configured power policy function to be invoked on each pass through the Idle loop. This function call will override both a 'false' setting of the "enablePolicy" setting in the Power Manager configuration object, as well as a previous runtime call to the Power_disablePolicy() function.

For some processor families, automatic power transitions can make initial application development more difficult, as well as being at odds with basic debugger operation. This convenience function allows an application to be initially configured, built, and debugged, without automatic power transitions during idle time. When the application is found to be working, this function can be called (typically in main()) to enable the policy to run, without having to change the application configuration.

See also
Power_disablePolicy()
Enabling power policy
Disabling power policy

◆ Power_getConstraintMask()

uint_fast32_t Power_getConstraintMask ( void  )

Get the constraints that have been declared with Power.

This function returns a bitmask indicating the constraints that are currently declared to the Power Manager (via previous calls to Power_setConstraint()). For each constraint that is currently declared, the corresponding bit in the bitmask will be set. For example, if two clients have independently declared two different constraints, the returned bitmask will have two bits set.

Constraint identifiers are device specific, and defined in the device-specific Power include file. For example, the constraints for MSP432 are defined in PowerMSP432.h. The corresponding bit in the bitmask returned by this function can be derived by a left-shift using the constraint identifier. For example, for MSP432, for the corresponding bit for the PowerMSP432_DISALLOW_SLEEP constraint, the bit position is determined by the operation: (1 << PowerMSP432_DISALLOW_SLEEP)

Returns
A bitmask of the currently declared constraints.
See also
Power_setConstraint()
Using power constraints

◆ Power_getDependencyCount()

int_fast16_t Power_getDependencyCount ( uint_fast16_t  resourceId)

Get the current dependency count for a resource.

This function returns the number of dependencies that are currently declared upon a resource.

Resource identifiers are device specific, and defined in the device-specific Power include file. For example, the resources for 64XX are defined in Power64XX.h.

Parameters
[in]resourceIdresource id
Returns
The number of dependencies declared for the resource.
Return values
Power_EINVALIDINPUTif the resourceId is invalid or this function is not supported by the device specific implementation.
See also
Power_setDependency()
Using power dependency

◆ Power_getPerformanceLevel()

uint_fast16_t Power_getPerformanceLevel ( void  )

Get the current performance level.

This function returns the current device performance level in effect.

If performance scaling is not supported for the device, this function will always indicate a performance level of zero.

Returns
The current performance level.
See also
Power_setPerformanceLevel()

◆ Power_getTransitionLatency()

uint32_t Power_getTransitionLatency ( Power_SleepState  sleepState,
Power_LatencyType  type 
)

Get the hardware transition latency for a sleep state.

This function reports the minimal hardware transition latency for a specific sleep state. The reported latency is that for a direct transition, and does not include any additional latency that might occur due to software-based notifications.

Sleep states are device specific, and defined in the device-specific Power include file. For example, the sleep states for 64XX are defined in Power64XX.h.

This function is typically called by the power policy function. The latency is reported in units of microseconds.

Parameters
[in]sleepStatethe sleep state
[in]typePower_Latency_Type (Power_TOTAL or Power_RESUME)
Returns
The latency value, in units of microseconds.
See also
Power transitions

◆ Power_setTransitionLatency()

void Power_setTransitionLatency ( Power_SleepState  sleepState,
Power_LatencyType  type,
uint32_t  latencyTime 
)

◆ Power_getThresholds()

uint32_t Power_getThresholds ( Power_SleepState  sleepState)

◆ Power_setThresholds()

void Power_setThresholds ( Power_SleepState  sleepState,
uint32_t  latencyTime 
)

◆ Power_getLowPowModeTaken()

Power_SleepState Power_getLowPowModeTaken ( )

◆ Power_setLowPowModeTaken()

void Power_setLowPowModeTaken ( Power_SleepState  mode)

◆ Power_getTransitionState()

uint_fast16_t Power_getTransitionState ( void  )

Get the current transition state of the Power Manager.

Returns
The current Power_Transition_State.
Return values
Power_ACTIVEreturned when no transitions are in progress.
Power_ENTERING_SLEEPreturned during the transition to sleep, before sleep has occurred.
Power_EXITING_SLEEPreturned after wakeup, as the device is being transitioned back to Power_ACTIVE.
Power_CHANGING_PERF_LEVELreturned when a change is being made to the performance level.
See also
Power transitions

◆ Power_idleFunc()

void Power_idleFunc ( unsigned long long  sleepTimeus)

Power function to be added to the application idle loop.

This function should be added to the application idle loop. (The method to do this depends upon the operating system being used.) This function will invoke the configured power policy function when appropriate. The specific policy function to be invoked is configured as the 'policyFxn' in the application-defined Power configuration object.

◆ Power_init()

int_fast16_t Power_init ( void  )

Power initialization function.

This function initializes Power Manager internal state.

Warning
The application is responsible for ensuring this function is called prior to any other Power API. Additionally, this function must be be called prior to any other TI-Driver's APIs. This function is normally called prior to any operating system initialization.
Returns
Power_SOK

◆ 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.

This function registers a function to be called when a Power event occurs. Registrations and the corresponding notifications are processed in first-in-first-out (FIFO) order. The function registered must behave as described later, below.

The pNotifyObj parameter is a pointer to a pre-allocated, opaque object that will be used by Power to support the notification. This object could be dynamically allocated, or declared as a global object. This function will properly initialized the object's fields as appropriate; the caller just needs to provide a pointer to this pre-existing object.

The eventTypes parameter identifies the type of power event(s) for which the notify function being registered is to be called. (Event identifiers are device specific, and defined in the device-specific Power include file. For example, the events for MSP432 are defined in PowerMSP432.h.) The eventTypes parameter for this function call is treated as a bitmask, so multiple event types can be registered at once, using a common callback function. For example, to call the specified notifyFxn when both the entering deepsleep and awake from deepsleep events occur, eventTypes should be specified as: PowerMSP432_ENTERING_DEEPSLEEP | PowerMSP432_AWAKE_DEEPSLEEP

The notifyFxn parameter specifies a callback function to be called when the specified Power event occurs. The notifyFxn must implement the following signature: status = notifyFxn(eventType, eventArg, clientArg);

Where: eventType identifies the event being signaled, eventArg is an optional event-specific argument, and clientArg is an arbitrary argument specified by the client at registration. Note that multiple types of events can be specified when registering the notification callback function, but when the callback function is actually called by Power, only a single eventType will be specified for the callback (i.e., the current event). The status returned by the client notification function must be one of the following constants: Power_NOTIFYDONE if the client processed the notification successfully, or Power_NOTIFYERROR if an error occurred during notification.

The clientArg parameter is an arbitrary, client-defined argument to be passed back to the client upon notification. This argument may allow one notify function to be used by multiple instances of a driver (that is, the clientArg can be used to identify the instance of the driver that is being notified).

Parameters
[in]pNotifyObjPower_NotifyObj preallocated by caller
[in]eventTypesevent type or types
[in]notifyFxnclient's Power_NotifyFxn function
[in]clientArgclient-specified argument to pass with notification
Return values
Power_SOKon success.
Power_EINVALIDPOINTERif either pNotifyObj or notifyFxn are NULL.
See also
Power_unregisterNotify()
Using power notify

◆ Power_releaseConstraint()

int_fast16_t Power_releaseConstraint ( uint_fast16_t  constraintId)

Release a previously declared constraint.

This function releases a constraint that was previously declared with Power_setConstraint(). For example, if a device driver is starting an I/O transaction and wants to prohibit activation of a sleep state during the transaction, it uses Power_setConstraint() to declare the constraint, before starting the transaction. When the transaction completes, the driver calls this function to release the constraint, to allow the Power manager to once again allow transitions to sleep.

Constraint identifiers are device specific, and defined in the device-specific Power include file. For example, the constraints for MSP432 are defined in PowerMSP432.h.

Only one constraint can be specified with each call to this function; to release multiple constraints this function must be called multiple times.

It is critical that clients call Power_releaseConstraint() when operational constraints no longer exists. Otherwise, Power may be left unnecessarily restricted from activating power savings.

Precondition
Power_setConstraint() must have been called first.
Parameters
[in]constraintIdconstraint id
Returns
CC26XX/CC13XX only: Power_SOK. To minimize code size asserts are used internally to check that the constraintId is valid,valid, and that the constraint count is not already zero; the function always returns Power_SOK.
All other devices: Power_SOK on success, Power_EINVALIDINPUT if the constraintId is invalid, and Power_EFAIL if the constraint count is already zero.
See also
Power_setConstraint()
Using power constraints

◆ Power_releaseDependency()

int_fast16_t Power_releaseDependency ( uint_fast16_t  resourceId)

Release a previously declared dependency.

This function releases a dependency that had been previously declared upon a resource (by a call to Power_setDependency()).

Resource identifiers are device specific, and defined in the device-specific Power include file. For example, the resources for 64XX are defined in Power64XX.h.

Parameters
[in]resourceIdresource id
Returns
CC26XX/CC13XX only: Power_SOK. To minimize code size asserts are used internally to check that the resourceId is valid, and that the resource reference count is not already zero; the function always returns Power_SOK.
All other devices: Power_SOK on success, Power_EINVALIDINPUT if the resourceId is invalid, and Power_EFAIL if the resource reference count is already zero.
See also
Power_setDependency()
Using power dependency

◆ Power_setConstraint()

int_fast16_t Power_setConstraint ( uint_fast16_t  constraintId)

Declare an operational constraint.

Before taking certain actions, the Power Manager checks to see if the requested action would conflict with a client-declared constraint. If the action does conflict, Power will not proceed with the request. This is the function that allows clients to declare their constraints with Power.

Constraint identifiers are device specific, and defined in the device-specific Power include file. For example, the constraints for MSP432 are defined in PowerMSP432.h.

Only one constraint can be specified with each call to this function; to declare multiple constraints this function must be called multiple times.

Parameters
[in]constraintIdconstraint id
Returns
CC26XX/CC13XX only: Power_SOK. To minimize code size an assert is used internally to check that the constraintId is valid; the function always returns Power_SOK.
All other devices: Power_SOK on success, Power_EINVALIDINPUT if the constraintId is invalid.
See also
Power_releaseConstraint()
Using power constraints

◆ Power_setDependency()

int_fast16_t Power_setDependency ( uint_fast16_t  resourceId)

Declare a dependency upon a resource.

This function declares a dependency upon a resource. For example, if a UART driver needs a specific UART peripheral, it uses this function to declare this to the Power Manager. If the resource had been inactive, then Power will activate the peripheral during this function call.

What is needed to make a peripheral resource 'active' will vary by device family. For some devices this may be a simple enable of a clock to the specified peripheral. For others it may also require a power on of a power domain. In either case, the Power Manager will take care of these details, and will also implement reference counting for resources and their interdependencies. For example, if multiple UART peripherals reside in a shared serial power domain, the Power Manager will power up the serial domain when it is first needed, and then automatically power the domain off later, when all related dependencies for the relevant peripherals are released.

Resource identifiers are device specific, and defined in the device-specific Power include file. For example, the resources for 64XX are defined in Power64XX.h.

Parameters
[in]resourceIdresource id
Returns
CC26XX/CC13XX only: Power_SOK. To minimize code size an assert is used internally to check that the resourceId is valid; the function always returns Power_SOK.
All other devices: Power_SOK on success, Power_EINVALIDINPUT if the reseourceId is invalid.
See also
Power_releaseDependency()
Using power dependency

◆ Power_setPerformanceLevel()

int_fast16_t Power_setPerformanceLevel ( uint_fast16_t  level)

Set the MCU performance level.

This function manages a transition to a new device performance level. Before the actual transition is initiated, notifications will be sent to any clients who've registered with Power_registerNotify() for a 'start change performance level' notification. The event name is device specific, and defined in the device-specific Power include file. For example, for MSP432, the event is "PowerMSP432_START_CHANGE_PERF_LEVEL", which is defined in PowerMSP432.h. Once notifications have been completed, the change to the performance level is initiated. After the level change is completed, there is a comparable event that can be used to signal a client that the change has completed. For example, on MSP432 the "PowerMSP432_DONE_CHANGE_PERF_LEVEL" event can be used to signal completion.

This function will not return until the new performance level is in effect. If performance scaling is not supported for the device, or is prohibited by an active constraint, or if the specified level is invalid, then an error status will be returned.

Parameters
[in]levelthe new performance level
Return values
Power_SOKon success.
Power_EINVALIDINPUTif the specified performance level is out of range of valid levels.
Power_EBUSYif another transition is already in progress, or if a single constraint is set to prohibit any change to the performance level.
Power_ECHANGE_NOT_ALLOWEDif a level-specific constraint prohibits a change to the requested level.
Power_EFAILif performance scaling is not supported, if an error occurred during initialization, or if an error occurred during client notifications.
See also
Power_getPerformanceLevel()

◆ Power_setPolicy()

void Power_setPolicy ( Power_PolicyFxn  policy)

Set a new Power policy.

This function allows a new Power_PolicyFxn function to be selected at runtime.

Parameters
[in]policythe new Power_PolicyFxn function

◆ Power_sleep()

int_fast16_t Power_sleep ( uint_fast16_t  sleepState)

Transition the device into a sleep state.

This function is called from the power policy when it has made a decision to put the device in a specific sleep state. This function returns to the caller (the policy function) once the device has awoken from sleep.

Warning
This function must be called with interrupts disabled, and should not be called directly by the application, or by any drivers. This function does not check declared constraints; the policy function must check constraints before calling this function to initiate sleep.
Parameters
[in]sleepStatethe sleep state
Return values
Power_SOKon success, the device has slept and is awake again.
Power_EFAILif an error occurred during client notifications, or if a general failure occurred.
Power_EINVALIDINPUTif the sleepState is invalid.
Power_EBUSYif another transition is already in progress.

◆ Power_unregisterNotify()

void Power_unregisterNotify ( Power_NotifyObj pNotifyObj)

Unregister previously registered notifications.

This function unregisters for event notifications that were previously registered with Power_registerNotify(). The caller must specify a pointer to the same notification object used during registration.

Parameters
[in]pNotifyObjThe Power_NotifyObj used with the original call to Power_registerNotify()
See also
Power_registerNotify()
Using power notify