Refactor led macro, now we can specify the led to on/off.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 5 Nov 2010 14:07:28 +0000 (14:07 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 5 Nov 2010 14:07:28 +0000 (14:07 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4517 38d2e660-2303-0410-9eaa-f027e97ec537

boards/sam3n-ek/hw/hw_led.h

index 0951b9bebbd83adb76410caf58aeacbb31a18d6a..8f92b3be5f703f76c86bbd3341d74ab8c90f31df 100644 (file)
 #ifndef HW_LED_H
 #define HW_LED_H
 
+#include <io/cm3.h>
+
 #include <cfg/macros.h>
 
+#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 { \