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