2 * -------------------------------------------
3 * MSP432 DriverLib - v3_10_00_09
4 * -------------------------------------------
6 * --COPYRIGHT--,BSD,BSD
7 * Copyright (c) 2014, 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->KEY = PSS_KEY_VALUE;
51 static void __PSSLock()
57 void PSS_enableForcedDCDCOperation(void)
61 BITBAND_PERI(PSS->CTL0, PSS_CTL0_DCDC_FORCE_OFS) = 1;
66 void PSS_disableForcedDCDCOperation(void)
70 BITBAND_PERI(PSS->CTL0, PSS_CTL0_DCDC_FORCE_OFS) = 0;
76 void PSS_enableHighSidePinToggle(bool activeLow)
81 PSS->CTL0 |= (PSS_CTL0_SVMHOE | PSS_CTL0_SVMHOUTPOLAL);
84 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVMHOUTPOLAL_OFS) = 0;
85 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVMHOE_OFS) = 1;
91 void PSS_disableHighSidePinToggle(void)
95 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVMHOE_OFS) = 0;
100 void PSS_enableHighSide(void)
104 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVSMHOFF_OFS) = 0;
109 void PSS_disableHighSide(void)
113 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVSMHOFF_OFS) = 1;
118 void PSS_setHighSidePerformanceMode(uint_fast8_t powerMode)
122 if (powerMode == PSS_FULL_PERFORMANCE_MODE)
123 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVSMHLP_OFS) = 0;
125 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVSMHLP_OFS) = 1;
130 uint_fast8_t PSS_getHighSidePerformanceMode(void)
132 if (BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVSMHLP_OFS))
133 return PSS_NORMAL_PERFORMANCE_MODE;
135 return PSS_FULL_PERFORMANCE_MODE;
138 void PSS_enableHighSideMonitor(void)
142 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVSMHS_OFS) = 1;
147 void PSS_disableHighSideMonitor(void)
151 BITBAND_PERI(PSS->CTL0, PSS_CTL0_SVSMHS_OFS) = 0;
156 void PSS_setHighSideVoltageTrigger(uint_fast8_t triggerVoltage)
160 ASSERT(!(triggerVoltage & 0xF8))
162 PSS->CTL0 &= ~PSS_CTL0_SVSMHTH_MASK;
163 PSS->CTL0 |= (triggerVoltage & 0x07) << PSS_CTL0_SVSMHTH_OFS;
168 uint_fast8_t PSS_getHighSideVoltageTrigger(void)
170 return (uint_fast8_t)((PSS->CTL0 & PSS_CTL0_SVSMHTH_MASK)
171 >> PSS_CTL0_SVSMHTH_OFS);
174 void PSS_enableInterrupt(void)
177 BITBAND_PERI(PSS->IE,PSS_IE_SVSMHIE_OFS) = 1;
181 void PSS_disableInterrupt(void)
184 BITBAND_PERI(PSS->IE,PSS_IE_SVSMHIE_OFS) = 0;
188 uint32_t PSS_getInterruptStatus(void)
193 void PSS_clearInterruptFlag(void)
196 BITBAND_PERI(PSS->CLRIFG,PSS_CLRIFG_CLRSVSMHIFG_OFS) = 0;
200 void PSS_registerInterrupt(void (*intHandler)(void))
203 // Register the interrupt handler, returning an error if an error occurs.
205 Interrupt_registerInterrupt(INT_PSS, intHandler);
208 // Enable the system control interrupt.
210 Interrupt_enableInterrupt(INT_PSS);
213 void PSS_unregisterInterrupt(void)
216 // Disable the interrupt.
218 Interrupt_disableInterrupt(INT_PSS);
221 // Unregister the interrupt handler.
223 Interrupt_unregisterInterrupt(INT_PSS);