1 /* --COPYRIGHT--,BSD 2 * Copyright (c) 2017, Texas Instruments Incorporated 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the name of Texas Instruments Incorporated nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * --/COPYRIGHT--*/ 32 #ifndef RTC_C_H_ 33 #define RTC_C_H_ 34 35 //***************************************************************************** 36 // 37 //! \addtogroup rtc_api 38 //! @{ 39 // 40 //***************************************************************************** 41 42 43 //***************************************************************************** 44 // 45 // If building with a C++ compiler, make all of the definitions in this header 46 // have a C binding. 47 // 48 //***************************************************************************** 49 #ifdef __cplusplus 50 extern "C" 51 { 52 #endif 53 54 #include <stdint.h> 55 #include <stdbool.h> 56 #include <ti/devices/msp432p4xx/inc/msp.h> 57 58 //***************************************************************************** 59 // 60 //The following is a struct that can be passed to RTC_CalendarInit() in the 61 //CalendarTime parameter, as well as returned by RTC_getCalendarTime() 62 // 63 //***************************************************************************** 64 typedef struct _RTC_C_Calendar 65 { 66 uint_fast8_t seconds; 67 uint_fast8_t minutes; 68 uint_fast8_t hours; 69 uint_fast8_t dayOfWeek; 70 uint_fast8_t dayOfmonth; 71 uint_fast8_t month; 72 uint_fast16_t year; 73 } RTC_C_Calendar; 74 75 //***************************************************************************** 76 // 77 //The following are values that can be passed to RTC_setCalibrationData() 78 // 79 //***************************************************************************** 80 #define RTC_C_CALIBRATIONFREQ_OFF (RTC_C_CTL13_CALF_0) 81 #define RTC_C_CALIBRATIONFREQ_512HZ (RTC_C_CTL13_CALF_1) 82 #define RTC_C_CALIBRATIONFREQ_256HZ (RTC_C_CTL13_CALF_2) 83 #define RTC_C_CALIBRATIONFREQ_1HZ (RTC_C_CTL13_CALF_3) 84 85 //***************************************************************************** 86 // 87 //The following are values that can be passed to RTC_setCalibrationData() 88 // 89 //***************************************************************************** 90 #define RTC_C_CALIBRATION_DOWN1PPM ( !(RTC_C_OCAL_OCALS) ) 91 #define RTC_C_CALIBRATION_UP1PPM (RTC_C_OCAL_OCALS) 92 93 //***************************************************************************** 94 // 95 //The following are values that can be passed to 96 //RTC_setTemperatureCompensation() 97 // 98 //***************************************************************************** 99 #define RTC_C_COMPENSATION_DOWN1PPM ( !(RTC_C_TCMP_TCMPS) ) 100 #define RTC_C_COMPENSATION_UP1PPM (RTC_C_TCMP_TCMPS) 101 102 //***************************************************************************** 103 // 104 //The following are values that can be passed to RTC_iniRTC_Calendar() 105 // 106 //***************************************************************************** 107 #define RTC_C_FORMAT_BINARY ( !(RTC_C_CTL13_BCD) ) 108 #define RTC_C_FORMAT_BCD (RTC_C_CTL13_BCD) 109 110 //***************************************************************************** 111 // 112 //The following is a value that can be passed to RTC_seRTC_CalendarAlarm() 113 // 114 //***************************************************************************** 115 #define RTC_C_ALARMCONDITION_OFF (0x80) 116 117 //***************************************************************************** 118 // 119 //The following are values that can be passed to RTC_seRTC_CalendarEvent() 120 //in the eventSelect parameter. 121 // 122 //***************************************************************************** 123 #define RTC_C_CALENDAREVENT_MINUTECHANGE (RTC_C_CTL13_TEV_0) 124 #define RTC_C_CALENDAREVENT_HOURCHANGE (RTC_C_CTL13_TEV_1) 125 #define RTC_C_CALENDAREVENT_NOON (RTC_C_CTL13_TEV_2) 126 #define RTC_C_CALENDAREVENT_MIDNIGHT (RTC_C_CTL13_TEV_3) 127 128 //***************************************************************************** 129 // 130 //The following are values that can be passed to RTC_definePrescaleEvent() 131 // 132 //***************************************************************************** 133 #define RTC_C_PRESCALE_0 (0x0) 134 #define RTC_C_PRESCALE_1 (0x1) 135 136 //***************************************************************************** 137 // 138 //The following are values that can be passed to RTC_definePrescaleEvent() 139 //in the prescaleEventDivider parameter. 140 // 141 //***************************************************************************** 142 #define RTC_C_PSEVENTDIVIDER_2 (RTC_C_PS0CTL_RT0IP_0) 143 #define RTC_C_PSEVENTDIVIDER_4 (RTC_C_PS0CTL_RT0IP_1) 144 #define RTC_C_PSEVENTDIVIDER_8 (RTC_C_PS0CTL_RT0IP_2) 145 #define RTC_C_PSEVENTDIVIDER_16 (RTC_C_PS0CTL_RT0IP_3) 146 #define RTC_C_PSEVENTDIVIDER_32 (RTC_C_PS0CTL_RT0IP_4) 147 #define RTC_C_PSEVENTDIVIDER_64 (RTC_C_PS0CTL_RT0IP_5) 148 #define RTC_C_PSEVENTDIVIDER_128 (RTC_C_PS0CTL_RT0IP_6) 149 #define RTC_C_PSEVENTDIVIDER_256 (RTC_C_PS0CTL_RT0IP_7) 150 151 //***************************************************************************** 152 // 153 //The following are values that can be passed to the interrupt functions 154 // 155 //***************************************************************************** 156 #define RTC_C_OSCILLATOR_FAULT_INTERRUPT RTC_C_CTL0_OFIE 157 #define RTC_C_TIME_EVENT_INTERRUPT RTC_C_CTL0_TEVIE 158 #define RTC_C_CLOCK_ALARM_INTERRUPT RTC_C_CTL0_AIE 159 #define RTC_C_CLOCK_READ_READY_INTERRUPT RTC_C_CTL0_RDYIE 160 #define RTC_C_PRESCALE_TIMER0_INTERRUPT 0x02 161 #define RTC_C_PRESCALE_TIMER1_INTERRUPT 0x01 162 163 //***************************************************************************** 164 // 165 //! Starts the RTC. 166 //! 167 //! This function clears the RTC main hold bit to allow the RTC to function. 168 //! 169 //! \return None 170 // 171 //***************************************************************************** 172 extern void RTC_C_startClock(void); 173 174 //***************************************************************************** 175 // 176 //! Holds the RTC. 177 //! 178 //! This function sets the RTC main hold bit to disable RTC functionality. 179 //! 180 //! \return None 181 // 182 //***************************************************************************** 183 extern void RTC_C_holdClock(void); 184 185 //***************************************************************************** 186 // 187 //! Allows and Sets the frequency output to RTCLK pin for calibration 188 //! measurement. 189 //! 190 //! \param frequencySelect is the frequency output to RTCLK. 191 //! Valid values are 192 //! - \b RTC_C_CALIBRATIONFREQ_OFF - turn off calibration 193 //! output [Default] 194 //! - \b RTC_C_CALIBRATIONFREQ_512HZ - output signal at 512Hz 195 //! for calibration 196 //! - \b RTC_C_CALIBRATIONFREQ_256HZ - output signal at 256Hz 197 //! for calibration 198 //! - \b RTC_C_CALIBRATIONFREQ_1HZ - output signal at 1Hz 199 //! for calibration 200 //! 201 //! This function sets a frequency to measure at the RTCLK output pin. After 202 //! testing the set frequency, the calibration could be set accordingly. 203 //! 204 //! \return None 205 // 206 //***************************************************************************** 207 extern void RTC_C_setCalibrationFrequency(uint_fast16_t frequencySelect); 208 209 //***************************************************************************** 210 // 211 //! Sets the specified calibration for the RTC. 212 //! 213 //! \param offsetDirection is the direction that the calibration offset will 214 //! go. Valid values are 215 //! - \b RTC_C_CALIBRATION_DOWN1PPM - calibrate at steps of -1 216 //! - \b RTC_C_CALIBRATION_UP1PPM - calibrat at steps of +1 217 //! \param offsetValue is the value that the offset will be a factor of; a 218 //! valid value is any integer from 1-240. 219 //! 220 //! This function sets the calibration offset to make the RTC as accurate as 221 //! possible. The offsetDirection can be either +1-ppm or -1-ppm, and the 222 //! offsetValue should be from 1-240 and is multiplied by the direction setting 223 //! (i.e. +1-ppm * 8 (offsetValue) = +8-ppm). 224 //! 225 //! \return None 226 // 227 //***************************************************************************** 228 extern void RTC_C_setCalibrationData(uint_fast8_t offsetDirection, 229 uint_fast8_t offsetValue); 230 231 //***************************************************************************** 232 // 233 //! Sets the specified temperature compensation for the RTC. 234 //! 235 //! \param offsetDirection is the direction that the calibration offset will 236 //! go. Valid values are 237 //! - \b RTC_C_COMPENSATION_DOWN1PPM - calibrate at steps of -1 238 //! - \b RTC_C_COMPENSATION_UP1PPM - calibrate at steps of +1 239 //! \param offsetValue is the value that the offset will be a factor of; a 240 //! value is any integer from 1-240. 241 //! 242 //! This function sets the calibration offset to make the RTC as accurate as 243 //! possible. The offsetDirection can be either +1-ppm or -1-ppm, and the 244 //! offsetValue should be from 1-240 and is multiplied by the direction setting 245 //! (i.e. +1-ppm * 8 (offsetValue) = +8-ppm). 246 //! 247 //! \return true if calibration was set, false if it could not be set 248 //! 249 // 250 //***************************************************************************** 251 extern bool RTC_C_setTemperatureCompensation(uint_fast16_t offsetDirection, 252 uint_fast8_t offsetValue); 253 254 //***************************************************************************** 255 // 256 //! Initializes the settings to operate the RTC in Calendar mode. 257 //! 258 //! \param calendarTime is the structure containing the values for the Calendar 259 //! to be initialized to. 260 //! Valid values should be of type Calendar and should contain the 261 //! following members and corresponding values: 262 //! - \b seconds between 0-59 263 //! - \b minutes between 0-59 264 //! - \b hours between 0-23 265 //! - \b dayOfWeek between 0-6 266 //! - \b dayOfmonth between 1-31 267 //! - \b month between 1-12 268 //! - \b year between 0-4095 269 //! \note Values beyond the ones specified may result in erratic behavior. 270 //! \param formatSelect is the format for the Calendar registers to use. 271 //! Valid values are 272 //! - \b RTC_C_FORMAT_BINARY [Default] 273 //! - \b RTC_C_FORMAT_BCD 274 //! 275 //! This function initializes the Calendar mode of the RTC module. 276 //! 277 //! \return None 278 // 279 //***************************************************************************** 280 extern void RTC_C_initCalendar(const RTC_C_Calendar *calendarTime, 281 uint_fast16_t formatSelect); 282 283 //***************************************************************************** 284 // 285 //! Returns the Calendar Time stored in the Calendar registers of the RTC. 286 //! 287 //! 288 //! This function returns the current Calendar time in the form of a Calendar 289 //! structure. 290 //! 291 //! \return A Calendar structure containing the current time. 292 // 293 //***************************************************************************** 294 extern RTC_C_Calendar RTC_C_getCalendarTime(void); 295 296 //***************************************************************************** 297 // 298 //! Sets and Enables the desired Calendar Alarm settings. 299 //! 300 //! \param minutesAlarm is the alarm condition for the minutes. 301 //! Valid values are 302 //! - An integer between 0-59, OR 303 //! - \b RTC_C_ALARMCONDITION_OFF [Default] 304 //! \param hoursAlarm is the alarm condition for the hours. 305 //! Valid values are 306 //! - An integer between 0-24, OR 307 //! - \b RTC_C_ALARMCONDITION_OFF [Default] 308 //! \param dayOfWeekAlarm is the alarm condition for the day of week. 309 //! Valid values are 310 //! - An integer between 0-6, OR 311 //! - \b RTC_C_ALARMCONDITION_OFF [Default] 312 //! \param dayOfmonthAlarm is the alarm condition for the day of the month. 313 //! Valid values are 314 //! - An integer between 0-31, OR 315 //! - \b RTC_C_ALARMCONDITION_OFF [Default] 316 //! 317 //! This function sets a Calendar interrupt condition to assert the RTCAIFG 318 //! interrupt flag. The condition is a logical and of all of the parameters. 319 //! For example if the minutes and hours alarm is set, then the interrupt will 320 //! only assert when the minutes AND the hours change to the specified setting. 321 //! Use the RTC_ALARM_OFF for any alarm settings that should not be apart of 322 //! the alarm condition. 323 //! 324 //! \return None 325 // 326 //***************************************************************************** 327 extern void RTC_C_setCalendarAlarm(uint_fast8_t minutesAlarm, 328 uint_fast8_t hoursAlarm, uint_fast8_t dayOfWeekAlarm, 329 uint_fast8_t dayOfmonthAlarm); 330 331 //***************************************************************************** 332 // 333 //! Sets a single specified Calendar interrupt condition. 334 //! 335 //! \param eventSelect is the condition selected. 336 //! Valid values are 337 //! - \b RTC_C_CALENDAREVENT_MINUTECHANGE - assert interrupt on every 338 //! minute 339 //! - \b RTC_C_CALENDAREVENT_HOURCHANGE - assert interrupt on every hour 340 //! - \b RTC_C_CALENDAREVENT_NOON - assert interrupt when hour is 12 341 //! - \b RTC_C_CALENDAREVENT_MIDNIGHT - assert interrupt when hour is 0 342 //! 343 //! This function sets a specified event to assert the RTCTEVIFG interrupt. This 344 //! interrupt is independent from the Calendar alarm interrupt. 345 //! 346 //! \return None 347 // 348 //***************************************************************************** 349 extern void RTC_C_setCalendarEvent(uint_fast16_t eventSelect); 350 351 //***************************************************************************** 352 // 353 //! Sets up an interrupt condition for the selected Prescaler. 354 //! 355 //! \param prescaleSelect is the prescaler to define an interrupt for. 356 //! Valid values are 357 //! - \b RTC_C_PRESCALE_0 358 //! - \b RTC_C_PRESCALE_1 359 //! \param prescaleEventDivider is a divider to specify when an interrupt can 360 //! occur based on the clock source of the selected prescaler. 361 //! (Does not affect timer of the selected prescaler). 362 //! Valid values are 363 //! - \b RTC_C_PSEVENTDIVIDER_2 [Default] 364 //! - \b RTC_C_PSEVENTDIVIDER_4 365 //! - \b RTC_C_PSEVENTDIVIDER_8 366 //! - \b RTC_C_PSEVENTDIVIDER_16 367 //! - \b RTC_C_PSEVENTDIVIDER_32 368 //! - \b RTC_C_PSEVENTDIVIDER_64 369 //! - \b RTC_C_PSEVENTDIVIDER_128 370 //! - \b RTC_C_PSEVENTDIVIDER_256 371 //! 372 //! This function sets the condition for an interrupt to assert based on the 373 //! individual prescalers. 374 //! 375 //! \return None 376 // 377 //***************************************************************************** 378 extern void RTC_C_definePrescaleEvent(uint_fast8_t prescaleSelect, 379 uint_fast8_t prescaleEventDivider); 380 381 //***************************************************************************** 382 // 383 //! Returns the selected Prescaler value. 384 //! 385 //! \param prescaleSelect is the prescaler to obtain the value of. 386 //! Valid values are 387 //! - \b RTC_C_PRESCALE_0 388 //! - \b RTC_C_PRESCALE_1 389 //! 390 //! This function returns the value of the selected prescale counter register. 391 //! The counter should be held before reading. If in counter mode, the 392 //! individual prescaler can be held, while in Calendar mode the whole RTC must 393 //! be held. 394 //! 395 //! \return The value of the specified Prescaler count register 396 // 397 //***************************************************************************** 398 extern uint_fast8_t RTC_C_getPrescaleValue(uint_fast8_t prescaleSelect); 399 400 //***************************************************************************** 401 // 402 //! Sets the selected Prescaler value. 403 //! 404 //! \param prescaleSelect is the prescaler to set the value for. 405 //! Valid values are 406 //! - \b RTC_C_PRESCALE_0 407 //! - \b RTC_C_PRESCALE_1 408 //! \param prescaleCounterValue is the specified value to set the prescaler to; 409 //! a valid value is any integer from 0-255. 410 //! 411 //! This function sets the prescale counter value. Before setting the prescale 412 //! counter, it should be held. 413 //! 414 //! \return None 415 // 416 //***************************************************************************** 417 extern void RTC_C_setPrescaleValue(uint_fast8_t prescaleSelect, 418 uint_fast8_t prescaleCounterValue); 419 420 //***************************************************************************** 421 // 422 //! Returns the given BCD value in Binary Format 423 //! 424 //! \param valueToConvert is the raw value in BCD format to convert to 425 //! Binary. 426 //! 427 //! This function converts BCD values to Binary format. 428 //! 429 //! \return The Binary version of the valueToConvert parameter. 430 // 431 //***************************************************************************** 432 extern uint16_t RTC_C_convertBCDToBinary(uint16_t valueToConvert); 433 434 //***************************************************************************** 435 // 436 //! Returns the given Binary value in BCD Format 437 //! 438 439 //! \param valueToConvert is the raw value in Binary format to convert to 440 //! BCD. 441 //! 442 //! This function converts Binary values to BCD format. 443 //! 444 //! \return The BCD version of the valueToConvert parameter. 445 // 446 //***************************************************************************** 447 extern uint16_t RTC_C_convertBinaryToBCD(uint16_t valueToConvert); 448 449 //***************************************************************************** 450 // 451 //! Enables selected RTC interrupt sources. 452 //! 453 //! \param interruptMask is a bit mask of the interrupts to enable. 454 //! Mask Value is the logical OR of any of the following 455 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in 456 //! counter mode or when Calendar event condition defined by 457 //! setCalendarEvent() is met. 458 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in 459 //! Calendar mode is met. 460 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar 461 //! registers are settled. 462 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 463 //! event condition is met. 464 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 465 //! event condition is met. 466 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is 467 //! a problem with the 32kHz oscillator, while the RTC is running. 468 //! 469 //! This function enables the selected RTC interrupt source. Only the sources 470 //! that are enabled can be reflected to the processor interrupt; disabled 471 //! sources have no effect on the processor. 472 //! 473 //! \return None 474 // 475 //***************************************************************************** 476 extern void RTC_C_enableInterrupt(uint8_t interruptMask); 477 478 //***************************************************************************** 479 // 480 //! Disables selected RTC interrupt sources. 481 //! 482 //! \param interruptMask is a bit mask of the interrupts to disable. 483 //! Mask Value is the logical OR of any of the following 484 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in 485 //! counter mode or when Calendar event condition defined by 486 //! setCalendarEvent() is met. 487 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in 488 //! Calendar mode is met. 489 //! - \b RTC_CLOCK_READ_READY_INTERRUPT - asserts when Calendar 490 //! registers are settled. 491 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 492 //! event condition is met. 493 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 494 //! event condition is met. 495 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a 496 //! problem with the 32kHz oscillator, while the RTC is running. 497 //! 498 //! This function disables the selected RTC interrupt source. Only the sources 499 //! that are enabled can be reflected to the processor interrupt; disabled 500 //! sources have no effect on the processor. 501 //! 502 //! \return None 503 // 504 //***************************************************************************** 505 extern void RTC_C_disableInterrupt(uint8_t interruptMask); 506 507 //***************************************************************************** 508 // 509 //! Returns the status of the interrupts flags. 510 //! 511 //! \return A bit mask of the selected interrupt flag's status. 512 //! Mask Value is the logical OR of any of the following 513 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in 514 //! counter mode or when Calendar event condition defined by 515 //! setCalendarEvent() is met. 516 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in 517 //! Calendar mode is met. 518 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar 519 //! registers are settled. 520 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 521 //! event condition is met. 522 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 523 //! event condition is met. 524 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a 525 //! problem with the 32kHz oscillator, while the RTC is running. 526 // 527 //***************************************************************************** 528 extern uint_fast8_t RTC_C_getInterruptStatus(void); 529 530 //***************************************************************************** 531 // 532 //! Returns the status of the interrupts flags masked with the enabled 533 //! interrupts. This function is useful to call in ISRs to get a 534 //! list of pending interrupts that are actually enabled and could have caused 535 //! the ISR. 536 //! 537 //! \return A bit mask of the selected interrupt flag's status. 538 //! Mask Value is the logical OR of any of the following 539 //! - \b RTC_TIME_EVENT_INTERRUPT - asserts when counter overflows in 540 //! counter mode or when Calendar event condition defined by 541 //! setCalendarEvent() is met. 542 //! - \b RTC_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in 543 //! Calendar mode is met. 544 //! - \b RTC_CLOCK_READ_READY_INTERRUPT - asserts when Calendar 545 //! registers are settled. 546 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 547 //! event condition is met. 548 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 549 //! event condition is met. 550 //! - \b RTC_OSCILLATOR_FAULT_INTERRUPT - asserts if there is a problem 551 //! with the 32kHz oscillator, while the RTC is running. 552 // 553 //***************************************************************************** 554 extern uint_fast8_t RTC_C_getEnabledInterruptStatus(void); 555 556 //***************************************************************************** 557 // 558 //! Clears selected RTC interrupt flags. 559 //! 560 //! \param interruptFlagMask is a bit mask of the interrupt flags to be 561 //! cleared. Mask Value is the logical OR of any of the following 562 //! - \b RTC_C_TIME_EVENT_INTERRUPT - asserts when counter overflows in 563 //! counter mode or when Calendar event condition defined by 564 //! setCalendarEvent() is met. 565 //! - \b RTC_C_CLOCK_ALARM_INTERRUPT - asserts when alarm condition in 566 //! Calendar mode is met. 567 //! - \b RTC_C_CLOCK_READ_READY_INTERRUPT - asserts when Calendar 568 //! registers are settled. 569 //! - \b RTC_C_PRESCALE_TIMER0_INTERRUPT - asserts when Prescaler 0 570 //! event condition is met. 571 //! - \b RTC_C_PRESCALE_TIMER1_INTERRUPT - asserts when Prescaler 1 572 //! event condition is met. 573 //! - \b RTC_C_OSCILLATOR_FAULT_INTERRUPT - asserts if there is 574 //! a problem with the 32kHz oscillator, while the RTC is running. 575 //! 576 //! This function clears the RTC interrupt flag is cleared, so that it no longer 577 //! asserts. 578 //! 579 //! \return None 580 // 581 //***************************************************************************** 582 extern void RTC_C_clearInterruptFlag(uint_fast8_t interruptFlagMask); 583 584 //***************************************************************************** 585 // 586 //! Registers an interrupt handler for the RTC interrupt. 587 //! 588 //! \param intHandler is a pointer to the function to be called when the 589 //! RTC interrupt occurs. 590 //! 591 //! This function registers the handler to be called when a RTC 592 //! interrupt occurs. This function enables the global interrupt in the 593 //! interrupt controller; specific AES interrupts must be enabled 594 //! via RTC_enableInterrupt(). It is the interrupt handler's responsibility to 595 //! clear the interrupt source via RTC_clearInterruptFlag(). 596 //! 597 //! \return None. 598 // 599 //***************************************************************************** 600 extern void RTC_C_registerInterrupt(void (*intHandler)(void)); 601 602 //***************************************************************************** 603 // 604 //! Unregisters the interrupt handler for the RTC interrupt 605 //! 606 //! This function unregisters the handler to be called when RTC 607 //! interrupt occurs. This function also masks off the interrupt in the 608 //! interrupt controller so that the interrupt handler no longer is called. 609 //! 610 //! \sa Interrupt_registerInterrupt() for important information about 611 //! registering interrupt handlers. 612 //! 613 //! \return None. 614 // 615 //***************************************************************************** 616 extern void RTC_C_unregisterInterrupt(void); 617 618 /* Defines for future devices that might have multiple instances */ 619 #define RTC_C_startClockMultipleInstance(a) RTC_C_startClock() 620 #define RTC_C_holdClockMultipleInstance(a) RTC_C_holdClock() 621 #define RTC_C_setCalibrationFrequencyMultipleInstance(a,b) RTC_C_setCalibrationFrequency(b) 622 #define RTC_C_setCalibrationDataMultipleInstance(a,b,c) RTC_C_setCalibrationData(b,c) 623 #define RTC_C_setTemperatureCompensationMultipleInstance(a,b,c) RTC_C_setTemperatureCompensation(b,c) 624 #define RTC_C_initCalendarMultipleInstance(a,b,c) RTC_C_initCalendar(b,c) 625 #define RTC_C_getCalendarTimeMultipleInstance(a) RTC_C_getCalendarTime() 626 #define RTC_C_setCalendarAlarmMultipleInstance(a,b,c,d,e) RTC_C_setCalendarAlarm(b,c,d,e) 627 #define RTC_C_setCalendarEventMultipleInstance(a,b) RTC_C_setCalendarEvent(b) 628 #define RTC_C_definePrescaleEventMultipleInstance(a,b,c) RTC_C_definePrescaleEvent(b,c) 629 #define RTC_C_getPrescaleValueMultipleInstance(a,b) RTC_C_getPrescaleValue(b) 630 #define RTC_C_setPrescaleValueMultipleInstance(a,b,c) RTC_C_setPrescaleValue(b,c) 631 #define RTC_C_convertBCDToBinaryMultipleInstance(a,b) RTC_C_convertBCDToBinary(b) 632 #define RTC_C_convertBinaryToBCDMultipleInstance(a,b) RTC_C_convertBinaryToBCD(b) 633 #define RTC_C_enableInterruptMultipleInstance(a,b) RTC_C_enableInterrupt(b) 634 #define RTC_C_disableInterruptMultipleInstance(a,b) RTC_C_disableInterrupt(b) 635 #define RTC_C_getInterruptStatusMultipleInstance(a) RTC_C_getInterruptStatus() 636 #define RTC_C_getEnabledInterruptStatusMultipleInstance(a) RTC_C_getEnabledInterruptStatus() 637 #define RTC_C_clearInterruptFlagMultipleInstance(a,b) RTC_C_clearInterruptFlag(b) 638 #define RTC_C_registerInterruptMultipleInstance(a,b) RTC_C_registerInterrupt(b) 639 #define RTC_C_unregisterInterruptMultipleInstance(a) RTC_C_unregisterInterrupt() 640 641 //***************************************************************************** 642 // 643 // Mark the end of the C bindings section for C++ compilers. 644 // 645 //***************************************************************************** 646 #ifdef __cplusplus 647 } 648 #endif 649 650 //***************************************************************************** 651 // 652 // Close the Doxygen group. 653 //! @} 654 // 655 //***************************************************************************** 656 657 #endif /* RTC_H */ 658