TI-RTOS Drivers  tidrivers_full_2_20_00_08
PowerMSP432.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  */
48 #ifndef ti_drivers_power_PowerMSP432__include
49 #define ti_drivers_power_PowerMSP432__include
50 
51 #include <stdint.h>
52 #include <ti/drivers/utils/List.h>
53 #include <ti/drivers/Power.h>
54 
55 /* driverlib header files */
56 #include <pcm.h>
57 #include <cs.h>
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /* latency times in microseconds (derived from device datasheet) */
64 #define PowerMSP432_RESUMETIMESLEEP 32
65 #define PowerMSP432_TOTALTIMESLEEP 40
66 #define PowerMSP432_RESUMETIMEDEEPSLEEP_0 16
67 #define PowerMSP432_TOTALTIMEDEEPSLEEP_0 40
68 #define PowerMSP432_RESUMETIMEDEEPSLEEP_1 16
69 #define PowerMSP432_TOTALTIMEDEEPSLEEP_1 40
70 
71 /* Power resources (for declaring dependencies) */
72 #define PowerMSP432_PERIPH_ADC14 0
73 #define PowerMSP432_PERIPH_DMA 1
74 #define PowerMSP432_PERIPH_EUSCI_A0 2
75 #define PowerMSP432_PERIPH_EUSCI_A1 3
76 #define PowerMSP432_PERIPH_EUSCI_A2 4
77 #define PowerMSP432_PERIPH_EUSCI_A3 5
78 #define PowerMSP432_PERIPH_EUSCI_B0 6
79 #define PowerMSP432_PERIPH_EUSCI_B1 7
80 #define PowerMSP432_PERIPH_EUSCI_B2 8
81 #define PowerMSP432_PERIPH_EUSCI_B3 9
82 #define PowerMSP432_PERIPH_TIMER_A0 10
83 #define PowerMSP432_PERIPH_TIMER_A1 11
84 #define PowerMSP432_PERIPH_TIMER_A2 12
85 #define PowerMSP432_PERIPH_TIMER_A3 13
86 #define PowerMSP432_PERIPH_TIMER_T32 14
87 
88 /* Power constraints */
89 #define PowerMSP432_DISALLOW_SLEEP 0
90 #define PowerMSP432_DISALLOW_DEEPSLEEP_0 1
91 #define PowerMSP432_DISALLOW_DEEPSLEEP_1 2
92 #define PowerMSP432_DISALLOW_SHUTDOWN_0 3
93 #define PowerMSP432_DISALLOW_SHUTDOWN_1 4
94 #define PowerMSP432_DISALLOW_PERFLEVEL_0 5
95 #define PowerMSP432_DISALLOW_PERFLEVEL_1 6
96 #define PowerMSP432_DISALLOW_PERFLEVEL_2 7
97 #define PowerMSP432_DISALLOW_PERFLEVEL_3 8
98 #define PowerMSP432_DISALLOW_PERFLEVEL_4 9
99 #define PowerMSP432_DISALLOW_PERF_CHANGES 10
100 #define PowerMSP432_NUMCONSTRAINTS 11
101 
102 /* Power events */
103 #define PowerMSP432_ENTERING_SLEEP 0x1
104 #define PowerMSP432_ENTERING_DEEPSLEEP 0x2
105 #define PowerMSP432_ENTERING_SHUTDOWN 0x4
106 #define PowerMSP432_AWAKE_SLEEP 0x8
107 #define PowerMSP432_AWAKE_DEEPSLEEP 0x10
108 #define PowerMSP432_START_CHANGE_PERF_LEVEL 0x20
109 #define PowerMSP432_DONE_CHANGE_PERF_LEVEL 0x40
110 #define PowerMSP432_NUMEVENTS 7
111 
112 /* Power sleep states */
113 #define PowerMSP432_SLEEP 0x1
114 #define PowerMSP432_DEEPSLEEP_0 0x2
115 #define PowerMSP432_DEEPSLEEP_1 0x4
116 
117 /* Power shutdown states */
118 #define PowerMSP432_SHUTDOWN_0 0x0
119 #define PowerMSP432_SHUTDOWN_1 0x1
120 
125 typedef struct PowerMSP432_PerfLevel {
126  unsigned int activeState; /* device active state */
127  unsigned int VCORE; /* VCORE level */
128  unsigned int clockSource; /* clock source */
129  unsigned int DCORESEL; /* DCO select bits */
130  unsigned int DIVM; /* MCLK divider */
131  unsigned int DIVHS; /* HSMLK divider */
132  unsigned int DIVS; /* SMCLK divider */
133  unsigned int flashWaitStates; /* flash wait states */
134  bool enableFlashBuffer; /* enable flash read buffers? */
135  unsigned int MCLK; /* resulting MCLK frequency */
136  unsigned int HSMCLK; /* resulting HSMCLK frequency */
137  unsigned int SMCLK; /* resulting SMCLK frequency */
138  unsigned int ACLK; /* resulting ACLK frequency */
139 } PowerMSP432_PerfLevel;
143 typedef struct PowerMSP432_Freqs {
144  unsigned int MCLK;
145  unsigned int HSMCLK;
146  unsigned int SMCLK;
147  unsigned int ACLK;
149 
151 typedef struct PowerMSP432_ConfigV1 {
152  Power_PolicyInitFxn policyInitFxn; /* init function for power policy */
153  Power_PolicyFxn policyFxn; /* the power policy function */
154  unsigned int initialPerfLevel; /* initial performance level */
155  bool enablePolicy; /* enables power policy function to run in idle loop */
156  bool enablePerf; /* enables performance level control */
157  bool enableParking; /* enables automatic pin parking during LPM3 and LPM4 */
159 
164 typedef struct PowerMSP432_ModuleState {
165  List_List notifyList;
166  uint32_t constraintMask;
167  unsigned int state;
168  unsigned int currentPerfLevel;
169  bool enablePolicy;
170  bool perfInitialized;
171  bool initialized;
172  uint8_t constraintCounts[PowerMSP432_NUMCONSTRAINTS];
173  Power_PolicyFxn policyFxn;
174 } PowerMSP432_ModuleState;
177 /* default policy init function for config structure */
178 void PowerMSP432_initPolicy(void);
179 
180 /* default power policy function for config structure */
181 void PowerMSP432_sleepPolicy(void);
182 
183 /* more agressive power policy function using deepsleep */
184 void PowerMSP432_deepSleepPolicy(void);
185 
186 /* OS-specific frequency update function */
188 
189 /* OS-specific scheduler disable function */
191 
192 /* OS-specific scheduler restore function */
194 
195 /* function to get the number of performance levels */
196 unsigned int PowerMSP432_getNumPerfLevels(void);
197 
198 /* function to get the frequencies for a specific performance level */
199 void PowerMSP432_getFreqs(unsigned int level, PowerMSP432_Freqs * freqs);
200 
201 /*
202  * On MSP432 peripheral clocks are managed automatically by the device; there
203  * is no need for software control. Use #defines for the dependency APIs to
204  * eliminate any footprint.
205  */
206 #define Power_getDependencyCount(resourceId) 0
207 #define Power_releaseDependency(resourceId)
208 #define Power_setDependency(resourceId)
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* ti_drivers_PowerMSP432_PowerMSP432__include */
bool enablePerf
Definition: PowerMSP432.h:156
void PowerMSP432_getFreqs(unsigned int level, PowerMSP432_Freqs *freqs)
void PowerMSP432_updateFreqs(PowerMSP432_Freqs *freqs)
Structure holding device frequencies (in Hz)
Definition: PowerMSP432.h:143
void PowerMSP432_sleepPolicy(void)
Definition: List.h:131
unsigned int PowerMSP432_getNumPerfLevels(void)
void PowerMSP432_schedulerDisable(void)
unsigned int MCLK
Definition: PowerMSP432.h:144
struct PowerMSP432_ConfigV1 PowerMSP432_ConfigV1
Power global configuration (MSP432-specific)
unsigned int HSMCLK
Definition: PowerMSP432.h:145
void(* Power_PolicyInitFxn)(void)
Power policy initialization function pointer.
Definition: Power.h:91
Power manager interface.
struct PowerMSP432_Freqs PowerMSP432_Freqs
Structure holding device frequencies (in Hz)
void PowerMSP432_initPolicy(void)
void PowerMSP432_schedulerRestore(void)
void(* Power_PolicyFxn)(void)
Power policy function pointer.
Definition: Power.h:96
Power global configuration (MSP432-specific)
Definition: PowerMSP432.h:151
bool enableParking
Definition: PowerMSP432.h:157
bool enablePolicy
Definition: PowerMSP432.h:155
void PowerMSP432_deepSleepPolicy(void)
#define PowerMSP432_NUMCONSTRAINTS
Definition: PowerMSP432.h:100
Power_PolicyFxn policyFxn
Definition: PowerMSP432.h:153
unsigned int ACLK
Definition: PowerMSP432.h:147
Power_PolicyInitFxn policyInitFxn
Definition: PowerMSP432.h:152
unsigned int SMCLK
Definition: PowerMSP432.h:146
unsigned int initialPerfLevel
Definition: PowerMSP432.h:154
Linked List interface for use in drivers.
Copyright 2016, Texas Instruments Incorporated