Skip to content

Commit

Permalink
SQUASHME: fix interrupt handling
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-k committed May 7, 2015
1 parent 49a16d9 commit 268c737
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cpu/samd21/periph/rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ void rtt_set_overflow_cb(rtt_cb_t cb, void *arg)
rtt_callback.overflow_cb = cb;
rtt_callback.overflow_arg = arg;

/* Enable Overflow Interrupt */
/* Enable Overflow Interrupt and clear flag */
RtcMode0 *rtcMode0 = &(RTT_DEV);
rtcMode0->INTENSET.bit.OVF = 1;
rtcMode0->INTFLAG.bit.OVF = 1;
}

void rtt_clear_overflow_cb(void)
Expand Down Expand Up @@ -140,8 +141,9 @@ void rtt_set_alarm(uint32_t alarm, rtt_cb_t cb, void *arg)
rtcMode0->COMP[0].reg = alarm;
while (rtcMode0->STATUS.bit.SYNCBUSY);

/* Enable Compare Interrupt */
/* Enable Compare Interrupt and clear flag */
rtcMode0->INTENSET.bit.CMP0 = 1;
rtcMode0->INTFLAG.bit.CMP0 = 1;
}

void rtt_clear_alarm(void)
Expand Down Expand Up @@ -179,14 +181,14 @@ void RTT_ISR(void)
RtcMode0 *rtcMode0 = &(RTT_DEV);
uint8_t status = rtcMode0->INTFLAG.reg;

if (status & RTC_MODE0_INTFLAG_CMP0) {
if ( (status & RTC_MODE0_INTFLAG_CMP0) && (rtt_callback.alarm_cb != NULL) ) {
rtt_callback.alarm_cb(rtt_callback.alarm_cb);
rtcMode0->INTFLAG.reg = RTC_MODE0_INTFLAG_CMP0;
rtcMode0->INTFLAG.bit.CMP0 = 1;
}

if (status & RTC_MODE0_INTFLAG_OVF) {
if ( (status & RTC_MODE0_INTFLAG_OVF) && (rtt_callback.overflow_cb != NULL) ) {
rtt_callback.overflow_cb(rtt_callback.overflow_arg);
rtcMode0->INTFLAG.reg = RTC_MODE0_INTFLAG_OVF;
rtcMode0->INTFLAG.bit.OVF = 1;
}

if (sched_context_switch_request) {
Expand Down

0 comments on commit 268c737

Please sign in to comment.