interrupt_config.h
Go to the documentation of this file.
00001 #if defined(__AVR__)
00002 
00003 #include <avr/io.h>
00004 #include <avr/interrupt.h>
00005 
00006 #define attachInterrupt(num, func, mode) enableInterrupt(num)
00007 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
00008 #define SCRAMBLE_INT_ORDER(num) ((num < 4) ? num + 2 : ((num < 6) ? num - 4 : num))
00009 #define DESCRAMBLE_INT_ORDER(num) ((num < 2) ? num + 4 : ((num < 6) ? num - 2 : num))
00010 #else
00011 #define SCRAMBLE_INT_ORDER(num) (num)
00012 #define DESCRAMBLE_INT_ORDER(num) (num)
00013 #endif
00014 
00015 static void enableInterrupt(uint8_t num)
00016 {
00017         switch (DESCRAMBLE_INT_ORDER(num)) {
00018                 #if defined(EICRA) && defined(EIMSK)
00019                 case 0:
00020                         EICRA = (EICRA & 0xFC) | 0x01;
00021                         EIMSK |= 0x01;
00022                         return;
00023                 case 1:
00024                         EICRA = (EICRA & 0xF3) | 0x04;
00025                         EIMSK |= 0x02;
00026                         return;
00027                 case 2:
00028                         EICRA = (EICRA & 0xCF) | 0x10;
00029                         EIMSK |= 0x04;
00030                         return;
00031                 case 3:
00032                         EICRA = (EICRA & 0x3F) | 0x40;
00033                         EIMSK |= 0x08;
00034                         return;
00035                 #elif defined(MCUCR) && defined(GICR)
00036                 case 0:
00037                         MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
00038                         GICR |= (1 << INT0);
00039                         return;
00040                 case 1:
00041                         MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
00042                         GICR |= (1 << INT1);
00043                         return;
00044                 #elif defined(MCUCR) && defined(GIMSK)
00045                 case 0:
00046                         MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
00047                         GIMSK |= (1 << INT0);
00048                         return;
00049                 case 1:
00050                         MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
00051                         GIMSK |= (1 << INT1);
00052                         return;
00053                 #endif
00054                 #if defined(EICRB) && defined(EIMSK)
00055                 case 4:
00056                         EICRB = (EICRB & 0xFC) | 0x01;
00057                         EIMSK |= 0x10;
00058                         return;
00059                 case 5:
00060                         EICRB = (EICRB & 0xF3) | 0x04;
00061                         EIMSK |= 0x20;
00062                         return;
00063                 case 6:
00064                         EICRB = (EICRB & 0xCF) | 0x10;
00065                         EIMSK |= 0x40;
00066                         return;
00067                 case 7:
00068                         EICRB = (EICRB & 0x3F) | 0x40;
00069                         EIMSK |= 0x80;
00070                         return;
00071                 #endif
00072         }
00073 }
00074 
00075 #elif defined(__PIC32MX__)
00076 
00077 #ifdef ENCODER_OPTIMIZE_INTERRUPTS
00078 #undef ENCODER_OPTIMIZE_INTERRUPTS
00079 #endif
00080 
00081 #else
00082 
00083 #ifdef ENCODER_OPTIMIZE_INTERRUPTS
00084 #undef ENCODER_OPTIMIZE_INTERRUPTS
00085 #endif
00086 
00087 #endif


lizi_arduino
Author(s): RoboTiCan
autogenerated on Wed Aug 26 2015 12:24:22