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

75 行
2.1KB

  1. #ifndef FREQUENCYTIMER2_IS_IN
  2. #define FREQUENCYTIMER2_IS_IN
  3. /*
  4. FrequencyTimer2.h - A frequency generator and interrupt generator library
  5. Author: Jim Studt, jim@federated.com
  6. Copyright (c) 2007 David A. Mellis. All right reserved.
  7. http://www.arduino.cc/playground/Code/FrequencyTimer2
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Lesser General Public
  10. License as published by the Free Software Foundation; either
  11. version 2.1 of the License, or (at your option) any later version.
  12. This library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Lesser General Public License for more details.
  16. You should have received a copy of the GNU Lesser General Public
  17. License along with this library; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #if ARDUINO >= 100
  21. #include "Arduino.h"
  22. #else
  23. #include "WProgram.h"
  24. #endif
  25. // Arduino Mega
  26. #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  27. #define FREQUENCYTIMER2_PIN 10
  28. // Teensy++
  29. #elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
  30. #define FREQUENCYTIMER2_PIN 24
  31. // Teensy 3.x
  32. #elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
  33. #define FREQUENCYTIMER2_PIN 5
  34. // Teensy LC
  35. #elif defined(__MKL26Z64__)
  36. #error "Sorry, FrequencyTimer2 does not work on Teensy LC"
  37. // Sanguino
  38. #elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
  39. #define FREQUENCYTIMER2_PIN 15
  40. // Arduino Uno, Duemilanove, Diecimila, etc
  41. #else
  42. #define FREQUENCYTIMER2_PIN 11
  43. #endif
  44. class FrequencyTimer2
  45. {
  46. private:
  47. static uint8_t enabled;
  48. public:
  49. static void (*onOverflow)(); // not really public, but I can't work out the 'friend' for the SIGNAL
  50. public:
  51. static void setPeriod(unsigned long);
  52. static unsigned long getPeriod();
  53. static void setOnOverflow( void (*)() );
  54. static void enable();
  55. static void disable();
  56. };
  57. #endif