From d21eb97de4ce14506a08765b21ae681f29a46d45 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Wed, 29 Nov 2006 19:35:43 +0000 Subject: [PATCH] Adding some comments to explain the interrupts. --- targets/arduino/WInterrupts.c | 7 +++++++ targets/arduino/wiring.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/targets/arduino/WInterrupts.c b/targets/arduino/WInterrupts.c index 8b44bed2e..87dc25e6a 100755 --- a/targets/arduino/WInterrupts.c +++ b/targets/arduino/WInterrupts.c @@ -41,7 +41,13 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { intFunc[interruptNum] = userFunc; if (interruptNum == 0) { + // Configure the interrupt mode (trigger on low input, any change, rising + // edge, or falling edge). The mode constants were chosen to correspond + // to the configuration bits in the hardware register, so we simply shift + // the mode into place. MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00); + + // Enable the interrupt. GICR |= (1 << INT0); } else { MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10); @@ -53,6 +59,7 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) { void detachInterrupt(uint8_t interruptNum) { if(interruptNum < EXTERNAL_NUM_INTERRUPTS) { if (interruptNum == 0) + // Disable the interrupt. GICR &= ~(1 << INT0); else GICR &= ~(1 << INT1); diff --git a/targets/arduino/wiring.c b/targets/arduino/wiring.c index 9890c5b09..b3444cbd9 100755 --- a/targets/arduino/wiring.c +++ b/targets/arduino/wiring.c @@ -41,7 +41,7 @@ // Define constants and variables for buffering incoming serial data. We're // using a ring buffer (I think), in which rx_buffer_head is the index of the // location to which to write the next incoming character and rx_buffer_tail -// is the index of the location from which to read +// is the index of the location from which to read. #define RX_BUFFER_SIZE 128 unsigned char rx_buffer[RX_BUFFER_SIZE];