X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=boards%2Fsam3x-ek%2Fhw%2Fhw_led.h;fp=boards%2Fsam3x-ek%2Fhw%2Fhw_led.h;h=ce808b616d30ee7c4b7be3be1e09bf237af749aa;hb=97a3b5115cb89465a7f9bf16cb657aca46ff9841;hp=0000000000000000000000000000000000000000;hpb=b3eb079f0ff76073493cba30f64783f94c044b95;p=bertos.git diff --git a/boards/sam3x-ek/hw/hw_led.h b/boards/sam3x-ek/hw/hw_led.h new file mode 100644 index 00000000..ce808b61 --- /dev/null +++ b/boards/sam3x-ek/hw/hw_led.h @@ -0,0 +1,101 @@ +/** + * \file + * + * + * \brief Led on/off macros. + * + * \author Stefano Fedrigo + */ + +#ifndef HW_LED_H +#define HW_LED_H + +#include + +#include + +/* + * Note that power led (RED) is on by default. + */ +#define LED_GREEN 0 +#define LED_AMBER 1 +#define LED_BLUE 2 +#define LED_RED 3 +#define LED_DEFAULT LED_GREEN + +// Leds +#define LED_GREEN_PIN BV(13) // Port B +#define LED_AMBER_PIN BV(12) // Port B +#define LED_BLUE_PIN BV(12) // Port A +#define LED_RED_PIN BV(13) // Port A + +#define LED_ON(led) \ + do { \ + if (led == LED_GREEN) \ + PIOB_CODR = LED_GREEN_PIN; \ + else if (led == LED_AMBER) \ + PIOB_CODR = LED_AMBER_PIN; \ + else if (led == LED_BLUE) \ + PIOA_CODR = LED_BLUE_PIN; \ + else if (led == LED_RED) \ + PIOA_SODR = LED_RED_PIN; \ + else \ + ASSERT(0); \ + } while (0) + + +#define LED_OFF(led) \ + do { \ + if (led == LED_GREEN) \ + PIOB_SODR = LED_GREEN_PIN; \ + else if (led == LED_AMBER) \ + PIOB_SODR = LED_AMBER_PIN; \ + else if (led == LED_BLUE) \ + PIOA_SODR = LED_BLUE_PIN; \ + else if (led == LED_RED) \ + PIOA_CODR = LED_RED_PIN; \ + else \ + ASSERT(0); \ + } while (0) + + +#define LED_INIT() \ + do { \ + PIOA_SODR = LED_BLUE_PIN; \ + PIOA_CODR = LED_RED_PIN; \ + PIOA_OER = LED_BLUE_PIN | LED_RED_PIN; \ + PIOA_PER = LED_BLUE_PIN | LED_RED_PIN; \ + PIOB_SODR = LED_GREEN_PIN | LED_AMBER_PIN; \ + PIOB_OER = LED_GREEN_PIN | LED_AMBER_PIN; \ + PIOB_PER = LED_GREEN_PIN | LED_AMBER_PIN; \ + } while(0) + +#endif /* HW_LED_H */