mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-26 06:53:52 +01:00
boards/fox: unified LED defines
This commit is contained in:
parent
845e2f1cd7
commit
c9677c4350
@ -19,34 +19,17 @@
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
static void leds_init(void);
|
||||
|
||||
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: PB12
|
||||
* - Red: PB10
|
||||
*/
|
||||
static void leds_init(void)
|
||||
{
|
||||
/* green pin */
|
||||
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
|
||||
LED_GREEN_PORT->CR[0] = (0x3 << ((LED_GREEN_PIN-8)*4));
|
||||
/* red pin */;
|
||||
LED_RED_PORT->CR[0] = (0x3 << ((LED_RED_PIN-8)*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_set(LED0_PIN);
|
||||
gpio_set(LED1_PIN);
|
||||
}
|
||||
|
||||
@ -81,32 +81,22 @@ extern "C" {
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name LED pin definitions
|
||||
* @brief LED pin definitions and handlers
|
||||
* @{
|
||||
*/
|
||||
#define LED_RED_PORT (GPIOB)
|
||||
#define LED_RED_PIN (10)
|
||||
#define LED_RED_GPIO GPIO_PIN(PORT_B,10)
|
||||
#define LED_GREEN_PORT (GPIOB)
|
||||
#define LED_GREEN_PIN (12)
|
||||
#define LED_GREEN_GPIO GPIO_PIN(PORT_B,12)
|
||||
/** @} */
|
||||
#define LED0_PIN GPIO_PIN(PORT_B, 10)
|
||||
#define LED1_PIN GPIO_PIN(PORT_B, 12)
|
||||
|
||||
/**
|
||||
* @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 << 10)
|
||||
#define LED1_MASK (1 << 12)
|
||||
|
||||
#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 LED0_ON (GPIOB->ODR &= ~LED0_MASK)
|
||||
#define LED0_OFF (GPIOB->ODR |= LED0_MASK)
|
||||
#define LED0_TOGGLE (GPIOB->ODR ^= LED0_MASK)
|
||||
|
||||
#define LED_ORANGE_ON
|
||||
#define LED_ORANGE_OFF
|
||||
#define LED_ORANGE_TOGGLE
|
||||
#define LED1_ON (GPIOB->ODR &= ~LED1_MASK)
|
||||
#define LED1_OFF (GPIOB->ODR |= LED1_MASK)
|
||||
#define LED1_TOGGLE (GPIOB->ODR ^= LED1_MASK)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user