// // This file is part of the GNU ARM Eclipse distribution. // Copyright (c) 2014 Liviu Ionescu. // #ifndef BLINKLED_H_ #define BLINKLED_H_ #include "stm32f4xx.h" #include "stm32f4xx_hal.h" // ----- LED definitions ------------------------------------------------------ // Adjust these definitions for your own board. #if defined(BOARD_OLIMEX_STM32_E407) // STM32-E407 definitions (the GREEN led, C13, active low) // Port numbers: 0=A, 1=B, 2=C, 3=D, 4=E, 5=F, 6=G, ... #define BLINK_PORT_NUMBER (2) #define BLINK_PIN_NUMBER (13) #define BLINK_ACTIVE_LOW (1) #else // STM32F4DISCOVERY definitions (the GREEN led, D12, active high) // (SEGGER J-Link device name: STM32F407VG). #define BLINK_PORT_NUMBER (0) #define BLINK_PIN_NUMBER (8) #define BLINK_ACTIVE_LOW (0) #endif #define BLINK_GPIOx(_N) ((GPIO_TypeDef *)(GPIOA_BASE + (GPIOB_BASE-GPIOA_BASE)*(_N))) #define BLINK_PIN_MASK(_N) (1 << (_N)) #define BLINK_RCC_MASKx(_N) (RCC_AHB1ENR_GPIOAEN << (_N)) // ---------------------------------------------------------------------------- extern void blink_led_init(void); // ---------------------------------------------------------------------------- inline void blink_led_on(void); inline void blink_led_off(void); // ---------------------------------------------------------------------------- inline void __attribute__((always_inline)) blink_led_on(void) { #if (BLINK_ACTIVE_LOW) HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER), BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_RESET); #else HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER), BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_SET); #endif } inline void __attribute__((always_inline)) blink_led_off(void) { #if (BLINK_ACTIVE_LOW) HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER), BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_SET); #else HAL_GPIO_WritePin(BLINK_GPIOx(BLINK_PORT_NUMBER), BLINK_PIN_MASK(BLINK_PIN_NUMBER), GPIO_PIN_RESET); #endif } // ---------------------------------------------------------------------------- #endif // BLINKLED_H_