global: remove definitions for other boards not used for this project
This commit is contained in:
parent
33ec1bcd26
commit
dcd773b9d8
42
global.c
42
global.c
|
@ -66,9 +66,6 @@ char* b2s(uint64_t binary, uint8_t rjust)
|
|||
inline void led_on(void)
|
||||
{
|
||||
#if defined(LED_PIN)
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_PIN(LED_PIN)); // set LED pin push-pull
|
||||
#endif // BUSVOODOO
|
||||
#if defined(LED_ON) && LED_ON
|
||||
gpio_set(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#else
|
||||
|
@ -81,14 +78,10 @@ inline void led_on(void)
|
|||
inline void led_off(void)
|
||||
{
|
||||
#if defined(LED_PIN)
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LED_PIN)); // set LED pin to floating to disable LEDs
|
||||
#else
|
||||
#if defined(LED_ON) && LED_ON
|
||||
gpio_clear(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#else
|
||||
gpio_set(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#endif // BUSVOODOO
|
||||
#endif // LED_ON
|
||||
#endif // LED_PIN
|
||||
}
|
||||
|
@ -97,9 +90,6 @@ inline void led_off(void)
|
|||
inline void led_toggle(void)
|
||||
{
|
||||
#if defined(LED_PIN)
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_PIN(LED_PIN)); // set LED pin to push-pull
|
||||
#endif // BUSVOODOO
|
||||
gpio_toggle(GPIO_PORT(LED_PIN), GPIO_PIN(LED_PIN));
|
||||
#endif // LED_PIN
|
||||
}
|
||||
|
@ -186,42 +176,12 @@ void board_setup(void)
|
|||
#if defined(LED_PIN)
|
||||
// setup LED
|
||||
rcc_periph_clock_enable(GPIO_RCC(LED_PIN)); // enable clock for LED
|
||||
#if defined(BUSVOODOO)
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LED_PIN)); // set LED pin to floating to disable LEDs
|
||||
#else
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_PIN(LED_PIN)); // set LED pin to output push-pull do drive LED
|
||||
#endif
|
||||
gpio_set_mode(GPIO_PORT(LED_PIN), GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, GPIO_PIN(LED_PIN)); // LED it controller by pMOS by default pulled up
|
||||
led_off(); // switch off LED per default
|
||||
#endif // LED_PIN
|
||||
|
||||
// setup button
|
||||
#if defined(BUTTON_PIN)
|
||||
rcc_periph_clock_enable(GPIO_RCC(BUTTON_PIN)); // enable clock for button
|
||||
gpio_set_mode(GPIO_PORT(BUTTON_PIN), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO_PIN(BUTTON_PIN)); // set button pin to input
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable alternate function clock for external interrupt
|
||||
exti_select_source(GPIO_EXTI(BUTTON_PIN), GPIO_PORT(BUTTON_PIN)); // mask external interrupt of this pin only for this port
|
||||
#if defined(BUTTON_PRESSED) && BUTTON_PRESSED
|
||||
gpio_clear(GPIO_PORT(BUTTON_PIN), GPIO_PIN(BUTTON_PIN)); // pull down to be able to detect button push (go high)
|
||||
exti_set_trigger(GPIO_EXTI(BUTTON_PIN), EXTI_TRIGGER_RISING); // trigger when button is pressed
|
||||
#else
|
||||
gpio_set(GPIO_PORT(BUTTON_PIN), GPIO_PIN(BUTTON_PIN)); // pull up to be able to detect button push (go low)
|
||||
exti_set_trigger(GPIO_EXTI(BUTTON_PIN), EXTI_TRIGGER_FALLING); // trigger when button is pressed
|
||||
#endif
|
||||
exti_enable_request(GPIO_EXTI(BUTTON_PIN)); // enable external interrupt
|
||||
nvic_enable_irq(GPIO_NVIC_EXTI_IRQ(BUTTON_PIN)); // enable interrupt
|
||||
#endif
|
||||
|
||||
// reset user input buffer
|
||||
user_input_available = false;
|
||||
user_input_i = 0;
|
||||
user_input_used = 0;
|
||||
}
|
||||
|
||||
#if defined(BUTTON_PIN)
|
||||
/** interrupt service routine called when button is pressed */
|
||||
void GPIO_EXTI_ISR(BUTTON_PIN)(void)
|
||||
{
|
||||
exti_reset_request(GPIO_EXTI(BUTTON_PIN)); // reset interrupt
|
||||
button_flag = true; // perform button action
|
||||
}
|
||||
#endif
|
||||
|
|
37
global.h
37
global.h
|
@ -617,46 +617,13 @@
|
|||
* @note the onboard LED of the USB cable tester is controlled along the display power and USB pull-up
|
||||
* @{
|
||||
*/
|
||||
#if defined(SYSTEM_BOARD) || defined(CORE_BOARD)
|
||||
#define LED_PIN PA1 /**< GPIO pin (pin 11) */
|
||||
#define LED_ON 0 /**< LED is on when pin is low */
|
||||
#elif defined(BLUE_PILL)
|
||||
#define LED_PIN PC13 /**< GPIO pin */
|
||||
#define LED_ON 0 /**< LED is on when pin is low */
|
||||
#elif defined(BLACK_PILL)
|
||||
#define LED_PIN PB12 /**< GPIO pin */
|
||||
#define LED_ON 0 /**< LED is on when pin is low */
|
||||
#elif defined(MAPLE_MINI)
|
||||
#define LED_PIN PB1 /**< GPIO pin (pin 19) */
|
||||
#define LED_ON 1 /**< LED is on when pin is high */
|
||||
#elif defined(STLINKV2) // it's sometimes a STM32F101, but it seems to have all STM32F103 features
|
||||
/* on ST-Link V2 clone dongle in aluminum case LED is on pin PA9 (remap USART1_TX if used) */
|
||||
#define LED_PIN PA9 /**< GPIO pin */
|
||||
#define LED_ON 1 /**< the color and on level depends on the clone */
|
||||
#elif defined(BLASTER)
|
||||
#define LED_PIN PA5 /**< GPIO pin */
|
||||
#define LED_ON 0 /**< red LED on when low (green LED is on when device is powered) */
|
||||
#elif defined(BUSVOODOO)
|
||||
#define LED_PIN PA8 /**< GPIO pin */
|
||||
#define LED_ON 1 /**< blue LED is on when pin is high, red LED is on when pin is low, LED is off when LED is floating */
|
||||
#endif
|
||||
// #define LED_PIN PD13 /**< GPIO pin */
|
||||
// #define LED_ON 0 /**< LED is on when pin is low */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup board_button board user button GPIO
|
||||
* @{
|
||||
*/
|
||||
#if defined(MAPLE_MINI)
|
||||
/* on maple mini user button is on 32/PB8 */
|
||||
#define BUTTON_PIN PB8 /**< GPIO pin (pin PB8 on maple mini) */
|
||||
#define BUTTON_PRESSED 1 /**< pin is high when button is pressed */
|
||||
#elif defined(CORE_BOARD)
|
||||
/* on core board user button is on PA8 */
|
||||
#define BUTTON_PIN PA8 /**< GPIO pin (pin PA8) */
|
||||
#define BUTTON_PRESSED 0 /**< pin is low when button is pressed */
|
||||
#endif
|
||||
|
||||
// #define LED_PIN PD13 /**< GPIO pin */
|
||||
// #define LED_ON 0 /**< LED is on when pin is low */
|
||||
/** @} */
|
||||
|
||||
/** @defgroup input to force DFU mode on low, even if application is valid
|
||||
|
|
Loading…
Reference in New Issue