Skip to content

Commit

Permalink
boards/weio: unified LED defines
Browse files Browse the repository at this point in the history
  • Loading branch information
haukepetersen committed Mar 15, 2016
1 parent beddceb commit c5cfe70
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 50 deletions.
30 changes: 5 additions & 25 deletions boards/weio/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,15 @@
* @}
*/

#include "cpu.h"
#include "board.h"

static void leds_init(void);
extern void SystemInit(void);

void board_init(void)
{
/* initialize and turn off the boards LEDs */
LED_PORT->DIR[1] = (LED0_MASK | LED1_MASK | LED2_MASK);
LED_PORT->SET[1] = (LED0_MASK | LED1_MASK | LED2_MASK);

/* initialize the CPU */
cpu_init();
/* initialize the boards LEDs */
leds_init();
}

/**
* @brief Initialize the boards on-board LEDs (LED1 to LED4)
*
* The LED initialization is hard-coded in this function. As the LEDs are soldered
* onto the board they are fixed to their CPU pins.
*
* The LEDs are connected to the following pins:
* - LED1: P1.13
* - LED2: P1.14
* - LED3: P1.15
*/
static void leds_init(void)
{
/* configure LED pins as output */
LED_PORT->DIR[1] = (LED1_PIN | LED2_PIN | LED3_PIN);

/* clear all LEDs */
LED_PORT->SET[1] = (LED1_PIN | LED2_PIN | LED3_PIN);
}
44 changes: 19 additions & 25 deletions boards/weio/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,29 @@ extern "C" {
#endif

/**
* @name LED pin definitions
* @brief LED pin definitions and handlers
* @{
*/
#define LED0_PIN GPIO_PIN(0, 13)
#define LED1_PIN GPIO_PIN(0, 14)
#define LED2_PIN GPIO_PIN(0, 15)

#define LED_PORT LPC_GPIO
#define LED1_PIN BIT13
#define LED2_PIN BIT14
#define LED3_PIN BIT15
/** @} */
#define LED0_MASK BIT13
#define LED1_MASK BIT14
#define LED2_MASK BIT15

/**
* @name Macros for controlling the on-board LEDs.
* @{
*/
#define LED1_ON (LED_PORT->CLR[1] = LED1_PIN)
#define LED1_OFF (LED_PORT->SET[1] = LED1_PIN)
#define LED1_TOGGLE (LED_PORT->NOT[1] = LED1_PIN)
#define LED2_ON (LED_PORT->CLR[1] = LED2_PIN)
#define LED2_OFF (LED_PORT->SET[1] = LED2_PIN)
#define LED2_TOGGLE (LED_PORT->NOT[1] = LED2_PIN)
#define LED3_ON (LED_PORT->CLR[1] = LED3_PIN)
#define LED3_OFF (LED_PORT->SET[1] = LED3_PIN)
#define LED3_TOGGLE (LED_PORT->NOT[1] = LED3_PIN)
/* for compatibility to other boards */
#define LED_GREEN_ON LED2_ON
#define LED_GREEN_OFF LED2_OFF
#define LED_GREEN_TOGGLE LED2_TOGGLE
#define LED_RED_ON LED1_ON
#define LED_RED_OFF LED1_OFF
#define LED_RED_TOGGLE LED1_TOGGLE
#define LED0_ON (LED_PORT->CLR[1] = LED0_MASK)
#define LED0_OFF (LED_PORT->SET[1] = LED0_MASK)
#define LED0_TOGGLE (LED_PORT->NOT[1] = LED0_MASK)

#define LED1_ON (LED_PORT->CLR[1] = LED1_MASK)
#define LED1_OFF (LED_PORT->SET[1] = LED1_MASK)
#define LED1_TOGGLE (LED_PORT->NOT[1] = LED1_MASK)

#define LED2_ON (LED_PORT->CLR[1] = LED2_MASK)
#define LED2_OFF (LED_PORT->SET[1] = LED2_MASK)
#define LED2_TOGGLE (LED_PORT->NOT[1] = LED2_MASK)
/** @} */

/**
Expand Down

0 comments on commit c5cfe70

Please sign in to comment.