diff --git a/global.c b/global.c index 39f56b6..8795909 100644 --- a/global.c +++ b/global.c @@ -196,20 +196,20 @@ void board_setup(void) #endif // LED_PIN // setup button -#if defined(BUTTON_PORT) && defined(BUTTON_PIN) +#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(BUTTON_PIN)); // set button pin to input + 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(BUTTON_PIN)); // pull down to be able to detect button push (go high) + 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(BUTTON_PIN)); // pull up to be able to detect button push (go low) + 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(NVIC_EXTI_IRQ(BUTTON_PIN)); // enable interrupt + nvic_enable_irq(GPIO_NVIC_EXTI_IRQ(BUTTON_PIN)); // enable interrupt #endif // reset user input buffer