Contiki 2.5
leds-arch.c
1 #include <dev/leds.h>
2 #include <AT91SAM7S64.h>
3 
4 #define GREEN_PIN AT91C_PIO_PA3
5 #define YELLOW_PIN AT91C_PIO_PA4
6 #define RED_PIN AT91C_PIO_PA8
7 
8 #define ALL_PINS (GREEN_PIN | YELLOW_PIN | RED_PIN)
9 
10 void
12 {
13  *AT91C_PIOA_PER = ALL_PINS;
14  *AT91C_PIOA_OER = ALL_PINS;
15  *AT91C_PIOA_MDER = ALL_PINS;
16  *AT91C_PIOA_SODR = ALL_PINS;
17 }
18 
19 unsigned char
20 leds_arch_get(void)
21 {
22  unsigned char on = 0;
23  if (*AT91C_PIOA_ODSR & GREEN_PIN) on |= LEDS_GREEN;
24  if (*AT91C_PIOA_ODSR & YELLOW_PIN) on |= LEDS_YELLOW;
25  if (*AT91C_PIOA_ODSR & RED_PIN) on |= LEDS_RED;
26  return on;
27 }
28 
29 void
30 leds_arch_set(unsigned char leds)
31 {
32  unsigned int set = 0;
33  if (leds & LEDS_GREEN) set |= GREEN_PIN;
34  if (leds & LEDS_YELLOW) set |= YELLOW_PIN;
35  if (leds & LEDS_RED) set |= RED_PIN;
36  *AT91C_PIOA_CODR = set;
37  *AT91C_PIOA_SODR = (~set) & ALL_PINS;
38 }