2020-2021 Sunseeker Telemetry and Lighting System
rtc_b.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // rtc_b.h - Driver for the RTC_B Module.
4 //
5 //*****************************************************************************
6 
7 #ifndef __MSP430WARE_RTC_B_H__
8 #define __MSP430WARE_RTC_B_H__
9 
10 #include "inc/hw_memmap.h"
11 
12 #ifdef __MSP430_HAS_RTC_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 //
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_B_configureCalendarAlarmParam {
59  uint8_t minutesAlarm;
63  uint8_t hoursAlarm;
67  uint8_t dayOfWeekAlarm;
71  uint8_t dayOfMonthAlarm;
72 } RTC_B_configureCalendarAlarmParam;
73 
74 
75 //*****************************************************************************
76 //
77 // The following are values that can be passed to the frequencySelect parameter
78 // for functions: RTC_B_setCalibrationFrequency().
79 //
80 //*****************************************************************************
81 #define RTC_B_CALIBRATIONFREQ_OFF (RTCCALF_0)
82 #define RTC_B_CALIBRATIONFREQ_512HZ (RTCCALF_1)
83 #define RTC_B_CALIBRATIONFREQ_256HZ (RTCCALF_2)
84 #define RTC_B_CALIBRATIONFREQ_1HZ (RTCCALF_3)
85 
86 //*****************************************************************************
87 //
88 // The following are values that can be passed to the offsetDirection parameter
89 // for functions: RTC_B_setCalibrationData().
90 //
91 //*****************************************************************************
92 #define RTC_B_CALIBRATION_DOWN2PPM (!(RTCCALS))
93 #define RTC_B_CALIBRATION_UP4PPM (RTCCALS)
94 
95 //*****************************************************************************
96 //
97 // The following are values that can be passed to the formatSelect parameter
98 // for functions: RTC_B_initCalendar().
99 //
100 //*****************************************************************************
101 #define RTC_B_FORMAT_BINARY (!(RTCBCD))
102 #define RTC_B_FORMAT_BCD (RTCBCD)
103 
104 //*****************************************************************************
105 //
106 // The following are values that can be passed to the param parameter for
107 // functions: RTC_B_configureCalendarAlarm(), RTC_B_configureCalendarAlarm(),
108 // RTC_B_configureCalendarAlarm(), and RTC_B_configureCalendarAlarm().
109 //
110 //*****************************************************************************
111 #define RTC_B_ALARMCONDITION_OFF (0x80)
112 
113 //*****************************************************************************
114 //
115 // The following are values that can be passed to the eventSelect parameter for
116 // functions: RTC_B_setCalendarEvent().
117 //
118 //*****************************************************************************
119 #define RTC_B_CALENDAREVENT_MINUTECHANGE (RTCTEV_0)
120 #define RTC_B_CALENDAREVENT_HOURCHANGE (RTCTEV_1)
121 #define RTC_B_CALENDAREVENT_NOON (RTCTEV_2)
122 #define RTC_B_CALENDAREVENT_MIDNIGHT (RTCTEV_3)
123 
124 //*****************************************************************************
125 //
126 // The following are values that can be passed to the prescaleEventDivider
127 // parameter for functions: RTC_B_definePrescaleEvent().
128 //
129 //*****************************************************************************
130 #define RTC_B_PSEVENTDIVIDER_2 (RT0IP_0)
131 #define RTC_B_PSEVENTDIVIDER_4 (RT0IP_1)
132 #define RTC_B_PSEVENTDIVIDER_8 (RT0IP_2)
133 #define RTC_B_PSEVENTDIVIDER_16 (RT0IP_3)
134 #define RTC_B_PSEVENTDIVIDER_32 (RT0IP_4)
135 #define RTC_B_PSEVENTDIVIDER_64 (RT0IP_5)
136 #define RTC_B_PSEVENTDIVIDER_128 (RT0IP_6)
137 #define RTC_B_PSEVENTDIVIDER_256 (RT0IP_7)
138 
139 //*****************************************************************************
140 //
141 // The following are values that can be passed to the prescaleSelect parameter
142 // for functions: RTC_B_definePrescaleEvent(), RTC_B_getPrescaleValue(), and
143 // RTC_B_setPrescaleValue().
144 //
145 //*****************************************************************************
146 #define RTC_B_PRESCALE_0 (0x0)
147 #define RTC_B_PRESCALE_1 (0x2)
148 
149 //*****************************************************************************
150 //
151 // The following are values that can be passed to the interruptMask parameter
152 // for functions: RTC_B_enableInterrupt(), and RTC_B_disableInterrupt(); the
153 // interruptFlagMask parameter for functions: RTC_B_getInterruptStatus(), and
154 // RTC_B_clearInterrupt() as well as returned by the RTC_B_getInterruptStatus()
155 // function.
156 //
157 //*****************************************************************************
158 #define RTC_B_TIME_EVENT_INTERRUPT RTCTEVIE
159 #define RTC_B_CLOCK_ALARM_INTERRUPT RTCAIE
160 #define RTC_B_CLOCK_READ_READY_INTERRUPT RTCRDYIE
161 #define RTC_B_PRESCALE_TIMER0_INTERRUPT 0x02
162 #define RTC_B_PRESCALE_TIMER1_INTERRUPT 0x01
163 #define RTC_B_OSCILLATOR_FAULT_INTERRUPT RTCOFIE
164 
165 //*****************************************************************************
166 //
167 // Prototypes for the APIs.
168 //
169 //*****************************************************************************
170 
171 //*****************************************************************************
172 //
180 //
181 //*****************************************************************************
182 extern void RTC_B_startClock(uint16_t baseAddress);
183 
184 //*****************************************************************************
185 //
193 //
194 //*****************************************************************************
195 extern void RTC_B_holdClock(uint16_t baseAddress);
196 
197 //*****************************************************************************
198 //
219 //
220 //*****************************************************************************
221 extern void RTC_B_setCalibrationFrequency(uint16_t baseAddress,
222  uint16_t frequencySelect);
223 
224 //*****************************************************************************
225 //
247 //
248 //*****************************************************************************
249 extern void RTC_B_setCalibrationData(uint16_t baseAddress,
250  uint8_t offsetDirection,
251  uint8_t offsetValue);
252 
253 //*****************************************************************************
254 //
279 //
280 //*****************************************************************************
281 extern void RTC_B_initCalendar(uint16_t baseAddress,
282  Calendar *CalendarTime,
283  uint16_t formatSelect);
284 
285 //*****************************************************************************
286 //
297 //
298 //*****************************************************************************
299 extern Calendar RTC_B_getCalendarTime(uint16_t baseAddress);
300 
301 //*****************************************************************************
302 //
316 //
317 //*****************************************************************************
318 extern void RTC_B_configureCalendarAlarm(uint16_t baseAddress,
319  RTC_B_configureCalendarAlarmParam *param);
320 
321 //*****************************************************************************
322 //
339 //
340 //*****************************************************************************
341 extern void RTC_B_setCalendarEvent(uint16_t baseAddress,
342  uint16_t eventSelect);
343 
344 //*****************************************************************************
345 //
371 //
372 //*****************************************************************************
373 extern void RTC_B_definePrescaleEvent(uint16_t baseAddress,
374  uint8_t prescaleSelect,
375  uint8_t prescaleEventDivider);
376 
377 //*****************************************************************************
378 //
392 //
393 //*****************************************************************************
394 extern uint8_t RTC_B_getPrescaleValue(uint16_t baseAddress,
395  uint8_t prescaleSelect);
396 
397 //*****************************************************************************
398 //
414 //
415 //*****************************************************************************
416 extern void RTC_B_setPrescaleValue(uint16_t baseAddress,
417  uint8_t prescaleSelect,
418  uint8_t prescaleCounterValue);
419 
420 //*****************************************************************************
421 //
446 //
447 //*****************************************************************************
448 extern void RTC_B_enableInterrupt(uint16_t baseAddress,
449  uint8_t interruptMask);
450 
451 //*****************************************************************************
452 //
477 //
478 //*****************************************************************************
479 extern void RTC_B_disableInterrupt(uint16_t baseAddress,
480  uint8_t interruptMask);
481 
482 //*****************************************************************************
483 //
522 //
523 //*****************************************************************************
524 extern uint8_t RTC_B_getInterruptStatus(uint16_t baseAddress,
525  uint8_t interruptFlagMask);
526 
527 //*****************************************************************************
528 //
553 //
554 //*****************************************************************************
555 extern void RTC_B_clearInterrupt(uint16_t baseAddress,
556  uint8_t interruptFlagMask);
557 
558 //*****************************************************************************
559 //
570 //
571 //*****************************************************************************
572 extern uint16_t RTC_B_convertBCDToBinary(uint16_t baseAddress,
573  uint16_t valueToConvert);
574 
575 //*****************************************************************************
576 //
587 //
588 //*****************************************************************************
589 extern uint16_t RTC_B_convertBinaryToBCD(uint16_t baseAddress,
590  uint16_t valueToConvert);
591 
592 //*****************************************************************************
593 //
594 // Mark the end of the C bindings section for C++ compilers.
595 //
596 //*****************************************************************************
597 #ifdef __cplusplus
598 }
599 #endif
600 
601 #endif
602 #endif // __MSP430WARE_RTC_B_H__
MPU_initThreeSegmentsParam param