]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - msp430-bsl/msp430-bsl.git/blob - source/driverlib/MSP430F5xx_6xx/rtc_b.h
MSP-BSL v3.0
[msp430-bsl/msp430-bsl.git] / source / driverlib / MSP430F5xx_6xx / rtc_b.h
1 /* --COPYRIGHT--,BSD\r
2  * Copyright (c) 2014, Texas Instruments Incorporated\r
3  * All rights reserved.\r
4  *\r
5  * Redistribution and use in source and binary forms, with or without\r
6  * modification, are permitted provided that the following conditions\r
7  * are met:\r
8  *\r
9  * *  Redistributions of source code must retain the above copyright\r
10  *    notice, this list of conditions and the following disclaimer.\r
11  *\r
12  * *  Redistributions in binary form must reproduce the above copyright\r
13  *    notice, this list of conditions and the following disclaimer in the\r
14  *    documentation and/or other materials provided with the distribution.\r
15  *\r
16  * *  Neither the name of Texas Instruments Incorporated nor the names of\r
17  *    its contributors may be used to endorse or promote products derived\r
18  *    from this software without specific prior written permission.\r
19  *\r
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31  * --/COPYRIGHT--*/\r
32 //*****************************************************************************\r
33 //\r
34 // rtc_b.h - Driver for the RTC_B Module.\r
35 //\r
36 //*****************************************************************************\r
37 \r
38 #ifndef __MSP430WARE_RTC_B_H__\r
39 #define __MSP430WARE_RTC_B_H__\r
40 \r
41 #include "inc/hw_memmap.h"\r
42 \r
43 #ifdef __MSP430_HAS_RTC_B__\r
44 \r
45 //*****************************************************************************\r
46 //\r
47 // If building with a C++ compiler, make all of the definitions in this header\r
48 // have a C binding.\r
49 //\r
50 //*****************************************************************************\r
51 #ifdef __cplusplus\r
52 extern "C"\r
53 {\r
54 #endif\r
55 \r
56 //*****************************************************************************\r
57 //\r
58 // The following is a struct that can be passed to RTC_B_CalendarInit() in the\r
59 // CalendarTime parameter, as well as returned by RTC_B_getCalendarTime()\r
60 //\r
61 //*****************************************************************************\r
62 typedef struct {\r
63         uint8_t Seconds;\r
64         uint8_t Minutes;\r
65         uint8_t Hours;\r
66         uint8_t DayOfWeek;\r
67         uint8_t DayOfMonth;\r
68         uint8_t Month;\r
69         uint16_t Year;\r
70 } Calendar;\r
71 \r
72 //******************************************************************************\r
73 //\r
74 // The following is a struct that is passed to RTC_B_configureCalendarAlarm()\r
75 //\r
76 //******************************************************************************\r
77 typedef struct RTC_B_configureCalendarAlarmParam {\r
78         uint8_t minutesAlarm;\r
79         uint8_t hoursAlarm;\r
80         uint8_t dayOfWeekAlarm;\r
81         uint8_t dayOfMonthAlarm;\r
82 } RTC_B_configureCalendarAlarmParam;\r
83 \r
84 //*****************************************************************************\r
85 //\r
86 // The following are values that can be passed to the frequencySelect parameter\r
87 // for functions: RTC_B_setCalibrationFrequency().\r
88 //\r
89 //*****************************************************************************\r
90 #define RTC_B_CALIBRATIONFREQ_OFF                                   (RTCCALF_0)\r
91 #define RTC_B_CALIBRATIONFREQ_512HZ                                 (RTCCALF_1)\r
92 #define RTC_B_CALIBRATIONFREQ_256HZ                                 (RTCCALF_2)\r
93 #define RTC_B_CALIBRATIONFREQ_1HZ                                   (RTCCALF_3)\r
94 \r
95 //*****************************************************************************\r
96 //\r
97 // The following are values that can be passed to the offsetDirection parameter\r
98 // for functions: RTC_B_setCalibrationData().\r
99 //\r
100 //*****************************************************************************\r
101 #define RTC_B_CALIBRATION_DOWN2PPM                                 (!(RTCCALS))\r
102 #define RTC_B_CALIBRATION_UP4PPM                                      (RTCCALS)\r
103 \r
104 //*****************************************************************************\r
105 //\r
106 // The following are values that can be passed to the formatSelect parameter\r
107 // for functions: RTC_B_initCalendar(), and RTC_B_calendarInit().\r
108 //\r
109 //*****************************************************************************\r
110 #define RTC_B_FORMAT_BINARY                                         (!(RTCBCD))\r
111 #define RTC_B_FORMAT_BCD                                               (RTCBCD)\r
112 \r
113 //*****************************************************************************\r
114 //\r
115 // The following are values that can be passed to the minutesAlarm parameter\r
116 // for functions: RTC_B_setCalendarAlarm(); the dayOfMonthAlarm parameter for\r
117 // functions: RTC_B_setCalendarAlarm(); the hoursAlarm parameter for functions:\r
118 // RTC_B_setCalendarAlarm(); the dayOfWeekAlarm parameter for functions:\r
119 // RTC_B_setCalendarAlarm().\r
120 //\r
121 //*****************************************************************************\r
122 #define RTC_B_ALARMCONDITION_OFF                                         (0x80)\r
123 \r
124 //*****************************************************************************\r
125 //\r
126 // The following are values that can be passed to the eventSelect parameter for\r
127 // functions: RTC_B_setCalendarEvent().\r
128 //\r
129 //*****************************************************************************\r
130 #define RTC_B_CALENDAREVENT_MINUTECHANGE                             (RTCTEV_0)\r
131 #define RTC_B_CALENDAREVENT_HOURCHANGE                               (RTCTEV_1)\r
132 #define RTC_B_CALENDAREVENT_NOON                                     (RTCTEV_2)\r
133 #define RTC_B_CALENDAREVENT_MIDNIGHT                                 (RTCTEV_3)\r
134 \r
135 //*****************************************************************************\r
136 //\r
137 // The following are values that can be passed to the prescaleEventDivider\r
138 // parameter for functions: RTC_B_definePrescaleEvent().\r
139 //\r
140 //*****************************************************************************\r
141 #define RTC_B_PSEVENTDIVIDER_2                                        (RT0IP_0)\r
142 #define RTC_B_PSEVENTDIVIDER_4                                        (RT0IP_1)\r
143 #define RTC_B_PSEVENTDIVIDER_8                                        (RT0IP_2)\r
144 #define RTC_B_PSEVENTDIVIDER_16                                       (RT0IP_3)\r
145 #define RTC_B_PSEVENTDIVIDER_32                                       (RT0IP_4)\r
146 #define RTC_B_PSEVENTDIVIDER_64                                       (RT0IP_5)\r
147 #define RTC_B_PSEVENTDIVIDER_128                                      (RT0IP_6)\r
148 #define RTC_B_PSEVENTDIVIDER_256                                      (RT0IP_7)\r
149 \r
150 //*****************************************************************************\r
151 //\r
152 // The following are values that can be passed to the prescaleSelect parameter\r
153 // for functions: RTC_B_definePrescaleEvent(), RTC_B_getPrescaleValue(), and\r
154 // RTC_B_setPrescaleValue().\r
155 //\r
156 //*****************************************************************************\r
157 #define RTC_B_PRESCALE_0                                                  (0x0)\r
158 #define RTC_B_PRESCALE_1                                                  (0x2)\r
159 \r
160 //*****************************************************************************\r
161 //\r
162 // The following are values that can be passed to the interruptMask parameter\r
163 // for functions: RTC_B_enableInterrupt(), and RTC_B_disableInterrupt(); the\r
164 // interruptFlagMask parameter for functions: RTC_B_getInterruptStatus(), and\r
165 // RTC_B_clearInterrupt() as well as returned by the RTC_B_getInterruptStatus()\r
166 // function.\r
167 //\r
168 //*****************************************************************************\r
169 #define RTC_B_TIME_EVENT_INTERRUPT                                     RTCTEVIE\r
170 #define RTC_B_CLOCK_ALARM_INTERRUPT                                      RTCAIE\r
171 #define RTC_B_CLOCK_READ_READY_INTERRUPT                               RTCRDYIE\r
172 #define RTC_B_PRESCALE_TIMER0_INTERRUPT                                    0x02\r
173 #define RTC_B_PRESCALE_TIMER1_INTERRUPT                                    0x01\r
174 #define RTC_B_OSCILLATOR_FAULT_INTERRUPT                                RTCOFIE\r
175 \r
176 //*****************************************************************************\r
177 //\r
178 // Prototypes for the APIs.\r
179 //\r
180 //*****************************************************************************\r
181 extern void RTC_B_startClock(uint16_t baseAddress);\r
182 \r
183 extern void RTC_B_holdClock(uint16_t baseAddress);\r
184 \r
185 extern void RTC_B_setCalibrationFrequency(uint16_t baseAddress,\r
186                                           uint16_t frequencySelect);\r
187 \r
188 extern void RTC_B_setCalibrationData(uint16_t baseAddress,\r
189                                      uint8_t offsetDirection,\r
190                                      uint8_t offsetValue);\r
191 \r
192 extern void RTC_B_initCalendar(uint16_t baseAddress,\r
193                                Calendar *CalendarTime,\r
194                                uint16_t formatSelect);\r
195 \r
196 extern Calendar RTC_B_getCalendarTime(uint16_t baseAddress);\r
197 \r
198 extern void RTC_B_configureCalendarAlarm(uint16_t baseAddress,\r
199                                          RTC_B_configureCalendarAlarmParam *param);\r
200 \r
201 extern void RTC_B_setCalendarEvent(uint16_t baseAddress,\r
202                                    uint16_t eventSelect);\r
203 \r
204 extern void RTC_B_definePrescaleEvent(uint16_t baseAddress,\r
205                                       uint8_t prescaleSelect,\r
206                                       uint8_t prescaleEventDivider);\r
207 \r
208 extern uint8_t RTC_B_getPrescaleValue(uint16_t baseAddress,\r
209                                       uint8_t prescaleSelect);\r
210 \r
211 extern void RTC_B_setPrescaleValue(uint16_t baseAddress,\r
212                                    uint8_t prescaleSelect,\r
213                                    uint8_t prescaleCounterValue);\r
214 \r
215 extern void RTC_B_enableInterrupt(uint16_t baseAddress,\r
216                                   uint8_t interruptMask);\r
217 \r
218 extern void RTC_B_disableInterrupt(uint16_t baseAddress,\r
219                                    uint8_t interruptMask);\r
220 \r
221 extern uint8_t RTC_B_getInterruptStatus(uint16_t baseAddress,\r
222                                         uint8_t interruptFlagMask);\r
223 \r
224 extern void RTC_B_clearInterrupt(uint16_t baseAddress,\r
225                                  uint8_t interruptFlagMask);\r
226 \r
227 extern uint16_t RTC_B_convertBCDToBinary(uint16_t baseAddress,\r
228                                          uint16_t valueToConvert);\r
229 \r
230 extern uint16_t RTC_B_convertBinaryToBCD(uint16_t baseAddress,\r
231                                          uint16_t valueToConvert);\r
232 \r
233 //*****************************************************************************\r
234 //\r
235 // The following are deprecated APIs.\r
236 //\r
237 //*****************************************************************************\r
238 #define RTC_B_setPrescaleCounterValue                    RTC_B_setPrescaleValue\r
239 \r
240 //*****************************************************************************\r
241 //\r
242 // The following are deprecated APIs.\r
243 //\r
244 //*****************************************************************************\r
245 extern void RTC_B_calendarInit(uint16_t baseAddress,\r
246                                Calendar CalendarTime,\r
247                                uint16_t formatSelect);\r
248 \r
249 extern void RTC_B_setCalendarAlarm(uint16_t baseAddress,\r
250                                    uint8_t minutesAlarm,\r
251                                    uint8_t hoursAlarm,\r
252                                    uint8_t dayOfWeekAlarm,\r
253                                    uint8_t dayOfMonthAlarm);\r
254 \r
255 //*****************************************************************************\r
256 //\r
257 // Mark the end of the C bindings section for C++ compilers.\r
258 //\r
259 //*****************************************************************************\r
260 #ifdef __cplusplus\r
261 }\r
262 #endif\r
263 \r
264 #endif\r
265 #endif // __MSP430WARE_RTC_B_H__\r