Contiki 2.6
|
00001 #include <dev/leds.h> 00002 #include <AT91SAM7S64.h> 00003 00004 #define GREEN_PIN AT91C_PIO_PA3 00005 #define YELLOW_PIN AT91C_PIO_PA4 00006 #define RED_PIN AT91C_PIO_PA8 00007 00008 #define ALL_PINS (GREEN_PIN | YELLOW_PIN | RED_PIN) 00009 00010 void 00011 leds_arch_init(void) 00012 { 00013 *AT91C_PIOA_PER = ALL_PINS; 00014 *AT91C_PIOA_OER = ALL_PINS; 00015 *AT91C_PIOA_MDER = ALL_PINS; 00016 *AT91C_PIOA_SODR = ALL_PINS; 00017 } 00018 00019 unsigned char 00020 leds_arch_get(void) 00021 { 00022 unsigned char on = 0; 00023 if (*AT91C_PIOA_ODSR & GREEN_PIN) on |= LEDS_GREEN; 00024 if (*AT91C_PIOA_ODSR & YELLOW_PIN) on |= LEDS_YELLOW; 00025 if (*AT91C_PIOA_ODSR & RED_PIN) on |= LEDS_RED; 00026 return on; 00027 } 00028 00029 void 00030 leds_arch_set(unsigned char leds) 00031 { 00032 unsigned int set = 0; 00033 if (leds & LEDS_GREEN) set |= GREEN_PIN; 00034 if (leds & LEDS_YELLOW) set |= YELLOW_PIN; 00035 if (leds & LEDS_RED) set |= RED_PIN; 00036 *AT91C_PIOA_CODR = set; 00037 *AT91C_PIOA_SODR = (~set) & ALL_PINS; 00038 }