1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, 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  * --/COPYRIGHT--*/
32 #include <ti/devices/msp432p4xx/driverlib/ref_a.h>
33 #include <ti/devices/msp432p4xx/driverlib/debug.h>
34 
REF_A_setReferenceVoltage(uint_fast8_t referenceVoltageSelect)35 void REF_A_setReferenceVoltage(uint_fast8_t referenceVoltageSelect)
36 {
37     ASSERT(referenceVoltageSelect <= REF_A_VREF2_5V);
38 
39     REF_A->CTL0 = (REF_A->CTL0 &  ~REF_A_CTL0_VSEL_3) | referenceVoltageSelect;
40 }
41 
REF_A_disableTempSensor(void)42 void REF_A_disableTempSensor(void)
43 {
44     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_TCOFF_OFS) = 1;
45 }
46 
REF_A_enableTempSensor(void)47 void REF_A_enableTempSensor(void)
48 {
49     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_TCOFF_OFS) = 0;
50 }
51 
REF_A_enableReferenceVoltageOutput(void)52 void REF_A_enableReferenceVoltageOutput(void)
53 {
54     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_OUT_OFS) = 1;
55 }
56 
REF_A_disableReferenceVoltageOutput(void)57 void REF_A_disableReferenceVoltageOutput(void)
58 {
59     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_OUT_OFS) = 0;
60 }
61 
REF_A_enableReferenceVoltage(void)62 void REF_A_enableReferenceVoltage(void)
63 {
64     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_ON_OFS) = 1;
65 }
66 
REF_A_disableReferenceVoltage(void)67 void REF_A_disableReferenceVoltage(void)
68 {
69     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_ON_OFS) = 0;
70 }
71 
REF_A_getBandgapMode(void)72 uint_fast8_t REF_A_getBandgapMode(void)
73 {
74     return (REF_A->CTL0 & REF_A_CTL0_BGMODE);
75 }
76 
REF_A_isBandgapActive(void)77 bool REF_A_isBandgapActive(void)
78 {
79     return BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_BGACT_OFS);
80 }
81 
REF_A_isRefGenBusy(void)82 bool REF_A_isRefGenBusy(void)
83 {
84     return BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_GENBUSY_OFS);
85 }
86 
REF_A_isRefGenActive(void)87 bool REF_A_isRefGenActive(void)
88 {
89     return BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_GENACT_OFS);
90 }
91 
REF_A_getBufferedBandgapVoltageStatus(void)92 bool REF_A_getBufferedBandgapVoltageStatus(void)
93 {
94     return BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_BGRDY_OFS);
95 }
96 
REF_A_getVariableReferenceVoltageStatus(void)97 bool REF_A_getVariableReferenceVoltageStatus(void)
98 {
99     return BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_GENRDY_OFS);
100 }
101 
REF_A_setReferenceVoltageOneTimeTrigger(void)102 void REF_A_setReferenceVoltageOneTimeTrigger(void)
103 {
104     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_GENOT_OFS) = 1;
105 }
106 
REF_A_setBufferedBandgapVoltageOneTimeTrigger(void)107 void REF_A_setBufferedBandgapVoltageOneTimeTrigger(void)
108 {
109     BITBAND_PERI(REF_A->CTL0,REF_A_CTL0_BGOT_OFS) = 1;
110 }
111 
112