MSP430 DriverLib for MSP430FR2xx_4xx Devices  2.91.13.01
sac.h
1 //*****************************************************************************
2 //
3 // sac.h - Driver for the SAC Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_SAC_H__
8 #define __MSP430WARE_SAC_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_SACx__
13 
14 //*****************************************************************************
15 //
16 // If building with a C++ compiler, make all of the definitions in this header
17 // have a C binding.
18 //
19 //*****************************************************************************
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 //*****************************************************************************
26 //
27 // The following are values that can be passed to the positiveInput parameter
28 // for functions: SAC_OA_init().
29 //
30 //*****************************************************************************
31 #define SAC_OA_POSITIVE_INPUT_SOURCE_EXTERNAL 0x0
32 #define SAC_OA_POSITIVE_INPUT_SOURCE_DAC PSEL0
33 #define SAC_OA_POSITIVE_INPUT_SOURCE_PAIR_OA PSEL1
34 #define SAC_OA_POSITIVE_INPUT_SOURCE_DISCONNECTED 0xF
35 
36 //*****************************************************************************
37 //
38 // The following are values that can be passed to the negativeInput parameter
39 // for functions: SAC_OA_init().
40 //
41 //*****************************************************************************
42 #define SAC_OA_NEGATIVE_INPUT_SOURCE_EXTERNAL 0x0
43 #define SAC_OA_NEGATIVE_INPUT_SOURCE_PGA NSEL0
44 #define SAC_OA_NEGATIVE_INPUT_SOURCE_DISCONNECTED 0xF
45 
46 //*****************************************************************************
47 //
48 // The following are values that can be passed to the powerMode parameter for
49 // functions: SAC_OA_selectPowerMode().
50 //
51 //*****************************************************************************
52 #define SAC_OA_POWER_MODE_HIGH_SPEED_HIGH_POWER 0x0
53 #define SAC_OA_POWER_MODE_LOW_SPEED_LOW_POWER OAPM
54 
55 //*****************************************************************************
56 //
57 // The following are values that can be passed to the mode parameter for
58 // functions: SAC_PGA_setMode().
59 //
60 //*****************************************************************************
61 #define SAC_PGA_MODE_INVERTING MSEL_0
62 #define SAC_PGA_MODE_BUFFER MSEL_1
63 #define SAC_PGA_MODE_NONINVERTING MSEL_2
64 #define SAC_PGA_MODE_CASCADE_OA_INVERTING MSEL_3
65 
66 //*****************************************************************************
67 //
68 // The following are values that can be passed to the gain parameter for
69 // functions: SAC_PGA_setGain().
70 //
71 //*****************************************************************************
72 #define SAC_PGA_GAIN_BIT0 GAIN0
73 #define SAC_PGA_GAIN_BIT1 GAIN1
74 #define SAC_PGA_GAIN_BIT2 GAIN2
75 
76 //*****************************************************************************
77 //
78 // The following are values that can be passed to the load parameter for
79 // functions: SAC_DAC_selectLoad().
80 //
81 //*****************************************************************************
82 #define SAC_DAC_LOAD_DACDAT_WRITTEN DACLSEL_0
83 #define SAC_DAC_LOAD_DEVICE_SPECIFIC_0 DACLSEL_2
84 #define SAC_DAC_LOAD_DEVICE_SPECIFIC_1 DACLSEL_3
85 
86 //*****************************************************************************
87 //
88 // The following are values that can be passed to the reference parameter for
89 // functions: SAC_DAC_selectRefVoltage().
90 //
91 //*****************************************************************************
92 #define SAC_DAC_PRIMARY_REFERENCE DACSREF_0
93 #define SAC_DAC_SECONDARY_REFERENCE DACSREF_1
94 
95 //*****************************************************************************
96 //
97 // The following are values that can be passed to the data parameter for
98 // functions: SAC_DAC_setData().
99 //
100 //*****************************************************************************
101 #define SAC_DAC_DATA_BIT0 DACDATA0
102 #define SAC_DAC_DATA_BIT1 DACDATA1
103 #define SAC_DAC_DATA_BIT2 DACDATA2
104 #define SAC_DAC_DATA_BIT3 DACDATA3
105 #define SAC_DAC_DATA_BIT4 DACDATA4
106 #define SAC_DAC_DATA_BIT5 DACDATA5
107 #define SAC_DAC_DATA_BIT6 DACDATA6
108 #define SAC_DAC_DATA_BIT7 DACDATA7
109 #define SAC_DAC_DATA_BIT8 DACDATA8
110 #define SAC_DAC_DATA_BIT9 DACDATA9
111 #define SAC_DAC_DATA_BIT10 DACDATA10
112 #define SAC_DAC_DATA_BIT11 DACDATA11
113 
114 //*****************************************************************************
115 //
116 // Prototypes for the APIs.
117 //
118 //*****************************************************************************
119 
120 //*****************************************************************************
121 //
122 //! \brief Initializes SAC OA with positive input and negative input. Available
123 //! to at least SAC-L1.
124 //!
125 //! This function initializes SAC OA with positive input and negative input.
126 //! Available to at least SAC-L1. Please consult your device-specific datasheet
127 //! to see what SAC level is available.
128 //!
129 //! \param baseAddress is the base address of the SAC module.
130 //! \param positiveInput selects the positive input source
131 //! Valid values are:
132 //! - \b SAC_OA_POSITIVE_INPUT_SOURCE_EXTERNAL [Default]
133 //! - \b SAC_OA_POSITIVE_INPUT_SOURCE_DAC
134 //! - \b SAC_OA_POSITIVE_INPUT_SOURCE_PAIR_OA
135 //! - \b SAC_OA_POSITIVE_INPUT_SOURCE_DISCONNECTED
136 //! \n Modified bits are \b PSEL and \b PMUXEN of \b SACxOA register.
137 //! \param negativeInput selects the negative input source
138 //! Valid values are:
139 //! - \b SAC_OA_NEGATIVE_INPUT_SOURCE_EXTERNAL [Default]
140 //! - \b SAC_OA_NEGATIVE_INPUT_SOURCE_PGA
141 //! - \b SAC_OA_NEGATIVE_INPUT_SOURCE_DISCONNECTED
142 //! \n Modified bits are \b NSEL and \b NMUXEN of \b SACxOA register.
143 //!
144 //! \return None
145 //
146 //*****************************************************************************
147 extern void SAC_OA_init(uint16_t baseAddress,
148  uint16_t positiveInput,
149  uint16_t negativeInput);
150 
151 //*****************************************************************************
152 //
153 //! \brief Selects power mode for OA. Available to at least SAC-L1.
154 //!
155 //! This function selects power mode for OA. Available to at least SAC-L1.
156 //! Please consult your device-specific datasheet to see what SAC level is
157 //! available.
158 //!
159 //! \param baseAddress is the base address of the SAC module.
160 //! \param powerMode selects OA power mode.
161 //! Valid values are:
162 //! - \b SAC_OA_POWER_MODE_HIGH_SPEED_HIGH_POWER [Default]
163 //! - \b SAC_OA_POWER_MODE_LOW_SPEED_LOW_POWER
164 //! \n Modified bits are \b OAPM of \b SACxOA register.
165 //!
166 //! \return None
167 //
168 //*****************************************************************************
169 extern void SAC_OA_selectPowerMode(uint16_t baseAddress,
170  uint16_t powerMode);
171 
172 //*****************************************************************************
173 //
174 //! \brief Enables OA. Available to at least SAC-L1.
175 //!
176 //! This will enables OA for normal mode. Available to at least SAC-L1. Please
177 //! consult your device-specific datasheet to see what SAC level is available.
178 //!
179 //! \param baseAddress is the base address of the SAC module.
180 //!
181 //! \return None
182 //
183 //*****************************************************************************
184 extern void SAC_OA_enable(uint16_t baseAddress);
185 
186 //*****************************************************************************
187 //
188 //! \brief Disables OA. Available to at least SAC-L1.
189 //!
190 //! This will disable OA and OA outputs high impedance. Available to at least
191 //! SAC-L1. Please consult your device-specific datasheet to see what SAC level
192 //! is available.
193 //!
194 //! \param baseAddress is the base address of the SAC module.
195 //!
196 //! \return None
197 //
198 //*****************************************************************************
199 extern void SAC_OA_disable(uint16_t baseAddress);
200 
201 //*****************************************************************************
202 //
203 //! \brief Enables the SAC all modules. Available to at least SAC-L1.
204 //!
205 //! This will enable SAC all modules. Available to at least SAC-L1. Please
206 //! consult your device-specific datasheet to see what SAC level is available.
207 //!
208 //! \param baseAddress is the base address of the SAC module.
209 //!
210 //! \return None
211 //
212 //*****************************************************************************
213 extern void SAC_enable(uint16_t baseAddress);
214 
215 //*****************************************************************************
216 //
217 //! \brief Disables the SAC all modules. Available to at least SAC-L1.
218 //!
219 //! This will disable SAC all modules. Available to at least SAC-L1. Please
220 //! consult your device-specific datasheet to see what SAC level is available.
221 //!
222 //! \param baseAddress is the base address of the SAC module.
223 //!
224 //! \return None
225 //
226 //*****************************************************************************
227 extern void SAC_disable(uint16_t baseAddress);
228 
229 //*****************************************************************************
230 //
231 //! \brief SAC PGA mode selection. Only available to at least SAC-L2.
232 //!
233 //! Allows selection of different SAC PGA modes. Only available to at least
234 //! SAC-L2. Please consult your device-specific datasheet to see what SAC level
235 //! is available.
236 //!
237 //! \param baseAddress is the base address of the SAC module.
238 //! \param mode selects PGA mode.
239 //! Valid values are:
240 //! - \b SAC_PGA_MODE_INVERTING
241 //! - \b SAC_PGA_MODE_BUFFER [Default]
242 //! - \b SAC_PGA_MODE_NONINVERTING
243 //! - \b SAC_PGA_MODE_CASCADE_OA_INVERTING
244 //! \n Modified bits are \b MSEL of \b SACxPGA register.
245 //!
246 //! \return None
247 //
248 //*****************************************************************************
249 extern void SAC_PGA_setMode(uint16_t baseAddress,
250  uint16_t mode);
251 
252 //*****************************************************************************
253 //
254 //! \brief SAC PGA gain configuration. Only available to at least SAC-L2.
255 //!
256 //! Allows different SAC PGA gain configurations. Only available to at least
257 //! SAC-L2. Please consult your device-specific datasheet to see what SAC level
258 //! is available.
259 //!
260 //! \param baseAddress is the base address of the SAC module.
261 //! \param gain selects PGA gain configuration.
262 //! Mask value is the logical OR of any of the following:
263 //! - \b SAC_PGA_GAIN_BIT0 [Default]
264 //! - \b SAC_PGA_GAIN_BIT1
265 //! - \b SAC_PGA_GAIN_BIT2
266 //! \n Modified bits are \b GAIN of \b SACxPGA register.
267 //!
268 //! \return None
269 //
270 //*****************************************************************************
271 extern void SAC_PGA_setGain(uint16_t baseAddress,
272  uint16_t gain);
273 
274 //*****************************************************************************
275 //
276 //! \brief SAC DAC enable. Only available to at least SAC-L3.
277 //!
278 //! Enables SAC DAC. Can be modified only when DACEN = 0. Only available to at
279 //! least SAC-L3. Please consult your device-specific datasheet to see what SAC
280 //! level is available.
281 //!
282 //! \param baseAddress is the base address of the SAC module.
283 //!
284 //! \return None
285 //
286 //*****************************************************************************
287 extern void SAC_DAC_enable(uint16_t baseAddress);
288 
289 //*****************************************************************************
290 //
291 //! \brief SAC DAC disable. Only available to at least SAC-L3.
292 //!
293 //! Disables SAC DAC. Can be modified only when DACEN = 0. Only available to at
294 //! least SAC-L3. Please consult your device-specific datasheet to see what SAC
295 //! level is available.
296 //!
297 //! \param baseAddress is the base address of the SAC module.
298 //!
299 //! \return None
300 //
301 //*****************************************************************************
302 extern void SAC_DAC_disable(uint16_t baseAddress);
303 
304 //*****************************************************************************
305 //
306 //! \brief SAC DAC interrupt enable. Only available to at least SAC-L3.
307 //!
308 //! Enables SAC DAC interrupt. Can be modified only when DACEN = 0.
309 //! Asynchronously enable the SAC and the SAC DAC interrupt to prevent
310 //! unexpected results. Only available to at least SAC-L3. Please consult your
311 //! device-specific datasheet to see what SAC level is available.
312 //!
313 //! \param baseAddress is the base address of the SAC module.
314 //!
315 //! \return None
316 //
317 //*****************************************************************************
318 extern void SAC_DAC_interruptEnable(uint16_t baseAddress);
319 
320 //*****************************************************************************
321 //
322 //! \brief SAC DAC interrupt disable. Only available to at least SAC-L3.
323 //!
324 //! Disables SAC DAC interrupt. Can be modified only when DACEN = 0. Only
325 //! available to at least SAC-L3. Please consult your device-specific datasheet
326 //! to see what SAC level is available.
327 //!
328 //! \param baseAddress is the base address of the SAC module.
329 //!
330 //! \return None
331 //
332 //*****************************************************************************
333 extern void SAC_DAC_interruptDisable(uint16_t baseAddress);
334 
335 //*****************************************************************************
336 //
337 //! \brief SAC DAC DMA request enable. Only available to at least SAC-L3.
338 //!
339 //! Enables SAC DAC DMA request. Can be modified only when DACEN = 0. Only
340 //! available to at least SAC-L3. Please consult your device-specific datasheet
341 //! to see what SAC level is available.
342 //!
343 //! \param baseAddress is the base address of the SAC module.
344 //!
345 //! \return None
346 //
347 //*****************************************************************************
348 extern void SAC_DAC_DMARequestEnable(uint16_t baseAddress);
349 
350 //*****************************************************************************
351 //
352 //! \brief SAC DAC DMA request disable. Only available to at least SAC-L3.
353 //!
354 //! Disables SAC DAC DMA request. Can be modified only when DACEN = 0. Only
355 //! available to at least SAC-L3. Please consult your device-specific datasheet
356 //! to see what SAC level is available.
357 //!
358 //! \param baseAddress is the base address of the SAC module.
359 //!
360 //! \return None
361 //
362 //*****************************************************************************
363 extern void SAC_DAC_DMARequestDisable(uint16_t baseAddress);
364 
365 //*****************************************************************************
366 //
367 //! \brief SAC DAC load select. Only available to at least SAC-L3.
368 //!
369 //! Selects the load trigger for the DAC latch. DACENC must be set for the DAC
370 //! to update, except when DACLSEL = 0. Can be modified only when DACEN = 0.
371 //! Only available to at least SAC-L3. Please consult your device-specific
372 //! datasheet to see what SAC level is available.
373 //!
374 //! \param baseAddress is the base address of the SAC module.
375 //! \param load selects DAC load.
376 //! Valid values are:
377 //! - \b SAC_DAC_LOAD_DACDAT_WRITTEN [Default]
378 //! - \b SAC_DAC_LOAD_DEVICE_SPECIFIC_0
379 //! - \b SAC_DAC_LOAD_DEVICE_SPECIFIC_1
380 //! \n Modified bits are \b DACLSEL of \b SACxDAC register.
381 //!
382 //! \return None
383 //
384 //*****************************************************************************
385 extern void SAC_DAC_selectLoad(uint16_t baseAddress,
386  uint16_t load);
387 
388 //*****************************************************************************
389 //
390 //! \brief SAC DAC select reference voltage. Only available to at least SAC-L3.
391 //!
392 //! Selects SAC DAC select reference voltage, primary or secondary. Can be
393 //! modified only when DACEN = 0. Only available to at least SAC-L3. Please
394 //! consult your device-specific datasheet to see what SAC level is available.
395 //!
396 //! \param baseAddress is the base address of the SAC module.
397 //! \param reference selects DAC reference voltage.
398 //! Valid values are:
399 //! - \b SAC_DAC_PRIMARY_REFERENCE [Default]
400 //! - \b SAC_DAC_SECONDARY_REFERENCE
401 //! \n Modified bits are \b DACSREF of \b SACxDAC register.
402 //!
403 //! \return None
404 //
405 //*****************************************************************************
406 extern void SAC_DAC_selectRefVoltage(uint16_t baseAddress,
407  uint16_t reference);
408 
409 //*****************************************************************************
410 //
411 //! \brief Get SAC DAC data. Only available to at least SAC-L3.
412 //!
413 //! Gets from SAC DAC data. Bit 11 represents the MSB. Only word access to
414 //! SACxDAT register is allowed. Byte operation may cause unexpected results.
415 //! Only available to at least SAC-L3. Please consult your device-specific
416 //! datasheet to see what SAC level is available.
417 //!
418 //! \param baseAddress is the base address of the SAC module.
419 //!
420 //! \return 12-bit value from SAC DAC data.
421 //
422 //*****************************************************************************
423 extern uint16_t SAC_DAC_getData(uint16_t baseAddress);
424 
425 //*****************************************************************************
426 //
427 //! \brief Set SAC DAC data. Only available to at least SAC-L3.
428 //!
429 //! Sets data to SAC DAC. Bit 11 represents the MSB. Only word access to
430 //! SACxDAT register is allowed. Byte operation may cause unexpected results.
431 //! Only available to at least SAC-L3. Please consult your device-specific
432 //! datasheet to see what SAC level is available.
433 //!
434 //! \param baseAddress is the base address of the SAC module.
435 //! \param data sends DAC data.
436 //! Mask value is the logical OR of any of the following:
437 //! - \b SAC_DAC_DATA_BIT0 [Default]
438 //! - \b SAC_DAC_DATA_BIT1
439 //! - \b SAC_DAC_DATA_BIT2
440 //! - \b SAC_DAC_DATA_BIT3
441 //! - \b SAC_DAC_DATA_BIT4
442 //! - \b SAC_DAC_DATA_BIT5
443 //! - \b SAC_DAC_DATA_BIT6
444 //! - \b SAC_DAC_DATA_BIT7
445 //! - \b SAC_DAC_DATA_BIT8
446 //! - \b SAC_DAC_DATA_BIT9
447 //! - \b SAC_DAC_DATA_BIT10
448 //! - \b SAC_DAC_DATA_BIT11
449 //! \n Modified bits are \b DACDATA of \b SACxDAT register.
450 //!
451 //! \return None
452 //
453 //*****************************************************************************
454 extern void SAC_DAC_setData(uint16_t baseAddress,
455  uint16_t data);
456 
457 //*****************************************************************************
458 //
459 //! \brief Get SAC DAC data update flag. Only available to at least SAC-L3.
460 //!
461 //! Gets flag of SAC DAC update status. Only available to at least SAC-L3.
462 //! Please consult your device-specific datasheet to see what SAC level is
463 //! available.
464 //!
465 //! \param baseAddress is the base address of the SAC module.
466 //!
467 //! \return True or false whether DAC latch data register updated
468 //
469 //*****************************************************************************
470 extern bool SAC_DAC_getIFG(uint16_t baseAddress);
471 
472 //*****************************************************************************
473 //
474 //! \brief Clears SAC DAC data update flag. Only available to at least SAC-L3.
475 //!
476 //! Clears SAC DAC data update flag by writing 1. It could also be cleared by
477 //! reading SACxIV register. If DMA is enabled, this flag is automatically
478 //! cleared by DMA when a new data request is accepted. Can be modified only
479 //! when DACEN = 0. Only available to at least SAC-L3. Please consult your
480 //! device-specific datasheet to see what SAC level is available.
481 //!
482 //! \param baseAddress is the base address of the SAC module.
483 //!
484 //! \return None
485 //
486 //*****************************************************************************
487 extern void SAC_DAC_clearIFG(uint16_t baseAddress);
488 
489 //*****************************************************************************
490 //
491 //! \brief Get SAC DAC interrupt vector value. Only available to at least
492 //! SAC-L3.
493 //!
494 //! Get SAC DAC interrupt vector value. Only word access to the SACIVx register
495 //! is recommended. Only available to at least SAC-L3. Please consult your
496 //! device-specific datasheet to see what SAC level is available.
497 //!
498 //! \param baseAddress is the base address of the SAC module.
499 //!
500 //! \return SAC DAC interrupt vector value
501 //
502 //*****************************************************************************
503 extern uint16_t SAC_getInterruptVector(uint16_t baseAddress);
504 
505 //*****************************************************************************
506 //
507 // Mark the end of the C bindings section for C++ compilers.
508 //
509 //*****************************************************************************
510 #ifdef __cplusplus
511 }
512 #endif
513 
514 #endif
515 #endif // __MSP430WARE_SAC_H__
void SAC_DAC_DMARequestEnable(uint16_t baseAddress)
SAC DAC DMA request enable. Only available to at least SAC-L3.
Definition: sac.c:111
void SAC_DAC_setData(uint16_t baseAddress, uint16_t data)
Set SAC DAC data. Only available to at least SAC-L3.
Definition: sac.c:142
void SAC_OA_init(uint16_t baseAddress, uint16_t positiveInput, uint16_t negativeInput)
Initializes SAC OA with positive input and negative input. Available to at least SAC-L1.
Definition: sac.c:25
void SAC_DAC_selectLoad(uint16_t baseAddress, uint16_t load)
SAC DAC load select. Only available to at least SAC-L3.
Definition: sac.c:123
void SAC_DAC_clearIFG(uint16_t baseAddress)
Clears SAC DAC data update flag. Only available to at least SAC-L3.
Definition: sac.c:152
void SAC_OA_enable(uint16_t baseAddress)
Enables OA. Available to at least SAC-L1.
Definition: sac.c:50
void SAC_PGA_setGain(uint16_t baseAddress, uint16_t gain)
SAC PGA gain configuration. Only available to at least SAC-L2.
Definition: sac.c:80
void SAC_PGA_setMode(uint16_t baseAddress, uint16_t mode)
SAC PGA mode selection. Only available to at least SAC-L2.
Definition: sac.c:74
void SAC_DAC_enable(uint16_t baseAddress)
SAC DAC enable. Only available to at least SAC-L3.
Definition: sac.c:89
void SAC_DAC_interruptDisable(uint16_t baseAddress)
SAC DAC interrupt disable. Only available to at least SAC-L3.
Definition: sac.c:105
bool SAC_DAC_getIFG(uint16_t baseAddress)
Get SAC DAC data update flag. Only available to at least SAC-L3.
Definition: sac.c:147
void SAC_enable(uint16_t baseAddress)
Enables the SAC all modules. Available to at least SAC-L1.
Definition: sac.c:60
void SAC_DAC_disable(uint16_t baseAddress)
SAC DAC disable. Only available to at least SAC-L3.
Definition: sac.c:94
uint16_t SAC_DAC_getData(uint16_t baseAddress)
Get SAC DAC data. Only available to at least SAC-L3.
Definition: sac.c:137
uint16_t SAC_getInterruptVector(uint16_t baseAddress)
Get SAC DAC interrupt vector value. Only available to at least SAC-L3.
Definition: sac.c:158
void SAC_DAC_selectRefVoltage(uint16_t baseAddress, uint16_t reference)
SAC DAC select reference voltage. Only available to at least SAC-L3.
Definition: sac.c:130
void SAC_OA_disable(uint16_t baseAddress)
Disables OA. Available to at least SAC-L1.
Definition: sac.c:55
void SAC_DAC_interruptEnable(uint16_t baseAddress)
SAC DAC interrupt enable. Only available to at least SAC-L3.
Definition: sac.c:99
void SAC_DAC_DMARequestDisable(uint16_t baseAddress)
SAC DAC DMA request disable. Only available to at least SAC-L3.
Definition: sac.c:117
void SAC_disable(uint16_t baseAddress)
Disables the SAC all modules. Available to at least SAC-L1.
Definition: sac.c:65
void SAC_OA_selectPowerMode(uint16_t baseAddress, uint16_t powerMode)
Selects power mode for OA. Available to at least SAC-L1.
Definition: sac.c:44

Copyright 2020, Texas Instruments Incorporated