TI-RTOS Drivers  tidrivers_full_2_20_01_10
Power.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, 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  */
55 #ifndef ti_drivers_Power__include
56 #define ti_drivers_Power__include
57 
58 #include <stdint.h>
59 #include <ti/drivers/utils/List.h>
60 
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 /* Power latency types */
66 #define Power_TOTAL 1
67 #define Power_RESUME 2
69 /* Power notify responses */
70 #define Power_NOTIFYDONE 0
71 #define Power_NOTIFYERROR 1
73 /* Power status */
74 #define Power_SOK 0
75 #define Power_EFAIL 1
76 #define Power_EINVALIDPOINTER 2
77 #define Power_ECHANGE_NOT_ALLOWED 3
78 #define Power_EBUSY 4
80 /* Power transition states */
81 #define Power_ACTIVE 1
82 #define Power_ENTERING_SLEEP 2
83 #define Power_EXITING_SLEEP 3
84 #define Power_ENTERING_SHUTDOWN 4
85 #define Power_CHANGING_PERF_LEVEL 5
91 typedef void (*Power_PolicyInitFxn)(void);
92 
96 typedef void (*Power_PolicyFxn)(void);
97 
101 typedef int (*Power_NotifyFxn)(unsigned int eventType, uintptr_t eventArg,
102  uintptr_t clientArg);
103 
112 typedef struct Power_NotifyObj {
114  unsigned int eventTypes;
116  uintptr_t clientArg;
118 
131 void Power_disablePolicy(void);
132 
152 void Power_enablePolicy(void);
153 
176 unsigned int Power_getConstraintMask(void);
177 
194 unsigned int Power_getDependencyCount(unsigned int resourceId);
195 
208 unsigned int Power_getPerformanceLevel(void);
209 
231 uint32_t Power_getTransitionLatency(unsigned int sleepState, unsigned int type);
232 
244 unsigned int Power_getTransitionState(void);
245 
256 void Power_idleFunc(void);
257 
266 void Power_init(void);
267 
327 unsigned int Power_registerNotify(Power_NotifyObj *pNotifyObj,
328  unsigned int eventTypes,
329  Power_NotifyFxn notifyFxn,
330  uintptr_t clientArg);
331 
358 void Power_releaseConstraint(unsigned int constraintId);
359 
374 void Power_releaseDependency(unsigned int resourceId);
375 
395 void Power_setConstraint(unsigned int constraintId);
396 
424 void Power_setDependency(unsigned int resourceId);
425 
460 unsigned int Power_setPerformanceLevel(unsigned int level);
461 
469 void Power_setPolicy(Power_PolicyFxn policy);
470 
512 unsigned int Power_shutdown(unsigned int shutdownState, uint32_t shutdownTime);
513 
533 unsigned int Power_sleep(unsigned int sleepState);
534 
546 void Power_unregisterNotify(Power_NotifyObj *pNotifyObj);
547 
548 #ifdef __cplusplus
549 }
550 #endif
551 
552 #endif /* ti_drivers_Power__include */
int(* Power_NotifyFxn)(unsigned int eventType, uintptr_t eventArg, uintptr_t clientArg)
Power notify function pointer.
Definition: Power.h:101
void Power_releaseDependency(unsigned int resourceId)
Release a previously declared dependency.
unsigned int Power_setPerformanceLevel(unsigned int level)
Set the MCU performance level.
void Power_releaseConstraint(unsigned int constraintId)
Release a previously declared constraint.
unsigned int Power_sleep(unsigned int sleepState)
Transition the device into a sleep state.
Power_NotifyFxn notifyFxn
Definition: Power.h:115
unsigned int eventTypes
Definition: Power.h:114
unsigned int Power_getPerformanceLevel(void)
Get the current performance level.
void(* Power_PolicyFxn)(void)
Power policy function pointer.
Definition: Power.h:96
uintptr_t clientArg
Definition: Power.h:116
Definition: List.h:126
void Power_setPolicy(Power_PolicyFxn policy)
Set a new Power policy.
unsigned int Power_getDependencyCount(unsigned int resourceId)
Get the current dependency count for a resource.
Power notify object structure.
Definition: Power.h:112
void Power_setConstraint(unsigned int constraintId)
Declare an operational constraint.
void Power_init(void)
Power initialization function.
void Power_unregisterNotify(Power_NotifyObj *pNotifyObj)
Unregister previously registered notifications.
void Power_disablePolicy(void)
Disable the configured power policy from running when the CPU is idle.
struct Power_NotifyObj Power_NotifyObj
Power notify object structure.
List_Elem link
Definition: Power.h:113
void Power_enablePolicy(void)
Enable the configured power policy to run when the CPU is idle.
unsigned int Power_getTransitionState(void)
Get the current transition state of the Power manager.
uint32_t Power_getTransitionLatency(unsigned int sleepState, unsigned int type)
Get the hardware transition latency for a sleep state.
void Power_idleFunc(void)
Power function to be added to the application idle loop.
void Power_setDependency(unsigned int resourceId)
Declare a dependency upon a resource.
unsigned int Power_shutdown(unsigned int shutdownState, uint32_t shutdownTime)
Put the device into a shutdown state.
unsigned int Power_getConstraintMask(void)
Get the constraints that have been declared with Power.
unsigned int Power_registerNotify(Power_NotifyObj *pNotifyObj, unsigned int eventTypes, Power_NotifyFxn notifyFxn, uintptr_t clientArg)
Register a function to be called upon a specific power event.
Linked List interface for use in drivers.
Copyright 2016, Texas Instruments Incorporated