2020-2021 Sunseeker Telemetry and Lighting System
rtc_c.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // rtc_c.h - Driver for the RTC_C Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_RTC_C_H__
8 #define __MSP430WARE_RTC_C_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #if defined(__MSP430_HAS_RTC_C__) || defined(__MSP430_HAS_RTC_CE__)
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 Calendar {
34  uint8_t Seconds;
36  uint8_t Minutes;
38  uint8_t Hours;
40  uint8_t DayOfWeek;
42  uint8_t DayOfMonth;
44  uint8_t Month;
46  uint16_t Year;
47 } Calendar;
48 
49 //*****************************************************************************
50 //
53 //
54 //*****************************************************************************
55 typedef struct RTC_C_configureCalendarAlarmParam {
59  uint8_t minutesAlarm;
63  uint8_t hoursAlarm;
67  uint8_t dayOfWeekAlarm;
71  uint8_t dayOfMonthAlarm;
72 } RTC_C_configureCalendarAlarmParam;
73 
74 
75 //*****************************************************************************
76 //
77 // The following are values that can be passed to the frequencySelect parameter
78 // for functions: RTC_C_setCalibrationFrequency().
79 //
80 //*****************************************************************************
81 #define RTC_C_CALIBRATIONFREQ_OFF (RTCCALF_0)
82 #define RTC_C_CALIBRATIONFREQ_512HZ (RTCCALF_1)
83 #define RTC_C_CALIBRATIONFREQ_256HZ (RTCCALF_2)
84 #define RTC_C_CALIBRATIONFREQ_1HZ (RTCCALF_3)
85 
86 //*****************************************************************************
87 //
88 // The following are values that can be passed to the offsetDirection parameter
89 // for functions: RTC_C_setCalibrationData().
90 //
91 //*****************************************************************************
92 #define RTC_C_CALIBRATION_DOWN1PPM (!(RTCCALS))
93 #define RTC_C_CALIBRATION_UP1PPM (RTCCALS)
94 
95 //*****************************************************************************
96 //
97 // The following are values that can be passed to the offsetDirection parameter
98 // for functions: RTC_C_setTemperatureCompensation().
99 //
100 //*****************************************************************************
101 #define RTC_C_COMPENSATION_DOWN1PPM (!(RTCTCMPS))
102 #define RTC_C_COMPENSATION_UP1PPM (RTCTCMPS)
103 
104 //*****************************************************************************
105 //
106 // The following are values that can be passed to the clockSelect parameter for
107 // functions: RTC_C_initCounter().
108 //
109 //*****************************************************************************
110 #define RTC_C_CLOCKSELECT_32KHZ_OSC (RTCSSEL_0)
111 #define RTC_C_CLOCKSELECT_RT1PS (RTCSSEL_2)
112 
113 //*****************************************************************************
114 //
115 // The following are values that can be passed to the counterSizeSelect
116 // parameter for functions: RTC_C_initCounter().
117 //
118 //*****************************************************************************
119 #define RTC_C_COUNTERSIZE_8BIT (RTCTEV_0)
120 #define RTC_C_COUNTERSIZE_16BIT (RTCTEV_1)
121 #define RTC_C_COUNTERSIZE_24BIT (RTCTEV_2)
122 #define RTC_C_COUNTERSIZE_32BIT (RTCTEV_3)
123 
124 //*****************************************************************************
125 //
126 // The following are values that can be passed to the formatSelect parameter
127 // for functions: RTC_C_initCalendar().
128 //
129 //*****************************************************************************
130 #define RTC_C_FORMAT_BINARY (!(RTCBCD))
131 #define RTC_C_FORMAT_BCD (RTCBCD)
132 
133 //*****************************************************************************
134 //
135 // The following are values that can be passed to the param parameter for
136 // functions: RTC_C_configureCalendarAlarm(), RTC_C_configureCalendarAlarm(),
137 // RTC_C_configureCalendarAlarm(), and RTC_C_configureCalendarAlarm().
138 //
139 //*****************************************************************************
140 #define RTC_C_ALARMCONDITION_OFF (0x80)
141 
142 //*****************************************************************************
143 //
144 // The following are values that can be passed to the eventSelect parameter for
145 // functions: RTC_C_setCalendarEvent().
146 //
147 //*****************************************************************************
148 #define RTC_C_CALENDAREVENT_MINUTECHANGE (RTCTEV_0)
149 #define RTC_C_CALENDAREVENT_HOURCHANGE (RTCTEV_1)
150 #define RTC_C_CALENDAREVENT_NOON (RTCTEV_2)
151 #define RTC_C_CALENDAREVENT_MIDNIGHT (RTCTEV_3)
152 
153 //*****************************************************************************
154 //
155 // The following are values that can be passed to the prescaleDivider parameter
156 // for functions: RTC_C_initCounterPrescale().
157 //
158 //*****************************************************************************
159 #define RTC_C_PSDIVIDER_2 (RT0PSDIV_0)
160 #define RTC_C_PSDIVIDER_4 (RT0PSDIV_1)
161 #define RTC_C_PSDIVIDER_8 (RT0PSDIV_2)
162 #define RTC_C_PSDIVIDER_16 (RT0PSDIV_3)
163 #define RTC_C_PSDIVIDER_32 (RT0PSDIV_4)
164 #define RTC_C_PSDIVIDER_64 (RT0PSDIV_5)
165 #define RTC_C_PSDIVIDER_128 (RT0PSDIV_6)
166 #define RTC_C_PSDIVIDER_256 (RT0PSDIV_7)
167 
168 //*****************************************************************************
169 //
170 // The following are values that can be passed to the prescaleClockSelect
171 // parameter for functions: RTC_C_initCounterPrescale().
172 //
173 //*****************************************************************************
174 #define RTC_C_PSCLOCKSELECT_ACLK (RT1SSEL_0)
175 #define RTC_C_PSCLOCKSELECT_SMCLK (RT1SSEL_1)
176 #define RTC_C_PSCLOCKSELECT_RT0PS (RT1SSEL_2)
177 
178 //*****************************************************************************
179 //
180 // The following are values that can be passed to the prescaleEventDivider
181 // parameter for functions: RTC_C_definePrescaleEvent().
182 //
183 //*****************************************************************************
184 #define RTC_C_PSEVENTDIVIDER_2 (RT0IP_0)
185 #define RTC_C_PSEVENTDIVIDER_4 (RT0IP_1)
186 #define RTC_C_PSEVENTDIVIDER_8 (RT0IP_2)
187 #define RTC_C_PSEVENTDIVIDER_16 (RT0IP_3)
188 #define RTC_C_PSEVENTDIVIDER_32 (RT0IP_4)
189 #define RTC_C_PSEVENTDIVIDER_64 (RT0IP_5)
190 #define RTC_C_PSEVENTDIVIDER_128 (RT0IP_6)
191 #define RTC_C_PSEVENTDIVIDER_256 (RT0IP_7)
192 
193 //*****************************************************************************
194 //
195 // The following are values that can be passed to the prescaleSelect parameter
196 // for functions: RTC_C_initCounterPrescale(), RTC_C_holdCounterPrescale(),
197 // RTC_C_startCounterPrescale(), RTC_C_definePrescaleEvent(),
198 // RTC_C_getPrescaleValue(), and RTC_C_setPrescaleValue().
199 //
200 //*****************************************************************************
201 #define RTC_C_PRESCALE_0 (0x0)
202 #define RTC_C_PRESCALE_1 (0x2)
203 
204 //*****************************************************************************
205 //
206 // The following are values that can be passed to the interruptMask parameter
207 // for functions: RTC_C_enableInterrupt(), and RTC_C_disableInterrupt(); the
208 // interruptFlagMask parameter for functions: RTC_C_getInterruptStatus(), and
209 // RTC_C_clearInterrupt() as well as returned by the RTC_C_getInterruptStatus()
210 // function.
211 //
212 //*****************************************************************************
213 #define RTC_C_TIME_EVENT_INTERRUPT RTCTEVIE
214 #define RTC_C_CLOCK_ALARM_INTERRUPT RTCAIE
215 #define RTC_C_CLOCK_READ_READY_INTERRUPT RTCRDYIE
216 #define RTC_C_PRESCALE_TIMER0_INTERRUPT 0x02
217 #define RTC_C_PRESCALE_TIMER1_INTERRUPT 0x01
218 #define RTC_C_OSCILLATOR_FAULT_INTERRUPT RTCOFIE
219 
220 //*****************************************************************************
221 //
222 // Prototypes for the APIs.
223 //
224 //*****************************************************************************
225 
226 //*****************************************************************************
227 //
235 //
236 //*****************************************************************************
237 extern void RTC_C_startClock(uint16_t baseAddress);
238 
239 //*****************************************************************************
240 //
248 //
249 //*****************************************************************************
250 extern void RTC_C_holdClock(uint16_t baseAddress);
251 
252 //*****************************************************************************
253 //
274 //
275 //*****************************************************************************
276 extern void RTC_C_setCalibrationFrequency(uint16_t baseAddress,
277  uint16_t frequencySelect);
278 
279 //*****************************************************************************
280 //
300 //
301 //*****************************************************************************
302 extern void RTC_C_setCalibrationData(uint16_t baseAddress,
303  uint8_t offsetDirection,
304  uint8_t offsetValue);
305 
306 //*****************************************************************************
307 //
329 //
330 //*****************************************************************************
331 extern void RTC_C_initCounter(uint16_t baseAddress,
332  uint16_t clockSelect,
333  uint16_t counterSizeSelect);
334 
335 //*****************************************************************************
336 //
356 //
357 //*****************************************************************************
358 extern bool RTC_C_setTemperatureCompensation(uint16_t baseAddress,
359  uint16_t offsetDirection,
360  uint8_t offsetValue);
361 
362 //*****************************************************************************
363 //
388 //
389 //*****************************************************************************
390 extern void RTC_C_initCalendar(uint16_t baseAddress,
391  Calendar *CalendarTime,
392  uint16_t formatSelect);
393 
394 //*****************************************************************************
395 //
406 //
407 //*****************************************************************************
408 extern Calendar RTC_C_getCalendarTime(uint16_t baseAddress);
409 
410 //*****************************************************************************
411 //
425 //
426 //*****************************************************************************
427 extern void RTC_C_configureCalendarAlarm(uint16_t baseAddress,
428  RTC_C_configureCalendarAlarmParam *param);
429 
430 //*****************************************************************************
431 //
448 //
449 //*****************************************************************************
450 extern void RTC_C_setCalendarEvent(uint16_t baseAddress,
451  uint16_t eventSelect);
452 
453 //*****************************************************************************
454 //
464 //
465 //*****************************************************************************
466 extern uint32_t RTC_C_getCounterValue(uint16_t baseAddress);
467 
468 //*****************************************************************************
469 //
479 //
480 //*****************************************************************************
481 extern void RTC_C_setCounterValue(uint16_t baseAddress,
482  uint32_t counterValue);
483 
484 //*****************************************************************************
485 //
519 //
520 //*****************************************************************************
521 extern void RTC_C_initCounterPrescale(uint16_t baseAddress,
522  uint8_t prescaleSelect,
523  uint16_t prescaleClockSelect,
524  uint16_t prescaleDivider);
525 
526 //*****************************************************************************
527 //
543 //
544 //*****************************************************************************
545 extern void RTC_C_holdCounterPrescale(uint16_t baseAddress,
546  uint8_t prescaleSelect);
547 
548 //*****************************************************************************
549 //
562 //
563 //*****************************************************************************
564 extern void RTC_C_startCounterPrescale(uint16_t baseAddress,
565  uint8_t prescaleSelect);
566 
567 //*****************************************************************************
568 //
594 //
595 //*****************************************************************************
596 extern void RTC_C_definePrescaleEvent(uint16_t baseAddress,
597  uint8_t prescaleSelect,
598  uint8_t prescaleEventDivider);
599 
600 //*****************************************************************************
601 //
615 //
616 //*****************************************************************************
617 extern uint8_t RTC_C_getPrescaleValue(uint16_t baseAddress,
618  uint8_t prescaleSelect);
619 
620 //*****************************************************************************
621 //
637 //
638 //*****************************************************************************
639 extern void RTC_C_setPrescaleValue(uint16_t baseAddress,
640  uint8_t prescaleSelect,
641  uint8_t prescaleCounterValue);
642 
643 //*****************************************************************************
644 //
669 //
670 //*****************************************************************************
671 extern void RTC_C_enableInterrupt(uint16_t baseAddress,
672  uint8_t interruptMask);
673 
674 //*****************************************************************************
675 //
700 //
701 //*****************************************************************************
702 extern void RTC_C_disableInterrupt(uint16_t baseAddress,
703  uint8_t interruptMask);
704 
705 //*****************************************************************************
706 //
745 //
746 //*****************************************************************************
747 extern uint8_t RTC_C_getInterruptStatus(uint16_t baseAddress,
748  uint8_t interruptFlagMask);
749 
750 //*****************************************************************************
751 //
776 //
777 //*****************************************************************************
778 extern void RTC_C_clearInterrupt(uint16_t baseAddress,
779  uint8_t interruptFlagMask);
780 
781 //*****************************************************************************
782 //
793 //
794 //*****************************************************************************
795 extern uint16_t RTC_C_convertBCDToBinary(uint16_t baseAddress,
796  uint16_t valueToConvert);
797 
798 //*****************************************************************************
799 //
810 //
811 //*****************************************************************************
812 extern uint16_t RTC_C_convertBinaryToBCD(uint16_t baseAddress,
813  uint16_t valueToConvert);
814 
815 //*****************************************************************************
816 //
817 // Mark the end of the C bindings section for C++ compilers.
818 //
819 //*****************************************************************************
820 #ifdef __cplusplus
821 }
822 #endif
823 
824 #endif
825 #endif // __MSP430WARE_RTC_C_H__
MPU_initThreeSegmentsParam param