rtc_c.h
Go to the documentation of this file.
1 #ifndef RTC_C_H_
2 #define RTC_C_H_
3 
4 //*****************************************************************************
5 //
8 //
9 //*****************************************************************************
10 
11 
12 //*****************************************************************************
13 //
14 // If building with a C++ compiler, make all of the definitions in this header
15 // have a C binding.
16 //
17 //*****************************************************************************
18 #ifdef __cplusplus
19 extern "C"
20 {
21 #endif
22 
23 #include <stdint.h>
24 #include "register_remap.h"
25 #include <stdbool.h>
26 #include <msp432.h>
27 
28 //*****************************************************************************
29 //
30 //The following is a struct that can be passed to RTC_CalendarInit() in the
31 //CalendarTime parameter, as well as returned by RTC_getCalendarTime()
32 //
33 //*****************************************************************************
34 typedef struct _RTC_C_Calendar
35 {
36  uint_fast8_t seconds;
37  uint_fast8_t minutes;
38  uint_fast8_t hours;
39  uint_fast8_t dayOfWeek;
40  uint_fast8_t dayOfmonth;
41  uint_fast8_t month;
42  uint_fast16_t year;
44 
45 //*****************************************************************************
46 //
47 //The following are values that can be passed to RTC_setCalibrationData()
48 //
49 //*****************************************************************************
50 #define RTC_C_CALIBRATIONFREQ_OFF (RTCCALF_0)
51 #define RTC_C_CALIBRATIONFREQ_512HZ (RTCCALF_1)
52 #define RTC_C_CALIBRATIONFREQ_256HZ (RTCCALF_2)
53 #define RTC_C_CALIBRATIONFREQ_1HZ (RTCCALF_3)
54 
55 //*****************************************************************************
56 //
57 //The following are values that can be passed to RTC_setCalibrationData()
58 //
59 //*****************************************************************************
60 #define RTC_C_CALIBRATION_DOWN1PPM ( !(RTCOCALS) )
61 #define RTC_C_CALIBRATION_UP1PPM (RTCOCALS)
62 
63 //*****************************************************************************
64 //
65 //The following are values that can be passed to
66 //RTC_setTemperatureCompensation()
67 //
68 //*****************************************************************************
69 #define RTC_C_COMPENSATION_DOWN1PPM ( !(RTCTCMPS) )
70 #define RTC_C_COMPENSATION_UP1PPM (RTCTCMPS)
71 
72 //*****************************************************************************
73 //
74 //The following are values that can be passed to RTC_iniRTC_Calendar()
75 //
76 //*****************************************************************************
77 #define RTC_C_FORMAT_BINARY ( !(RTCBCD) )
78 #define RTC_C_FORMAT_BCD (RTCBCD)
79 
80 //*****************************************************************************
81 //
82 //The following is a value that can be passed to RTC_seRTC_CalendarAlarm()
83 //
84 //*****************************************************************************
85 #define RTC_C_ALARMCONDITION_OFF (0x80)
86 
87 //*****************************************************************************
88 //
89 //The following are values that can be passed to RTC_seRTC_CalendarEvent()
90 //in the eventSelect parameter.
91 //
92 //*****************************************************************************
93 #define RTC_C_CALENDAREVENT_MINUTECHANGE (RTCTEV_0)
94 #define RTC_C_CALENDAREVENT_HOURCHANGE (RTCTEV_1)
95 #define RTC_C_CALENDAREVENT_NOON (RTCTEV_2)
96 #define RTC_C_CALENDAREVENT_MIDNIGHT (RTCTEV_3)
97 
98 //*****************************************************************************
99 //
100 //The following are values that can be passed to RTC_definePrescaleEvent()
101 //
102 //*****************************************************************************
103 #define RTC_C_PRESCALE_0 (0x0)
104 #define RTC_C_PRESCALE_1 (0x1)
105 
106 //*****************************************************************************
107 //
108 //The following are values that can be passed to RTC_definePrescaleEvent()
109 //in the prescaleEventDivider parameter.
110 //
111 //*****************************************************************************
112 #define RTC_C_PSEVENTDIVIDER_2 (RT0IP_0)
113 #define RTC_C_PSEVENTDIVIDER_4 (RT0IP_1)
114 #define RTC_C_PSEVENTDIVIDER_8 (RT0IP_2)
115 #define RTC_C_PSEVENTDIVIDER_16 (RT0IP_3)
116 #define RTC_C_PSEVENTDIVIDER_32 (RT0IP_4)
117 #define RTC_C_PSEVENTDIVIDER_64 (RT0IP_5)
118 #define RTC_C_PSEVENTDIVIDER_128 (RT0IP_6)
119 #define RTC_C_PSEVENTDIVIDER_256 (RT0IP_7)
120 
121 //*****************************************************************************
122 //
123 //The following are values that can be passed to the interrupt functions
124 //
125 //*****************************************************************************
126 #define RTC_C_OSCILLATOR_FAULT_INTERRUPT RTCOFIE
127 #define RTC_C_TIME_EVENT_INTERRUPT RTCTEVIE
128 #define RTC_C_CLOCK_ALARM_INTERRUPT RTCAIE
129 #define RTC_C_CLOCK_READ_READY_INTERRUPT RTCRDYIE
130 #define RTC_C_PRESCALE_TIMER0_INTERRUPT 0x02
131 #define RTC_C_PRESCALE_TIMER1_INTERRUPT 0x01
132 
133 //*****************************************************************************
134 //
140 //
141 //*****************************************************************************
142 extern void RTC_C_startClock(void);
143 
144 //*****************************************************************************
145 //
151 //
152 //*****************************************************************************
153 extern void RTC_C_holdClock(void);
154 
155 //*****************************************************************************
156 //
175 //
176 //*****************************************************************************
177 extern void RTC_C_setCalibrationFrequency(uint_fast16_t frequencySelect);
178 
179 //*****************************************************************************
180 //
196 //
197 //*****************************************************************************
198 extern void RTC_C_setCalibrationData(uint_fast8_t offsetDirection,
199  uint_fast8_t offsetValue);
200 
201 //*****************************************************************************
202 //
219 //
220 //*****************************************************************************
221 extern bool RTC_C_setTemperatureCompensation(uint_fast16_t offsetDirection,
222  uint_fast8_t offsetValue);
223 
224 //*****************************************************************************
225 //
247 //
248 //*****************************************************************************
249 extern void RTC_C_initCalendar(const RTC_C_Calendar *calendarTime,
250  uint_fast16_t formatSelect);
251 
252 //*****************************************************************************
253 //
261 //
262 //*****************************************************************************
264 
265 //*****************************************************************************
266 //
294 //
295 //*****************************************************************************
296 extern void RTC_C_setCalendarAlarm(uint_fast8_t minutesAlarm,
297  uint_fast8_t hoursAlarm, uint_fast8_t dayOfWeekAlarm,
298  uint_fast8_t dayOfmonthAlarm);
299 
300 //*****************************************************************************
301 //
316 //
317 //*****************************************************************************
318 extern void RTC_C_setCalendarEvent(uint_fast16_t eventSelect);
319 
320 //*****************************************************************************
321 //
345 //
346 //*****************************************************************************
347 extern void RTC_C_definePrescaleEvent(uint_fast8_t prescaleSelect,
348  uint_fast8_t prescaleEventDivider);
349 
350 //*****************************************************************************
351 //
365 //
366 //*****************************************************************************
367 extern uint_fast8_t RTC_C_getPrescaleValue(uint_fast8_t prescaleSelect);
368 
369 //*****************************************************************************
370 //
384 //
385 //*****************************************************************************
386 extern void RTC_C_setPrescaleValue(uint_fast8_t prescaleSelect,
387  uint_fast8_t prescaleCounterValue);
388 
389 //*****************************************************************************
390 //
399 //
400 //*****************************************************************************
401 extern uint16_t RTC_C_convertBCDToBinary(uint16_t valueToConvert);
402 
403 //*****************************************************************************
404 //
407 
414 //
415 //*****************************************************************************
416 extern uint16_t RTC_C_convertBinaryToBCD(uint16_t valueToConvert);
417 
418 //*****************************************************************************
419 //
443 //
444 //*****************************************************************************
445 extern void RTC_C_enableInterrupt(uint8_t interruptMask);
446 
447 //*****************************************************************************
448 //
472 //
473 //*****************************************************************************
474 extern void RTC_C_disableInterrupt(uint8_t interruptMask);
475 
476 //*****************************************************************************
477 //
495 //
496 //*****************************************************************************
497 extern uint_fast8_t RTC_C_getInterruptStatus(void);
498 
499 //*****************************************************************************
500 //
521 //
522 //*****************************************************************************
523 extern uint_fast8_t RTC_C_getEnabledInterruptStatus(void);
524 
525 //*****************************************************************************
526 //
549 //
550 //*****************************************************************************
551 extern void RTC_C_clearInterruptFlag(uint_fast8_t interruptFlagMask);
552 
553 //*****************************************************************************
554 //
567 //
568 //*****************************************************************************
569 extern void RTC_C_registerInterrupt(void (*intHandler)(void));
570 
571 //*****************************************************************************
572 //
583 //
584 //*****************************************************************************
585 extern void RTC_C_unregisterInterrupt(void);
586 
587 /* Defines for future devices that might have multiple instances */
588 #define RTC_C_startClockMultipleInstance(a) RTC_C_startClock()
589 #define RTC_C_holdClockMultipleInstance(a) RTC_C_holdClock()
590 #define RTC_C_setCalibrationFrequencyMultipleInstance(a,b) RTC_C_setCalibrationFrequency(b)
591 #define RTC_C_setCalibrationDataMultipleInstance(a,b,c) RTC_C_setCalibrationData(b,c)
592 #define RTC_C_setTemperatureCompensationMultipleInstance(a,b,c) RTC_C_setTemperatureCompensation(b,c)
593 #define RTC_C_initCalendarMultipleInstance(a,b,c) RTC_C_initCalendar(b,c)
594 #define RTC_C_getCalendarTimeMultipleInstance(a) RTC_C_getCalendarTime()
595 #define RTC_C_setCalendarAlarmMultipleInstance(a,b,c,d,e) RTC_C_setCalendarAlarm(b,c,d,e)
596 #define RTC_C_setCalendarEventMultipleInstance(a,b) RTC_C_setCalendarEvent(b)
597 #define RTC_C_definePrescaleEventMultipleInstance(a,b,c) RTC_C_definePrescaleEvent(b,c)
598 #define RTC_C_getPrescaleValueMultipleInstance(a,b) RTC_C_getPrescaleValue(b)
599 #define RTC_C_setPrescaleValueMultipleInstance(a,b,c) RTC_C_setPrescaleValue(b,c)
600 #define RTC_C_convertBCDToBinaryMultipleInstance(a,b) RTC_C_convertBCDToBinary(b)
601 #define RTC_C_convertBinaryToBCDMultipleInstance(a,b) RTC_C_convertBinaryToBCD(b)
602 #define RTC_C_enableInterruptMultipleInstance(a,b) RTC_C_enableInterrupt(b)
603 #define RTC_C_disableInterruptMultipleInstance(a,b) RTC_C_disableInterrupt(b)
604 #define RTC_C_getInterruptStatusMultipleInstance(a) RTC_C_getInterruptStatus()
605 #define RTC_C_getEnabledInterruptStatusMultipleInstance(a) RTC_C_getEnabledInterruptStatus()
606 #define RTC_C_clearInterruptFlagMultipleInstance(a,b) RTC_C_clearInterruptFlag(b)
607 #define RTC_C_registerInterruptMultipleInstance(a,b) RTC_C_registerInterrupt(b)
608 #define RTC_C_unregisterInterruptMultipleInstance(a) RTC_C_unregisterInterrupt()
609 
610 //*****************************************************************************
611 //
612 // Mark the end of the C bindings section for C++ compilers.
613 //
614 //*****************************************************************************
615 #ifdef __cplusplus
616 }
617 #endif
618 
619 //*****************************************************************************
620 //
621 // Close the Doxygen group.
623 //
624 //*****************************************************************************
625 
626 #endif /* RTC_H */
void RTC_C_startClock(void)
Definition: rtc_c.c:5
Definition: rtc_c.h:34
void RTC_C_definePrescaleEvent(uint_fast8_t prescaleSelect, uint_fast8_t prescaleEventDivider)
Definition: rtc_c.c:107
uint_fast8_t RTC_C_getEnabledInterruptStatus(void)
Definition: rtc_c.c:230
void RTC_C_setCalibrationData(uint_fast8_t offsetDirection, uint_fast8_t offsetValue)
Definition: rtc_c.c:26
void RTC_C_setPrescaleValue(uint_fast8_t prescaleSelect, uint_fast8_t prescaleCounterValue)
Definition: rtc_c.c:129
uint_fast8_t hours
Definition: rtc_c.h:38
uint_fast16_t year
Definition: rtc_c.h:42
uint_fast8_t minutes
Definition: rtc_c.h:37
void RTC_C_holdClock(void)
Definition: rtc_c.c:12
void RTC_C_setCalendarEvent(uint_fast16_t eventSelect)
Definition: rtc_c.c:100
uint_fast8_t dayOfmonth
Definition: rtc_c.h:40
void RTC_C_registerInterrupt(void(*intHandler)(void))
Definition: rtc_c.c:291
uint_fast8_t RTC_C_getInterruptStatus(void)
Definition: rtc_c.c:199
RTC_C_Calendar RTC_C_getCalendarTime(void)
Definition: rtc_c.c:71
void RTC_C_clearInterruptFlag(uint_fast8_t interruptFlagMask)
Definition: rtc_c.c:268
void RTC_C_disableInterrupt(uint8_t interruptMask)
Definition: rtc_c.c:177
void RTC_C_unregisterInterrupt(void)
Definition: rtc_c.c:297
bool RTC_C_setTemperatureCompensation(uint_fast16_t offsetDirection, uint_fast8_t offsetValue)
Definition: rtc_c.c:34
void RTC_C_initCalendar(const RTC_C_Calendar *calendarTime, uint_fast16_t formatSelect)
Definition: rtc_c.c:48
struct _RTC_C_Calendar RTC_C_Calendar
uint16_t RTC_C_convertBinaryToBCD(uint16_t valueToConvert)
Definition: rtc_c.c:151
void RTC_C_setCalendarAlarm(uint_fast8_t minutesAlarm, uint_fast8_t hoursAlarm, uint_fast8_t dayOfWeekAlarm, uint_fast8_t dayOfmonthAlarm)
Definition: rtc_c.c:89
uint_fast8_t month
Definition: rtc_c.h:41
void RTC_C_enableInterrupt(uint8_t interruptMask)
Definition: rtc_c.c:157
uint_fast8_t RTC_C_getPrescaleValue(uint_fast8_t prescaleSelect)
Definition: rtc_c.c:115
uint_fast8_t dayOfWeek
Definition: rtc_c.h:39
uint_fast8_t seconds
Definition: rtc_c.h:36
uint16_t RTC_C_convertBCDToBinary(uint16_t valueToConvert)
Definition: rtc_c.c:145
void RTC_C_setCalibrationFrequency(uint_fast16_t frequencySelect)
Definition: rtc_c.c:19

Copyright 2014, Texas Instruments Incorporated