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.
This commit is contained in:
steffen 2018-06-13 14:23:29 +02:00
parent ea2c9ca66b
commit 3ad71d5be0

View File

@ -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