Contiki 2.6

rtimer-arch-interrupt.c

00001 #include "rtimer-arch-interrupt.h"
00002 #include "rtimer-arch.h"
00003 #include <interrupt-utils.h>
00004 #include <AT91SAM7S64.h>
00005 
00006 #define DEBUG 1
00007 #if DEBUG
00008 #include <stdio.h>
00009 #define PRINTF(...) printf(__VA_ARGS__)
00010 #else
00011 #define PRINTF(...)
00012 #endif
00013 
00014 /* Here we have a proper stack frame and can use local variables */
00015 static void rtimer_int_safe() __attribute((noinline));
00016 static void
00017 rtimer_int_safe()
00018 {
00019   unsigned int status;
00020   status = RTIMER_ARCH_TIMER_BASE->TC_SR;
00021   if (status & AT91C_TC_CPAS) {
00022     rtimer_run_next();
00023   }
00024   *AT91C_AIC_EOICR = 0;
00025 }
00026 
00027 void NACKEDFUNC
00028 rtimer_interrupt (void) {
00029   ISR_STORE();
00030   ISR_ENABLE_NEST();
00031   rtimer_int_safe();
00032   ISR_DISABLE_NEST();
00033   ISR_RESTORE();
00034 }