Skip to content
Snippets Groups Projects
Commit 3ad71d5b authored by steffen's avatar steffen
Browse files

atmega_common/gpio.c Fixes GPIO interrupt

fixes the GPIO_LOW interrupt on the atmega platform.
It results from trying to shift GPIO_LOW. Since it is 0, it is not shiftable and will not be set correctly.
There were more issues with the other flanks too, as they are 0b01 or 0b00. If 0b11 was set as a flank before it would not be able to switch to any other mode anymore. Now the bits get cleared before the new flank will be written.
parent ea2c9ca6
No related branches found
No related tags found
No related merge requests found
...@@ -174,10 +174,12 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, ...@@ -174,10 +174,12 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
/* apply flank to interrupt number int_num */ /* apply flank to interrupt number int_num */
if (int_num < 4) { if (int_num < 4) {
EICRA &= ~(0x3 << (int_num * 2));
EICRA |= (flank << (int_num * 2)); EICRA |= (flank << (int_num * 2));
} }
#if defined(EICRB) #if defined(EICRB)
else { else {
EICRB &= ~(0x3 << ((int_num % 4) * 2));
EICRB |= (flank << ((int_num % 4) * 2)); EICRB |= (flank << ((int_num % 4) * 2));
} }
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment