MSP430 DriverLib for MSP430FR5xx_6xx Devices  2.91.13.01
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 1-12
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 +1-ppm or -1-ppm, and the
285 //! offsetValue should be from 1-240 and is multiplied by the direction setting
286 //! (i.e. +1-ppm * 8 (offsetValue) = +8-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: \n\b Seconds between 0-59 \n\b Minutes
377 //! between 0-59 \n\b Hours between 0-23 \n\b DayOfWeek between 0-6 \n\b
378 //! DayOfMonth between 1-31 \n\b Month between 1-12 \n\b Year between
379 //! 0-4095 \n\b NOTE: Values beyond the ones specified may result in
380 //! erratic behavior.
381 //! \param formatSelect is the format for the Calendar registers to use.
382 //! Valid values are:
383 //! - \b RTC_C_FORMAT_BINARY [Default]
384 //! - \b RTC_C_FORMAT_BCD
385 //! \n Modified bits are \b RTCBCD of \b RTCCTL1 register.
386 //!
387 //! \return None
388 //
389 //*****************************************************************************
390 extern void RTC_C_initCalendar(uint16_t baseAddress,
391  Calendar *CalendarTime,
392  uint16_t formatSelect);
393 
394 //*****************************************************************************
395 //
396 //! \brief Returns the Calendar Time stored in the Calendar registers of the
397 //! RTC.
398 //!
399 //! This function returns the current Calendar time in the form of a Calendar
400 //! structure. The RTCRDY polling is used in this function to prevent reading
401 //! invalid time.
402 //!
403 //! \param baseAddress is the base address of the RTC_C module.
404 //!
405 //! \return A Calendar structure containing the current time.
406 //
407 //*****************************************************************************
408 extern Calendar RTC_C_getCalendarTime(uint16_t baseAddress);
409 
410 //*****************************************************************************
411 //
412 //! \brief Sets and Enables the desired Calendar Alarm settings.
413 //!
414 //! This function sets a Calendar interrupt condition to assert the RTCAIFG
415 //! interrupt flag. The condition is a logical and of all of the parameters.
416 //! For example if the minutes and hours alarm is set, then the interrupt will
417 //! only assert when the minutes AND the hours change to the specified setting.
418 //! Use the RTC_C_ALARM_OFF for any alarm settings that should not be apart of
419 //! the alarm condition.
420 //!
421 //! \param baseAddress is the base address of the RTC_C module.
422 //! \param param is the pointer to struct for calendar alarm configuration.
423 //!
424 //! \return None
425 //
426 //*****************************************************************************
427 extern void RTC_C_configureCalendarAlarm(uint16_t baseAddress,
429 
430 //*****************************************************************************
431 //
432 //! \brief Sets a single specified Calendar interrupt condition
433 //!
434 //! This function sets a specified event to assert the RTCTEVIFG interrupt.
435 //! This interrupt is independent from the Calendar alarm interrupt.
436 //!
437 //! \param baseAddress is the base address of the RTC_C module.
438 //! \param eventSelect is the condition selected.
439 //! Valid values are:
440 //! - \b RTC_C_CALENDAREVENT_MINUTECHANGE - assert interrupt on every
441 //! minute
442 //! - \b RTC_C_CALENDAREVENT_HOURCHANGE - assert interrupt on every hour
443 //! - \b RTC_C_CALENDAREVENT_NOON - assert interrupt when hour is 12
444 //! - \b RTC_C_CALENDAREVENT_MIDNIGHT - assert interrupt when hour is 0
445 //! \n Modified bits are \b RTCTEV of \b RTCCTL register.
446 //!
447 //! \return None
448 //
449 //*****************************************************************************
450 extern void RTC_C_setCalendarEvent(uint16_t baseAddress,
451  uint16_t eventSelect);
452 
453 //*****************************************************************************
454 //
455 //! \brief Returns the value of the Counter register.
456 //!
457 //! This function returns the value of the counter register for the RTC_C
458 //! module. It will return the 32-bit value no matter the size set during
459 //! initialization. The RTC should be held before trying to use this function.
460 //!
461 //! \param baseAddress is the base address of the RTC_C module.
462 //!
463 //! \return The raw value of the full 32-bit Counter Register.
464 //
465 //*****************************************************************************
466 extern uint32_t RTC_C_getCounterValue(uint16_t baseAddress);
467 
468 //*****************************************************************************
469 //
470 //! \brief Sets the value of the Counter register
471 //!
472 //! This function sets the counter register of the RTC_C module.
473 //!
474 //! \param baseAddress is the base address of the RTC_C module.
475 //! \param counterValue is the value to set the Counter register to; a valid
476 //! value may be any 32-bit integer.
477 //!
478 //! \return None
479 //
480 //*****************************************************************************
481 extern void RTC_C_setCounterValue(uint16_t baseAddress,
482  uint32_t counterValue);
483 
484 //*****************************************************************************
485 //
486 //! \brief Initializes the Prescaler for Counter mode.
487 //!
488 //! This function initializes the selected prescaler for the counter mode in
489 //! the RTC_C module. If the RTC is initialized in Calendar mode, then these
490 //! are automatically initialized. The Prescalers can be used to divide a clock
491 //! source additionally before it gets to the main RTC clock.
492 //!
493 //! \param baseAddress is the base address of the RTC_C module.
494 //! \param prescaleSelect is the prescaler to initialize.
495 //! Valid values are:
496 //! - \b RTC_C_PRESCALE_0
497 //! - \b RTC_C_PRESCALE_1
498 //! \param prescaleClockSelect is the clock to drive the selected prescaler.
499 //! Valid values are:
500 //! - \b RTC_C_PSCLOCKSELECT_ACLK
501 //! - \b RTC_C_PSCLOCKSELECT_SMCLK
502 //! - \b RTC_C_PSCLOCKSELECT_RT0PS - use Prescaler 0 as source to
503 //! Prescaler 1 (May only be used if prescaleSelect is
504 //! RTC_C_PRESCALE_1)
505 //! \n Modified bits are \b RTxSSEL of \b RTCPSxCTL register.
506 //! \param prescaleDivider is the divider for the selected clock source.
507 //! Valid values are:
508 //! - \b RTC_C_PSDIVIDER_2 [Default]
509 //! - \b RTC_C_PSDIVIDER_4
510 //! - \b RTC_C_PSDIVIDER_8
511 //! - \b RTC_C_PSDIVIDER_16
512 //! - \b RTC_C_PSDIVIDER_32
513 //! - \b RTC_C_PSDIVIDER_64
514 //! - \b RTC_C_PSDIVIDER_128
515 //! - \b RTC_C_PSDIVIDER_256
516 //! \n Modified bits are \b RTxPSDIV of \b RTCPSxCTL register.
517 //!
518 //! \return None
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 //
528 //! \brief Holds the selected Prescaler.
529 //!
530 //! This function holds the prescale counter from continuing. This will only
531 //! work in counter mode, in Calendar mode, the RTC_C_holdClock() must be used.
532 //! In counter mode, if using both prescalers in conjunction with the main RTC
533 //! counter, then stopping RT0PS will stop RT1PS, but stopping RT1PS will not
534 //! stop RT0PS.
535 //!
536 //! \param baseAddress is the base address of the RTC_C module.
537 //! \param prescaleSelect is the prescaler to hold.
538 //! Valid values are:
539 //! - \b RTC_C_PRESCALE_0
540 //! - \b RTC_C_PRESCALE_1
541 //!
542 //! \return None
543 //
544 //*****************************************************************************
545 extern void RTC_C_holdCounterPrescale(uint16_t baseAddress,
546  uint8_t prescaleSelect);
547 
548 //*****************************************************************************
549 //
550 //! \brief Starts the selected Prescaler.
551 //!
552 //! This function starts the selected prescale counter. This function will only
553 //! work if the RTC is in counter mode.
554 //!
555 //! \param baseAddress is the base address of the RTC_C module.
556 //! \param prescaleSelect is the prescaler to start.
557 //! Valid values are:
558 //! - \b RTC_C_PRESCALE_0
559 //! - \b RTC_C_PRESCALE_1
560 //!
561 //! \return None
562 //
563 //*****************************************************************************
564 extern void RTC_C_startCounterPrescale(uint16_t baseAddress,
565  uint8_t prescaleSelect);
566 
567 //*****************************************************************************
568 //
569 //! \brief Sets up an interrupt condition for the selected Prescaler.
570 //!
571 //! This function sets the condition for an interrupt to assert based on the
572 //! individual prescalers.
573 //!
574 //! \param baseAddress is the base address of the RTC_C module.
575 //! \param prescaleSelect is the prescaler to define an interrupt for.
576 //! Valid values are:
577 //! - \b RTC_C_PRESCALE_0
578 //! - \b RTC_C_PRESCALE_1
579 //! \param prescaleEventDivider is a divider to specify when an interrupt can
580 //! occur based on the clock source of the selected prescaler. (Does not
581 //! affect timer of the selected prescaler).
582 //! Valid values are:
583 //! - \b RTC_C_PSEVENTDIVIDER_2 [Default]
584 //! - \b RTC_C_PSEVENTDIVIDER_4
585 //! - \b RTC_C_PSEVENTDIVIDER_8
586 //! - \b RTC_C_PSEVENTDIVIDER_16
587 //! - \b RTC_C_PSEVENTDIVIDER_32
588 //! - \b RTC_C_PSEVENTDIVIDER_64
589 //! - \b RTC_C_PSEVENTDIVIDER_128
590 //! - \b RTC_C_PSEVENTDIVIDER_256
591 //! \n Modified bits are \b RTxIP of \b RTCPSxCTL register.
592 //!
593 //! \return None
594 //
595 //*****************************************************************************
596 extern void RTC_C_definePrescaleEvent(uint16_t baseAddress,
597  uint8_t prescaleSelect,
598  uint8_t prescaleEventDivider);
599 
600 //*****************************************************************************
601 //
602 //! \brief Returns the selected prescaler value.
603 //!
604 //! This function returns the value of the selected prescale counter register.
605 //! Note that the counter value should be held by calling RTC_C_holdClock()
606 //! before calling this API.
607 //!
608 //! \param baseAddress is the base address of the RTC_C module.
609 //! \param prescaleSelect is the prescaler to obtain the value of.
610 //! Valid values are:
611 //! - \b RTC_C_PRESCALE_0
612 //! - \b RTC_C_PRESCALE_1
613 //!
614 //! \return The value of the specified prescaler count register
615 //
616 //*****************************************************************************
617 extern uint8_t RTC_C_getPrescaleValue(uint16_t baseAddress,
618  uint8_t prescaleSelect);
619 
620 //*****************************************************************************
621 //
622 //! \brief Sets the selected Prescaler value.
623 //!
624 //! This function sets the prescale counter value. Before setting the prescale
625 //! counter, it should be held by calling RTC_C_holdClock().
626 //!
627 //! \param baseAddress is the base address of the RTC_C module.
628 //! \param prescaleSelect is the prescaler to set the value for.
629 //! Valid values are:
630 //! - \b RTC_C_PRESCALE_0
631 //! - \b RTC_C_PRESCALE_1
632 //! \param prescaleCounterValue is the specified value to set the prescaler to.
633 //! Valid values are any integer between 0-255
634 //! \n Modified bits are \b RTxPS of \b RTxPS register.
635 //!
636 //! \return None
637 //
638 //*****************************************************************************
639 extern void RTC_C_setPrescaleValue(uint16_t baseAddress,
640  uint8_t prescaleSelect,
641  uint8_t prescaleCounterValue);
642 
643 //*****************************************************************************
644 //
645 //! \brief Enables selected RTC interrupt sources.
646 //!
647 //! This function enables the selected RTC interrupt source. Only the sources
648 //! that are enabled can be reflected to the processor interrupt; disabled
649 //! sources have no effect on the processor. Does not clear interrupt flags.
650 //!
651 //! \param baseAddress is the base address of the RTC_C module.
652 //! \param interruptMask is a bit mask of the interrupts to enable.
653 //! Mask value is the logical OR of any of the following:
654 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
655 //! counter mode or when Calendar event condition defined by
656 //! defineCalendarEvent() is met.
657 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
658 //! Calendar mode is met.
659 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
660 //! registers are settled.
661 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
662 //! event condition is met.
663 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
664 //! event condition is met.
665 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
666 //! problem with the 32kHz oscillator, while the RTC is running.
667 //!
668 //! \return None
669 //
670 //*****************************************************************************
671 extern void RTC_C_enableInterrupt(uint16_t baseAddress,
672  uint8_t interruptMask);
673 
674 //*****************************************************************************
675 //
676 //! \brief Disables selected RTC interrupt sources.
677 //!
678 //! This function disables the selected RTC interrupt source. Only the sources
679 //! that are enabled can be reflected to the processor interrupt; disabled
680 //! sources have no effect on the processor.
681 //!
682 //! \param baseAddress is the base address of the RTC_C module.
683 //! \param interruptMask is a bit mask of the interrupts to disable.
684 //! Mask value is the logical OR of any of the following:
685 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
686 //! counter mode or when Calendar event condition defined by
687 //! defineCalendarEvent() is met.
688 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
689 //! Calendar mode is met.
690 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
691 //! registers are settled.
692 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
693 //! event condition is met.
694 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
695 //! event condition is met.
696 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
697 //! problem with the 32kHz oscillator, while the RTC is running.
698 //!
699 //! \return None
700 //
701 //*****************************************************************************
702 extern void RTC_C_disableInterrupt(uint16_t baseAddress,
703  uint8_t interruptMask);
704 
705 //*****************************************************************************
706 //
707 //! \brief Returns the status of the selected interrupts flags.
708 //!
709 //! This function returns the status of the interrupt flag for the selected
710 //! channel.
711 //!
712 //! \param baseAddress is the base address of the RTC_C module.
713 //! \param interruptFlagMask is a bit mask of the interrupt flags to return the
714 //! status of.
715 //! Mask value is the logical OR of any of the following:
716 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
717 //! counter mode or when Calendar event condition defined by
718 //! defineCalendarEvent() is met.
719 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
720 //! Calendar mode is met.
721 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
722 //! registers are settled.
723 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
724 //! event condition is met.
725 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
726 //! event condition is met.
727 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
728 //! problem with the 32kHz oscillator, while the RTC is running.
729 //!
730 //! \return Logical OR of any of the following:
731 //! - \b RTC_C_TIME_EVENT_INTERRUPT asserts when counter overflows in
732 //! counter mode or when Calendar event condition defined by
733 //! defineCalendarEvent() is met.
734 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT asserts when alarm condition in
735 //! Calendar mode is met.
736 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT asserts when Calendar
737 //! registers are settled.
738 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT asserts when Prescaler 0 event
739 //! condition is met.
740 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT asserts when Prescaler 1 event
741 //! condition is met.
742 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT asserts if there is a problem
743 //! with the 32kHz oscillator, while the RTC is running.
744 //! \n indicating the status of the masked interrupts
745 //
746 //*****************************************************************************
747 extern uint8_t RTC_C_getInterruptStatus(uint16_t baseAddress,
748  uint8_t interruptFlagMask);
749 
750 //*****************************************************************************
751 //
752 //! \brief Clears selected RTC interrupt flags.
753 //!
754 //! This function clears the RTC interrupt flag is cleared, so that it no
755 //! longer asserts.
756 //!
757 //! \param baseAddress is the base address of the RTC_C module.
758 //! \param interruptFlagMask is a bit mask of the interrupt flags to be
759 //! cleared.
760 //! Mask value is the logical OR of any of the following:
761 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in
762 //! counter mode or when Calendar event condition defined by
763 //! defineCalendarEvent() is met.
764 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in
765 //! Calendar mode is met.
766 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar
767 //! registers are settled.
768 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0
769 //! event condition is met.
770 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1
771 //! event condition is met.
772 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a
773 //! problem with the 32kHz oscillator, while the RTC is running.
774 //!
775 //! \return None
776 //
777 //*****************************************************************************
778 extern void RTC_C_clearInterrupt(uint16_t baseAddress,
779  uint8_t interruptFlagMask);
780 
781 //*****************************************************************************
782 //
783 //! \brief Convert the given BCD value to binary format
784 //!
785 //! This function converts BCD values to binary format. This API uses the
786 //! hardware registers to perform the conversion rather than a software method.
787 //!
788 //! \param baseAddress is the base address of the RTC_C module.
789 //! \param valueToConvert is the raw value in BCD format to convert to Binary.
790 //! \n Modified bits are \b BCD2BIN of \b BCD2BIN register.
791 //!
792 //! \return The binary version of the input parameter
793 //
794 //*****************************************************************************
795 extern uint16_t RTC_C_convertBCDToBinary(uint16_t baseAddress,
796  uint16_t valueToConvert);
797 
798 //*****************************************************************************
799 //
800 //! \brief Convert the given binary value to BCD format
801 //!
802 //! This function converts binary values to BCD format. This API uses the
803 //! hardware registers to perform the conversion rather than a software method.
804 //!
805 //! \param baseAddress is the base address of the RTC_C module.
806 //! \param valueToConvert is the raw value in Binary format to convert to BCD.
807 //! \n Modified bits are \b BIN2BCD of \b BIN2BCD register.
808 //!
809 //! \return The BCD version of the valueToConvert parameter
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__
void RTC_C_setCounterValue(uint16_t baseAddress, uint32_t counterValue)
Sets the value of the Counter register.
Definition: rtc_c.c:155
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:134
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:270
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:143
uint16_t RTC_C_convertBinaryToBCD(uint16_t baseAddress, uint16_t valueToConvert)
Convert the given binary value to BCD format.
Definition: rtc_c.c:332
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:325
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:191
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:206
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:107
uint8_t Month
Month between 1-12.
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:68
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:197
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:171
void RTC_C_clearInterrupt(uint16_t baseAddress, uint8_t interruptFlagMask)
Clears selected RTC interrupt flags.
Definition: rtc_c.c:299
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:84
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:231
void RTC_C_disableInterrupt(uint16_t baseAddress, uint8_t interruptMask)
Disables selected RTC interrupt sources.
Definition: rtc_c.c:250
void RTC_C_setPrescaleValue(uint16_t baseAddress, uint8_t prescaleSelect, uint8_t prescaleCounterValue)
Sets the selected Prescaler value.
Definition: rtc_c.c:218
void RTC_C_holdCounterPrescale(uint16_t baseAddress, uint8_t prescaleSelect)
Holds the selected Prescaler.
Definition: rtc_c.c:185
void RTC_C_configureCalendarAlarm(uint16_t baseAddress, RTC_C_configureCalendarAlarmParam *param)
Sets and Enables the desired Calendar Alarm settings.
Definition: rtc_c.c:124
uint8_t Seconds
Seconds of minute between 0-59.
Definition: rtc_b.h:34

Copyright 2020, Texas Instruments Incorporated