Contiki 2.6
|
00001 #include <AT91SAM7S64.h> 00002 #include <stdio.h> 00003 #include <sys/process.h> 00004 #include <sys/procinit.h> 00005 #include <sys/etimer.h> 00006 #include <dev/leds.h> 00007 #include <debug-uart.h> 00008 #include <interrupt-utils.h> 00009 00010 volatile const char * volatile input_line = NULL; 00011 volatile unsigned int input_line_len = 0; 00012 00013 static void 00014 recv_input(const char *str, unsigned int len) 00015 { 00016 /* Assume that the line is handled before any new characters is written 00017 to the buffer */ 00018 input_line = str; 00019 input_line_len = len; 00020 } 00021 PROCESS(blink_process, "LED blink process"); 00022 00023 PROCESS_THREAD(blink_process, ev , data) 00024 { 00025 static struct etimer timer; 00026 PROCESS_BEGIN(); 00027 etimer_set(&timer, CLOCK_SECOND/2); 00028 while(1) { 00029 PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_EXIT || 00030 ev== PROCESS_EVENT_TIMER); 00031 if (ev == PROCESS_EVENT_EXIT) break; 00032 leds_invert(LEDS_RED); 00033 #if 0 00034 { 00035 DISABLE_FIFOP_INT(); 00036 printf("FSMSTATE: %04x",cc2420_getreg(CC2420_FSMSTATE)); 00037 ENABLE_FIFOP_INT(); 00038 if (SFD_IS_1) printf(" SFD"); 00039 if (FIFO_IS_1) printf(" FIFO"); 00040 if (FIFOP_IS_1) printf(" FIFOP"); 00041 putchar('\n'); 00042 } 00043 #endif 00044 etimer_reset(&timer); 00045 } 00046 printf("Ended process\n"); 00047 PROCESS_END(); 00048 } 00049 PROCINIT(&etimer_process, &blink_process); 00050 int 00051 main() 00052 { 00053 disableIRQ(); 00054 disableFIQ(); 00055 *AT91C_AIC_IDCR = 0xffffffff; 00056 *AT91C_PMC_PCDR = 0xffffffff; 00057 *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA); 00058 00059 dbg_setup_uart(); 00060 printf("Initialising\n"); 00061 dbg_set_input_handler(recv_input); 00062 leds_arch_init(); 00063 clock_init(); 00064 00065 process_init(); 00066 printf("Started\n"); 00067 00068 procinit_init(); 00069 enableIRQ(); 00070 printf("Processes running\n"); 00071 while(1) { 00072 do { 00073 /* Reset watchdog. */ 00074 } while(process_run() > 0); 00075 /* Idle! */ 00076 /* Stop processor clock */ 00077 *AT91C_PMC_SCDR |= AT91C_PMC_PCK; 00078 } 00079 return 0; 00080 }