TI-RTOS Drivers  tidrivers_msp43x_2_16_00_08
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  */
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_Config {
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 */
158 
163 typedef struct PowerMSP432_ModuleState {
164  List_List notifyList;
165  uint32_t constraintMask;
166  unsigned int state;
167  unsigned int currentPerfLevel;
168  bool enablePolicy;
169  bool perfInitialized;
170  bool initialized;
171  uint8_t constraintCounts[PowerMSP432_NUMCONSTRAINTS];
172 } PowerMSP432_ModuleState;
175 /* default policy init function for config structure */
176 void PowerMSP432_initPolicy(void);
177 
178 /* default power policy function for config structure */
179 void PowerMSP432_sleepPolicy(void);
180 
181 /* OS-specific frequency update function */
183 
184 /* OS-specific scheduler disable function */
186 
187 /* OS-specific scheduler restore function */
189 
190 /* function to get the number of performance levels */
191 unsigned int PowerMSP432_getNumPerfLevels(void);
192 
193 /* function to get the frequencies for a specific performance level */
194 void PowerMSP432_getFreqs(unsigned int level, PowerMSP432_Freqs * freqs);
195 
196 /*
197  * On MSP432 peripheral clocks are managed automatically by the device; there
198  * is no need for software control. Use #defines for the dependency APIs to
199  * eliminate any footprint.
200  */
201 #define Power_getDependencyCount(resourceId) 0
202 #define Power_releaseDependency(resourceId)
203 #define Power_setDependency(resourceId)
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 #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:143
Power_PolicyInitFxn policyInitFxn
Definition: PowerMSP432.h:152
void PowerMSP432_sleepPolicy(void)
Definition: List.h:131
unsigned int PowerMSP432_getNumPerfLevels(void)
void PowerMSP432_schedulerDisable(void)
unsigned int MCLK
Definition: PowerMSP432.h:144
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)
unsigned int initialPerfLevel
Definition: PowerMSP432.h:154
void PowerMSP432_initPolicy(void)
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:153
#define PowerMSP432_NUMCONSTRAINTS
Definition: PowerMSP432.h:100
Power global configuration (MSP432-specific)
Definition: PowerMSP432.h:151
bool enablePolicy
Definition: PowerMSP432.h:155
unsigned int ACLK
Definition: PowerMSP432.h:147
bool enablePerf
Definition: PowerMSP432.h:156
unsigned int SMCLK
Definition: PowerMSP432.h:146
Linked List interface for use in drivers.
Copyright 2016, Texas Instruments Incorporated