boards/limifrog-v1: unified LED defines
This commit is contained in:
parent
b34eb922eb
commit
c0a881c5f8
@ -19,40 +19,13 @@
|
||||
*/
|
||||
|
||||
#include "board.h"
|
||||
#include "cpu.h"
|
||||
#include "periph/gpio.h"
|
||||
|
||||
static void leds_init(void);
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
/* initialize the boards LEDs */
|
||||
leds_init();
|
||||
gpio_init(LED0_PIN, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||
/* initialize the CPU */
|
||||
cpu_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize the boards on-board LEDs
|
||||
*
|
||||
* The LED initialization is hard-coded in this function.
|
||||
* As the LED is soldered onto the board it is fixed to
|
||||
* its CPU pins.
|
||||
*
|
||||
* The red LED is connected to pin PC3
|
||||
*/
|
||||
static void leds_init(void)
|
||||
{
|
||||
/* enable clock for port GPIOC */
|
||||
RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
|
||||
/* set output speed to 50MHz */
|
||||
LED_RED_PORT->OSPEEDR |= GPIO_OSPEEDER_OSPEEDR3;
|
||||
/* set output type to push-pull */
|
||||
LED_RED_PORT->OTYPER &= ~(GPIO_OTYPER_OT_3);
|
||||
/* configure pin as general output */
|
||||
LED_RED_PORT->MODER &= ~(GPIO_MODER_MODER3);
|
||||
LED_RED_PORT->MODER |= GPIO_MODER_MODER3_0;
|
||||
/* disable pull resistors */
|
||||
LED_RED_PORT->PUPDR &= ~(GPIO_PUPDR_PUPDR3);
|
||||
/* turn all LEDs off */
|
||||
LED_RED_PORT->BRR = (1 << 3);
|
||||
}
|
||||
|
||||
@ -31,27 +31,17 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @name LED pin definitions
|
||||
* @brief LED pin definitions and handlers
|
||||
* @{
|
||||
*/
|
||||
#define LED_RED_PORT (GPIOC)
|
||||
#define LED_RED_PIN (3)
|
||||
#define LED_RED_GPIO GPIO_PIN(PORT_C,3)
|
||||
/** @} */
|
||||
#define LED0_PIN GPIO_PIN(PORT_C, 3)
|
||||
|
||||
/**
|
||||
* @name Macros for controlling the on-board LEDs.
|
||||
* @{
|
||||
*/
|
||||
#define LED_GREEN_ON
|
||||
#define LED_GREEN_OFF
|
||||
#define LED_GREEN_TOGGLE
|
||||
#define LED_ORANGE_ON
|
||||
#define LED_ORANGE_OFF
|
||||
#define LED_ORANGE_TOGGLE
|
||||
#define LED_RED_ON (LED_RED_PORT->BSRRL = (1 << LED_RED_PIN))
|
||||
#define LED_RED_OFF (LED_RED_PORT->BSRRH = (1 << LED_RED_PIN))
|
||||
#define LED_RED_TOGGLE (LED_RED_PORT->ODR ^= (1 << LED_RED_PIN))
|
||||
#define LED0_PORT (GPIOC)
|
||||
#define LED0_MASK (1 << 3)
|
||||
|
||||
#define LED0_ON (LED0_PORT->BSRRL = LED0_MASK)
|
||||
#define LED0_OFF (LED0_PORT->BSRRH = LED0_MASK)
|
||||
#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user