boards/mulle: unified LED defines

pr/gpio
Hauke Petersen 7 years ago
parent c1aef11844
commit 07c303ce73

@ -38,15 +38,6 @@ static nvram_spi_params_t nvram_spi_params = {
.address_count = MULLE_NVRAM_SPI_ADDRESS_COUNT,
};
/**
* @brief Initialize the boards on-board LEDs
*
* The LEDs are initialized here in order to be able to use them in the early
* boot for diagnostics.
*
*/
static inline void leds_init(void);
/** @brief Initialize the GPIO pins controlling the power switches. */
static inline void power_pins_init(void);
@ -67,8 +58,11 @@ static int mulle_nvram_init(void);
void board_init(void)
{
int status;
/* initialize the boards LEDs, this is done first for debugging purposes */
leds_init();
/* initialize the boards LEDs */
gpio_init(LED0_PIN, GPIO_DIR_OUT, GPIO_NOPULL);
gpio_init(LED1_PIN, GPIO_DIR_OUT, GPIO_NOPULL);
gpio_init(LED2_PIN, GPIO_DIR_OUT, GPIO_NOPULL);
/* Initialize power control pins */
power_pins_init();
@ -85,8 +79,6 @@ void board_init(void)
/* Turn on AVDD for reading voltages */
gpio_set(MULLE_POWER_AVDD);
LED_RED_ON;
/* Initialize RTC oscillator as early as possible since we are using it as a
* base clock for the FLL.
* It takes a while to stabilize the oscillator, therefore we do this as
@ -119,8 +111,6 @@ void board_init(void)
/* initialize the CPU */
cpu_init();
LED_YELLOW_ON;
/* NVRAM requires xtimer for timing */
xtimer_init();
@ -130,23 +120,6 @@ void board_init(void)
/* Increment boot counter */
increase_boot_count();
}
LED_GREEN_ON;
}
/**
* @brief Initialize the boards on-board LEDs
*
* The LEDs are initialized here in order to be able to use them in the early
* boot for diagnostics.
*
*/
static inline void leds_init(void)
{
/* The pin configuration can be found in board.h and periph_conf.h */
gpio_init(LED_RED_GPIO, GPIO_DIR_OUT, GPIO_NOPULL);
gpio_init(LED_YELLOW_GPIO, GPIO_DIR_OUT, GPIO_NOPULL);
gpio_init(LED_GREEN_GPIO, GPIO_DIR_OUT, GPIO_NOPULL);
}
static inline void power_pins_init(void)

@ -34,35 +34,29 @@
#define DISABLE_WDOG 1
/**
* @name LEDs configuration
* @brief LED pin definitions and handlers
* @{
*/
#define LED_RED_PORT PTC
#define LED_RED_PIN 15
#define LED_RED_GPIO GPIO_PIN(PORT_C, LED_RED_PIN)
#define LED_YELLOW_PORT PTC
#define LED_YELLOW_PIN 14
#define LED_YELLOW_GPIO GPIO_PIN(PORT_C, LED_YELLOW_PIN)
#define LED_GREEN_PORT PTC
#define LED_GREEN_PIN 13
#define LED_GREEN_GPIO GPIO_PIN(PORT_C, LED_GREEN_PIN)
/** @} */
/**
* @name Macros for controlling the on-board LEDs.
* @{
*/
#define LED_RED_ON (LED_RED_PORT->PSOR = (1 << LED_RED_PIN))
#define LED_RED_OFF (LED_RED_PORT->PCOR = (1 << LED_RED_PIN))
#define LED_RED_TOGGLE (LED_RED_PORT->PTOR = (1 << LED_RED_PIN))
#define LED_YELLOW_ON (LED_YELLOW_PORT->PSOR = (1 << LED_YELLOW_PIN))
#define LED_YELLOW_OFF (LED_YELLOW_PORT->PCOR = (1 << LED_YELLOW_PIN))
#define LED_YELLOW_TOGGLE (LED_YELLOW_PORT->PTOR = (1 << LED_YELLOW_PIN))
#define LED_GREEN_ON (LED_GREEN_PORT->PSOR = (1 << LED_GREEN_PIN))
#define LED_GREEN_OFF (LED_GREEN_PORT->PCOR = (1 << LED_GREEN_PIN))
#define LED_GREEN_TOGGLE (LED_GREEN_PORT->PTOR = (1 << LED_GREEN_PIN))
#define LED_PORT PTC
#define LED0_BIT (15)
#define LED1_BIT (14)
#define LED2_BIT (13)
#define LED0_PIN GPIO_PIN(PORT_C, LED0_BIT)
#define LED1_PIN GPIO_PIN(PORT_C, LED1_BIT)
#define LED2_PIN GPIO_PIN(PORT_C, LED2_BIT)
#define LED0_ON (BITBAND_REG32(LED_PORT->PSOR, LED0_BIT) = 1)
#define LED0_OFF (BITBAND_REG32(LED_PORT->PCOR, LED0_BIT) = 1)
#define LED0_TOGGLE (BITBAND_REG32(LED_PORT->PTOR, LED0_BIT) = 1)
#define LED1_ON (BITBAND_REG32(LED_PORT->PSOR, LED1_BIT) = 1)
#define LED1_OFF (BITBAND_REG32(LED_PORT->PCOR, LED1_BIT) = 1)
#define LED1_TOGGLE (BITBAND_REG32(LED_PORT->PTOR, LED1_BIT) = 1)
#define LED2_ON (BITBAND_REG32(LED_PORT->PSOR, LED2_BIT) = 1)
#define LED2_OFF (BITBAND_REG32(LED_PORT->PCOR, LED2_BIT) = 1)
#define LED2_TOGGLE (BITBAND_REG32(LED_PORT->PTOR, LED2_BIT) = 1)
/** @} */
#ifdef __cplusplus

Loading…
Cancel
Save