BSP430  20141115
Board Support Package for MSP430 microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pmm.h
Go to the documentation of this file.
1 /* Copyright 2012-2014, Peter A. Bigot
2  *
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 are met:
7  *
8  * * Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * * Neither the name of the software nor the names of its contributors may be
16  * used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  */
31 
63 #ifndef BSP430_PERIPH_PMM_H
64 #define BSP430_PERIPH_PMM_H
65 
66 #include <bsp430/periph.h>
67 
74 #define BSP430_MODULE_PMM (defined(__MSP430_HAS_PMM__) \
75  || defined(__MSP430_HAS_PMM_FR5xx__) \
76  || defined(__MSP430_HAS_PMM_FRAM__))
77 
87 #define BSP430_MODULE_PMM_FRAM (defined(__MSP430_HAS_PMM_FR5xx__) \
88  || defined(__MSP430_HAS_PMM_FRAM__))
89 
97 #define BSP430_PMM_SUPPORTS_COREV ((BSP430_MODULE_PMM - 0) && ! (BSP430_MODULE_PMM_FRAM - 0))
98 
106 #define BSP430_PMM_SUPPORTS_SVSM ((BSP430_MODULE_PMM - 0) && ! (BSP430_MODULE_PMM_FRAM - 0))
107 
108 #if defined(BSP430_DOXYGEN) || (BSP430_MODULE_PMM - 0)
109 
110 #if defined(BSP430_DOXYGEN) || defined(LOCKLPM5)
111 /* LOCKLPM5 is the clue to whether LPMx.5 mode is supported. The
112  * PM5CTL0 register exists on all MCUs with PMM except the pre-A
113  * MSP430F54xx and the CC430x1xx chips (at least, it is not declared
114  * on those chips). */
115 
133 #define BSP430_PMM_ENTER_LPMXp5_NI() do { \
134  PMMCTL0_H = PMMPW_H; \
135  PMMCTL0 = PMMPW | PMMREGOFF; \
136  PMMCTL0_H = !PMMPW_H; \
137  } while (0)
138 
139 #endif /* LOCKLPM5 */
140 
163 #if defined(BSP430_DOXYGEN) || defined(LOCKLPM5)
164 #define BSP430_PMM_CLEAR_LOCKLPM5() do { \
165  PMMCTL0_H = PMMPW_H; \
166  PM5CTL0 &= ~LOCKLPM5; \
167  PMMCTL0_H = !PMMPW_H; \
168  } while (0)
169 #else /* LOCKLPM5 */
170 #define BSP430_PMM_CLEAR_LOCKLPM5() do { } while (0)
171 #endif /* LOCKLPM5 */
172 
173 #if defined(BSP430_DOXYGEN) || (BSP430_PMM_SUPPORTS_SVSM - 0)
174 
220 #define BSP430_PMM_SET_SVSMCTL_NI(hctl_,lctl_) do { \
221  PMMCTL0_H = PMMPW_H; \
222  SVSMHCTL = (hctl_); \
223  SVSMLCTL = (lctl_); \
224  PMMCTL0_H = !PMMPW_H; \
225  } while (0)
226 #endif /* BSP430_PMM_SUPPORTS_SVSM */
227 
229 static BSP430_CORE_INLINE
230 void
232 {
233  PMMCTL0 = PMMPW | PMMSWBOR;
234 }
235 
237 static BSP430_CORE_INLINE
238 void
240 {
241  PMMCTL0 = PMMPW | PMMSWPOR;
242 }
243 
244 #if defined(BSP430_DOXYGEN) || (BSP430_PMM_SUPPORTS_COREV - 0)
245 
259 #if defined(BSP430_DOXYGEN)
260 #define BSP430_PMM_COREV_FOR_MCLK(mclk_) include <bsp430/platform.h>
261 #endif /* BSP430_PMM_COREV_FOR_MCLK */
262 
284 int iBSP430pmmSetCoreVoltageLevel_ni (unsigned int target_level);
285 
286 #endif /* PMM not FRAM */
287 
288 #endif /* BSP430_MODULE_PMM */
289 
290 #endif /* BSP430_PERIPH_PMM_H */
int iBSP430pmmSetCoreVoltageLevel_ni(unsigned int target_level)
#define BSP430_CORE_INLINE
Definition: core.h:439
Generic peripheral support for MSP430 MCUs.
static BSP430_CORE_INLINE void vBSP430pmmInducePOR(void)
Definition: pmm.h:239
static BSP430_CORE_INLINE void vBSP430pmmInduceBOR(void)
Definition: pmm.h:231