MSP430 DriverLib for MSP430FR5xx_6xx Devices  2.70.00.08
 All Data Structures Files Functions Variables Enumerations Modules Pages
rtc_c.h
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 #ifdef __MSP430_HAS_RTC_C__
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 //
28 //! \brief Used in the RTC_C_initCalendar() function as the CalendarTime
29 //! parameter.
30 //
31 //*****************************************************************************
32 typedef struct Calendar {
33  //! Seconds of minute between 0-59
34  uint8_t Seconds;
35  //! Minutes of hour between 0-59
36  uint8_t Minutes;
37  //! Hour of day between 0-23
38  uint8_t Hours;
39  //! Day of week between 0-6
40  uint8_t DayOfWeek;
41  //! Day of month between 1-31
42  uint8_t DayOfMonth;
43  //! Month between 0-11
44  uint8_t Month;
45  //! Year between 0-4095
46  uint16_t Year;
47 } Calendar;
48 
49 //*****************************************************************************
50 //
51 //! \brief Used in the RTC_C_configureCalendarAlarm() function as the param
52 //! parameter.
53 //
54 //*****************************************************************************
56  //! Is the alarm condition for the minutes.
57  //! \n Valid values are:
58  //! - \b RTC_C_ALARMCONDITION_OFF [Default]
59  uint8_t minutesAlarm;
60  //! Is the alarm condition for the hours.
61  //! \n Valid values are:
62  //! - \b RTC_C_ALARMCONDITION_OFF [Default]
63  uint8_t hoursAlarm;
64  //! Is the alarm condition for the day of week.
65  //! \n Valid values are:
66  //! - \b RTC_C_ALARMCONDITION_OFF [Default]
67  uint8_t dayOfWeekAlarm;
68  //! Is the alarm condition for the day of the month.
69  //! \n Valid values are:
70  //! - \b RTC_C_ALARMCONDITION_OFF [Default]
71  uint8_t dayOfMonthAlarm;
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 //
228 //! \brief Starts the RTC.
229 //!
230 //! This function clears the RTC main hold bit to allow the RTC to function.
231 //!
232 //! \param baseAddress is the base address of the RTC_C module.
233 //!
234 //! \return None
235 //
236 //*****************************************************************************
237 extern void RTC_C_startClock(uint16_t baseAddress);
238 
239 //*****************************************************************************
240 //
241 //! \brief Holds the RTC.
242 //!
243 //! This function sets the RTC main hold bit to disable RTC functionality.
244 //!
245 //! \param baseAddress is the base address of the RTC_C module.
246 //!
247 //! \return None
248 //
249 //*****************************************************************************
250 extern void RTC_C_holdClock(uint16_t baseAddress);
251 
252 //*****************************************************************************
253 //
254 //! \brief Allows and Sets the frequency output to RTCCLK pin for calibration
255 //! measurement.
256 //!
257 //! This function sets a frequency to measure at the RTCCLK output pin. After
258 //! testing the set frequency, the calibration could be set accordingly.
259 //!
260 //! \param baseAddress is the base address of the RTC_C module.
261 //! \param frequencySelect is the frequency output to RTCCLK.
262 //! Valid values are:
263 //! - \b RTC_C_CALIBRATIONFREQ_OFF [Default] - turn off calibration
264 //! output
265 //! - \b RTC_C_CALIBRATIONFREQ_512HZ - output signal at 512Hz for
266 //! calibration
267 //! - \b RTC_C_CALIBRATIONFREQ_256HZ - output signal at 256Hz for
268 //! calibration
269 //! - \b RTC_C_CALIBRATIONFREQ_1HZ - output signal at 1Hz for
270 //! calibration
271 //! \n Modified bits are \b RTCCALF of \b RTCCTL3 register.
272 //!
273 //! \return None
274 //
275 //*****************************************************************************
276 extern void RTC_C_setCalibrationFrequency(uint16_t baseAddress,
277  uint16_t frequencySelect);
278 
279 //*****************************************************************************
280 //
281 //! \brief Sets the specified calibration for the RTC.
282 //!
283 //! This function sets the calibration offset to make the RTC as accurate as
284 //! possible. The offsetDirection can be either +4-ppm or -2-ppm, and the
285 //! offsetValue should be from 1-63 and is multiplied by the direction setting
286 //! (i.e. +4-ppm * 8 (offsetValue) = +32-ppm).
287 //!
288 //! \param baseAddress is the base address of the RTC_C module.
289 //! \param offsetDirection is the direction that the calibration offset will
290 //! go.
291 //! Valid values are:
292 //! - \b RTC_C_CALIBRATION_DOWN1PPM - calibrate at steps of -1
293 //! - \b RTC_C_CALIBRATION_UP1PPM - calibrate at steps of +1
294 //! \n Modified bits are \b RTC0CALS of \b RTC0CAL register.
295 //! \param offsetValue is the value that the offset will be a factor of; a
296 //! valid value is any integer from 1-240.
297 //! \n Modified bits are \b RTC0CALx of \b RTC0CAL register.
298 //!
299 //! \return None
300 //
301 //*****************************************************************************
302 extern void RTC_C_setCalibrationData(uint16_t baseAddress,
303  uint8_t offsetDirection,
304  uint8_t offsetValue);
305 
306 //*****************************************************************************
307 //
308 //! \brief Initializes the settings to operate the RTC in Counter mode.
309 //!
310 //! This function initializes the Counter mode of the RTC_C. Setting the clock
311 //! source and counter size will allow an interrupt from the RTCTEVIFG once an
312 //! overflow to the counter register occurs.
313 //!
314 //! \param baseAddress is the base address of the RTC_C module.
315 //! \param clockSelect is the selected clock for the counter mode to use.
316 //! Valid values are:
317 //! - \b RTC_C_CLOCKSELECT_32KHZ_OSC
318 //! - \b RTC_C_CLOCKSELECT_RT1PS
319 //! \n Modified bits are \b RTCSSEL of \b RTCCTL1 register.
320 //! \param counterSizeSelect is the size of the counter.
321 //! Valid values are:
322 //! - \b RTC_C_COUNTERSIZE_8BIT [Default]
323 //! - \b RTC_C_COUNTERSIZE_16BIT
324 //! - \b RTC_C_COUNTERSIZE_24BIT
325 //! - \b RTC_C_COUNTERSIZE_32BIT
326 //! \n Modified bits are \b RTCTEV of \b RTCCTL1 register.
327 //!
328 //! \return None
329 //
330 //*****************************************************************************
331 extern void RTC_C_initCounter(uint16_t baseAddress,
332  uint16_t clockSelect,
333  uint16_t counterSizeSelect);
334 
335 //*****************************************************************************
336 //
337 //! \brief Sets the specified temperature compensation for the RTC.
338 //!
339 //! This function sets the calibration offset to make the RTC as accurate as
340 //! possible. The offsetDirection can be either +1-ppm or -1-ppm, and the
341 //! offsetValue should be from 1-240 and is multiplied by the direction setting
342 //! (i.e. +1-ppm * 8 (offsetValue) = +8-ppm).
343 //!
344 //! \param baseAddress is the base address of the RTC_C module.
345 //! \param offsetDirection is the direction that the calibration offset wil go
346 //! Valid values are:
347 //! - \b RTC_C_COMPENSATION_DOWN1PPM
348 //! - \b RTC_C_COMPENSATION_UP1PPM
349 //! \n Modified bits are \b RTCTCMPS of \b RTCTCMP register.
350 //! \param offsetValue is the value that the offset will be a factor of; a
351 //! valid value is any integer from 1-240.
352 //! \n Modified bits are \b RTCTCMPx of \b RTCTCMP register.
353 //!
354 //! \return STATUS_SUCCESS or STATUS_FAILURE of setting the temperature
355 //! compensation
356 //
357 //*****************************************************************************
358 extern bool RTC_C_setTemperatureCompensation(uint16_t baseAddress,
359  uint16_t offsetDirection,
360  uint8_t offsetValue);
361 
362 //*****************************************************************************
363 //
364 //! \brief Initializes the settings to operate the RTC in calendar mode
365 //!
366 //! This function initializes the Calendar mode of the RTC module. To prevent
367 //! potential erroneous alarm conditions from occurring, the alarm should be
368 //! disabled by clearing the RTCAIE, RTCAIFG and AE bits with APIs:
369 //! RTC_C_disableInterrupt(), RTC_C_clearInterrupt() and
370 //! RTC_C_configureCalendarAlarm() before calendar initialization.
371 //!
372 //! \param baseAddress is the base address of the RTC_C module.
373 //! \param CalendarTime is the pointer to the structure containing the values
374 //! for the Calendar to be initialized to. Valid values should be of
375 //! type pointer to Calendar and should contain the following members
376 //! and corresponding values: \b Seconds between 0-59 \b Minutes between
377 //! 0-59 \b Hours between 0-23 \b DayOfWeek between 0-6 \b DayOfMonth
378 //! between 1-31 \b Year between 0-4095 NOTE: Values beyond the ones
379 //! specified may result in erratic behavior.
380 //! \param formatSelect is the format for the Calendar registers to use.
381 //! Valid values are:
382 //! - \b RTC_C_FORMAT_BINARY [Default]
383 //! - \b RTC_C_FORMAT_BCD
384 //! \n Modified bits are \b RTCBCD of \b RTCCTL1 register.
385 //!
386 //! \return None
387 //
388 //*****************************************************************************
389 extern void RTC_C_initCalendar(uint16_t baseAddress,
390  Calendar *CalendarTime,
391  uint16_t formatSelect);
392 
393 //*****************************************************************************
394 //
395 //! \brief Returns the Calendar Time stored in the Calendar registers of the
396 //! RTC.
397 //!
398 //! This function returns the current Calendar time in the form of a Calendar
399 //! structure. The RTCRDY polling is used in this function to prevent reading
400 //! invalid time.
401 //!
402 //! \param baseAddress is the base address of the RTC_C module.
403 //!
404 //! \return A Calendar structure containing the current time.
405 //
406 //*****************************************************************************
407 extern Calendar RTC_C_getCalendarTime(uint16_t baseAddress);
408 
409 //*****************************************************************************
410 //
411 //! \brief Sets and Enables the desired Calendar Alarm settings.
412 //!
413 //! This function sets a Calendar interrupt condition to assert the RTCAIFG
414 //! interrupt flag. The condition is a logical and of all of the parameters.
415 //! For example if the minutes and hours alarm is set, then the interrupt will
416 //! only assert when the minutes AND the hours change to the specified setting.
417 //! Use the RTC_C_ALARM_OFF for any alarm settings that should not be apart of
418 //! the alarm condition.
419 //!
420 //! \param baseAddress is the base address of the RTC_C module.
421 //! \param param is the pointer to struct for calendar alarm configuration.
422 //!
423 //! \return None
424 //
425 //*****************************************************************************
426 extern void RTC_C_configureCalendarAlarm(uint16_t baseAddress,
428 
429 //*****************************************************************************
430 //
431 //! \brief Sets a single specified Calendar interrupt condition
432 //!
433 //! This function sets a specified event to assert the RTCTEVIFG interrupt.
434 //! This interrupt is independent from the Calendar alarm interrupt.
435 //!
436 //! \param baseAddress is the base address of the RTC_C module.
437 //! \param eventSelect is the condition selected.
438 //! Valid values are:
439 //! - \b RTC_C_CALENDAREVENT_MINUTECHANGE - assert interrupt on every
440 //! minute
441 //! - \b RTC_C_CALENDAREVENT_HOURCHANGE - assert interrupt on every hour
442 //! - \b RTC_C_CALENDAREVENT_NOON - assert interrupt when hour is 12
443 //! - \b RTC_C_CALENDAREVENT_MIDNIGHT - assert interrupt when hour is 0
444 //! \n Modified bits are \b RTCTEV of \b RTCCTL register.
445 //!
446 //! \return None
447 //
448 //*****************************************************************************
449 extern void RTC_C_setCalendarEvent(uint16_t baseAddress,
450  uint16_t eventSelect);
451 
452 //*****************************************************************************
453 //
454 //! \brief Returns the value of the Counter register.
455 //!
456 //! This function returns the value of the counter register for the RTC_C
457 //! module. It will return the 32-bit value no matter the size set during
458 //! initialization. The RTC should be held before trying to use this function.
459 //!
460 //! \param baseAddress is the base address of the RTC_C module.
461 //!
462 //! \return The raw value of the full 32-bit Counter Register.
463 //
464 //*****************************************************************************
465 extern uint32_t RTC_C_getCounterValue(uint16_t baseAddress);
466 
467 //*****************************************************************************
468 //
469 //! \brief Sets the value of the Counter register
470 //!
471 //! This function sets the counter register of the RTC_C module.
472 //!
473 //! \param baseAddress is the base address of the RTC_C module.
474 //! \param counterValue is the value to set the Counter register to; a valid
475 //! value may be any 32-bit integer.
476 //!
477 //! \return None
478 //
479 //*****************************************************************************
480 extern void RTC_C_setCounterValue(uint16_t baseAddress,
481  uint32_t counterValue);
482 
483 //*****************************************************************************
484 //
485 //! \brief Initializes the Prescaler for Counter mode.
486 //!
487 //! This function initializes the selected prescaler for the counter mode in
488 //! the RTC_C module. If the RTC is initialized in Calendar mode, then these
489 //! are automatically initialized. The Prescalers can be used to divide a clock
490 //! source additionally before it gets to the main RTC clock.
491 //!
492 //! \param baseAddress is the base address of the RTC_C module.
493 //! \param prescaleSelect is the prescaler to initialize.
494 //! Valid values are:
495 //! - \b RTC_C_PRESCALE_0
496 //! - \b RTC_C_PRESCALE_1
497 //! \param prescaleClockSelect is the clock to drive the selected prescaler.
498 //! Valid values are:
499 //! - \b RTC_C_PSCLOCKSELECT_ACLK
500 //! - \b RTC_C_PSCLOCKSELECT_SMCLK
501 //! - \b RTC_C_PSCLOCKSELECT_RT0PS - use Prescaler 0 as source to
502 //! Prescaler 1 (May only be used if prescaleSelect is
503 //! RTC_C_PRESCALE_1)
504 //! \n Modified bits are \b RTxSSEL of \b RTCPSxCTL register.
505 //! \param prescaleDivider is the divider for the selected clock source.
506 //! Valid values are:
507 //! - \b RTC_C_PSDIVIDER_2 [Default]
508 //! - \b RTC_C_PSDIVIDER_4
509 //! - \b RTC_C_PSDIVIDER_8
510 //! - \b RTC_C_PSDIVIDER_16
511 //! - \b RTC_C_PSDIVIDER_32
512 //! - \b RTC_C_PSDIVIDER_64
513 //! - \b RTC_C_PSDIVIDER_128
514 //! - \b RTC_C_PSDIVIDER_256
515 //! \n Modified bits are \b RTxPSDIV of \b RTCPSxCTL register.
516 //!
517 //! \return None
518 //
519 //*****************************************************************************
520 extern void RTC_C_initCounterPrescale(uint16_t baseAddress,
521  uint8_t prescaleSelect,
522  uint16_t prescaleClockSelect,
523  uint16_t prescaleDivider);
524 
525 //*****************************************************************************
526 //
527 //! \brief Holds the selected Prescaler.
528 //!
529 //! This function holds the prescale counter from continuing. This will only
530 //! work in counter mode, in Calendar mode, the RTC_C_holdClock() must be used.
531 //! In counter mode, if using both prescalers in conjunction with the main RTC
532 //! counter, then stopping RT0PS will stop RT1PS, but stopping RT1PS will not
533 //! stop RT0PS.
534 //!
535 //! \param baseAddress is the base address of the RTC_C module.
536 //! \param prescaleSelect is the prescaler to hold.
537 //! Valid values are:
538 //! - \b RTC_C_PRESCALE_0
539 //! - \b RTC_C_PRESCALE_1
540 //!
541 //! \return None
542 //
543 //*****************************************************************************
544 extern void RTC_C_holdCounterPrescale(uint16_t baseAddress,
545  uint8_t prescaleSelect);
546 
547 //*****************************************************************************
548 //
549 //! \brief Starts the selected Prescaler.
550 //!
551 //! This function starts the selected prescale counter. This function will only
552 //! work if the RTC is in counter mode.
553 //!
554 //! \param baseAddress is the base address of the RTC_C module.
555 //! \param prescaleSelect is the prescaler to start.
556 //! Valid values are:
557 //! - \b RTC_C_PRESCALE_0
558 //! - \b RTC_C_PRESCALE_1
559 //!
560 //! \return None
561 //
562 //*****************************************************************************
563 extern void RTC_C_startCounterPrescale(uint16_t baseAddress,
564  uint8_t prescaleSelect);
565 
566 //*****************************************************************************
567 //
568 //! \brief Sets up an interrupt condition for the selected Prescaler.
569 //!
570 //! This function sets the condition for an interrupt to assert based on the
571 //! individual prescalers.
572 //!
573 //! \param baseAddress is the base address of the RTC_C module.
574 //! \param prescaleSelect is the prescaler to define an interrupt for.
575 //! Valid values are:
576 //! - \b RTC_C_PRESCALE_0
577 //! - \b RTC_C_PRESCALE_1
578 //! \param prescaleEventDivider is a divider to specify when an interrupt can
579 //! occur based on the clock source of the selected prescaler. (Does not
580 //! affect timer of the selected prescaler).
581 //! Valid values are:
582 //! - \b RTC_C_PSEVENTDIVIDER_2 [Default]
583 //! - \b RTC_C_PSEVENTDIVIDER_4
584 //! - \b RTC_C_PSEVENTDIVIDER_8
585 //! - \b RTC_C_PSEVENTDIVIDER_16
586 //! - \b RTC_C_PSEVENTDIVIDER_32
587 //! - \b RTC_C_PSEVENTDIVIDER_64
588 //! - \b RTC_C_PSEVENTDIVIDER_128
589 //! - \b RTC_C_PSEVENTDIVIDER_256
590 //! \n Modified bits are \b RTxIP of \b RTCPSxCTL register.
591 //!
592 //! \return None
593 //
594 //*****************************************************************************
595 extern void RTC_C_definePrescaleEvent(uint16_t baseAddress,
596  uint8_t prescaleSelect,
597  uint8_t prescaleEventDivider);
598 
599 //*****************************************************************************
600 //
601 //! \brief Returns the selected prescaler value.
602 //!
603 //! This function returns the value of the selected prescale counter register.
604 //! Note that the counter value should be held by calling RTC_C_holdClock()
605 //! before calling this API.
606 //!
607 //! \param baseAddress is the base address of the RTC_C module.
608 //! \param prescaleSelect is the prescaler to obtain the value of.
609 //! Valid values are:
610 //! - \b RTC_C_PRESCALE_0
611 //! - \b RTC_C_PRESCALE_1
612 //!
613 //! \return The value of the specified prescaler count register
614 //
615 //*****************************************************************************
616 extern uint8_t RTC_C_getPrescaleValue(uint16_t baseAddress,
617  uint8_t prescaleSelect);
618 
619 //*****************************************************************************
620 //
621 //! \brief Sets the selected Prescaler value.
622 //!
623 //! This function sets the prescale counter value. Before setting the prescale
624 //! counter, it should be held by calling RTC_C_holdClock().
625 //!
626 //! \param baseAddress is the base address of the RTC_C module.
627 //! \param prescaleSelect is the prescaler to set the value for.
628 //! Valid values are:
629 //! - \b RTC_C_PRESCALE_0
630 //! - \b RTC_C_PRESCALE_1
631 //! \param prescaleCounterValue is the specified value to set the prescaler to.
632 //! Valid values are any integer between 0-255
633 //! \n Modified bits are \b RTxPS of \b RTxPS register.
634 //!
635 //! \return None
636 //
637 //*****************************************************************************
638 extern void RTC_C_setPrescaleValue(uint16_t baseAddress,
639  uint8_t prescaleSelect,
640  uint8_t prescaleCounterValue);
641 
642 //*****************************************************************************
643 //
644 //! \brief Enables selected RTC interrupt sources.
645 //!
646 //! This function enables the selected RTC interrupt source. Only the sources
647 //! that are enabled can be reflected to the processor interrupt; disabled
648 //! sources have no effect on the processor. Does not clear interrupt flags.
649 //!
650 //! \param baseAddress is the base address of the RTC_C module.
651 //! \param interruptMask is a bit mask of the interrupts to enable.
652 //! Mask value is the logical OR of any of the following:
653 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
654 //! counter mode or when Calendar event condition defined by
655 //! defineCalendarEvent() is met.
656 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
657 //! Calendar mode is met.
658 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
659 //! registers are settled.
660 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
661 //! event condition is met.
662 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
663 //! event condition is met.
664 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
665 //! problem with the 32kHz oscillator, while the RTC is running.
666 //!
667 //! \return None
668 //
669 //*****************************************************************************
670 extern void RTC_C_enableInterrupt(uint16_t baseAddress,
671  uint8_t interruptMask);
672 
673 //*****************************************************************************
674 //
675 //! \brief Disables selected RTC interrupt sources.
676 //!
677 //! This function disables the selected RTC interrupt source. Only the sources
678 //! that are enabled can be reflected to the processor interrupt; disabled
679 //! sources have no effect on the processor.
680 //!
681 //! \param baseAddress is the base address of the RTC_C module.
682 //! \param interruptMask is a bit mask of the interrupts to disable.
683 //! Mask value is the logical OR of any of the following:
684 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
685 //! counter mode or when Calendar event condition defined by
686 //! defineCalendarEvent() is met.
687 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
688 //! Calendar mode is met.
689 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
690 //! registers are settled.
691 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
692 //! event condition is met.
693 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
694 //! event condition is met.
695 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
696 //! problem with the 32kHz oscillator, while the RTC is running.
697 //!
698 //! \return None
699 //
700 //*****************************************************************************
701 extern void RTC_C_disableInterrupt(uint16_t baseAddress,
702  uint8_t interruptMask);
703 
704 //*****************************************************************************
705 //
706 //! \brief Returns the status of the selected interrupts flags.
707 //!
708 //! This function returns the status of the interrupt flag for the selected
709 //! channel.
710 //!
711 //! \param baseAddress is the base address of the RTC_C module.
712 //! \param interruptFlagMask is a bit mask of the interrupt flags to return the
713 //! status of.
714 //! Mask value is the logical OR of any of the following:
715 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
716 //! counter mode or when Calendar event condition defined by
717 //! defineCalendarEvent() is met.
718 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
719 //! Calendar mode is met.
720 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
721 //! registers are settled.
722 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
723 //! event condition is met.
724 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
725 //! event condition is met.
726 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
727 //! problem with the 32kHz oscillator, while the RTC is running.
728 //!
729 //! \return Logical OR of any of the following:
730 //! - \b RTC_C_TIME_EVENT_INTERRUPT asserts when counter overflows in
731 //! counter mode or when Calendar event condition defined by
732 //! defineCalendarEvent() is met.
733 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT asserts when alarm condition in
734 //! Calendar mode is met.
735 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT asserts when Calendar
736 //! registers are settled.
737 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT asserts when Prescaler 0 event
738 //! condition is met.
739 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT asserts when Prescaler 1 event
740 //! condition is met.
741 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT asserts if there is a problem
742 //! with the 32kHz oscillator, while the RTC is running.
743 //! \n indicating the status of the masked interrupts
744 //
745 //*****************************************************************************
746 extern uint8_t RTC_C_getInterruptStatus(uint16_t baseAddress,
747  uint8_t interruptFlagMask);
748 
749 //*****************************************************************************
750 //
751 //! \brief Clears selected RTC interrupt flags.
752 //!
753 //! This function clears the RTC interrupt flag is cleared, so that it no
754 //! longer asserts.
755 //!
756 //! \param baseAddress is the base address of the RTC_C module.
757 //! \param interruptFlagMask is a bit mask of the interrupt flags to be
758 //! cleared.
759 //! Mask value is the logical OR of any of the following:
760 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
761 //! counter mode or when Calendar event condition defined by
762 //! defineCalendarEvent() is met.
763 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
764 //! Calendar mode is met.
765 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
766 //! registers are settled.
767 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
768 //! event condition is met.
769 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
770 //! event condition is met.
771 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
772 //! problem with the 32kHz oscillator, while the RTC is running.
773 //!
774 //! \return None
775 //
776 //*****************************************************************************
777 extern void RTC_C_clearInterrupt(uint16_t baseAddress,
778  uint8_t interruptFlagMask);
779 
780 //*****************************************************************************
781 //
782 //! \brief Convert the given BCD value to binary format
783 //!
784 //! This function converts BCD values to binary format. This API uses the
785 //! hardware registers to perform the conversion rather than a software method.
786 //!
787 //! \param baseAddress is the base address of the RTC_C module.
788 //! \param valueToConvert is the raw value in BCD format to convert to Binary.
789 //! \n Modified bits are \b BCD2BIN of \b BCD2BIN register.
790 //!
791 //! \return The binary version of the input parameter
792 //
793 //*****************************************************************************
794 extern uint16_t RTC_C_convertBCDToBinary(uint16_t baseAddress,
795  uint16_t valueToConvert);
796 
797 //*****************************************************************************
798 //
799 //! \brief Convert the given binary value to BCD format
800 //!
801 //! This function converts binary values to BCD format. This API uses the
802 //! hardware registers to perform the conversion rather than a software method.
803 //!
804 //! \param baseAddress is the base address of the RTC_C module.
805 //! \param valueToConvert is the raw value in Binary format to convert to BCD.
806 //! \n Modified bits are \b BIN2BCD of \b BIN2BCD register.
807 //!
808 //! \return The BCD version of the valueToConvert parameter
809 //
810 //*****************************************************************************
811 extern uint16_t RTC_C_convertBinaryToBCD(uint16_t baseAddress,
812  uint16_t valueToConvert);
813 
814 //*****************************************************************************
815 //
816 // Mark the end of the C bindings section for C++ compilers.
817 //
818 //*****************************************************************************
819 #ifdef __cplusplus
820 }
821 #endif
822 
823 #endif
824 #endif // __MSP430WARE_RTC_C_H__
void RTC_C_setCounterValue(uint16_t baseAddress, uint32_t counterValue)
Sets the value of the Counter register.
Definition: rtc_c.c:151
uint8_t Hours
Hour of day between 0-23.
Definition: rtc_b.h:38
void RTC_C_setCalendarEvent(uint16_t baseAddress, uint16_t eventSelect)
Sets a single specified Calendar interrupt condition.
Definition: rtc_c.c:130
void RTC_C_initCounter(uint16_t baseAddress, uint16_t clockSelect, uint16_t counterSizeSelect)
Initializes the settings to operate the RTC in Counter mode.
Definition: rtc_c.c:53
uint8_t RTC_C_getInterruptStatus(uint16_t baseAddress, uint8_t interruptFlagMask)
Returns the status of the selected interrupts flags.
Definition: rtc_c.c:262
void RTC_C_holdClock(uint16_t baseAddress)
Holds the RTC.
Definition: rtc_c.c:28
void RTC_C_setCalibrationData(uint16_t baseAddress, uint8_t offsetDirection, uint8_t offsetValue)
Sets the specified calibration for the RTC.
Definition: rtc_c.c:44
uint8_t dayOfMonthAlarm
Definition: rtc_c.h:71
uint32_t RTC_C_getCounterValue(uint16_t baseAddress)
Returns the value of the Counter register.
Definition: rtc_c.c:139
uint16_t RTC_C_convertBinaryToBCD(uint16_t baseAddress, uint16_t valueToConvert)
Convert the given binary value to BCD format.
Definition: rtc_c.c:324
uint16_t Year
Year between 0-4095.
Definition: rtc_b.h:46
uint16_t RTC_C_convertBCDToBinary(uint16_t baseAddress, uint16_t valueToConvert)
Convert the given BCD value to binary format.
Definition: rtc_c.c:317
uint8_t hoursAlarm
Definition: rtc_c.h:63
void RTC_C_startCounterPrescale(uint16_t baseAddress, uint8_t prescaleSelect)
Starts the selected Prescaler.
Definition: rtc_c.c:183
uint8_t DayOfWeek
Day of week between 0-6.
Definition: rtc_b.h:40
uint8_t RTC_C_getPrescaleValue(uint16_t baseAddress, uint8_t prescaleSelect)
Returns the selected prescaler value.
Definition: rtc_c.c:198
uint8_t Minutes
Minutes of hour between 0-59.
Definition: rtc_b.h:36
Calendar RTC_C_getCalendarTime(uint16_t baseAddress)
Returns the Calendar Time stored in the Calendar registers of the RTC.
Definition: rtc_c.c:103
uint8_t Month
Month between 0-11.
Definition: rtc_b.h:44
uint8_t DayOfMonth
Day of month between 1-31.
Definition: rtc_b.h:42
Used in the RTC_B_initCalendar() function as the CalendarTime parameter.
Definition: rtc_b.h:32
bool RTC_C_setTemperatureCompensation(uint16_t baseAddress, uint16_t offsetDirection, uint8_t offsetValue)
Sets the specified temperature compensation for the RTC.
Definition: rtc_c.c:64
uint8_t dayOfWeekAlarm
Definition: rtc_c.h:67
void RTC_C_definePrescaleEvent(uint16_t baseAddress, uint8_t prescaleSelect, uint8_t prescaleEventDivider)
Sets up an interrupt condition for the selected Prescaler.
Definition: rtc_c.c:189
uint8_t minutesAlarm
Definition: rtc_c.h:59
void RTC_C_initCounterPrescale(uint16_t baseAddress, uint8_t prescaleSelect, uint16_t prescaleClockSelect, uint16_t prescaleDivider)
Initializes the Prescaler for Counter mode.
Definition: rtc_c.c:167
void RTC_C_clearInterrupt(uint16_t baseAddress, uint8_t interruptFlagMask)
Clears selected RTC interrupt flags.
Definition: rtc_c.c:291
void RTC_C_startClock(uint16_t baseAddress)
Starts the RTC.
Definition: rtc_c.c:21
void RTC_C_initCalendar(uint16_t baseAddress, Calendar *CalendarTime, uint16_t formatSelect)
Initializes the settings to operate the RTC in calendar mode.
Definition: rtc_c.c:80
Used in the RTC_C_configureCalendarAlarm() function as the param parameter.
Definition: rtc_c.h:55
void RTC_C_setCalibrationFrequency(uint16_t baseAddress, uint16_t frequencySelect)
Allows and Sets the frequency output to RTCCLK pin for calibration measurement.
Definition: rtc_c.c:35
void RTC_C_enableInterrupt(uint16_t baseAddress, uint8_t interruptMask)
Enables selected RTC interrupt sources.
Definition: rtc_c.c:223
void RTC_C_disableInterrupt(uint16_t baseAddress, uint8_t interruptMask)
Disables selected RTC interrupt sources.
Definition: rtc_c.c:242
void RTC_C_setPrescaleValue(uint16_t baseAddress, uint8_t prescaleSelect, uint8_t prescaleCounterValue)
Sets the selected Prescaler value.
Definition: rtc_c.c:210
void RTC_C_holdCounterPrescale(uint16_t baseAddress, uint8_t prescaleSelect)
Holds the selected Prescaler.
Definition: rtc_c.c:177
void RTC_C_configureCalendarAlarm(uint16_t baseAddress, RTC_C_configureCalendarAlarmParam *param)
Sets and Enables the desired Calendar Alarm settings.
Definition: rtc_c.c:120
uint8_t Seconds
Seconds of minute between 0-59.
Definition: rtc_b.h:34

Copyright 2016, Texas Instruments Incorporated