]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MSP430FR5969_LaunchPad/driverlib/MSP430FR5xx_6xx/pmm.c
Start of an MSP430FR5969 IAR project - currently running Blinky only.
[freertos] / FreeRTOS / Demo / MSP430FR5969_LaunchPad / driverlib / MSP430FR5xx_6xx / pmm.c
1 /* --COPYRIGHT--,BSD\r
2  * Copyright (c) 2014, Texas Instruments Incorporated\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  *\r
9  * *  Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  * *  Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the distribution.\r
15  *\r
16  * *  Neither the name of Texas Instruments Incorporated nor the names of\r
17  *    its contributors may be used to endorse or promote products derived\r
18  *    from this software without specific prior written permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  * --/COPYRIGHT--*/\r
32 //*****************************************************************************\r
33 //\r
34 // pmm.c - Driver for the pmm Module.\r
35 //\r
36 //*****************************************************************************\r
37 \r
38 //*****************************************************************************\r
39 //\r
40 //! \addtogroup pmm_api pmm\r
41 //! @{\r
42 //\r
43 //*****************************************************************************\r
44 \r
45 #include "inc/hw_regaccess.h"\r
46 #include "inc/hw_memmap.h"\r
47 \r
48 #ifdef __MSP430_HAS_PMM_FRAM__\r
49 #include "pmm.h"\r
50 \r
51 #include <assert.h>\r
52 \r
53 void PMM_enableLowPowerReset(void)\r
54 {\r
55     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
56     HWREG8(PMM_BASE + OFS_PMMCTL0) |= PMMLPRST;\r
57     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
58 }\r
59 \r
60 void PMM_disableLowPowerReset(void)\r
61 {\r
62     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
63     HWREG8(PMM_BASE + OFS_PMMCTL0) &= ~PMMLPRST;\r
64     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
65 }\r
66 \r
67 void PMM_enableSVSH(void)\r
68 {\r
69     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
70     HWREG8(PMM_BASE + OFS_PMMCTL0_L) |= SVSHE;\r
71     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
72 }\r
73 \r
74 void PMM_disableSVSH(void)\r
75 {\r
76     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
77     HWREG8(PMM_BASE + OFS_PMMCTL0_L) &= ~SVSHE;\r
78     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
79 }\r
80 \r
81 void PMM_turnOnRegulator(void)\r
82 {\r
83     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
84     HWREG8(PMM_BASE + OFS_PMMCTL0) &= ~PMMREGOFF;\r
85     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
86 }\r
87 \r
88 void PMM_turnOffRegulator(void)\r
89 {\r
90     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
91     HWREG8(PMM_BASE + OFS_PMMCTL0) |= PMMREGOFF;\r
92     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
93 }\r
94 \r
95 void PMM_trigPOR(void)\r
96 {\r
97     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
98     HWREG8(PMM_BASE + OFS_PMMCTL0) |= PMMSWPOR;\r
99     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
100 }\r
101 \r
102 void PMM_trigBOR(void)\r
103 {\r
104     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
105     HWREG8(PMM_BASE + OFS_PMMCTL0) |= PMMSWBOR;\r
106     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
107 }\r
108 \r
109 void PMM_clearInterrupt(uint16_t mask)\r
110 {\r
111     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = PMMPW_H;\r
112     HWREG16(PMM_BASE + OFS_PMMIFG) &= ~mask;\r
113     HWREG8(PMM_BASE + OFS_PMMCTL0_H) = 0x00;\r
114 }\r
115 \r
116 uint16_t PMM_getInterruptStatus(uint16_t mask)\r
117 {\r
118     return ((HWREG16(PMM_BASE + OFS_PMMIFG)) & mask);\r
119 }\r
120 \r
121 void PMM_unlockLPM5(void)\r
122 {\r
123     HWREG8(PMM_BASE + OFS_PM5CTL0) &= ~LOCKLPM5;\r
124 }\r
125 \r
126 #endif\r
127 //*****************************************************************************\r
128 //\r
129 //! Close the doxygen group for pmm_api\r
130 //! @}\r
131 //\r
132 //*****************************************************************************\r