Power.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2018, 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 CONSEQUENTIAL 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  */
61 #ifndef ti_drivers_Power__include
62 #define ti_drivers_Power__include
63 
64 #include <stdbool.h>
65 #include <stdint.h>
66 
67 #include <ti/drivers/utils/List.h>
68 
69 #ifdef __cplusplus
70 extern "C" {
71 #endif
72 
73 /* Power latency types */
74 #define Power_TOTAL (1U)
75 #define Power_RESUME (2U)
77 /* Power notify responses */
78 #define Power_NOTIFYDONE (0)
79 #define Power_NOTIFYERROR (-1)
81 /* Power status */
82 #define Power_SOK (0)
83 #define Power_EFAIL (-1)
84 #define Power_EINVALIDINPUT (-2)
85 #define Power_EINVALIDPOINTER (-3)
86 #define Power_ECHANGE_NOT_ALLOWED (-4)
87 #define Power_EBUSY (-5)
89 /* Power transition states */
90 #define Power_ACTIVE (1U)
91 #define Power_ENTERING_SLEEP (2U)
92 #define Power_EXITING_SLEEP (3U)
93 #define Power_ENTERING_SHUTDOWN (4U)
94 #define Power_CHANGING_PERF_LEVEL (5U)
100 typedef void (*Power_PolicyInitFxn)(void);
101 
105 typedef void (*Power_PolicyFxn)(void);
106 
110 typedef int_fast16_t (*Power_NotifyFxn)(uint_fast16_t eventType,
111  uintptr_t eventArg, uintptr_t clientArg);
112 
121 typedef struct Power_NotifyObj_ {
123  uint_fast16_t eventTypes;
125  uintptr_t clientArg;
127 
142 bool Power_disablePolicy(void);
143 
163 void Power_enablePolicy(void);
164 
187 uint_fast32_t Power_getConstraintMask(void);
188 
206 int_fast16_t Power_getDependencyCount(uint_fast16_t resourceId);
207 
220 uint_fast16_t Power_getPerformanceLevel(void);
221 
243 uint_fast32_t Power_getTransitionLatency(uint_fast16_t sleepState,
244  uint_fast16_t type);
245 
259 uint_fast16_t Power_getTransitionState(void);
260 
271 void Power_idleFunc(void);
272 
283 int_fast16_t Power_init(void);
284 
345 int_fast16_t Power_registerNotify(Power_NotifyObj *pNotifyObj,
346  uint_fast16_t eventTypes,
348  uintptr_t clientArg);
349 
385 int_fast16_t Power_releaseConstraint(uint_fast16_t constraintId);
386 
410 int_fast16_t Power_releaseDependency(uint_fast16_t resourceId);
411 
438 int_fast16_t Power_setConstraint(uint_fast16_t constraintId);
439 
474 int_fast16_t Power_setDependency(uint_fast16_t resourceId);
475 
513 int_fast16_t Power_setPerformanceLevel(uint_fast16_t level);
514 
522 void Power_setPolicy(Power_PolicyFxn policy);
523 
565 int_fast16_t Power_shutdown(uint_fast16_t shutdownState,
566  uint_fast32_t shutdownTime);
567 
588 int_fast16_t Power_sleep(uint_fast16_t sleepState);
589 
601 void Power_unregisterNotify(Power_NotifyObj *pNotifyObj);
602 
603 #ifdef __cplusplus
604 }
605 #endif
606 
607 #endif /* ti_drivers_Power__include */
uint_fast32_t Power_getTransitionLatency(uint_fast16_t sleepState, uint_fast16_t type)
Get the hardware transition latency for a sleep state.
int_fast16_t Power_getDependencyCount(uint_fast16_t resourceId)
Get the current dependency count for a resource.
uintptr_t clientArg
Definition: Power.h:125
int_fast16_t Power_sleep(uint_fast16_t sleepState)
Transition the device into a sleep state.
int_fast16_t Power_init(void)
Power initialization function.
Power notify object structure.
Definition: Power.h:121
int_fast16_t(* Power_NotifyFxn)(uint_fast16_t eventType, uintptr_t eventArg, uintptr_t clientArg)
Power notify function pointer.
Definition: Power.h:110
int_fast16_t Power_setPerformanceLevel(uint_fast16_t level)
Set the MCU performance level.
int_fast16_t Power_setConstraint(uint_fast16_t constraintId)
Declare an operational constraint.
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.
void(* Power_PolicyFxn)(void)
Power policy function pointer.
Definition: Power.h:105
bool Power_disablePolicy(void)
Disable the configured power policy from running when the CPU is idle.
int_fast16_t Power_shutdown(uint_fast16_t shutdownState, uint_fast32_t shutdownTime)
Put the device into a shutdown state.
Definition: List.h:126
uint_fast16_t Power_getPerformanceLevel(void)
Get the current performance level.
void Power_setPolicy(Power_PolicyFxn policy)
Set a new Power policy.
struct Power_NotifyObj_ Power_NotifyObj
Power notify object structure.
int_fast16_t Power_releaseDependency(uint_fast16_t resourceId)
Release a previously declared dependency.
void Power_unregisterNotify(Power_NotifyObj *pNotifyObj)
Unregister previously registered notifications.
uint_fast32_t Power_getConstraintMask(void)
Get the constraints that have been declared with Power.
uint_fast16_t Power_getTransitionState(void)
Get the current transition state of the Power Manager.
List_Elem link
Definition: Power.h:122
int_fast16_t Power_releaseConstraint(uint_fast16_t constraintId)
Release a previously declared constraint.
int_fast16_t Power_setDependency(uint_fast16_t resourceId)
Declare a dependency upon a resource.
void Power_enablePolicy(void)
Enable the configured power policy to run when the CPU is idle.
void Power_idleFunc(void)
Power function to be added to the application idle loop.
Power_NotifyFxn notifyFxn
Definition: Power.h:124
uint_fast16_t eventTypes
Definition: Power.h:123
Linked List interface for use in drivers.
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale