/** * \brief Interrupt handler for the RTC. */ void RTC_Handler (void) { uint32_t status = RTC->RTC_SR; /* Second increment interrupt */ if ((status & RTC_SR_SEC) == RTC_SR_SEC) { /* Disable RTC interrupt */ RTC_DisableIt(RTC, RTC_IDR_SECDIS); RTC_ClearSCCR(RTC, RTC_SCCR_SECCLR); RTC_EnableIt(RTC, RTC_IER_SECEN); } else { /* Time or date alarm */ if ((status & RTC_SR_ALARM) == RTC_SR_ALARM) { /* Disable RTC interrupt */ RTC_DisableIt(RTC, RTC_IDR_ALRDIS); if (RTC_callBack != NULL) { RTC_callBack(); } RTC_ClearSCCR(RTC, RTC_SCCR_ALRCLR); RTC_EnableIt(RTC, RTC_IER_ALREN); } } }
void RTCDue::setAlarmDate (int day, int month) { uint8_t _day = day; uint8_t _month = month; RTC_EnableIt(RTC, RTC_IER_ALREN); RTC_SetDateAlarm(RTC, &_month, &_day); NVIC_EnableIRQ(RTC_IRQn); }
void RTCDue::setAlarmTime (int hour, int minute, int second) { uint8_t _hour = hour; uint8_t _minute = minute; uint8_t _second = second; RTC_EnableIt(RTC, RTC_IER_ALREN); RTC_SetTimeAlarm(RTC, &_hour, &_minute, &_second); NVIC_EnableIRQ(RTC_IRQn); }
void RTCDue::begin () { RTC_SetHourMode(RTC, 0); NVIC_DisableIRQ(RTC_IRQn); NVIC_ClearPendingIRQ(RTC_IRQn); NVIC_SetPriority(RTC_IRQn, 0); //NVIC_EnableIRQ(RTC_IRQn); RTC_EnableIt(RTC, RTC_IER_SECEN | RTC_IER_ALREN | RTC_IER_ACKEN); }
//------------------------------------------------------------------------------ // REAL TIME CLOCK //------------------------------------------------------------------------------ void RTC_IrqHandler(void) { volatile TDFM_ItServList *pTmpItServ; unsigned int status; status = AT91C_BASE_RTC->RTC_SR; if ((status & AT91C_RTC_SECEV) == AT91C_RTC_SECEV) { // Disable RTC interrupt RTC_DisableIt(AT91C_RTC_SECEV); } pTmpItServ = gpItHandlerFirst; while(pTmpItServ != NULL) { if(pTmpItServ->itID == AT91C_ID_RTC) pTmpItServ->ItHandler(); pTmpItServ = pTmpItServ->next; } AT91C_BASE_RTC->RTC_SCCR = AT91C_RTC_SECEV; RTC_EnableIt(AT91C_RTC_SECEV); }