From: asterix Date: Fri, 5 Nov 2010 14:07:28 +0000 (+0000) Subject: Refactor led macro, now we can specify the led to on/off. X-Git-Tag: 2.6.0~5^2~3 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=cc07cdcf518f1f2176e5754f26ba7aa4e9b9fbda;p=bertos.git Refactor led macro, now we can specify the led to on/off. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4517 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/boards/sam3n-ek/hw/hw_led.h b/boards/sam3n-ek/hw/hw_led.h index 0951b9be..8f92b3be 100644 --- a/boards/sam3n-ek/hw/hw_led.h +++ b/boards/sam3n-ek/hw/hw_led.h @@ -38,19 +38,44 @@ #ifndef HW_LED_H #define HW_LED_H +#include + #include +#define LED_BLUE 0 +#define LED_GREEN 1 +#define LED_AMBER 2 + // Leds #define LED_BLUE_PIN BV(23) // Port A #define LED_AMBER_PIN BV(25) // Port A #define LED_GREEN_PIN BV(14) // Port B -#define LED_BLUE_ON(led) (PIOA_CODR = LED_BLUE_PIN) -#define LED_BLUE_OFF(led) (PIOA_SODR = LED_BLUE_PIN) -#define LED_AMBER_ON(led) (PIOA_CODR = LED_AMBER_PIN) -#define LED_AMBER_OFF(led) (PIOA_SODR = LED_AMBER_PIN) -#define LED_GREEN_ON(led) (PIOB_CODR = LED_GREEN_PIN) -#define LED_GREEN_OFF(led) (PIOB_SODR = LED_GREEN_PIN) +#define LED_ON(led) \ + do { \ + if (led == LED_BLUE) \ + PIOA_CODR = LED_BLUE_PIN; \ + else if (led == LED_GREEN) \ + PIOB_CODR = LED_GREEN_PIN; \ + else if (led == LED_AMBER) \ + PIOA_CODR = LED_AMBER_PIN; \ + else \ + ASSERT(0); \ + } while (0) + + +#define LED_OFF(led) \ + do { \ + if (led == LED_BLUE) \ + PIOA_SODR = LED_BLUE_PIN; \ + else if (led == LED_GREEN) \ + PIOB_SODR = LED_GREEN_PIN; \ + else if (led == LED_AMBER) \ + PIOA_SODR = LED_AMBER_PIN; \ + else \ + ASSERT(0); \ + } while (0) + #define LED_INIT() \ do { \