PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
6.1KB

  1. /***************************************
  2. * REDUCED_CPU_BLOCK allows you to run
  3. * code at 2 MHz (VLPR). See micro_lp and
  4. * delay_lp to see how to convert core
  5. * functionality at F_CPU to work at 2 MHz.
  6. Supported Micros: T-LC/3.x
  7. ****************************************/
  8. #include <Snooze.h>
  9. #include "delay.h"
  10. // REDUCED_CPU_BLOCK needs a SnoozeBlock passed to it
  11. // so we pass a dummy SnoozeBlock with no Drivers installed.
  12. SnoozeBlock dummyConfig;
  13. void setup() {
  14. pinMode(LED_BUILTIN, OUTPUT);
  15. }
  16. void loop() {
  17. SOS(); // Blink sos at F_CPU
  18. REDUCED_CPU_BLOCK(dummyConfig) {
  19. /*
  20. * code inside this macro
  21. * will run at 2 MHz cpu.
  22. * code outside will run
  23. * at whatever speed you
  24. * compiled at.
  25. */
  26. SOS_LP();// Blink sos at 2 MHz
  27. }
  28. }
  29. // SOS from http://www.thejamesjones.com/blog/make-your-arduino-blink-sos
  30. void SOS() {
  31. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  32. delay(0250); // wait for a second
  33. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  34. delay(0250); // wait for a second
  35. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  36. delay(0250); // wait for a second
  37. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  38. delay(0250); // wait for a second
  39. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  40. delay(0250); // wait for a second
  41. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  42. delay(0600); // wait for a second
  43. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  44. delay(1000); // wait for a second
  45. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  46. delay(0250); // wait for a second
  47. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  48. delay(1000); // wait for a second
  49. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  50. delay(0250); // wait for a second
  51. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  52. delay(1000); // wait for a second
  53. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  54. delay(0250); // wait for a second
  55. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  56. delay(0250); // wait for a second
  57. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  58. delay(0250); // wait for a second
  59. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  60. delay(0250); // wait for a second
  61. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  62. delay(0250); // wait for a second
  63. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  64. delay(0250); // wait for a second
  65. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  66. delay(1000); // wait for a second
  67. }
  68. void SOS_LP() {
  69. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  70. delay_lp(0250); // wait for a second
  71. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  72. delay_lp(0250); // wait for a second
  73. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  74. delay_lp(0250); // wait for a second
  75. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  76. delay_lp(0250); // wait for a second
  77. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  78. delay_lp(0250); // wait for a second
  79. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  80. delay_lp(0600); // wait for a second
  81. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  82. delay_lp(1000); // wait for a second
  83. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  84. delay_lp(0250); // wait for a second
  85. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  86. delay_lp(1000); // wait for a second
  87. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  88. delay_lp(0250); // wait for a second
  89. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  90. delay_lp(1000); // wait for a second
  91. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  92. delay_lp(0250); // wait for a second
  93. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  94. delay_lp(0250); // wait for a second
  95. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  96. delay_lp(0250); // wait for a second
  97. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  98. delay_lp(0250); // wait for a second
  99. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  100. delay_lp(0250); // wait for a second
  101. digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
  102. delay_lp(0250); // wait for a second
  103. digitalWrite(LED_BUILTIN, LOW); // turn the LED_BUILTIN off by making the voltage LOW
  104. delay_lp(1000); // wait for a second
  105. }