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 #ifndef __REF_B_H__
33 #define __REF_B_H__
34 
35 //*****************************************************************************
36 //
37 //! \addtogroup ref_api
38 //! @{
39 //
40 //*****************************************************************************
41 
42 #include <ti/devices/msp432p4xx/inc/msp.h>
43 #include <stdbool.h>
44 #include <stdint.h>
45 
46 //*****************************************************************************
47 //
48 // If building with a C++ compiler, make all of the definitions in this header
49 // have a C binding.
50 //
51 //*****************************************************************************
52 #ifdef __cplusplus
53 extern "C"
54 {
55 #endif
56 
57 //*****************************************************************************
58 //
59 //The following are values that can be passed to Ref_setReferenceVoltage()
60 //in the referenceVoltageSelect parameter.
61 //
62 //*****************************************************************************
63 #define REF_A_VREF1_2V  REF_A_CTL0_VSEL_0
64 #define REF_A_VREF1_45V REF_A_CTL0_VSEL_1
65 #define REF_A_VREF2_5V  REF_A_CTL0_VSEL_3
66 
67 //*****************************************************************************
68 //
69 //The following are values that are returned by Ref_getBandgapMode().
70 //
71 //*****************************************************************************
72 #define REF_A_STATICMODE 0x0
73 #define REF_A_SAMPLEMODE REF_A_CTL0_BGMODE
74 
75 //*****************************************************************************
76 //
77 //! Sets the reference voltage for the voltage generator.
78 //!
79 //! \param referenceVoltageSelect is the desired voltage to generate for a
80 //!       reference voltage.
81 //!        Valid values are:
82 //!        - \b REF_A_VREF1_2V [Default]
83 //!        - \b REF_A_VREF1_45V
84 //!        - \b REF_A_VREF2_5V
85 //!        Modified bits are \b REFVSEL of \b REFCTL0 register.
86 //!
87 //! This function sets the reference voltage generated by the voltage generator
88 //! to be used by other peripherals. This reference voltage will only be valid
89 //! while the REF module is in control.
90 //! Please note, if the \link REF_A_isRefGenBusy() \endlink returns \b REF_BUSY,
91 //! this function  will have no effect.
92 //!
93 //! \return none
94 //
95 //*****************************************************************************
96 extern void REF_A_setReferenceVoltage(uint_fast8_t referenceVoltageSelect);
97 
98 //*****************************************************************************
99 //
100 //! Disables the internal temperature sensor to save power consumption.
101 //!
102 //! This function is used to turn off the internal temperature sensor to save
103 //! on power consumption. The temperature sensor is enabled by default. Please
104 //! note, that giving ADC12 module control over the REF module, the state of the
105 //! temperature sensor is dependent on the controls of the ADC12 module.
106 //! Please note, if the \link REF_A_isRefGenBusy() \endlink  returns
107 //! \b REF_A_BUSY, this function will have no effect.
108 //!
109 //! Modified bits are \b REFTCOFF of \b REFCTL0 register.
110 //! \return none
111 //
112 //*****************************************************************************
113 extern void REF_A_disableTempSensor(void);
114 
115 //*****************************************************************************
116 //
117 //! Enables the internal temperature sensor.
118 //!
119 //! This function is used to turn on the internal temperature sensor to use by
120 //! other peripherals. The temperature sensor is enabled by default.
121 //! Please note, if the \link REF_A_isRefGenBusy() \endlink returns
122 //! \b REF_A_BUSY, this function will have no effect.
123 //!
124 //! Modified bits are \b REFTCOFF of \b REFCTL0 register.
125 //!
126 //! \return none
127 //
128 //*****************************************************************************
129 extern void REF_A_enableTempSensor(void);
130 
131 //*****************************************************************************
132 //
133 //! Outputs the reference voltage to an output pin.
134 //!
135 //! This function is used to output the reference voltage being generated to an
136 //! output pin. Please note, the output pin is device specific. Please note,
137 //! that giving ADC12 module control over the REF module, the state of the
138 //! reference voltage as an output to a pin is dependent on the controls of the
139 //! ADC12 module.
140 //! Please note, if the \link REF_A_isRefGenBusy() \endlink returns
141 //! \b REF_A_BUSY, this function will have no effect.
142 //!
143 //! Modified bits are \b REFOUT of \b REFCTL0 register.
144 //! \return none
145 //
146 //*****************************************************************************
147 extern void REF_A_enableReferenceVoltageOutput(void);
148 
149 //*****************************************************************************
150 //
151 //! Disables the reference voltage as an output to a pin.
152 //!
153 //! This function is used to disables the reference voltage being generated to
154 //! be given to an output pin.
155 //! Please note, if the \link REF_A_isRefGenBusy() \endlink returns
156 //! \b REF_A_BUSY, this function will have no effect.
157 //!
158 //! Modified bits are \b REFOUT of \b REFCTL0 register.
159 //! \return none
160 //
161 //*****************************************************************************
162 extern void REF_A_disableReferenceVoltageOutput(void);
163 
164 //*****************************************************************************
165 //
166 //! Enables the reference voltage to be used by peripherals.
167 //!
168 //! This function is used to enable the generated reference voltage to be used
169 //! other peripherals or by an output pin, if enabled. Please note, that giving
170 //! ADC12 module control over the REF module, the state of the reference voltage
171 //! is dependent on the controls of the ADC12 module.
172 //! Please note, if the \link REF_A_isRefGenBusy() \endlink returns
173 //! REF_A_BUSY, this function will have no effect.
174 //!
175 //! Modified bits are \b REFON of \b REFCTL0 register.
176 //! \return none
177 //
178 //*****************************************************************************
179 extern void REF_A_enableReferenceVoltage(void);
180 
181 //*****************************************************************************
182 //
183 //! Disables the reference voltage.
184 //!
185 //! This function is used to disable the generated reference voltage.
186 //! Please note, if the \link REF_A_isRefGenBusy() \endlink returns
187 //!  \b  REF_A_BUSY, this function will have no effect.
188 //!
189 //! Modified bits are \b REFON of \b REFCTL0 register.
190 //! \return none
191 //
192 //*****************************************************************************
193 extern void REF_A_disableReferenceVoltage(void);
194 
195 //*****************************************************************************
196 //
197 //! Returns the bandgap mode of the REF module.
198 //!
199 //! This function is used to return the bandgap mode of the REF module,
200 //! requested by the peripherals using the bandgap. If a peripheral requests
201 //! static mode, then the bandgap mode will be static for all modules, whereas
202 //! if all of the peripherals using the bandgap request sample mode, then that
203 //! will be the mode returned. Sample mode allows the bandgap to be active only
204 //! when necessary to save on power consumption, static mode requires the
205 //! bandgap to be active until no peripherals are using it anymore.
206 //!
207 //! \return The bandgap mode of the REF module:
208 //!        - \b REF_A_STATICMODE if the bandgap is operating in static mode
209 //!        - \b REF_A_SAMPLEMODE if the bandgap is operating in sample mode
210 //
211 //*****************************************************************************
212 extern uint_fast8_t REF_A_getBandgapMode(void);
213 
214 //*****************************************************************************
215 //
216 //! Returns the active status of the bandgap in the REF module.
217 //!
218 //! This function is used to return the active status of the bandgap in the REF
219 //! module. If the bandgap is in use by a peripheral, then the status will be
220 //! seen as active.
221 //!
222 //! \return true if the bandgap is being used, false otherwise
223 //
224 //*****************************************************************************
225 extern bool REF_A_isBandgapActive(void);
226 
227 //*****************************************************************************
228 //
229 //! Returns the busy status of the reference generator in the REF module.
230 //!
231 //! This function is used to return the busy status of the reference generator
232 //! in the REF module. If the ref. generator is in use by a peripheral, then the
233 //! status will be seen as busy.
234 //!
235 //! \return true if the reference generator is being used, false otherwise.
236 //*****************************************************************************
237 extern bool REF_A_isRefGenBusy(void);
238 
239 //*****************************************************************************
240 //
241 //! Returns the active status of the reference generator in the REF module.
242 //!
243 //! This function is used to return the active status of the reference generator
244 //! in the REF module. If the ref. generator is on and ready to use, then the
245 //! status will be seen as active.
246 //!
247 //! \return true if the reference generator is active, false otherwise.
248 //
249 //*****************************************************************************
250 extern bool REF_A_isRefGenActive(void);
251 
252 //*****************************************************************************
253 //
254 //! Returns the busy status of the reference generator in the REF module.
255 //!
256 //! This function is used to return the buys status of the buffered bandgap
257 //! voltage in the REF module. If the ref. generator is on and ready to use,
258 //! then the status will be seen as active.
259 //!
260 //! \return true if the buffered bandgap voltage is ready to be used, false
261 //!         otherwise
262 //
263 //*****************************************************************************
264 extern bool REF_A_getBufferedBandgapVoltageStatus(void);
265 
266 //*****************************************************************************
267 //
268 //! Returns the busy status of the variable reference voltage in the REF module.
269 //!
270 //! This function is used to return the buys status of the variable reference
271 //! voltage in the REF module. If the ref. generator is on and ready to use,
272 //! then the status will be seen as active.
273 //!
274 //! \return true if the variable bandgap voltage is ready to be used, false
275 //!         otherwise
276 //
277 //*****************************************************************************
278 extern bool REF_A_getVariableReferenceVoltageStatus(void);
279 
280 //*****************************************************************************
281 //
282 //! Enables the one-time trigger of the reference voltage.
283 //!
284 //! Triggers the one-time generation of the variable reference voltage.  Once
285 //! the reference voltage request is set, this bit is cleared by hardware
286 //!
287 //! Modified bits are \b REFGENOT of \b REFCTL0 register.
288 //!
289 //! \return none
290 //
291 //*****************************************************************************
292 extern void REF_A_setReferenceVoltageOneTimeTrigger(void);
293 
294 //*****************************************************************************
295 //
296 //! Enables the one-time trigger of the buffered bandgap voltage.
297 //!
298 //! Triggers the one-time generation of the buffered bandgap voltage.  Once
299 //! the buffered bandgap voltage request is set, this bit is cleared by hardware
300 //!
301 //! Modified bits are \b RefGOT of \b REFCTL0 register.
302 //!
303 //! \return none
304 //
305 //*****************************************************************************
306 extern void REF_A_setBufferedBandgapVoltageOneTimeTrigger(void);
307 
308 /* Defines for future devices that might have multiple instances */
309 #define REF_A_setReferenceVoltageMultipleInstance(a,b) REF_A_setReferenceVoltage(b)
310 #define REF_A_disableTempSensorMultipleInstance(a) REF_A_disableTempSensor()
311 #define REF_A_enableTempSensorMultipleInstance(a) REF_A_enableTempSensor()
312 #define REF_A_enableReferenceVoltageOutputMultipleInstance(a) REF_A_enableReferenceVoltageOutput()
313 #define REF_A_disableReferenceVoltageOutputMultipleInstance(a) REF_A_disableReferenceVoltageOutput()
314 #define REF_A_enableReferenceVoltageMultipleInstance(a) REF_A_enableReferenceVoltage()
315 #define REF_A_disableReferenceVoltageMultipleInstance(a) REF_A_disableReferenceVoltage()
316 #define REF_A_getBandgapModeMultipleInstance(a) REF_A_getBandgapMode()
317 #define REF_A_isBandgapActiveMultipleInstance(a) REF_A_isBandgapActive()
318 #define REF_A_isRefGenBusyMultipleInstance(a) REF_A_isRefGenBusy()
319 #define REF_A_isRefGenActiveMultipleInstance(a) REF_A_isRefGenActive()
320 #define REF_A_getBufferedBandgapVoltageStatusMultipleInstance(a) REF_A_getBufferedBandgapVoltageStatus()
321 #define REF_A_getVariableReferenceVoltageStatusMultipleInstance(a) REF_A_getVariableReferenceVoltageStatus()
322 #define REF_A_setReferenceVoltageOneTimeTriggerMultipleInstance(a) REF_A_setReferenceVoltageOneTimeTrigger()
323 #define REF_A_setBufferedBandgapVoltageOneTimeTriggerMultipleInstance(a) REF_A_setBufferedBandgapVoltageOneTimeTrigger()
324 
325 //*****************************************************************************
326 //
327 // Mark the end of the C bindings section for C++ compilers.
328 //
329 //*****************************************************************************
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 //*****************************************************************************
335 //
336 // Close the Doxygen group.
337 //! @}
338 //
339 //*****************************************************************************
340 
341 #endif // __REF_A_H__
342