diff --git a/boards/stm32f0discovery/include/periph_conf.h b/boards/stm32f0discovery/include/periph_conf.h index ce08bd64d4..b9fdc988ec 100644 --- a/boards/stm32f0discovery/include/periph_conf.h +++ b/boards/stm32f0discovery/include/periph_conf.h @@ -183,14 +183,14 @@ extern "C" { /* IRQ config */ #define GPIO_IRQ_0 GPIO_0 #define GPIO_IRQ_1 GPIO_1 -#define GPIO_IRQ_2 GPIO_0 /* not configured */ -#define GPIO_IRQ_3 GPIO_0 /* not configured */ +#define GPIO_IRQ_2 -1 /* not configured */ +#define GPIO_IRQ_3 -1 /* not configured */ #define GPIO_IRQ_4 GPIO_2 #define GPIO_IRQ_5 GPIO_3 #define GPIO_IRQ_6 GPIO_4 #define GPIO_IRQ_7 GPIO_5 -#define GPIO_IRQ_8 GPIO_0 /* not configured */ -#define GPIO_IRQ_9 GPIO_0 /* not configured */ +#define GPIO_IRQ_8 -1 /* not configured */ +#define GPIO_IRQ_9 -1 /* not configured */ #define GPIO_IRQ_10 GPIO_6 #define GPIO_IRQ_11 GPIO_7 #define GPIO_IRQ_12 GPIO_8 diff --git a/cpu/stm32f0/periph/gpio.c b/cpu/stm32f0/periph/gpio.c index f9c1d77615..7cbd639df6 100644 --- a/cpu/stm32f0/periph/gpio.c +++ b/cpu/stm32f0/periph/gpio.c @@ -451,14 +451,18 @@ void gpio_write(gpio_t dev, int value) void isr_exti0_1(void) { +#if GPIO_IRQ_0 >= 0 if (EXTI->PR & EXTI_PR_PR0) { EXTI->PR |= EXTI_PR_PR0; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_0].cb(gpio_config[GPIO_IRQ_0].arg); } - else if (EXTI->PR & EXTI_PR_PR1) { +#endif +#if GPIO_IRQ_1 >= 0 + if (EXTI->PR & EXTI_PR_PR1) { EXTI->PR |= EXTI_PR_PR1; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_1].cb(gpio_config[GPIO_IRQ_1].arg); } +#endif if (sched_context_switch_request) { thread_yield(); } @@ -466,14 +470,18 @@ void isr_exti0_1(void) void isr_exti2_3(void) { +#if GPIO_IRQ_2 >= 0 if (EXTI->PR & EXTI_PR_PR2) { EXTI->PR |= EXTI_PR_PR2; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_2].cb(gpio_config[GPIO_IRQ_2].arg); } - else if (EXTI->PR & EXTI_PR_PR3) { +#endif +#if GPIO_IRQ_3 >= 0 + if (EXTI->PR & EXTI_PR_PR3) { EXTI->PR |= EXTI_PR_PR3; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_3].cb(gpio_config[GPIO_IRQ_3].arg); } +#endif if (sched_context_switch_request) { thread_yield(); } @@ -481,54 +489,78 @@ void isr_exti2_3(void) void isr_exti4_15(void) { +#if GPIO_IRQ_4 >= 0 if (EXTI->PR & EXTI_PR_PR4) { EXTI->PR |= EXTI_PR_PR4; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_4].cb(gpio_config[GPIO_IRQ_4].arg); } - else if (EXTI->PR & EXTI_PR_PR5) { +#endif +#if GPIO_IRQ_5 >= 0 + if (EXTI->PR & EXTI_PR_PR5) { EXTI->PR |= EXTI_PR_PR5; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_5].cb(gpio_config[GPIO_IRQ_5].arg); } - else if (EXTI->PR & EXTI_PR_PR6) { +#endif +#if GPIO_IRQ_6 >= 0 + if (EXTI->PR & EXTI_PR_PR6) { EXTI->PR |= EXTI_PR_PR6; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_6].cb(gpio_config[GPIO_IRQ_6].arg); } - else if (EXTI->PR & EXTI_PR_PR7) { +#endif +#if GPIO_IRQ_7 >= 0 + if (EXTI->PR & EXTI_PR_PR7) { EXTI->PR |= EXTI_PR_PR7; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_7].cb(gpio_config[GPIO_IRQ_7].arg); } - else if (EXTI->PR & EXTI_PR_PR8) { +#endif +#if GPIO_IRQ_8 >= 0 + if (EXTI->PR & EXTI_PR_PR8) { EXTI->PR |= EXTI_PR_PR8; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_8].cb(gpio_config[GPIO_IRQ_8].arg); } - else if (EXTI->PR & EXTI_PR_PR9) { +#endif +#if GPIO_IRQ_9 >= 0 + if (EXTI->PR & EXTI_PR_PR9) { EXTI->PR |= EXTI_PR_PR9; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_9].cb(gpio_config[GPIO_IRQ_9].arg); } - else if (EXTI->PR & EXTI_PR_PR10) { +#endif +#if GPIO_IRQ_10 >= 0 + if (EXTI->PR & EXTI_PR_PR10) { EXTI->PR |= EXTI_PR_PR10; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_10].cb(gpio_config[GPIO_IRQ_10].arg); } - else if (EXTI->PR & EXTI_PR_PR11) { +#endif +#if GPIO_IRQ_11 >= 0 + if (EXTI->PR & EXTI_PR_PR11) { EXTI->PR |= EXTI_PR_PR11; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_11].cb(gpio_config[GPIO_IRQ_11].arg); } - else if (EXTI->PR & EXTI_PR_PR12) { +#endif +#if GPIO_IRQ_12 >= 0 + if (EXTI->PR & EXTI_PR_PR12) { EXTI->PR |= EXTI_PR_PR12; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_12].cb(gpio_config[GPIO_IRQ_12].arg); } - else if (EXTI->PR & EXTI_PR_PR13) { +#endif +#if GPIO_IRQ_13 >= 0 + if (EXTI->PR & EXTI_PR_PR13) { EXTI->PR |= EXTI_PR_PR13; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_13].cb(gpio_config[GPIO_IRQ_13].arg); } - else if (EXTI->PR & EXTI_PR_PR14) { +#endif +#if GPIO_IRQ_14 >= 0 + if (EXTI->PR & EXTI_PR_PR14) { EXTI->PR |= EXTI_PR_PR14; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_14].cb(gpio_config[GPIO_IRQ_14].arg); } - else if (EXTI->PR & EXTI_PR_PR15) { +#endif +#if GPIO_IRQ_15 >= 0 + if (EXTI->PR & EXTI_PR_PR15) { EXTI->PR |= EXTI_PR_PR15; /* clear status bit by writing a 1 to it */ gpio_config[GPIO_IRQ_15].cb(gpio_config[GPIO_IRQ_15].arg); } +#endif if (sched_context_switch_request) { thread_yield(); }