mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
boards/spark-core: unified LED defines
This commit is contained in:
parent
a22b193190
commit
047050d032
@ -20,16 +20,22 @@
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
|
||||
static void leds_init(void);
|
||||
#include "periph/gpio.h"
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* 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);
|
||||
gpio_init(LED3_PIN, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
gpio_set(LED0_PIN);
|
||||
gpio_set(LED1_PIN);
|
||||
gpio_set(LED2_PIN);
|
||||
gpio_set(LED3_PIN);
|
||||
|
||||
/* initialize the CPU */
|
||||
cpu_init();
|
||||
/* initialize the boards LEDs */
|
||||
leds_init();
|
||||
/* disable systick interrupt, set by the spark bootloader */
|
||||
SysTick->CTRL = 0;
|
||||
/* signal to spark bootloader: do not enable IWDG! set Stop Mode Flag! */
|
||||
@ -37,30 +43,3 @@ void board_init(void)
|
||||
/* configure the RIOT vector table location to internal flash + spark bootloader offset */
|
||||
SCB->VTOR = LOCATION_VTABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the boards on-board LEDs
|
||||
*
|
||||
* The LEDs initialization is hard-coded in this function. As the LED is soldered
|
||||
* onto the board it is fixed to its CPU pins.
|
||||
*
|
||||
*/
|
||||
static void leds_init(void)
|
||||
{
|
||||
/* enable clock for port A */
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
|
||||
|
||||
/* reset pins */
|
||||
LED_PORT->CR[1] &= ~(0xf << (4*(LED_RED_PIN - 8)) |
|
||||
0xf << (4*(LED_GREEN_PIN - 8)) |
|
||||
0xf << (4*(LED_BLUE_PIN - 8)) |
|
||||
0xf << (4*(LED_WHITE_PIN - 8)));
|
||||
|
||||
/* set pins to out */
|
||||
LED_PORT->CR[1] |= (0x3 << (4*(LED_RED_PIN - 8)) |
|
||||
0x3 << (4*(LED_GREEN_PIN - 8)) |
|
||||
0x3 << (4*(LED_BLUE_PIN - 8)) |
|
||||
0x3 << (4*(LED_WHITE_PIN - 8)));
|
||||
|
||||
LED_PORT->BSRR = (1 << LED_RED_PIN) | (1 << LED_GREEN_PIN) | (1 << LED_BLUE_PIN) | (1 << LED_WHITE_PIN);
|
||||
}
|
||||
|
@ -41,32 +41,35 @@
|
||||
#define XTIMER_MASK (0xffff0000)
|
||||
|
||||
/**
|
||||
* @name LED pin definitions
|
||||
* @brief Macros for controlling the on-board LEDs
|
||||
* @{
|
||||
*/
|
||||
#define LED_PORT (GPIOA)
|
||||
#define LED_RED_PIN (9)
|
||||
#define LED_GREEN_PIN (10)
|
||||
#define LED_BLUE_PIN (8)
|
||||
#define LED_WHITE_PIN (13)
|
||||
/** @} */
|
||||
#define LED0_PIN GPIO_PIN(PORT_A, 9)
|
||||
#define LED1_PIN GPIO_PIN(PORT_A, 10)
|
||||
#define LED2_PIN GPIO_PIN(PORT_A, 8)
|
||||
#define LED3_PIN GPIO_PIN(PORT_A, 13)
|
||||
|
||||
/**
|
||||
* @name Macros for controlling the on-board LEDs.
|
||||
* @{
|
||||
*/
|
||||
#define LED_RED_ON (LED_PORT->BRR = (1<<LED_RED_PIN))
|
||||
#define LED_RED_OFF (LED_PORT->BSRR = (1<<LED_RED_PIN))
|
||||
#define LED_RED_TOGGLE (LED_PORT->ODR ^= (1<<LED_RED_PIN))
|
||||
#define LED_GREEN_ON (LED_PORT->BRR = (1<<LED_GREEN_PIN))
|
||||
#define LED_GREEN_OFF (LED_PORT->BSRR = (1<<LED_GREEN_PIN))
|
||||
#define LED_GREEN_TOGGLE (LED_PORT->ODR ^= (1<<LED_GREEN_PIN))
|
||||
#define LED_BLUE_ON (LED_PORT->BRR = (1<<LED_BLUE_PIN))
|
||||
#define LED_BLUE_OFF (LED_PORT->BSRR = (1<<LED_BLUE_PIN))
|
||||
#define LED_BLUE_TOGGLE (LED_PORT->ODR ^= (1<<LED_BLUE_PIN))
|
||||
#define LED_WHITE_ON (LED_PORT->BRR = (1<<LED_WHITE_PIN))
|
||||
#define LED_WHITE_OFF (LED_PORT->BSRR = (1<<LED_WHITE_PIN))
|
||||
#define LED_WHITE_TOGGLE (LED_PORT->ODR ^= (1<<LED_WHITE_PIN))
|
||||
#define LED_PORT (GPIOA)
|
||||
#define LED0_MASK (1 << 9)
|
||||
#define LED1_MASK (1 << 10)
|
||||
#define LED2_MASK (1 << 8)
|
||||
#define LED3_MASK (1 << 13)
|
||||
|
||||
#define LED0_ON (LED_PORT->BRR = LED0_MASK)
|
||||
#define LED0_OFF (LED_PORT->BSRR = LED0_MASK)
|
||||
#define LED0_TOGGLE (LED_PORT->ODR ^= LED0_MASK)
|
||||
|
||||
#define LED1_ON (LED_PORT->BRR = LED1_MASK)
|
||||
#define LED1_OFF (LED_PORT->BSRR = LED1_MASK)
|
||||
#define LED1_TOGGLE (LED_PORT->ODR ^= LED1_MASK)
|
||||
|
||||
#define LED2_ON (LED_PORT->BRR = LED2_MASK)
|
||||
#define LED2_OFF (LED_PORT->BSRR = LED2_MASK)
|
||||
#define LED2_TOGGLE (LED_PORT->ODR ^= LED2_MASK)
|
||||
|
||||
#define LED3_ON (LED_PORT->BRR = LED3_MASK)
|
||||
#define LED3_OFF (LED_PORT->BSRR = LED3_MASK)
|
||||
#define LED3_TOGGLE (LED_PORT->ODR ^= LED3_MASK)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user