Ejemplo n.º 1
0
/*FUNCTION****************************************************************
*
* Function Name    : _rtc_isr
* Returned Value   : none
* Comments         :
*    This is ISR for RTC module, triggered each second.
*
*END*********************************************************************/
void _rtc_isr
(
    /* [IN] rtc module pointer passed to interrupt */
    pointer ptr
)
{
    RTC_MemMapPtr rtc = RTC_BASE_PTR;
    uint_32 tsr_reg, status;
    uint_32 time_alarm;
    boolean alarm_fault = TRUE;

    status = rtc->SR;

    /* Time Invalid Flag, Time Overflow Flag */
    if (status & (RTC_SR_TIF_MASK | RTC_SR_TOF_MASK))
    {
        rtc->SR &= ~RTC_SR_TCE_MASK;    /* disable rtc timer - enable write access */
        rtc->TAR = 0xFFFFFFFF; /* e2574: RTC: Writing RTC_TAR[TAR] = 0 does not disable RTC alarm */
        /* if TIF or TOF flag is set, reading TSR return zero and we must set TSR to one */
        rtc->TSR = 1;                   /* this clear SR flags TIF, TOF */
        rtc->SR |= RTC_SR_TCE_MASK;

        user_requests |= ((status & RTC_SR_TIF_MASK) ? RTC_ISR_TIF : 0) | ((status & RTC_SR_TOF_MASK) ? RTC_ISR_TOF : 0);
    }

    /* Time Alarm Flag */
    if (status & RTC_SR_TAF_MASK)
    {
        /* TAR can be changed, store register to variable */
        time_alarm = rtc->TAR;
        if( time_alarm == alarm_time.seconds )
        {
            user_requests |= RTC_ISR_ALARM;
            _rtc_update_TAR( user_enables & ~RTC_ISR_ALARM );
            alarm_fault = FALSE;
        }
        if( time_alarm == sw_time.seconds )
        {
            user_requests |= RTC_ISR_STOPWATCH;
            _rtc_update_TAR( user_enables & ~RTC_ISR_STOPWATCH);
            alarm_fault = FALSE;
        }
        if( alarm_fault == TRUE )
        {
            _rtc_update_TAR( user_enables & ~( RTC_ISR_STOPWATCH | RTC_ISR_ALARM) );
        }
    }
    /* user callback */
    if ((NULL != user_isr) && (user_requests & user_enables))
    {
        user_isr ((pointer)rtc);
    }
}
Ejemplo n.º 2
0
/*FUNCTION****************************************************************
* 
* Function Name    : _rtc_isr
* Returned Value   : none
* Comments         :
*    This is ISR for RTC module, triggered each second.
*
*END*********************************************************************/
void _rtc_isr 
(
    /* [IN] rtc module pointer passed to interrupt */
    pointer ptr
)
{
    VMCF51XX_RTC_STRUCT_PTR rtc = (VMCF51XX_RTC_STRUCT_PTR)ptr;
    
    rtc->RTCSC |= MCF51XX_RTC_RTCSC_RTIF;   // clear interrupt flag

    user_requests |= MCF51XX_RTC_RTCISR_1HZ;   // second boundary
    real_time.seconds++;
    if (real_time.seconds > 59)   // minute boundary
    {
        real_time.seconds = 0;
        user_requests |= MCF51XX_RTC_RTCISR_MIN;
        if (stopwatch != (uint_32)-1) {   // stopwatch decrementer
          stopwatch--;
          if (stopwatch == (uint_32)-1) {
            user_requests |= MCF51XX_RTC_RTCISR_SW;
          }
        }          
        real_time.minutes++;
        if (real_time.minutes > 59)   // hour boundary
        {
            real_time.minutes = 0;
            user_requests |= MCF51XX_RTC_RTCISR_HR;
            real_time.hours++;
            if (real_time.hours > 23)   // days boundary
            {
                real_time.hours = 0;
                user_requests |= MCF51XX_RTC_RTCISR_DAY;
                real_time.days++;
            }    
        }    
    }
    // alarm checking
    if ((real_time.seconds == alarm_time.seconds) && (real_time.minutes == alarm_time.minutes) && (real_time.hours == alarm_time.hours) && (real_time.days == alarm_time.days)) {
      user_requests |= MCF51XX_RTC_RTCISR_ALM;
    }
    // user callback triggering
    if ((NULL != user_isr) && (user_requests & user_enables)) user_isr ((pointer)rtc);
}
Ejemplo n.º 3
0
__interrupt void app_isr (void) {
  // call user's ISR function
  if (user_isr()) {
    LPM3_EXIT;
  }
}