2020-2021 Sunseeker Telemetry and Lighting System
sd24_b.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // sd24_b.h - Driver for the SD24_B Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_SD24_B_H__
8 #define __MSP430WARE_SD24_B_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_SD24_B__
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 #include "inc/hw_memmap.h"
26 //*****************************************************************************
27 //
29 //
30 //*****************************************************************************
31 typedef struct SD24_B_initParam {
38  uint16_t clockSourceSelect;
49  uint16_t clockPreDivider;
84  uint16_t clockDivider;
89  uint16_t referenceSelect;
90 } SD24_B_initParam;
91 
92 //*****************************************************************************
93 //
95 //
96 //*****************************************************************************
97 typedef struct SD24_B_initConverterParam {
109  uint8_t converter;
114  uint8_t alignment;
125  uint8_t startSelect;
131  uint8_t conversionMode;
132 } SD24_B_initConverterParam;
133 
134 //*****************************************************************************
135 //
138 //
139 //*****************************************************************************
140 typedef struct SD24_B_initConverterAdvancedParam {
152  uint8_t converter;
157  uint8_t alignment;
168  uint8_t startSelect;
174  uint8_t conversionMode;
179  uint8_t dataFormat;
186  uint8_t sampleDelay;
195  uint16_t oversampleRatio;
206  uint8_t gain;
207 } SD24_B_initConverterAdvancedParam;
208 
209 
210 //*****************************************************************************
211 //
212 // The following are values that can be passed to the clockSourceSelect
213 // parameter for functions: SD24_B_init(); the param parameter for functions:
214 // SD24_B_init().
215 //
216 //*****************************************************************************
217 #define SD24_B_CLOCKSOURCE_MCLK (SD24SSEL__MCLK)
218 #define SD24_B_CLOCKSOURCE_SMCLK (SD24SSEL__SMCLK)
219 #define SD24_B_CLOCKSOURCE_ACLK (SD24SSEL__ACLK)
220 #define SD24_B_CLOCKSOURCE_SD24CLK (SD24SSEL__SD24CLK)
221 
222 //*****************************************************************************
223 //
224 // The following are values that can be passed to the referenceSelect parameter
225 // for functions: SD24_B_init(); the param parameter for functions:
226 // SD24_B_init().
227 //
228 //*****************************************************************************
229 #define SD24_B_REF_EXTERNAL (0x00)
230 #define SD24_B_REF_INTERNAL (SD24REFS)
231 
232 //*****************************************************************************
233 //
234 // The following are values that can be passed to the clockPreDivider parameter
235 // for functions: SD24_B_init(); the param parameter for functions:
236 // SD24_B_init().
237 //
238 //*****************************************************************************
239 #define SD24_B_PRECLOCKDIVIDER_1 (SD24PDIV_0)
240 #define SD24_B_PRECLOCKDIVIDER_2 (SD24PDIV_1)
241 #define SD24_B_PRECLOCKDIVIDER_4 (SD24PDIV_2)
242 #define SD24_B_PRECLOCKDIVIDER_8 (SD24PDIV_3)
243 #define SD24_B_PRECLOCKDIVIDER_16 (SD24PDIV_4)
244 #define SD24_B_PRECLOCKDIVIDER_32 (SD24PDIV_5)
245 #define SD24_B_PRECLOCKDIVIDER_64 (SD24PDIV_6)
246 #define SD24_B_PRECLOCKDIVIDER_128 (SD24PDIV_7)
247 
248 //*****************************************************************************
249 //
250 // The following are values that can be passed to the clockDivider parameter
251 // for functions: SD24_B_init(); the param parameter for functions:
252 // SD24_B_init().
253 //
254 //*****************************************************************************
255 #define SD24_B_CLOCKDIVIDER_1 (0x00)
256 #define SD24_B_CLOCKDIVIDER_2 (SD24DIV0)
257 #define SD24_B_CLOCKDIVIDER_3 (SD24DIV1)
258 #define SD24_B_CLOCKDIVIDER_4 (SD24DIV1 | SD24DIV0)
259 #define SD24_B_CLOCKDIVIDER_5 (SD24DIV2)
260 #define SD24_B_CLOCKDIVIDER_6 (SD24DIV2 | SD24DIV0)
261 #define SD24_B_CLOCKDIVIDER_7 (SD24DIV2 | SD24DIV1)
262 #define SD24_B_CLOCKDIVIDER_8 (SD24DIV2 | SD24DIV1 | SD24DIV0)
263 #define SD24_B_CLOCKDIVIDER_9 (SD24DIV3)
264 #define SD24_B_CLOCKDIVIDER_10 (SD24DIV3 | SD24DIV0)
265 #define SD24_B_CLOCKDIVIDER_11 (SD24DIV3 | SD24DIV1)
266 #define SD24_B_CLOCKDIVIDER_12 (SD24DIV3 | SD24DIV1 | SD24DIV0)
267 #define SD24_B_CLOCKDIVIDER_13 (SD24DIV3 | SD24DIV2)
268 #define SD24_B_CLOCKDIVIDER_14 (SD24DIV3 | SD24DIV2 | SD24DIV0)
269 #define SD24_B_CLOCKDIVIDER_15 (SD24DIV3 | SD24DIV2 | SD24DIV1)
270 #define SD24_B_CLOCKDIVIDER_16 (SD24DIV3 | SD24DIV2 | SD24DIV1 | SD24DIV0)
271 #define SD24_B_CLOCKDIVIDER_17 (SD24DIV4)
272 #define SD24_B_CLOCKDIVIDER_18 (SD24DIV4 | SD24DIV0)
273 #define SD24_B_CLOCKDIVIDER_19 (SD24DIV4 | SD24DIV1)
274 #define SD24_B_CLOCKDIVIDER_20 (SD24DIV4 | SD24DIV1 | SD24DIV0)
275 #define SD24_B_CLOCKDIVIDER_21 (SD24DIV4 | SD24DIV2)
276 #define SD24_B_CLOCKDIVIDER_22 (SD24DIV4 | SD24DIV2 | SD24DIV0)
277 #define SD24_B_CLOCKDIVIDER_23 (SD24DIV4 | SD24DIV2 | SD24DIV1)
278 #define SD24_B_CLOCKDIVIDER_24 (SD24DIV4 | SD24DIV2 | SD24DIV1 | SD24DIV0)
279 #define SD24_B_CLOCKDIVIDER_25 (SD24DIV4 | SD24DIV3)
280 #define SD24_B_CLOCKDIVIDER_26 (SD24DIV4 | SD24DIV3 | SD24DIV0)
281 #define SD24_B_CLOCKDIVIDER_27 (SD24DIV4 | SD24DIV3 | SD24DIV1)
282 #define SD24_B_CLOCKDIVIDER_28 (SD24DIV4 | SD24DIV3 | SD24DIV1 | SD24DIV0)
283 #define SD24_B_CLOCKDIVIDER_29 (SD24DIV4 | SD24DIV3 | SD24DIV2)
284 #define SD24_B_CLOCKDIVIDER_30 (SD24DIV4 | SD24DIV3 | SD24DIV2 | SD24DIV0)
285 #define SD24_B_CLOCKDIVIDER_31 (SD24DIV4 | SD24DIV3 | SD24DIV2 | SD24DIV1)
286 #define SD24_B_CLOCKDIVIDER_32 \
287  (SD24DIV4 | SD24DIV3 | SD24DIV2 | SD24DIV1 | SD24DIV0)
288 
289 //*****************************************************************************
290 //
291 // The following are values that can be passed to the param parameter for
292 // functions: SD24_B_initConverter(), and SD24_B_initConverterAdvanced().
293 //
294 //*****************************************************************************
295 #define SD24_B_CONTINUOUS_MODE (0x00)
296 #define SD24_B_SINGLE_MODE (SD24SNGL_H)
297 
298 //*****************************************************************************
299 //
300 // The following are values that can be passed to the converter parameter for
301 // functions: SD24_B_setConverterDataFormat(),
302 // SD24_B_startConverterConversion(), SD24_B_stopConverterConversion(),
303 // SD24_B_setInterruptDelay(), SD24_B_setConversionDelay(),
304 // SD24_B_setOversampling(), SD24_B_setGain(), SD24_B_getResults(),
305 // SD24_B_getHighWordResults(), SD24_B_enableInterrupt(),
306 // SD24_B_disableInterrupt(), SD24_B_clearInterrupt(), and
307 // SD24_B_getInterruptStatus(); the param parameter for functions:
308 // SD24_B_initConverter(), and SD24_B_initConverterAdvanced().
309 //
310 //*****************************************************************************
311 #define SD24_B_CONVERTER_0 0
312 #define SD24_B_CONVERTER_1 1
313 #define SD24_B_CONVERTER_2 2
314 #define SD24_B_CONVERTER_3 3
315 #define SD24_B_CONVERTER_4 4
316 #define SD24_B_CONVERTER_5 5
317 #define SD24_B_CONVERTER_6 6
318 #define SD24_B_CONVERTER_7 7
319 
320 //*****************************************************************************
321 //
322 // The following are values that can be passed to the param parameter for
323 // functions: SD24_B_initConverter(), and SD24_B_initConverterAdvanced().
324 //
325 //*****************************************************************************
326 #define SD24_B_ALIGN_RIGHT (0x00)
327 #define SD24_B_ALIGN_LEFT (SD24ALGN)
328 
329 //*****************************************************************************
330 //
331 // The following are values that can be passed to the param parameter for
332 // functions: SD24_B_initConverter(), and SD24_B_initConverterAdvanced().
333 //
334 //*****************************************************************************
335 #define SD24_B_CONVERSION_SELECT_SD24SC (SD24SCS__SD24SC)
336 #define SD24_B_CONVERSION_SELECT_EXT1 (SD24SCS__EXT1)
337 #define SD24_B_CONVERSION_SELECT_EXT2 (SD24SCS__EXT2)
338 #define SD24_B_CONVERSION_SELECT_EXT3 (SD24SCS__EXT3)
339 #define SD24_B_CONVERSION_SELECT_GROUP0 (SD24SCS__GROUP0)
340 #define SD24_B_CONVERSION_SELECT_GROUP1 (SD24SCS__GROUP1)
341 #define SD24_B_CONVERSION_SELECT_GROUP2 (SD24SCS__GROUP2)
342 #define SD24_B_CONVERSION_SELECT_GROUP3 (SD24SCS__GROUP3)
343 
344 //*****************************************************************************
345 //
346 // The following are values that can be passed to the oversampleRatio parameter
347 // for functions: SD24_B_setOversampling(); the param parameter for functions:
348 // SD24_B_initConverterAdvanced().
349 //
350 //*****************************************************************************
351 #define SD24_B_OVERSAMPLE_32 (OSR__32)
352 #define SD24_B_OVERSAMPLE_64 (OSR__64)
353 #define SD24_B_OVERSAMPLE_128 (OSR__128)
354 #define SD24_B_OVERSAMPLE_256 (OSR__256)
355 #define SD24_B_OVERSAMPLE_512 (OSR__512)
356 #define SD24_B_OVERSAMPLE_1024 (OSR__1024)
357 
358 //*****************************************************************************
359 //
360 // The following are values that can be passed to the dataFormat parameter for
361 // functions: SD24_B_setConverterDataFormat(); the param parameter for
362 // functions: SD24_B_initConverterAdvanced().
363 //
364 //*****************************************************************************
365 #define SD24_B_DATA_FORMAT_BINARY (SD24DF_0)
366 #define SD24_B_DATA_FORMAT_2COMPLEMENT (SD24DF_1)
367 
368 //*****************************************************************************
369 //
370 // The following are values that can be passed to the gain parameter for
371 // functions: SD24_B_setGain(); the param parameter for functions:
372 // SD24_B_initConverterAdvanced().
373 //
374 //*****************************************************************************
375 #define SD24_B_GAIN_1 (SD24GAIN_1)
376 #define SD24_B_GAIN_2 (SD24GAIN_2)
377 #define SD24_B_GAIN_4 (SD24GAIN_4)
378 #define SD24_B_GAIN_8 (SD24GAIN_8)
379 #define SD24_B_GAIN_16 (SD24GAIN_16)
380 #define SD24_B_GAIN_32 (SD24GAIN_32)
381 #define SD24_B_GAIN_64 (SD24GAIN_64)
382 #define SD24_B_GAIN_128 (SD24GAIN_128)
383 
384 //*****************************************************************************
385 //
386 // The following are values that can be passed to the sampleDelay parameter for
387 // functions: SD24_B_setInterruptDelay(); the param parameter for functions:
388 // SD24_B_initConverterAdvanced().
389 //
390 //*****************************************************************************
391 #define SD24_B_FOURTH_SAMPLE_INTERRUPT (SD24INTDLY_0)
392 #define SD24_B_THIRD_SAMPLE_INTERRUPT (SD24INTDLY_1)
393 #define SD24_B_SECOND_SAMPLE_INTERRUPT (SD24INTDLY_2)
394 #define SD24_B_FIRST_SAMPLE_INTERRUPT (SD24INTDLY_3)
395 
396 //*****************************************************************************
397 //
398 // The following are values that can be passed to the group parameter for
399 // functions: SD24_B_startGroupConversion(), and SD24_B_stopGroupConversion().
400 //
401 //*****************************************************************************
402 #define SD24_B_GROUP0 0
403 #define SD24_B_GROUP1 1
404 #define SD24_B_GROUP2 2
405 #define SD24_B_GROUP3 3
406 
407 //*****************************************************************************
408 //
409 // The following are values that can be passed to the interruptFlag parameter
410 // for functions: SD24_B_configureDMATrigger().
411 //
412 //*****************************************************************************
413 #define SD24_B_DMA_TRIGGER_IFG0 (SD24DMA_0)
414 #define SD24_B_DMA_TRIGGER_IFG1 (SD24DMA_1)
415 #define SD24_B_DMA_TRIGGER_IFG2 (SD24DMA_2)
416 #define SD24_B_DMA_TRIGGER_IFG3 (SD24DMA_3)
417 #define SD24_B_DMA_TRIGGER_IFG4 (SD24DMA_4)
418 #define SD24_B_DMA_TRIGGER_IFG5 (SD24DMA_5)
419 #define SD24_B_DMA_TRIGGER_IFG6 (SD24DMA_6)
420 #define SD24_B_DMA_TRIGGER_IFG7 (SD24DMA_7)
421 #define SD24_B_DMA_TRIGGER_TRGIFG (SD24DMA_8)
422 
423 //*****************************************************************************
424 //
425 // The following are values that can be passed to the mask parameter for
426 // functions: SD24_B_enableInterrupt(), SD24_B_disableInterrupt(),
427 // SD24_B_clearInterrupt(), and SD24_B_getInterruptStatus() as well as returned
428 // by the SD24_B_getInterruptStatus() function.
429 //
430 //*****************************************************************************
431 #define SD24_B_CONVERTER_INTERRUPT SD24IE0
432 #define SD24_B_CONVERTER_OVERFLOW_INTERRUPT SD24OVIE0
433 
434 //*****************************************************************************
435 //
436 // Prototypes for the APIs.
437 //
438 //*****************************************************************************
439 
440 //*****************************************************************************
441 //
457 //
458 //*****************************************************************************
459 extern void SD24_B_init(uint16_t baseAddress,
460  SD24_B_initParam *param);
461 
462 //*****************************************************************************
463 //
476 //
477 //*****************************************************************************
478 extern void SD24_B_initConverter(uint16_t baseAddress,
479  SD24_B_initConverterParam *param);
480 
481 //*****************************************************************************
482 //
494 //
495 //*****************************************************************************
496 extern void SD24_B_initConverterAdvanced(uint16_t baseAddress,
497  SD24_B_initConverterAdvancedParam *param);
498 
499 //*****************************************************************************
500 //
525 //
526 //*****************************************************************************
527 extern void SD24_B_setConverterDataFormat(uint16_t baseAddress,
528  uint8_t converter,
529  uint8_t dataFormat);
530 
531 //*****************************************************************************
532 //
548 //
549 //*****************************************************************************
550 extern void SD24_B_startGroupConversion(uint16_t baseAddress,
551  uint8_t group);
552 
553 //*****************************************************************************
554 //
570 //
571 //*****************************************************************************
572 extern void SD24_B_stopGroupConversion(uint16_t baseAddress,
573  uint8_t group);
574 
575 //*****************************************************************************
576 //
595 //
596 //*****************************************************************************
597 extern void SD24_B_startConverterConversion(uint16_t baseAddress,
598  uint8_t converter);
599 
600 //*****************************************************************************
601 //
620 //
621 //*****************************************************************************
622 extern void SD24_B_stopConverterConversion(uint16_t baseAddress,
623  uint8_t converter);
624 
625 //*****************************************************************************
626 //
647 //
648 //*****************************************************************************
649 extern void SD24_B_configureDMATrigger(uint16_t baseAddress,
650  uint16_t interruptFlag);
651 
652 //*****************************************************************************
653 //
681 //
682 //*****************************************************************************
683 extern void SD24_B_setInterruptDelay(uint16_t baseAddress,
684  uint8_t converter,
685  uint8_t sampleDelay);
686 
687 //*****************************************************************************
688 //
712 //
713 //*****************************************************************************
714 extern void SD24_B_setConversionDelay(uint16_t baseAddress,
715  uint8_t converter,
716  uint16_t cycleDelay);
717 
718 //*****************************************************************************
719 //
746 //
747 //*****************************************************************************
748 extern void SD24_B_setOversampling(uint16_t baseAddress,
749  uint8_t converter,
750  uint16_t oversampleRatio);
751 
752 //*****************************************************************************
753 //
782 //
783 //*****************************************************************************
784 extern void SD24_B_setGain(uint16_t baseAddress,
785  uint8_t converter,
786  uint8_t gain);
787 
788 //*****************************************************************************
789 //
809 //
810 //*****************************************************************************
811 extern uint32_t SD24_B_getResults(uint16_t baseAddress,
812  uint8_t converter);
813 
814 //*****************************************************************************
815 //
833 //
834 //*****************************************************************************
835 extern uint16_t SD24_B_getHighWordResults(uint16_t baseAddress,
836  uint8_t converter);
837 
838 //*****************************************************************************
839 //
864 //
865 //*****************************************************************************
866 extern void SD24_B_enableInterrupt(uint16_t baseAddress,
867  uint8_t converter,
868  uint16_t mask);
869 
870 //*****************************************************************************
871 //
897 //
898 //*****************************************************************************
899 extern void SD24_B_disableInterrupt(uint16_t baseAddress,
900  uint8_t converter,
901  uint16_t mask);
902 
903 //*****************************************************************************
904 //
927 //
928 //*****************************************************************************
929 extern void SD24_B_clearInterrupt(uint16_t baseAddress,
930  uint8_t converter,
931  uint16_t mask);
932 
933 //*****************************************************************************
934 //
959 //
960 //*****************************************************************************
961 extern uint16_t SD24_B_getInterruptStatus(uint16_t baseAddress,
962  uint8_t converter,
963  uint16_t mask);
964 
965 //*****************************************************************************
966 //
967 // Mark the end of the C bindings section for C++ compilers.
968 //
969 //*****************************************************************************
970 #ifdef __cplusplus
971 }
972 #endif
973 
974 #endif
975 #endif // __MSP430WARE_SD24_B_H__
MPU_initThreeSegmentsParam param