mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Adding some comments to explain the interrupts.
This commit is contained in:
parent
514a74849a
commit
d21eb97de4
@ -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);
|
||||
|
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user