2020-2021 Sunseeker Telemetry and Lighting System
rtc_a.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // rtc_a.h - Driver for the RTC_A Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_RTC_A_H__
8 #define __MSP430WARE_RTC_A_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_RTC__
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 //
30 //
31 //*****************************************************************************
32 typedef struct RTC_A_configureCalendarAlarmParam {
36  uint8_t minutesAlarm;
40  uint8_t hoursAlarm;
44  uint8_t dayOfWeekAlarm;
48  uint8_t dayOfMonthAlarm;
49 } RTC_A_configureCalendarAlarmParam;
50 
51 //*****************************************************************************
52 //
55 //
56 //*****************************************************************************
57 typedef struct Calendar {
59  uint8_t Seconds;
61  uint8_t Minutes;
63  uint8_t Hours;
65  uint8_t DayOfWeek;
67  uint8_t DayOfMonth;
69  uint8_t Month;
71  uint16_t Year;
72 } Calendar;
73 
74 
75 //*****************************************************************************
76 //
77 // The following are values that can be passed to the frequencySelect parameter
78 // for functions: RTC_A_setCalibrationFrequency().
79 //
80 //*****************************************************************************
81 #define RTC_A_CALIBRATIONFREQ_OFF (RTCCALF_0)
82 #define RTC_A_CALIBRATIONFREQ_512HZ (RTCCALF_1)
83 #define RTC_A_CALIBRATIONFREQ_256HZ (RTCCALF_2)
84 #define RTC_A_CALIBRATIONFREQ_1HZ (RTCCALF_3)
85 
86 //*****************************************************************************
87 //
88 // The following are values that can be passed to the offsetDirection parameter
89 // for functions: RTC_A_setCalibrationData().
90 //
91 //*****************************************************************************
92 #define RTC_A_CALIBRATION_DOWN2PPM (!(RTCCALS))
93 #define RTC_A_CALIBRATION_UP4PPM (RTCCALS)
94 
95 //*****************************************************************************
96 //
97 // The following are values that can be passed to the formatSelect parameter
98 // for functions: RTC_A_initCalendar().
99 //
100 //*****************************************************************************
101 #define RTC_A_FORMAT_BINARY (!(RTCBCD))
102 #define RTC_A_FORMAT_BCD (RTCBCD)
103 
104 //*****************************************************************************
105 //
106 // The following are values that can be passed to the param parameter for
107 // functions: RTC_A_configureCalendarAlarm(), RTC_A_configureCalendarAlarm(),
108 // RTC_A_configureCalendarAlarm(), and RTC_A_configureCalendarAlarm().
109 //
110 //*****************************************************************************
111 #define RTC_A_ALARMCONDITION_OFF (0x80)
112 
113 //*****************************************************************************
114 //
115 // The following are values that can be passed to the eventSelect parameter for
116 // functions: RTC_A_setCalendarEvent().
117 //
118 //*****************************************************************************
119 #define RTC_A_CALENDAREVENT_MINUTECHANGE (RTCTEV_0)
120 #define RTC_A_CALENDAREVENT_HOURCHANGE (RTCTEV_1)
121 #define RTC_A_CALENDAREVENT_NOON (RTCTEV_2)
122 #define RTC_A_CALENDAREVENT_MIDNIGHT (RTCTEV_3)
123 
124 //*****************************************************************************
125 //
126 // The following are values that can be passed to the prescaleSelect parameter
127 // for functions: RTC_A_initCounterPrescale(), RTC_A_holdCounterPrescale(),
128 // RTC_A_startCounterPrescale(), RTC_A_definePrescaleEvent(),
129 // RTC_A_getPrescaleValue(), and RTC_A_setPrescaleValue().
130 //
131 //*****************************************************************************
132 #define RTC_A_PRESCALE_0 (0x0)
133 #define RTC_A_PRESCALE_1 (0x2)
134 
135 //*****************************************************************************
136 //
137 // The following are values that can be passed to the clockSelect parameter for
138 // functions: RTC_A_initCounter().
139 //
140 //*****************************************************************************
141 #define RTC_A_CLOCKSELECT_ACLK (RTCSSEL_0)
142 #define RTC_A_CLOCKSELECT_SMCLK (RTCSSEL_1)
143 #define RTC_A_CLOCKSELECT_RT1PS (RTCSSEL_2)
144 
145 //*****************************************************************************
146 //
147 // The following are values that can be passed to the prescaleClockSelect
148 // parameter for functions: RTC_A_initCounterPrescale().
149 //
150 //*****************************************************************************
151 #define RTC_A_PSCLOCKSELECT_ACLK (RT1SSEL_0)
152 #define RTC_A_PSCLOCKSELECT_SMCLK (RT1SSEL_1)
153 #define RTC_A_PSCLOCKSELECT_RT0PS (RT1SSEL_2)
154 
155 //*****************************************************************************
156 //
157 // The following are values that can be passed to the counterSizeSelect
158 // parameter for functions: RTC_A_initCounter().
159 //
160 //*****************************************************************************
161 #define RTC_A_COUNTERSIZE_8BIT (RTCTEV_0)
162 #define RTC_A_COUNTERSIZE_16BIT (RTCTEV_1)
163 #define RTC_A_COUNTERSIZE_24BIT (RTCTEV_2)
164 #define RTC_A_COUNTERSIZE_32BIT (RTCTEV_3)
165 
166 //*****************************************************************************
167 //
168 // The following are values that can be passed to the prescaleDivider parameter
169 // for functions: RTC_A_initCounterPrescale().
170 //
171 //*****************************************************************************
172 #define RTC_A_PSDIVIDER_2 (RT0PSDIV_0)
173 #define RTC_A_PSDIVIDER_4 (RT0PSDIV_1)
174 #define RTC_A_PSDIVIDER_8 (RT0PSDIV_2)
175 #define RTC_A_PSDIVIDER_16 (RT0PSDIV_3)
176 #define RTC_A_PSDIVIDER_32 (RT0PSDIV_4)
177 #define RTC_A_PSDIVIDER_64 (RT0PSDIV_5)
178 #define RTC_A_PSDIVIDER_128 (RT0PSDIV_6)
179 #define RTC_A_PSDIVIDER_256 (RT0PSDIV_7)
180 
181 //*****************************************************************************
182 //
183 // The following are values that can be passed to the prescaleEventDivider
184 // parameter for functions: RTC_A_definePrescaleEvent().
185 //
186 //*****************************************************************************
187 #define RTC_A_PSEVENTDIVIDER_2 (RT0IP_0)
188 #define RTC_A_PSEVENTDIVIDER_4 (RT0IP_1)
189 #define RTC_A_PSEVENTDIVIDER_8 (RT0IP_2)
190 #define RTC_A_PSEVENTDIVIDER_16 (RT0IP_3)
191 #define RTC_A_PSEVENTDIVIDER_32 (RT0IP_4)
192 #define RTC_A_PSEVENTDIVIDER_64 (RT0IP_5)
193 #define RTC_A_PSEVENTDIVIDER_128 (RT0IP_6)
194 #define RTC_A_PSEVENTDIVIDER_256 (RT0IP_7)
195 
196 //*****************************************************************************
197 //
198 // The following are values that can be passed to the interruptMask parameter
199 // for functions: RTC_A_enableInterrupt(), and RTC_A_disableInterrupt(); the
200 // interruptFlagMask parameter for functions: RTC_A_getInterruptStatus(), and
201 // RTC_A_clearInterrupt() as well as returned by the RTC_A_getInterruptStatus()
202 // function.
203 //
204 //*****************************************************************************
205 #define RTC_A_TIME_EVENT_INTERRUPT RTCTEVIE
206 #define RTC_A_CLOCK_ALARM_INTERRUPT RTCAIE
207 #define RTC_A_CLOCK_READ_READY_INTERRUPT RTCRDYIE
208 #define RTC_A_PRESCALE_TIMER0_INTERRUPT 0x02
209 #define RTC_A_PRESCALE_TIMER1_INTERRUPT 0x01
210 
211 //*****************************************************************************
212 //
213 // Prototypes for the APIs.
214 //
215 //*****************************************************************************
216 
217 //*****************************************************************************
218 //
226 //
227 //*****************************************************************************
228 extern void RTC_A_startClock(uint16_t baseAddress);
229 
230 //*****************************************************************************
231 //
239 //
240 //*****************************************************************************
241 extern void RTC_A_holdClock(uint16_t baseAddress);
242 
243 //*****************************************************************************
244 //
265 //
266 //*****************************************************************************
267 extern void RTC_A_setCalibrationFrequency(uint16_t baseAddress,
268  uint16_t frequencySelect);
269 
270 //*****************************************************************************
271 //
293 //
294 //*****************************************************************************
295 extern void RTC_A_setCalibrationData(uint16_t baseAddress,
296  uint8_t offsetDirection,
297  uint8_t offsetValue);
298 
299 //*****************************************************************************
300 //
323 //
324 //*****************************************************************************
325 extern void RTC_A_initCounter(uint16_t baseAddress,
326  uint16_t clockSelect,
327  uint16_t counterSizeSelect);
328 
329 //*****************************************************************************
330 //
355 //
356 //*****************************************************************************
357 extern void RTC_A_initCalendar(uint16_t baseAddress,
358  Calendar *CalendarTime,
359  uint16_t formatSelect);
360 
361 //*****************************************************************************
362 //
373 //
374 //*****************************************************************************
375 extern Calendar RTC_A_getCalendarTime(uint16_t baseAddress);
376 
377 //*****************************************************************************
378 //
392 //
393 //*****************************************************************************
394 extern void RTC_A_configureCalendarAlarm(uint16_t baseAddress,
395  RTC_A_configureCalendarAlarmParam *param);
396 
397 //*****************************************************************************
398 //
415 //
416 //*****************************************************************************
417 extern void RTC_A_setCalendarEvent(uint16_t baseAddress,
418  uint16_t eventSelect);
419 
420 //*****************************************************************************
421 //
431 //
432 //*****************************************************************************
433 extern uint32_t RTC_A_getCounterValue(uint16_t baseAddress);
434 
435 //*****************************************************************************
436 //
446 //
447 //*****************************************************************************
448 extern void RTC_A_setCounterValue(uint16_t baseAddress,
449  uint32_t counterValue);
450 
451 //*****************************************************************************
452 //
486 //
487 //*****************************************************************************
488 extern void RTC_A_initCounterPrescale(uint16_t baseAddress,
489  uint8_t prescaleSelect,
490  uint16_t prescaleClockSelect,
491  uint16_t prescaleDivider);
492 
493 //*****************************************************************************
494 //
510 //
511 //*****************************************************************************
512 extern void RTC_A_holdCounterPrescale(uint16_t baseAddress,
513  uint8_t prescaleSelect);
514 
515 //*****************************************************************************
516 //
529 //
530 //*****************************************************************************
531 extern void RTC_A_startCounterPrescale(uint16_t baseAddress,
532  uint8_t prescaleSelect);
533 
534 //*****************************************************************************
535 //
561 //
562 //*****************************************************************************
563 extern void RTC_A_definePrescaleEvent(uint16_t baseAddress,
564  uint8_t prescaleSelect,
565  uint8_t prescaleEventDivider);
566 
567 //*****************************************************************************
568 //
582 //
583 //*****************************************************************************
584 extern uint8_t RTC_A_getPrescaleValue(uint16_t baseAddress,
585  uint8_t prescaleSelect);
586 
587 //*****************************************************************************
588 //
604 //
605 //*****************************************************************************
606 extern void RTC_A_setPrescaleValue(uint16_t baseAddress,
607  uint8_t prescaleSelect,
608  uint8_t prescaleCounterValue);
609 
610 //*****************************************************************************
611 //
634 //
635 //*****************************************************************************
636 extern void RTC_A_enableInterrupt(uint16_t baseAddress,
637  uint8_t interruptMask);
638 
639 //*****************************************************************************
640 //
663 //
664 //*****************************************************************************
665 extern void RTC_A_disableInterrupt(uint16_t baseAddress,
666  uint8_t interruptMask);
667 
668 //*****************************************************************************
669 //
704 //
705 //*****************************************************************************
706 extern uint8_t RTC_A_getInterruptStatus(uint16_t baseAddress,
707  uint8_t interruptFlagMask);
708 
709 //*****************************************************************************
710 //
733 //
734 //*****************************************************************************
735 extern void RTC_A_clearInterrupt(uint16_t baseAddress,
736  uint8_t interruptFlagMask);
737 
738 //*****************************************************************************
739 //
740 // Mark the end of the C bindings section for C++ compilers.
741 //
742 //*****************************************************************************
743 #ifdef __cplusplus
744 }
745 #endif
746 
747 #endif
748 #endif // __MSP430WARE_RTC_A_H__
MPU_initThreeSegmentsParam param