add core board methods
This commit is contained in:
parent
1bd4aef976
commit
c083b470b6
11
global.c
11
global.c
@ -58,7 +58,7 @@ char* b2s(uint64_t binary, uint8_t rjust)
|
||||
/** switch on board LED */
|
||||
void led_on(void)
|
||||
{
|
||||
#if defined(SYSTEM_BOARD) || defined(BLUE_PILL)
|
||||
#if defined(SYSTEM_BOARD) || defined(BLUE_PILL) || defined(CORE_BOARD)
|
||||
gpio_clear(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
#elif defined(MAPLE_MINI)
|
||||
gpio_set(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
@ -67,7 +67,7 @@ void led_on(void)
|
||||
/** switch off board LED */
|
||||
void led_off(void)
|
||||
{
|
||||
#if defined(SYSTEM_BOARD) || defined(BLUE_PILL)
|
||||
#if defined(SYSTEM_BOARD) || defined(BLUE_PILL) || defined(CORE_BOARD)
|
||||
gpio_set(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
#elif defined(MAPLE_MINI)
|
||||
gpio_clear(GPIO(LED_PORT), GPIO(LED_PIN));
|
||||
@ -90,10 +90,15 @@ void board_setup(void)
|
||||
#if defined(BUTTON_PORT) && defined(BUTTON_PIN)
|
||||
rcc_periph_clock_enable(RCC_GPIO(BUTTON_PORT)); // enable clock for button
|
||||
gpio_set_mode(GPIO(BUTTON_PORT), GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO(BUTTON_PIN)); // set button pin to input
|
||||
gpio_clear(GPIO(BUTTON_PORT), GPIO(BUTTON_PIN)); // pull down to be able to detect button push (go high)
|
||||
rcc_periph_clock_enable(RCC_AFIO); // enable alternate function clock for external interrupt
|
||||
exti_select_source(EXTI(BUTTON_PIN), GPIO(BUTTON_PORT)); // mask external interrupt of this pin only for this port
|
||||
#if defined(MAPLE_MINI)
|
||||
gpio_clear(GPIO(BUTTON_PORT), GPIO(BUTTON_PIN)); // pull down to be able to detect button push (go high)
|
||||
exti_set_trigger(EXTI(BUTTON_PIN), EXTI_TRIGGER_RISING); // trigger when button is pressed
|
||||
#elif defined(CORE_BOARD)
|
||||
gpio_set(GPIO(BUTTON_PORT), GPIO(BUTTON_PIN)); // pull up to be able to detect button push (go low)
|
||||
exti_set_trigger(EXTI(BUTTON_PIN), EXTI_TRIGGER_FALLING); // trigger when button is pressed
|
||||
#endif
|
||||
exti_enable_request(EXTI(BUTTON_PIN)); // enable external interrupt
|
||||
nvic_enable_irq(NVIC_EXTI_IRQ(BUTTON_PIN)); // enable interrupt
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user