From 12fef1b196d3eb4b5f35ba177d196cf2e1def95c Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 20 Jun 2011 20:50:22 -0300 Subject: [PATCH] atusb/fw/: disable INT0 if manipulating GPIOs (tentative) Since GPIO manipulations may cause stray INT0 activity, we turn off INT0 handing on ATUSB_GPIO. The MCU must be reset to restore access to INT0. There are still issues to resolve with the GPIO test. It may turn out that there's a less invasive solution than just turning off INT0 completely. - board_app.c (gpio): mask INT0 before manipulating GPIOs - board_app.c (board_app_init): make it clearer that EIMSK is a bit mask --- atusb/fw/board_app.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atusb/fw/board_app.c b/atusb/fw/board_app.c index 67e6353..3721e8b 100644 --- a/atusb/fw/board_app.c +++ b/atusb/fw/board_app.c @@ -93,6 +93,8 @@ void timer_init(void) int gpio(uint8_t port, uint8_t data, uint8_t dir, uint8_t mask, uint8_t *res) { + EIMSK = 0; /* must reset to recover INT_RF */ + switch (port) { case 1: DDRB = (DDRB & ~mask) | dir; @@ -154,5 +156,5 @@ void board_app_init(void) { /* enable INT0, trigger on rising edge */ EICRA = 1 << ISC01 | 1 << ISC00; - EIMSK = 1; + EIMSK = 1 << 0; }