2 * -------------------------------------------
3 * MSP432 DriverLib - v01_04_00_18
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2015, Texas Instruments Incorporated
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
27 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
29 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
32 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
33 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 /* Standard Includes */
40 /* DriverLib Includes */
42 #include <interrupt.h>
46 static void __PSSUnlock()
48 PSS->rKEY.r = PSS_KEY_VALUE;
51 static void __PSSLock()
56 void PSS_enableHighSidePinToggle(bool activeLow)
61 PSS->rCTL0.r |= (SVMHOE | SVMHOUTPOLAL);
64 BITBAND_PERI(PSS->rCTL0.r, SVMHOUTPOLAL_OFS) = 0;
65 BITBAND_PERI(PSS->rCTL0.r, SVMHOE_OFS) = 1;
71 void PSS_disableHighSidePinToggle(void)
75 BITBAND_PERI(PSS->rCTL0.r, SVMHOE_OFS) = 0;
80 void PSS_enableHighSide(void)
84 BITBAND_PERI(PSS->rCTL0.r, SVSMHOFF_OFS) = 0;
89 void PSS_disableHighSide(void)
93 BITBAND_PERI(PSS->rCTL0.r, SVSMHOFF_OFS) = 1;
98 void PSS_setHighSidePerformanceMode(uint_fast8_t powerMode)
102 if (powerMode == PSS_FULL_PERFORMANCE_MODE)
103 BITBAND_PERI(PSS->rCTL0.r, SVSMHLP_OFS) = 0;
105 BITBAND_PERI(PSS->rCTL0.r, SVSMHLP_OFS) = 1;
110 uint_fast8_t PSS_getHighSidePerformanceMode(void)
112 if (BITBAND_PERI(PSS->rCTL0.r, SVSMHLP_OFS))
113 return PSS_NORMAL_PERFORMANCE_MODE;
115 return PSS_FULL_PERFORMANCE_MODE;
118 void PSS_enableHighSideMonitor(void)
122 BITBAND_PERI(PSS->rCTL0.r, SVSMHS_OFS) = 1;
127 void PSS_disableHighSideMonitor(void)
131 BITBAND_PERI(PSS->rCTL0.r, SVSMHS_OFS) = 0;
136 void PSS_setHighSideVoltageTrigger(uint_fast8_t triggerVoltage)
140 ASSERT(!(triggerVoltage & 0xF8))
142 PSS->rCTL0.b.bSVSMHTH = triggerVoltage & 0x07;
147 uint_fast8_t PSS_getHighSideVoltageTrigger(void)
149 return PSS->rCTL0.b.bSVSMHTH;
153 void PSS_enableLowSide(void)
157 BITBAND_PERI(PSS->rCTL0.r, SVSLOFF_OFS) = 0;
162 void PSS_disableLowSide(void)
166 BITBAND_PERI(PSS->rCTL0.r, SVSLOFF_OFS) = 1;
172 void PSS_setLowSidePerformanceMode(uint_fast8_t ui8PowerMode)
176 if (ui8PowerMode == PSS_FULL_PERFORMANCE_MODE)
177 BITBAND_PERI(PSS->rCTL0.r, SVSLLP_OFS) = 0;
179 BITBAND_PERI(PSS->rCTL0.r, SVSLLP_OFS) = 1;
184 uint_fast8_t PSS_getLowSidePerformanceMode(void)
186 if (BITBAND_PERI(PSS->rCTL0.r, SVSLLP_OFS))
187 return PSS_NORMAL_PERFORMANCE_MODE;
189 return PSS_FULL_PERFORMANCE_MODE;
193 void PSS_enableInterrupt(void)
196 BITBAND_PERI(PSS->rIE.r,SVSMHIE_OFS) = 1;
200 void PSS_disableInterrupt(void)
203 BITBAND_PERI(PSS->rIE.r,SVSMHIE_OFS) = 0;
207 uint32_t PSS_getInterruptStatus(void)
212 void PSS_clearInterruptFlag(void)
215 BITBAND_PERI(PSS->rCLRIFG.r,CLRSVSMHIFG_OFS) = 0;
219 void PSS_registerInterrupt(void (*intHandler)(void))
222 // Register the interrupt handler, returning an error if an error occurs.
224 Interrupt_registerInterrupt(INT_PSS, intHandler);
227 // Enable the system control interrupt.
229 Interrupt_enableInterrupt(INT_PSS);
232 void PSS_unregisterInterrupt(void)
235 // Disable the interrupt.
237 Interrupt_disableInterrupt(INT_PSS);
240 // Unregister the interrupt handler.
242 Interrupt_unregisterInterrupt(INT_PSS);