AltSoftSerial_Boards.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* An Alternative Software Serial Library
  2. * http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
  3. * Copyright (c) 2014 PJRC.COM, LLC, Paul Stoffregen, paul@pjrc.com
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in
  13. * all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. * THE SOFTWARE.
  22. */
  23. // Teensy 2.0
  24. //
  25. #if defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY)
  26. //#define ALTSS_USE_TIMER1
  27. //#define INPUT_CAPTURE_PIN 22 // receive
  28. //#define OUTPUT_COMPARE_A_PIN 14 // transmit
  29. //#define OUTPUT_COMPARE_B_PIN 15 // unusable PWM
  30. //#define OUTPUT_COMPARE_C_PIN 4 // unusable PWM
  31. #define ALTSS_USE_TIMER3
  32. #define INPUT_CAPTURE_PIN 10 // receive
  33. #define OUTPUT_COMPARE_A_PIN 9 // transmit
  34. // Teensy++ 2.0
  35. //
  36. #elif defined(__AVR_AT90USB1286__) && defined(CORE_TEENSY)
  37. #define ALTSS_USE_TIMER1
  38. #define INPUT_CAPTURE_PIN 4 // receive
  39. #define OUTPUT_COMPARE_A_PIN 25 // transmit
  40. #define OUTPUT_COMPARE_B_PIN 26 // unusable PWM
  41. #define OUTPUT_COMPARE_C_PIN 27 // unusable PWM
  42. //#define ALTSS_USE_TIMER3
  43. //#define INPUT_CAPTURE_PIN 17 // receive
  44. //#define OUTPUT_COMPARE_A_PIN 16 // transmit
  45. //#define OUTPUT_COMPARE_B_PIN 15 // unusable PWM
  46. //#define OUTPUT_COMPARE_C_PIN 14 // unusable PWM
  47. // Teensy 3.x
  48. //
  49. #elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
  50. #define ALTSS_USE_FTM0
  51. #define INPUT_CAPTURE_PIN 20 // receive (FTM0_CH5)
  52. #define OUTPUT_COMPARE_A_PIN 21 // transmit (FTM0_CH6)
  53. #define OUTPUT_COMPARE_B_PIN 22 // unusable PWM (FTM0_CH0)
  54. #define OUTPUT_COMPARE_C_PIN 23 // PWM usable fixed freq
  55. #define OUTPUT_COMPARE_D_PIN 5 // PWM usable fixed freq
  56. #define OUTPUT_COMPARE_E_PIN 6 // PWM usable fixed freq
  57. #define OUTPUT_COMPARE_F_PIN 9 // PWM usable fixed freq
  58. #define OUTPUT_COMPARE_G_PIN 10 // PWM usable fixed freq
  59. // Wiring-S
  60. //
  61. #elif defined(__AVR_ATmega644P__) && defined(WIRING)
  62. #define ALTSS_USE_TIMER1
  63. #define INPUT_CAPTURE_PIN 6 // receive
  64. #define OUTPUT_COMPARE_A_PIN 5 // transmit
  65. #define OUTPUT_COMPARE_B_PIN 4 // unusable PWM
  66. // Arduino Uno, Duemilanove, LilyPad, etc
  67. //
  68. #elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
  69. #define ALTSS_USE_TIMER1
  70. #define INPUT_CAPTURE_PIN 8 // receive
  71. #define OUTPUT_COMPARE_A_PIN 9 // transmit
  72. #define OUTPUT_COMPARE_B_PIN 10 // unusable PWM
  73. // Arduino Leonardo & Yun (from Cristian Maglie)
  74. //
  75. #elif defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_LEONARDO) || defined(__AVR_ATmega32U4__)
  76. //#define ALTSS_USE_TIMER1
  77. //#define INPUT_CAPTURE_PIN 4 // receive
  78. //#define OUTPUT_COMPARE_A_PIN 9 // transmit
  79. //#define OUTPUT_COMPARE_B_PIN 10 // unusable PWM
  80. //#define OUTPUT_COMPARE_C_PIN 11 // unusable PWM
  81. #define ALTSS_USE_TIMER3
  82. #define INPUT_CAPTURE_PIN 13 // receive
  83. #define OUTPUT_COMPARE_A_PIN 5 // transmit
  84. // Arduino Mega
  85. //
  86. #elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  87. //#define ALTSS_USE_TIMER4
  88. //#define INPUT_CAPTURE_PIN 49 // receive
  89. //#define OUTPUT_COMPARE_A_PIN 6 // transmit
  90. //#define OUTPUT_COMPARE_B_PIN 7 // unusable PWM
  91. //#define OUTPUT_COMPARE_C_PIN 8 // unusable PWM
  92. #define ALTSS_USE_TIMER5
  93. #define INPUT_CAPTURE_PIN 48 // receive
  94. #define OUTPUT_COMPARE_A_PIN 46 // transmit
  95. #define OUTPUT_COMPARE_B_PIN 45 // unusable PWM
  96. #define OUTPUT_COMPARE_C_PIN 44 // unusable PWM
  97. // EnviroDIY Mayfly, Sodaq Mbili
  98. #elif defined ARDUINO_AVR_ENVIRODIY_MAYFLY || defined ARDUINO_AVR_SODAQ_MBILI
  99. #define ALTSS_USE_TIMER1
  100. #define INPUT_CAPTURE_PIN 6 // receive
  101. #define OUTPUT_COMPARE_A_PIN 5 // transmit
  102. #define OUTPUT_COMPARE_B_PIN 4 // unusable PWM
  103. // Sanguino, Mighty 1284
  104. #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega1284__)
  105. #define ALTSS_USE_TIMER1
  106. #define INPUT_CAPTURE_PIN 14 // receive
  107. #define OUTPUT_COMPARE_A_PIN 13 // transmit
  108. #define OUTPUT_COMPARE_B_PIN 12 // unusable PWM
  109. // Unknown board
  110. #else
  111. #error "Please define your board timer and pins"
  112. #endif