From cc07cdcf518f1f2176e5754f26ba7aa4e9b9fbda Mon Sep 17 00:00:00 2001 From: asterix Date: Fri, 5 Nov 2010 14:07:28 +0000 Subject: [PATCH] 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 --- boards/sam3n-ek/hw/hw_led.h | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) 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 { \ -- 2.25.1