PowerMSP432.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2019, 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  */
32 /*!****************************************************************************
33  * @file PowerMSP432.h
34  * @brief Power Driver interface for the MSP432P4
35  *
36  * The Power header file should be included in an application as follows:
37  * @code
38  * #include <ti/drivers/Power.h>
39  * #include <ti/drivers/power/PowerMSP432.h>
40  * @endcode
41  *
42  * Refer to @ref Power.h for a complete description of APIs.
43  *
44  ******************************************************************************
45  */
46 
47 #ifndef ti_drivers_power_PowerMSP432__include
48 #define ti_drivers_power_PowerMSP432__include
49 
50 #include <stdint.h>
51 
52 #include <ti/drivers/utils/List.h>
53 #include <ti/drivers/Power.h>
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* latency times in microseconds (derived from device datasheet) */
60 
62 #define PowerMSP432_RESUMETIMESLEEP 32
63 
65 #define PowerMSP432_TOTALTIMESLEEP 40
66 
68 #define PowerMSP432_RESUMETIMEDEEPSLEEP_0 16
69 
71 #define PowerMSP432_TOTALTIMEDEEPSLEEP_0 40
72 
74 #define PowerMSP432_RESUMETIMEDEEPSLEEP_1 16
75 
77 #define PowerMSP432_TOTALTIMEDEEPSLEEP_1 40
78 
79 /* Power resources (for declaring dependencies) */
80 #define PowerMSP432_PERIPH_ADC14 0
81 
83 #define PowerMSP432_PERIPH_DMA 1
84 
86 #define PowerMSP432_PERIPH_EUSCI_A0 2
87 
89 #define PowerMSP432_PERIPH_EUSCI_A1 3
90 
92 #define PowerMSP432_PERIPH_EUSCI_A2 4
93 
95 #define PowerMSP432_PERIPH_EUSCI_A3 5
96 
98 #define PowerMSP432_PERIPH_EUSCI_B0 6
99 
101 #define PowerMSP432_PERIPH_EUSCI_B1 7
102 
104 #define PowerMSP432_PERIPH_EUSCI_B2 8
105 
107 #define PowerMSP432_PERIPH_EUSCI_B3 9
108 
110 #define PowerMSP432_PERIPH_TIMER_A0 10
111 
113 #define PowerMSP432_PERIPH_TIMER_A1 11
114 
116 #define PowerMSP432_PERIPH_TIMER_A2 12
117 
119 #define PowerMSP432_PERIPH_TIMER_A3 13
120 
122 #define PowerMSP432_PERIPH_TIMER_T32 14
123 
126 /* Power constraints */
127 #define PowerMSP432_DISALLOW_SLEEP 0
128 
130 #define PowerMSP432_DISALLOW_DEEPSLEEP_0 1
131 
133 #define PowerMSP432_DISALLOW_DEEPSLEEP_1 2
134 
136 #define PowerMSP432_DISALLOW_SHUTDOWN_0 3
137 
139 #define PowerMSP432_DISALLOW_SHUTDOWN_1 4
140 
142 #define PowerMSP432_DISALLOW_PERFLEVEL_0 5
143 
145 #define PowerMSP432_DISALLOW_PERFLEVEL_1 6
146 
148 #define PowerMSP432_DISALLOW_PERFLEVEL_2 7
149 
151 #define PowerMSP432_DISALLOW_PERFLEVEL_3 8
152 
154 #define PowerMSP432_DISALLOW_PERFLEVEL_4 9
155 
157 #define PowerMSP432_DISALLOW_PERFLEVEL_5 10
158 
160 #define PowerMSP432_DISALLOW_PERFLEVEL_6 11
161 
163 #define PowerMSP432_DISALLOW_PERFLEVEL_7 12
164 
166 #define PowerMSP432_DISALLOW_PERF_CHANGES 13
167 
169 /* \cond */
170 #define PowerMSP432_NUMCONSTRAINTS 14
171 /* \endcond */
172 
173 /*
174  * Power events
175  *
176  * Each event ID must be a power of two and sequential without any gaps
177  */
178 #define PowerMSP432_ENTERING_SLEEP 0x1
179 
181 #define PowerMSP432_ENTERING_DEEPSLEEP 0x2
182 
184 #define PowerMSP432_ENTERING_SHUTDOWN 0x4
185 
187 #define PowerMSP432_AWAKE_SLEEP 0x8
188 
190 #define PowerMSP432_AWAKE_DEEPSLEEP 0x10
191 
193 #define PowerMSP432_START_CHANGE_PERF_LEVEL 0x20
194 
196 #define PowerMSP432_DONE_CHANGE_PERF_LEVEL 0x40
197 
199 /* \cond */
200 #define PowerMSP432_NUMEVENTS 7
201 /* \endcond */
202 
203 /* Power sleep states */
204 #define PowerMSP432_SLEEP 0x1
205 #define PowerMSP432_DEEPSLEEP_0 0x2
206 #define PowerMSP432_DEEPSLEEP_1 0x4
208 /* Power shutdown states */
209 #define PowerMSP432_SHUTDOWN_0 0x0
210 #define PowerMSP432_SHUTDOWN_1 0x1
212 /* Flag to indicate a custom, tuned DCO frequency */
213 #define CS_DCO_TUNE_FREQ 0x7
352 typedef struct PowerMSP432_PerfLevel {
353 
369  unsigned int activeState;
386  unsigned int VCORE;
392  unsigned int clockSource;
399  unsigned int DCORESEL;
406  unsigned int SELM;
413  unsigned int DIVM;
420  unsigned int SELS;
427  unsigned int DIVHS;
434  unsigned int DIVS;
441  unsigned int SELB;
448  unsigned int SELA;
455  unsigned int DIVA;
473  unsigned int flashWaitStates;
504  unsigned int MCLK;
511  unsigned int HSMCLK;
518  unsigned int SMCLK;
523  unsigned int BCLK;
528  unsigned int ACLK;
534  unsigned int tuneFreqDCO;
536 
538 typedef struct PowerMSP432_Freqs {
539  unsigned int MCLK;
540  unsigned int HSMCLK;
541  unsigned int SMCLK;
542  unsigned int BCLK;
543  unsigned int ACLK;
545 
547 typedef struct PowerMSP432_ConfigV1 {
589  unsigned int initialPerfLevel;
684  bool enableParking; /* enables automatic pin parking during LPM3 and LPM4 */
695  void (*resumeShutdownHookFxn)(void);
705  uint32_t numCustom;
729  unsigned int HFXTFREQ;
736  unsigned int LFXTDRIVE;
792  unsigned int priorityInterruptsCS;
797  void (*isrCS)(void);
799 
804 typedef struct PowerMSP432_ModuleState {
805  List_List notifyList;
806  uint32_t constraintMask;
807  unsigned int state;
808  unsigned int currentPerfLevel;
809  bool enablePolicy;
810  bool perfInitialized;
811  bool initialized;
812  uint8_t constraintCounts[PowerMSP432_NUMCONSTRAINTS];
813  Power_PolicyFxn policyFxn;
814 } PowerMSP432_ModuleState;
823 void PowerMSP432_initPolicy(void);
824 
840 void PowerMSP432_sleepPolicy(void);
841 
861 void PowerMSP432_deepSleepPolicy(void);
862 
869 void PowerMSP432_updateFreqs(PowerMSP432_Freqs *freqs);
870 
876 void PowerMSP432_schedulerDisable(void);
877 
883 void PowerMSP432_schedulerRestore(void);
884 
885 /* function to get the number of performance levels */
886 uint_fast16_t PowerMSP432_getNumPerfLevels(void);
887 
888 /* function to get the frequencies for a specific performance level */
889 int_fast16_t PowerMSP432_getFreqs(uint_fast16_t level,
890  PowerMSP432_Freqs * freqs);
891 
892 /*
893  * On MSP432 peripheral clocks are managed automatically by the device; there
894  * is no need for software control. Use #defines for the dependency APIs to
895  * eliminate any footprint.
896  */
897 /* \cond */
898 #define Power_getDependencyCount(resourceId) Power_EINVALIDINPUT
899 #define Power_releaseDependency(resourceId) Power_EINVALIDINPUT
900 #define Power_setDependency(resourceId) Power_EINVALIDINPUT
901 /* \endcond */
902 
903 #ifdef __cplusplus
904 }
905 #endif
906 
907 #endif /* ti_drivers_PowerMSP432_PowerMSP432__include */
unsigned int SMCLK
The expected SMCLK frequency for this performance level, in Hz.
Definition: PowerMSP432.h:518
bool enablePerf
Boolean specifying if performance scaling is enabled.
Definition: PowerMSP432.h:613
uint32_t numCustom
Number of custom performance levels.
Definition: PowerMSP432.h:705
unsigned int clockSource
The clock source for this performance level.
Definition: PowerMSP432.h:392
Structure holding device frequencies (in Hz)
Definition: PowerMSP432.h:538
void PowerMSP432_sleepPolicy(void)
The SLEEP Power Policy.
Definition: List.h:131
unsigned int SELB
The BCLK source.
Definition: PowerMSP432.h:441
unsigned int LFXTDRIVE
The low frequency crystal (LFXT) drive level.
Definition: PowerMSP432.h:736
unsigned int MCLK
Definition: PowerMSP432.h:539
struct PowerMSP432_ConfigV1 PowerMSP432_ConfigV1
Power global configuration (MSP432-specific)
unsigned int DIVA
The ACLK source divider.
Definition: PowerMSP432.h:455
unsigned int HSMCLK
Definition: PowerMSP432.h:540
bool bypassLFXT
Boolean specifying if the LFXT pin should be configured for LFXT bypass.
Definition: PowerMSP432.h:772
void(* Power_PolicyInitFxn)(void)
Power policy initialization function pointer.
Definition: Power.h:402
Power Manager.
unsigned int flashWaitStates
The number of Flash wait-states to be used for this performance level.
Definition: PowerMSP432.h:473
bool configurePinHFXT
Boolean specifying if the HFXT pin should be configured for HFXT function.
Definition: PowerMSP432.h:745
unsigned int HSMCLK
The expected HSMCLK frequency for this performance level, in Hz.
Definition: PowerMSP432.h:511
PowerMSP432_PerfLevel * customPerfLevels
Pointer to an optional array of custom performance levels.
Definition: PowerMSP432.h:701
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:788
unsigned int SELM
The MCLK source.
Definition: PowerMSP432.h:406
unsigned int DIVS
The SMCLK source divider.
Definition: PowerMSP432.h:434
unsigned int tuneFreqDCO
The target center frequency for custom tuning of the DCO, in Hz. This frequency value is used only wh...
Definition: PowerMSP432.h:534
void PowerMSP432_initPolicy(void)
The Power Policy initialization function.
unsigned int DCORESEL
The DCO frequency range selection.
Definition: PowerMSP432.h:399
void(* Power_PolicyFxn)(void)
Power policy function pointer.
Definition: Power.h:407
bool useExtendedPerf
Boolean specifying if extended performance scaling features are to be supported.
Definition: PowerMSP432.h:722
Power global configuration (MSP432-specific)
Definition: PowerMSP432.h:547
unsigned int VCORE
The core voltage level.
Definition: PowerMSP432.h:386
bool enableParking
Boolean specifying if pull resistors should be automatically applied to input pins during PowerMSP432...
Definition: PowerMSP432.h:684
unsigned int BCLK
The BCLK frequency for this performance level. Currently only 32768 Hz is supported.
Definition: PowerMSP432.h:523
unsigned int activeState
The active state for the device.
Definition: PowerMSP432.h:369
bool enablePolicy
Boolean specifying if the Power Policy function is enabled.
Definition: PowerMSP432.h:602
unsigned int BCLK
Definition: PowerMSP432.h:542
unsigned int DIVM
The MCLK source divider.
Definition: PowerMSP432.h:413
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:528
unsigned int DIVHS
The HSMCLK source divider.
Definition: PowerMSP432.h:427
Power_PolicyFxn policyFxn
The Power Policy function.
Definition: PowerMSP432.h:577
unsigned int SELA
The ACLK source.
Definition: PowerMSP432.h:448
unsigned int priorityInterruptsCS
The interrupt priority to be configured for CS interrupts.
Definition: PowerMSP432.h:792
unsigned int SELS
The HSMCLK and SMCLK source.
Definition: PowerMSP432.h:420
unsigned int ACLK
Definition: PowerMSP432.h:543
bool enableFlashBuffer
Boolean specifying if Flash read buffering should be enabled for this performance level...
Definition: PowerMSP432.h:497
unsigned int HFXTFREQ
The high frequency crystal (HFXT) frequency.
Definition: PowerMSP432.h:729
bool configurePinLFXT
Boolean specifying if the LFXT pin should be configured for LFXT function.
Definition: PowerMSP432.h:763
bool bypassHFXT
Boolean specifying if the HFXT pin should be configured for HFXT bypass.
Definition: PowerMSP432.h:754
Power_PolicyInitFxn policyInitFxn
The Power Policy&#39;s initialization function.
Definition: PowerMSP432.h:554
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:504
Structure defining a performance level.
Definition: PowerMSP432.h:352
unsigned int SMCLK
Definition: PowerMSP432.h:541
unsigned int initialPerfLevel
The initial performance level to be established during Power Manager initialization.
Definition: PowerMSP432.h:589
Linked List interface for use in drivers.
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale