boards/iotlab-m3: unified LED defines

pr/gpio
Hauke Petersen 7 years ago
parent 9f12d26902
commit b34eb922eb

@ -19,41 +19,18 @@
*/
#include "board.h"
#include "cpu.h"
static void leds_init(void);
#include "periph/gpio.h"
void board_init(void)
{
/* initialize the CPU */
cpu_init();
/* initialize the boards LEDs */
leds_init();
}
/**
* @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.
*
* The LEDs are connected to the following pin:
* - Green: PB5
* - Orange: PC10
* - Red: PD2
*/
static void leds_init(void)
{
/* green pin */
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
LED_GREEN_PORT->CR[0] = (0x3 << (LED_GREEN_PIN*4));
/* orange pin */
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
LED_ORANGE_PORT->CR[1] = (0x3 << ((LED_ORANGE_PIN-8)*4));
/* red pin */
RCC->APB2ENR |= RCC_APB2ENR_IOPDEN;
LED_RED_PORT->CR[0] = (0x3 << (LED_RED_PIN*4));
/* initialize the boards LEDs and turn them off */
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_set(LED0_PIN);
gpio_set(LED1_PIN);
gpio_set(LED2_PIN);
}

@ -108,35 +108,28 @@ extern "C" {
/** @} */
/**
* @name LED pin definitions
* @brief LED pin definitions and handlers
* @{
*/
#define LED_RED_PORT (GPIOD)
#define LED_RED_PIN (2)
#define LED_RED_GPIO GPIO_PIN(PORT_D,2)
#define LED_GREEN_PORT (GPIOB)
#define LED_GREEN_PIN (5)
#define LED_GREEN_GPIO GPIO_PIN(PORT_B,5)
#define LED_ORANGE_PORT (GPIOC)
#define LED_ORANGE_PIN (10)
#define LED_ORANGE_GPIO GPIO_PIN(PORT_C,10)
/** @} */
#define LED0_PIN GPIO_PIN(PORT_D, 2)
#define LED1_PIN GPIO_PIN(PORT_B, 5)
#define LED2_PIN GPIO_PIN(PORT_C, 10)
/**
* @name Macros for controlling the on-board LEDs.
* @{
*/
#define LED_RED_ON (LED_RED_PORT->ODR &= ~(1<<LED_RED_PIN))
#define LED_RED_OFF (LED_RED_PORT->ODR |= (1<<LED_RED_PIN))
#define LED_RED_TOGGLE (LED_RED_PORT->ODR ^= (1<<LED_RED_PIN))
#define LED0_MASK (1 << 2)
#define LED1_MASK (1 << 5)
#define LED2_MASK (1 << 10)
#define LED0_ON (GPIOD->ODR &= ~LED0_MASK)
#define LED0_OFF (GPIOD->ODR |= LED0_MASK)
#define LED0_TOGGLE (GPIOD->ODR ^= LED0_MASK)
#define LED_GREEN_ON (LED_GREEN_PORT->ODR &= ~(1<<LED_GREEN_PIN))
#define LED_GREEN_OFF (LED_GREEN_PORT->ODR |= (1<<LED_GREEN_PIN))
#define LED_GREEN_TOGGLE (LED_GREEN_PORT->ODR ^= (1<<LED_GREEN_PIN))
#define LED1_ON (GPIOB->ODR &= ~LED1_MASK)
#define LED1_OFF (GPIOB->ODR |= LED1_MASK)
#define LED1_TOGGLE (GPIOB->ODR ^= LED1_MASK)
#define LED_ORANGE_ON (LED_ORANGE_PORT->ODR &= ~(1<<LED_ORANGE_PIN))
#define LED_ORANGE_OFF (LED_ORANGE_PORT->ODR |= (1<<LED_ORANGE_PIN))
#define LED_ORANGE_TOGGLE (LED_ORANGE_PORT->ODR ^= (1<<LED_ORANGE_PIN))
#define LED2_ON (GPIOC->ODR &= ~LED2_MASK)
#define LED2_OFF (GPIOC->ODR |= LED2_MASK)
#define LED2_TOGGLE (GPIOC->ODR ^= LED2_MASK)
/** @} */
/**

@ -33,19 +33,19 @@ static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "LED(red)",
.pin = LED_RED_GPIO,
.pin = LED0_PIN,
.dir = GPIO_DIR_OUT,
.pull = GPIO_NOPULL,
},
{
.name = "LED(green)",
.pin = LED_GREEN_GPIO,
.pin = LED1_PIN,
.dir = GPIO_DIR_OUT,
.pull = GPIO_NOPULL,
},
{
.name = "LED(orange)",
.pin = LED_ORANGE_GPIO,
.pin = LED2_PIN,
.dir = GPIO_DIR_OUT,
.pull = GPIO_NOPULL,
},

Loading…
Cancel
Save