PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

88 行
1.9KB

  1. #if defined(__AVR__)
  2. #include <avr/io.h>
  3. #include <avr/interrupt.h>
  4. #define attachInterrupt(num, func, mode) enableInterrupt(num)
  5. #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  6. #define SCRAMBLE_INT_ORDER(num) ((num < 4) ? num + 2 : ((num < 6) ? num - 4 : num))
  7. #define DESCRAMBLE_INT_ORDER(num) ((num < 2) ? num + 4 : ((num < 6) ? num - 2 : num))
  8. #else
  9. #define SCRAMBLE_INT_ORDER(num) (num)
  10. #define DESCRAMBLE_INT_ORDER(num) (num)
  11. #endif
  12. static void enableInterrupt(uint8_t num)
  13. {
  14. switch (DESCRAMBLE_INT_ORDER(num)) {
  15. #if defined(EICRA) && defined(EIMSK)
  16. case 0:
  17. EICRA = (EICRA & 0xFC) | 0x01;
  18. EIMSK |= 0x01;
  19. return;
  20. case 1:
  21. EICRA = (EICRA & 0xF3) | 0x04;
  22. EIMSK |= 0x02;
  23. return;
  24. case 2:
  25. EICRA = (EICRA & 0xCF) | 0x10;
  26. EIMSK |= 0x04;
  27. return;
  28. case 3:
  29. EICRA = (EICRA & 0x3F) | 0x40;
  30. EIMSK |= 0x08;
  31. return;
  32. #elif defined(MCUCR) && defined(GICR)
  33. case 0:
  34. MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
  35. GICR |= (1 << INT0);
  36. return;
  37. case 1:
  38. MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
  39. GICR |= (1 << INT1);
  40. return;
  41. #elif defined(MCUCR) && defined(GIMSK)
  42. case 0:
  43. MCUCR = (MCUCR & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
  44. GIMSK |= (1 << INT0);
  45. return;
  46. case 1:
  47. MCUCR = (MCUCR & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
  48. GIMSK |= (1 << INT1);
  49. return;
  50. #endif
  51. #if defined(EICRB) && defined(EIMSK)
  52. case 4:
  53. EICRB = (EICRB & 0xFC) | 0x01;
  54. EIMSK |= 0x10;
  55. return;
  56. case 5:
  57. EICRB = (EICRB & 0xF3) | 0x04;
  58. EIMSK |= 0x20;
  59. return;
  60. case 6:
  61. EICRB = (EICRB & 0xCF) | 0x10;
  62. EIMSK |= 0x40;
  63. return;
  64. case 7:
  65. EICRB = (EICRB & 0x3F) | 0x40;
  66. EIMSK |= 0x80;
  67. return;
  68. #endif
  69. }
  70. }
  71. #elif defined(__PIC32MX__)
  72. #ifdef ENCODER_OPTIMIZE_INTERRUPTS
  73. #undef ENCODER_OPTIMIZE_INTERRUPTS
  74. #endif
  75. #else
  76. #ifdef ENCODER_OPTIMIZE_INTERRUPTS
  77. #undef ENCODER_OPTIMIZE_INTERRUPTS
  78. #endif
  79. #endif