mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
boards/stm32f0discovery: unified LED defines
This commit is contained in:
parent
047050d032
commit
7b1208a935
@ -19,45 +19,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include "periph/uart.h"
|
#include "periph/gpio.h"
|
||||||
|
|
||||||
|
|
||||||
static void leds_init(void);
|
|
||||||
|
|
||||||
void board_init(void)
|
void board_init(void)
|
||||||
{
|
{
|
||||||
/* initialize the boards LEDs */
|
/* initialize the boards LEDs */
|
||||||
leds_init();
|
gpio_init(LED0_PIN, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||||
|
gpio_init(LED1_PIN, GPIO_DIR_OUT, GPIO_NOPULL);
|
||||||
|
|
||||||
/* initialize the CPU */
|
/* initialize the CPU */
|
||||||
cpu_init();
|
cpu_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the boards on-board LEDs (LD3 and LD4)
|
|
||||||
*
|
|
||||||
* The LED initialization is hard-coded in this function. As the LEDs are soldered
|
|
||||||
* onto the board they are fixed to their CPU pins.
|
|
||||||
*
|
|
||||||
* The LEDs are connected to the following pins:
|
|
||||||
* - LD3: PC8
|
|
||||||
* - LD4: PC9
|
|
||||||
*/
|
|
||||||
void leds_init(void)
|
|
||||||
{
|
|
||||||
/* enable clock for port GPIOC */
|
|
||||||
RCC->AHBENR |= RCC_AHBENR_GPIOCEN;
|
|
||||||
|
|
||||||
/* set output speed to 50MHz */
|
|
||||||
LED_PORT->OSPEEDR |= 0x000f0000;
|
|
||||||
/* set output type to push-pull */
|
|
||||||
LED_PORT->OTYPER &= ~(0x00000300);
|
|
||||||
/* configure pins as general outputs */
|
|
||||||
LED_PORT->MODER &= ~(0x000f0000);
|
|
||||||
LED_PORT->MODER |= 0x00050000;
|
|
||||||
/* disable pull resistors */
|
|
||||||
LED_PORT->PUPDR &= ~(0x000f0000);
|
|
||||||
|
|
||||||
/* turn all LEDs off */
|
|
||||||
LED_PORT->BRR = 0x0300;
|
|
||||||
}
|
|
||||||
|
@ -27,33 +27,24 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @name LED pin definitions
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#define LED_PORT GPIOC
|
|
||||||
#define LD3_PIN (1 << 9)
|
|
||||||
#define LD4_PIN (1 << 8)
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Macros for controlling the on-board LEDs.
|
* @name Macros for controlling the on-board LEDs.
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define LD3_ON (LED_PORT->BSRR = LD3_PIN)
|
#define LED0_PIN GPIO_PIN(PORT_C, 9)
|
||||||
#define LD3_OFF (LED_PORT->BSRR = (LD3_PIN << 16))
|
#define LED1_PIN GPIO_PIN(PORT_C, 8)
|
||||||
#define LD3_TOGGLE (LED_PORT->ODR ^= LD3_PIN)
|
|
||||||
#define LD4_ON (LED_PORT->BSRR = LD4_PIN)
|
|
||||||
#define LD4_OFF (LED_PORT->BSRR = (LD4_PIN << 16))
|
|
||||||
#define LD4_TOGGLE (LED_PORT->ODR ^= LD4_PIN)
|
|
||||||
|
|
||||||
/* for compatibility to other boards */
|
#define LED_PORT GPIOC
|
||||||
#define LED_GREEN_ON LD3_ON
|
#define LED0_MASK (1 << 9)
|
||||||
#define LED_GREEN_OFF LD3_OFF
|
#define LED1_MASK (1 << 8)
|
||||||
#define LED_GREEN_TOGGLE LD3_TOGGLE
|
|
||||||
#define LED_RED_ON LD4_ON
|
#define LED0_ON (LED_PORT->BSRR = LED0_MASK)
|
||||||
#define LED_RED_OFF LD4_OFF
|
#define LED0_OFF (LED_PORT->BRR = LED0_MASK)
|
||||||
#define LED_RED_TOGGLE LD4_TOGGLE
|
#define LED0_TOGGLE (LED_PORT->ODR ^= LED0_MASK)
|
||||||
|
|
||||||
|
#define LED1_ON (LED_PORT->BSRR = LED1_MASK)
|
||||||
|
#define LED1_OFF (LED_PORT->BRR = LED1_MASK)
|
||||||
|
#define LED1_TOGGLE (LED_PORT->ODR ^= LED1_MASK)
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user