PowerMSP432.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  */
48 #ifndef ti_drivers_power_PowerMSP432__include
49 #define ti_drivers_power_PowerMSP432__include
50 
51 #include <stdint.h>
52 
53 #include <ti/devices/DeviceFamily.h>
54 
55 #include <ti/drivers/utils/List.h>
56 #include <ti/drivers/Power.h>
57 
58 /* driverlib header files */
59 #include <ti/devices/msp432p4xx/driverlib/pcm.h>
60 #include <ti/devices/msp432p4xx/driverlib/cs.h>
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65 
66 /* latency times in microseconds (derived from device datasheet) */
67 
69 #define PowerMSP432_RESUMETIMESLEEP 32
70 
72 #define PowerMSP432_TOTALTIMESLEEP 40
73 
75 #define PowerMSP432_RESUMETIMEDEEPSLEEP_0 16
76 
78 #define PowerMSP432_TOTALTIMEDEEPSLEEP_0 40
79 
81 #define PowerMSP432_RESUMETIMEDEEPSLEEP_1 16
82 
84 #define PowerMSP432_TOTALTIMEDEEPSLEEP_1 40
85 
86 /* Power resources (for declaring dependencies) */
87 #define PowerMSP432_PERIPH_ADC14 0
88 
90 #define PowerMSP432_PERIPH_DMA 1
91 
93 #define PowerMSP432_PERIPH_EUSCI_A0 2
94 
96 #define PowerMSP432_PERIPH_EUSCI_A1 3
97 
99 #define PowerMSP432_PERIPH_EUSCI_A2 4
100 
102 #define PowerMSP432_PERIPH_EUSCI_A3 5
103 
105 #define PowerMSP432_PERIPH_EUSCI_B0 6
106 
108 #define PowerMSP432_PERIPH_EUSCI_B1 7
109 
111 #define PowerMSP432_PERIPH_EUSCI_B2 8
112 
114 #define PowerMSP432_PERIPH_EUSCI_B3 9
115 
117 #define PowerMSP432_PERIPH_TIMER_A0 10
118 
120 #define PowerMSP432_PERIPH_TIMER_A1 11
121 
123 #define PowerMSP432_PERIPH_TIMER_A2 12
124 
126 #define PowerMSP432_PERIPH_TIMER_A3 13
127 
129 #define PowerMSP432_PERIPH_TIMER_T32 14
130 
133 /* Power constraints */
134 #define PowerMSP432_DISALLOW_SLEEP 0
135 
137 #define PowerMSP432_DISALLOW_DEEPSLEEP_0 1
138 
140 #define PowerMSP432_DISALLOW_DEEPSLEEP_1 2
141 
143 #define PowerMSP432_DISALLOW_SHUTDOWN_0 3
144 
146 #define PowerMSP432_DISALLOW_SHUTDOWN_1 4
147 
149 #define PowerMSP432_DISALLOW_PERFLEVEL_0 5
150 
152 #define PowerMSP432_DISALLOW_PERFLEVEL_1 6
153 
155 #define PowerMSP432_DISALLOW_PERFLEVEL_2 7
156 
158 #define PowerMSP432_DISALLOW_PERFLEVEL_3 8
159 
161 #define PowerMSP432_DISALLOW_PERFLEVEL_4 9
162 
164 #define PowerMSP432_DISALLOW_PERFLEVEL_5 10
165 
167 #define PowerMSP432_DISALLOW_PERFLEVEL_6 11
168 
170 #define PowerMSP432_DISALLOW_PERFLEVEL_7 12
171 
173 #define PowerMSP432_DISALLOW_PERF_CHANGES 13
174 
176 /* \cond */
177 #define PowerMSP432_NUMCONSTRAINTS 14
178 /* \endcond */
179 
180 /*
181  * Power events
182  *
183  * Each event ID must be a power of two and sequential without any gaps
184  */
185 #define PowerMSP432_ENTERING_SLEEP 0x1
186 
188 #define PowerMSP432_ENTERING_DEEPSLEEP 0x2
189 
191 #define PowerMSP432_ENTERING_SHUTDOWN 0x4
192 
194 #define PowerMSP432_AWAKE_SLEEP 0x8
195 
197 #define PowerMSP432_AWAKE_DEEPSLEEP 0x10
198 
200 #define PowerMSP432_START_CHANGE_PERF_LEVEL 0x20
201 
203 #define PowerMSP432_DONE_CHANGE_PERF_LEVEL 0x40
204 
206 /* \cond */
207 #define PowerMSP432_NUMEVENTS 7
208 /* \endcond */
209 
210 /* Power sleep states */
211 #define PowerMSP432_SLEEP 0x1
212 #define PowerMSP432_DEEPSLEEP_0 0x2
213 #define PowerMSP432_DEEPSLEEP_1 0x4
215 /* Power shutdown states */
216 #define PowerMSP432_SHUTDOWN_0 0x0
217 #define PowerMSP432_SHUTDOWN_1 0x1
356 typedef struct PowerMSP432_PerfLevel {
357 
365  unsigned int activeState;
372  unsigned int VCORE;
378  unsigned int clockSource;
385  unsigned int DCORESEL;
392  unsigned int SELM;
399  unsigned int DIVM;
406  unsigned int SELS;
413  unsigned int DIVHS;
420  unsigned int DIVS;
427  unsigned int SELB;
434  unsigned int SELA;
441  unsigned int DIVA;
448  unsigned int flashWaitStates;
463  unsigned int MCLK;
470  unsigned int HSMCLK;
477  unsigned int SMCLK;
482  unsigned int BCLK;
487  unsigned int ACLK;
489 
491 typedef struct PowerMSP432_Freqs {
492  unsigned int MCLK;
493  unsigned int HSMCLK;
494  unsigned int SMCLK;
495  unsigned int BCLK;
496  unsigned int ACLK;
498 
500 typedef struct PowerMSP432_ConfigV1 {
542  unsigned int initialPerfLevel;
637  bool enableParking; /* enables automatic pin parking during LPM3 and LPM4 */
648  void (*resumeShutdownHookFxn)(void);
658  uint32_t numCustom;
682  unsigned int HFXTFREQ;
689  unsigned int LFXTDRIVE;
745  unsigned int priorityInterruptsCS;
750  void (*isrCS)(void);
752 
757 typedef struct PowerMSP432_ModuleState {
758  List_List notifyList;
759  uint32_t constraintMask;
760  unsigned int state;
761  unsigned int currentPerfLevel;
762  bool enablePolicy;
763  bool perfInitialized;
764  bool initialized;
765  uint8_t constraintCounts[PowerMSP432_NUMCONSTRAINTS];
766  Power_PolicyFxn policyFxn;
767 } PowerMSP432_ModuleState;
776 void PowerMSP432_initPolicy(void);
777 
793 void PowerMSP432_sleepPolicy(void);
794 
814 void PowerMSP432_deepSleepPolicy(void);
815 
822 void PowerMSP432_updateFreqs(PowerMSP432_Freqs *freqs);
823 
829 void PowerMSP432_schedulerDisable(void);
830 
836 void PowerMSP432_schedulerRestore(void);
837 
838 /* function to get the number of performance levels */
839 uint_fast16_t PowerMSP432_getNumPerfLevels(void);
840 
841 /* function to get the frequencies for a specific performance level */
842 int_fast16_t PowerMSP432_getFreqs(uint_fast16_t level,
843  PowerMSP432_Freqs * freqs);
844 
845 /*
846  * On MSP432 peripheral clocks are managed automatically by the device; there
847  * is no need for software control. Use #defines for the dependency APIs to
848  * eliminate any footprint.
849  */
850 /* \cond */
851 #define Power_getDependencyCount(resourceId) Power_EINVALIDINPUT
852 #define Power_releaseDependency(resourceId) Power_EINVALIDINPUT
853 #define Power_setDependency(resourceId) Power_EINVALIDINPUT
854 /* \endcond */
855 
856 #ifdef __cplusplus
857 }
858 #endif
859 
860 #endif /* ti_drivers_PowerMSP432_PowerMSP432__include */
unsigned int SMCLK
The expected SMCLK frequency for this performance level, in Hz.
Definition: PowerMSP432.h:477
bool enablePerf
Boolean specifying if performance scaling is enabled.
Definition: PowerMSP432.h:566
uint32_t numCustom
Number of custom performance levels.
Definition: PowerMSP432.h:658
unsigned int clockSource
The clock source for this performance level.
Definition: PowerMSP432.h:378
Structure holding device frequencies (in Hz)
Definition: PowerMSP432.h:491
void PowerMSP432_sleepPolicy(void)
The SLEEP Power Policy.
Definition: List.h:131
unsigned int SELB
The BCLK source.
Definition: PowerMSP432.h:427
unsigned int LFXTDRIVE
The low frequency crystal (LFXT) drive level.
Definition: PowerMSP432.h:689
unsigned int MCLK
Definition: PowerMSP432.h:492
struct PowerMSP432_ConfigV1 PowerMSP432_ConfigV1
Power global configuration (MSP432-specific)
unsigned int DIVA
The ACLK source divider.
Definition: PowerMSP432.h:441
unsigned int HSMCLK
Definition: PowerMSP432.h:493
bool bypassLFXT
Boolean specifying if the LFXT pin should be configured for LFXT bypass.
Definition: PowerMSP432.h:725
void(* Power_PolicyInitFxn)(void)
Power policy initialization function pointer.
Definition: Power.h:100
Power Manager interface.
unsigned int flashWaitStates
The number of Flash wait-states to be used for this performance level.
Definition: PowerMSP432.h:448
bool configurePinHFXT
Boolean specifying if the HFXT pin should be configured for HFXT function.
Definition: PowerMSP432.h:698
unsigned int HSMCLK
The expected HSMCLK frequency for this performance level, in Hz.
Definition: PowerMSP432.h:470
PowerMSP432_PerfLevel * customPerfLevels
Pointer to an optional array of custom performance levels.
Definition: PowerMSP432.h:654
struct PowerMSP432_Freqs PowerMSP432_Freqs
Structure holding device frequencies (in Hz)
bool enableInterruptsCS
Boolean specifying if interrupts from the Clock System (CS) should be enabled for catching clock and ...
Definition: PowerMSP432.h:741
unsigned int SELM
The MCLK source.
Definition: PowerMSP432.h:392
unsigned int DIVS
The SMCLK source divider.
Definition: PowerMSP432.h:420
void PowerMSP432_initPolicy(void)
The Power Policy initialization function.
unsigned int DCORESEL
The DCO frequency range selection.
Definition: PowerMSP432.h:385
void(* Power_PolicyFxn)(void)
Power policy function pointer.
Definition: Power.h:105
bool useExtendedPerf
Boolean specifying if extended performance scaling features are to be supported.
Definition: PowerMSP432.h:675
Power global configuration (MSP432-specific)
Definition: PowerMSP432.h:500
unsigned int VCORE
The core voltage level.
Definition: PowerMSP432.h:372
bool enableParking
Boolean specifying if pull resistors should be automatically applied to input pins during PowerMSP432...
Definition: PowerMSP432.h:637
unsigned int BCLK
The BCLK frequency for this performance level. Currently only 32768 Hz is supported.
Definition: PowerMSP432.h:482
unsigned int activeState
The active state for the device.
Definition: PowerMSP432.h:365
bool enablePolicy
Boolean specifying if the Power Policy function is enabled.
Definition: PowerMSP432.h:555
unsigned int BCLK
Definition: PowerMSP432.h:495
unsigned int DIVM
The MCLK source divider.
Definition: PowerMSP432.h:399
void PowerMSP432_deepSleepPolicy(void)
The DEEPSLEEP Power Policy.
unsigned int ACLK
The ACLK frequency for this performance level. Currently only 32768 Hz is supported.
Definition: PowerMSP432.h:487
unsigned int DIVHS
The HSMCLK source divider.
Definition: PowerMSP432.h:413
Power_PolicyFxn policyFxn
The Power Policy function.
Definition: PowerMSP432.h:530
unsigned int SELA
The ACLK source.
Definition: PowerMSP432.h:434
unsigned int priorityInterruptsCS
The interrupt priority to be configured for CS interrupts.
Definition: PowerMSP432.h:745
unsigned int SELS
The HSMCLK and SMCLK source.
Definition: PowerMSP432.h:406
unsigned int ACLK
Definition: PowerMSP432.h:496
bool enableFlashBuffer
Boolean specifying if Flash read buffering should be enabled for this performance level...
Definition: PowerMSP432.h:456
unsigned int HFXTFREQ
The high frequency crystal (HFXT) frequency.
Definition: PowerMSP432.h:682
bool configurePinLFXT
Boolean specifying if the LFXT pin should be configured for LFXT function.
Definition: PowerMSP432.h:716
bool bypassHFXT
Boolean specifying if the HFXT pin should be configured for HFXT bypass.
Definition: PowerMSP432.h:707
Power_PolicyInitFxn policyInitFxn
The Power Policy&#39;s initialization function.
Definition: PowerMSP432.h:507
struct PowerMSP432_PerfLevel PowerMSP432_PerfLevel
Structure defining a performance level.
unsigned int MCLK
The expected MCLK frequency for this performance level, in Hz.
Definition: PowerMSP432.h:463
Structure defining a performance level.
Definition: PowerMSP432.h:356
unsigned int SMCLK
Definition: PowerMSP432.h:494
unsigned int initialPerfLevel
The initial performance level to be established during Power Manager initialization.
Definition: PowerMSP432.h:542
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