From 7487d1c486c8ffbd4079f0308742d9a27911c78c Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Sat, 3 Apr 2021 02:19:12 -0400 Subject: [PATCH] v1.4.0 ### Major Releases v1.4.0 1. Add support to **Generic or Sparkfun AVR ATmega_32U4** such as **AVR_MAKEYMAKEY, AVR_PROMICRO, etc.** 2. Add support to **Generic or Sparkfun AVR ATmega_328(P)** such as **ARDUINO_REDBOT, ARDUINO_AVR_DIGITAL_SANDBOX, etc.** 3. Add support to **Generic or Sparkfun AVR ATmega128RFA1** such as **ATMEGA128RFA1_DEV_BOARD, etc.** 4. Add support to **Adafruit AVR ATMEGA_32U4** such as **AVR_FLORA8, AVR_FEATHER32U4, etc.** 5. Add support to **Adafruit AVR ATMEGA_328(P)** such as **AVR_FEATHER328P, AVR_METRO, etc.** 6. Add support to **AVR ATMEGA_16U4, ATMEGA_32U4** such as **Leonardo, YUN, ESPLORA, etc.** 7. Add support to **Sparkfun SAMD21 boards** such as **SparkFun_RedBoard_Turbo, SparkFun_Qwiic_Micro, etc.** 8. Add support to **Sparkfun SAMD51 boards** such as **SparkFun_SAMD51_Thing_Plus, SparkFun_SAMD51_MicroMod, etc.** 9. Update examples --- CONTRIBUTING.md | 2 +- README.md | 122 +++++++++++++++----- library.json | 4 +- library.properties | 2 +- src/AVRTimerInterrupt_Generic.h | 58 +++++++++- src/ESP32TimerInterrupt_Generic.h | 3 +- src/ESP8266TimerInterrupt_Generic.h | 3 +- src/ISR_Timer-Impl_Generic.h | 3 +- src/ISR_Timer_Generic.h | 5 +- src/NRF52TimerInterrupt_Generic.h | 3 +- src/NRF52_MBED_TimerInterrupt_Generic.h | 3 +- src/SAMDTimerInterrupt_Generic.h | 34 +++++- src/SAMDUETimerInterrupt_Generic.h | 3 +- src/STM32TimerInterrupt_Generic.h | 3 +- src/TeensyTimerInterrupt_Generic.h | 3 +- src/TimerInterrupt_Generic.h | 120 ++++++++++++++++--- src/TimerInterrupt_Generic_Debug.h | 19 +-- src_cpp/AVRTimerInterrupt_Generic.h | 58 +++++++++- src_cpp/ESP32TimerInterrupt_Generic.h | 5 +- src_cpp/ESP8266TimerInterrupt_Generic.h | 5 +- src_cpp/ISR_Timer_Generic.cpp | 3 +- src_cpp/ISR_Timer_Generic.h | 5 +- src_cpp/NRF52TimerInterrupt_Generic.h | 5 +- src_cpp/NRF52_MBED_TimerInterrupt_Generic.h | 5 +- src_cpp/SAMDTimerInterrupt_Generic.h | 34 +++++- src_cpp/SAMDUETimerInterrupt_Generic.h | 5 +- src_cpp/STM32TimerInterrupt_Generic.h | 5 +- src_cpp/TeensyTimerInterrupt_Generic.h | 5 +- src_cpp/TimerInterrupt_Generic.h | 120 ++++++++++++++++--- src_cpp/TimerInterrupt_Generic_Debug.h | 19 +-- src_h/AVRTimerInterrupt_Generic.h | 58 +++++++++- src_h/ESP32TimerInterrupt_Generic.h | 5 +- src_h/ESP8266TimerInterrupt_Generic.h | 5 +- src_h/ISR_Timer-Impl_Generic.h | 3 +- src_h/ISR_Timer_Generic.h | 5 +- src_h/NRF52TimerInterrupt_Generic.h | 5 +- src_h/NRF52_MBED_TimerInterrupt_Generic.h | 5 +- src_h/SAMDTimerInterrupt_Generic.h | 34 +++++- src_h/SAMDUETimerInterrupt_Generic.h | 5 +- src_h/STM32TimerInterrupt_Generic.h | 5 +- src_h/TeensyTimerInterrupt_Generic.h | 5 +- src_h/TimerInterrupt_Generic.h | 120 ++++++++++++++++--- src_h/TimerInterrupt_Generic_Debug.h | 19 +-- 43 files changed, 772 insertions(+), 166 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b4a57450..33b65eab 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,7 +29,7 @@ Please ensure to specify the following: Arduino IDE version: 1.8.13 Arduino SAMDUE Core Version 1.6.12 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.4.0-51-generic #56-Ubuntu SMP Mon Oct 5 14:28:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.4.0-70-generic #78-Ubuntu SMP Fri Mar 19 13:29:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Context: I encountered a crash while trying to use the Timer Interrupt. diff --git a/README.md b/README.md index a6383c76..a8305316 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ * [Currently Supported Boards](#currently-supported-boards) * [Important Notes about ISR](#important-notes-about-isr) * [Changelog](#changelog) + * [Major Releases v1.4.0](#major-releases-v140) * [Releases v1.3.2](#releases-v132) * [Releases v1.3.1](#releases-v131) * [Releases v1.3.0](#releases-v130) @@ -180,15 +181,23 @@ For example, Teensy 4.x, with **super-high clock frequency of 600MHz and Timer1 For Teensy 4.x, this library will be expanded to use other available hardware timers, such as **FTM, GPT, QUAD, PIT**, in addition to current **Timer1 and Timer3**. +--- + #### Currently Supported Boards - **ESP8266** + - **ESP32** + - **AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox etc.**. + - **Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)**. - **Adafruit SAM21 (Itsy-Bitsy M0, Metro M0, Feather M0, Gemma M0, etc.)**. - **Adafruit SAM51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.)**. - **Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)** + - **Sparkfun SAMD21 boards** such as **SparkFun_RedBoard_Turbo, SparkFun_Qwiic_Micro, etc.** + - **Sparkfun SAMD51 boards** such as **SparkFun_SAMD51_Thing_Plus, SparkFun_SAMD51_MicroMod, etc.** + - **STM32 (Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32F1, STM32F3, STM32F4, STM32H7, STM32L0, etc.)**. - **STM32F/L/H/G/WB/MP1 (Nucleo-64 L053R8,Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32Fx, STM32H7, STM32Lx, STM32Gx, STM32WB, STM32MP1, etc.) having 64K+ Flash program memory.** @@ -198,9 +207,18 @@ For Teensy 4.x, this library will be expanded to use other available hardware ti - **Teensy LC** - **Teensy++ 2.0 and Teensy 2.0** - - **Arduino AVR boards** such as : - - **Arduino Uno / Nano, Mega / Mini / Arduino Ethernet, Fio, BT, LilyPad, Pro, Pro Mini, NG, UNO Wifi, etc.** + - **Arduino, Adafruit, Sparkfun, Generic AVR boards** such as : + - Arduino Uno / Mega / Duemilanove / Diecimila / LilyPad / Mini / Fio / Nano, etc. + - **Arduino ATMega 16U4, 32U4** such as AVR Leonardo, Leonardo ETH, YUN, Esplora, LILYPAD_USB, AVR_ROBOT_CONTROL, AVR_ROBOT_MOTOR, AVR_INDUSTRIAL101, etc. + - **Adafruit ATMega 32U4** such as AVR_FLORA8, AVR_FEATHER32U4, AVR_CIRCUITPLAY, AVR_ITSYBITSY32U4_5V, AVR_ITSYBITSY32U4_3V, AVR_BLUEFRUITMICRO, AVR_ADAFRUIT32U4, etc. + - **Adafruit ATMega 328(P)** such as AVR_METRO, AVR_FEATHER328P, AVR_PROTRINKET5, AVR_PROTRINKET3, AVR_PROTRINKET5FTDI, AVR_PROTRINKET3FTDI, etc. + - **Generic or Sparkfun AVR ATmega_32U4** such as **AVR_MAKEYMAKEY, AVR_PROMICRO, etc.** + - **Generic or Sparkfun AVR ATmega_328(P)** such as **ARDUINO_REDBOT, ARDUINO_AVR_DIGITAL_SANDBOX, etc.** + - **Generic or Sparkfun AVR ATmega128RFA1** such as **ATMEGA128RFA1_DEV_BOARD, etc.** + - **Arduino Nano-33-BLE** + + - **Arduino SAM DUE**. #### Important Notes about ISR @@ -214,6 +232,18 @@ For Teensy 4.x, this library will be expanded to use other available hardware ti ## Changelog +### Major Releases v1.4.0 + +1. Add support to **Generic or Sparkfun AVR ATmega_32U4** such as **AVR_MAKEYMAKEY, AVR_PROMICRO, etc.** +2. Add support to **Generic or Sparkfun AVR ATmega_328(P)** such as **ARDUINO_REDBOT, ARDUINO_AVR_DIGITAL_SANDBOX, etc.** +3. Add support to **Generic or Sparkfun AVR ATmega128RFA1** such as **ATMEGA128RFA1_DEV_BOARD, etc.** +4. Add support to **Adafruit AVR ATMEGA_32U4** such as **AVR_FLORA8, AVR_FEATHER32U4, etc.** +5. Add support to **Adafruit AVR ATMEGA_328(P)** such as **AVR_FEATHER328P, AVR_METRO, etc.** +6. Add support to **AVR ATMEGA_16U4, ATMEGA_32U4** such as **Leonardo, YUN, ESPLORA, etc.** +7. Add support to **Sparkfun SAMD21 boards** such as **SparkFun_RedBoard_Turbo, SparkFun_Qwiic_Micro, etc.** +8. Add support to **Sparkfun SAMD51 boards** such as **SparkFun_SAMD51_Thing_Plus, SparkFun_SAMD51_MicroMod, etc.** +9. Update examples + ### Releases v1.3.2 1. Clean-up all compiler warnings possible. @@ -248,32 +278,35 @@ For Teensy 4.x, this library will be expanded to use other available hardware ti ## Prerequisites 1. [`Arduino IDE 1.8.13+` for Arduino](https://www.arduino.cc/en/Main/Software) - 2. [`ESP32 Core 1.0.5+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/) + 2. [`ESP32 Core 1.0.6+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/) 3. [`ESP8266 Core 2.7.4+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/). To use ESP8266 core 2.7.1+ for LittleFS. 4. [`Arduino AVR core 1.8.3+`](https://github.com/arduino/ArduinoCore-avr) for Arduino (Use Arduino Board Manager) for AVR boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-avr.svg)](https://github.com/arduino/ArduinoCore-avr/releases/latest) - 5. [`Teensy core v1.53+`](https://www.pjrc.com/teensy/td_download.html) for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards. **Ready** from v1.0.0. - 6. [`Arduino SAM DUE core v1.6.12+`](https://github.com/arduino/ArduinoCore-sam) for SAM DUE ARM Cortex-M3 boards. - 7. [`Arduino SAMD core 1.8.11+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest) - 8. [`Adafruit SAMD core 1.6.5+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest) - 9. [`Seeeduino SAMD core 1.8.1+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/) -10. [`Adafruit nRF52 v0.21.0+`](https://github.com/adafruit/Adafruit_nRF52_Arduino) for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, **NINA_B302_ublox**, etc. [![GitHub release](https://img.shields.io/github/release/adafruit/Adafruit_nRF52_Arduino.svg)](https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/latest) -11. [`Arduino Core for STM32 v1.9.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32F/L/H/G/WB/MP1 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest) -12. [`Blynk library 0.6.1+`](https://github.com/blynkkk/blynk-library/releases). [![Latest release](https://img.shields.io/github/release/blynkkk/blynk-library.svg)](https://github.com/blynkkk/blynk-library/releases/latest/) to use with certain example. -13. For built-in LAN8742A Ethernet: + 5. [`Adafruit AVR core 1.4.13+`](https://github.com/adafruit/Adafruit_Arduino_Boards) for Adafruit AVR boards. Use Arduino Board Manager to install. + 6. [`Sparkfun AVR core 1.1.13+`](https://github.com/sparkfun/Arduino_Boards) for Sparkfun AVR boards. Use Arduino Board Manager to install. + 7. [`Teensy core v1.53+`](https://www.pjrc.com/teensy/td_download.html) for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards. + 8. [`Arduino SAM DUE core v1.6.12+`](https://github.com/arduino/ArduinoCore-sam) for SAM DUE ARM Cortex-M3 boards. + 9. [`Arduino SAMD core 1.8.11+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest) +10. [`Adafruit SAMD core 1.6.5+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest) +11. [`Seeeduino SAMD core 1.8.1+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/) +12. [`Sparkfun SAMD core 1.8.1+`](https://github.com/sparkfun/Arduino_Boards) for SAMD21/SAMD51 boards (SparkFun_RedBoard_Turbo, SparkFun_SAMD51_Thing_Plus, etc.). +13. [`Adafruit nRF52 v0.21.0+`](https://github.com/adafruit/Adafruit_nRF52_Arduino) for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, **NINA_B302_ublox**, etc. [![GitHub release](https://img.shields.io/github/release/adafruit/Adafruit_nRF52_Arduino.svg)](https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/latest) +14. [`Arduino Core for STM32 v1.9.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32F/L/H/G/WB/MP1 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest) +15. [`Blynk library 0.6.1+`](https://github.com/blynkkk/blynk-library/releases). [![Latest release](https://img.shields.io/github/release/blynkkk/blynk-library.svg)](https://github.com/blynkkk/blynk-library/releases/latest/) to use with certain example. +16. For built-in LAN8742A Ethernet: - [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for built-in LAN8742A Ethernet on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/STM32Ethernet.svg)](https://github.com/stm32duino/STM32Ethernet/releases/latest) - [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP) for built-in LAN8742A Ethernet on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/LwIP.svg)](https://github.com/stm32duino/LwIP/releases/latest) -14. For W5x00 Ethernet: +17. For W5x00 Ethernet: - [`Ethernet library v2.0.0+`](https://github.com/arduino-libraries/Ethernet) for W5100, W5200 and W5500. [![GitHub release](https://img.shields.io/github/release/arduino-libraries/Ethernet.svg)](https://github.com/arduino-libraries/Ethernet/releases/latest) - [`EthernetLarge library v2.0.0+`](https://github.com/OPEnSLab-OSU/EthernetLarge) for W5100, W5200 and W5500. - [`Ethernet2 library v1.0.4+`](https://github.com/khoih-prog/Ethernet2) for W5500. [![GitHub release](https://img.shields.io/github/release/adafruit/Ethernet2.svg)](https://github.com/adafruit/Ethernet2/releases/latest) - [`Ethernet3 library v1.5.5+`](https://github.com/sstaub/Ethernet3) for W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip. [![GitHub release](https://img.shields.io/github/release/sstaub/Ethernet3.svg)](https://github.com/sstaub/Ethernet3/releases/latest) -15. For ENC28J60 Ethernet: +18. For ENC28J60 Ethernet: - [`EthernetENC library v2.0.0+`](https://github.com/jandrassy/EthernetENC) for ENC28J60. [![GitHub release](https://img.shields.io/github/release/jandrassy/EthernetENC.svg)](https://github.com/jandrassy/EthernetENC/releases/latest). **New and Better** - [`UIPEthernet library v2.0.9+`](https://github.com/UIPEthernet/UIPEthernet) for ENC28J60. [![GitHub release](https://img.shields.io/github/release/UIPEthernet/UIPEthernet.svg)](https://github.com/UIPEthernet/UIPEthernet/releases/latest) -16. [`WiFiNINA_Generic library v1.8.2+`](https://github.com/khoih-prog/WiFiNINA_Generic) to use WiFiNINA modules/shields. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiNINA_Generic.svg?)](https://www.ardu-badge.com/WiFiNINA_Generic) if using WiFiNINA for boards such as Nano 33 IoT, nRF52, Teensy, etc. -17. [`Blynk_WiFiNINA_WM library 1.0.4+`](hhttps://github.com/khoih-prog/Blynk_WiFiNINA_WM) to use with Blynk-WiFiNINA-related example. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/Blynk_WiFiNINA_WM.svg?)](https://www.ardu-badge.com/Blynk_WiFiNINA_WM) -18. To use with certain example - - [`SimpleTimer library`](https://github.com/schinken/SimpleTimer) for [ISR_16_Timers_Array examples](examples/NRF52/ISR_16_Timers_Array). +19. [`WiFiNINA_Generic library v1.8.5+`](https://github.com/khoih-prog/WiFiNINA_Generic) to use WiFiNINA modules/shields. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiNINA_Generic.svg?)](https://www.ardu-badge.com/WiFiNINA_Generic) if using WiFiNINA for boards such as Nano 33 IoT, nRF52, Teensy, etc. +20. [`Blynk_WiFiNINA_WM library 1.0.4+`](hhttps://github.com/khoih-prog/Blynk_WiFiNINA_WM) to use with Blynk-WiFiNINA-related example. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/Blynk_WiFiNINA_WM.svg?)](https://www.ardu-badge.com/Blynk_WiFiNINA_WM) +21. To use with certain example + - [`SimpleTimer library`](https://github.com/jfturcot/SimpleTimer) for [ISR_16_Timers_Array examples](examples/NRF52/ISR_16_Timers_Array). --- --- @@ -1661,7 +1694,7 @@ Only **Timer1 and Timer2** are supported for Nano, UNO, etc. boards possessing 3 #include "ISR_Timer_Generic.h" -#include // https://github.com/schinken/SimpleTimer +#include // https://github.com/jfturcot/SimpleTimer #ifndef LED_BUILTIN #define LED_BUILTIN 13 @@ -1984,7 +2017,7 @@ While software timer, **programmed for 2s, is activated after 10.917s !!!**. The ``` Starting ISR_Timer_Complex_Ethernet on SAM DUE -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 Using Timer(0) = TC0, channel = 0, IRQ = TC0_IRQn Timer(0), us = 50000.00 ITimer attached to Timer(0) @@ -2076,7 +2109,7 @@ While software timer, **programmed for 2s, is activated after 4.867s !!!**. Then ``` Starting ISR_Timer_Complex_Ethernet on NRF52840_FEATHER -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 NRF52TimerInterrupt: F_CPU (MHz) = 64, Timer = NRF_TIMER2 NRF52TimerInterrupt: _fre = 1000000.00, _count = 50000 Starting ITimer OK, millis() = 1419 @@ -2170,7 +2203,7 @@ In this example, 16 independent ISR Timers are used, yet utilized just one Hardw ``` Starting ISR_16_Timers_Array on SAMD_NANO_33_IOT -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 CPU Frequency = 48 MHz F_CPU (MHz) = 48, TIMER_HZ = 48 TC_Timer::startTimer _Timer = 0x42002c00, TC3 = 0x42002c00 @@ -2294,7 +2327,7 @@ The following is the sample terminal output when running example [**TimerInterru ``` Starting TimerInterruptTest on Teensy 4.0/4.1 -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 CPU Frequency = 600 MHz TEENSY_TIMER_1, F_BUS_ACTUAL (MHz) = 150, request interval = 30000, actual interval (us) = 29999 Prescale = 7, _timerCount = 17578 @@ -2340,7 +2373,7 @@ While software timer, **programmed for 2s, is activated after 3.435s !!!** ``` Starting Argument_None on ESP32_DEV -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 CPU Frequency = 240 MHz ESP32TimerInterrupt: _timerNo = 1, _fre = 1000000.00, _count = 0 - 50000 Starting ITimer OK, millis() = 2140 @@ -2407,7 +2440,7 @@ While software timer, **programmed for 2s, is activated after 4.258s !!!** ``` Starting ISR_Timer_Complex on ESP8266_NODEMCU -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 CPU Frequency = 160 MHz ESP8266TimerInterrupt: _fre = 312500.00, _count = 15625 Starting ITimer OK, millis() = 64 @@ -2457,7 +2490,7 @@ While software timer, **programmed for 2s, is activated after 9.782s !!!**. Then ``` Starting ISR_Timer_Complex on NUCLEO_F767ZI -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 CPU Frequency = 216 MHz STM32TimerInterrupt: Timer Input Freq (Hz) = 216000000, _fre = 1000000.00, _count = 50000 Starting ITimer OK, millis() = 6 @@ -2518,7 +2551,7 @@ The following is the sample terminal output when running example [**TimerInterru ``` Starting TimerInterruptTest on NUCLEO_F767ZI -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 CPU Frequency = 216 MHz STM32TimerInterrupt: Timer Input Freq (Hz) = 216000000, _fre = 1000000.00, _count = 1000000 Starting ITimer0 OK, millis() = 108 @@ -2574,7 +2607,7 @@ While software timer, **programmed for 2s, is activated after more than 3.000s i ``` Starting ISR_16_Timers_Array_Complex on Nano 33 BLE -TimerInterrupt_Generic v1.3.2 +TimerInterrupt_Generic v1.4.0 NRF52_MBED_TimerInterrupt: Timer = NRF_TIMER3 NRF52_MBED_TimerInterrupt: _fre = 1000000.00, _count = 10000 Starting ITimer OK, millis() = 714 @@ -3072,6 +3105,18 @@ Sometimes, the library will only work if you update the board core to the latest ## Releases +### Major Releases v1.4.0 + +1. Add support to **Generic or Sparkfun AVR ATmega_32U4** such as **AVR_MAKEYMAKEY, AVR_PROMICRO, etc.** +2. Add support to **Generic or Sparkfun AVR ATmega_328(P)** such as **ARDUINO_REDBOT, ARDUINO_AVR_DIGITAL_SANDBOX, etc.** +3. Add support to **Generic or Sparkfun AVR ATmega128RFA1** such as **ATMEGA128RFA1_DEV_BOARD, etc.** +4. Add support to **Adafruit AVR ATMEGA_32U4** such as **AVR_FLORA8, AVR_FEATHER32U4, etc.** +5. Add support to **Adafruit AVR ATMEGA_328(P)** such as **AVR_FEATHER328P, AVR_METRO, etc.** +6. Add support to **AVR ATMEGA_16U4, ATMEGA_32U4** such as **Leonardo, YUN, ESPLORA, etc.** +7. Add support to **Sparkfun SAMD21 boards** such as **SparkFun_RedBoard_Turbo, SparkFun_Qwiic_Micro, etc.** +8. Add support to **Sparkfun SAMD51 boards** such as **SparkFun_SAMD51_Thing_Plus, SparkFun_SAMD51_MicroMod, etc.** +9. Update examples + ### Releases v1.3.2 1. Clean-up all compiler warnings possible. @@ -3101,15 +3146,21 @@ Sometimes, the library will only work if you update the board core to the latest --- -### Currently Supported Boards +#### Currently Supported Boards - **ESP8266** + - **ESP32** + - **AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox etc.**. + - **Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)**. - **Adafruit SAM21 (Itsy-Bitsy M0, Metro M0, Feather M0, Gemma M0, etc.)**. - **Adafruit SAM51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.)**. - **Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)** + - **Sparkfun SAMD21 boards** such as **SparkFun_RedBoard_Turbo, SparkFun_Qwiic_Micro, etc.** + - **Sparkfun SAMD51 boards** such as **SparkFun_SAMD51_Thing_Plus, SparkFun_SAMD51_MicroMod, etc.** + - **STM32 (Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32F1, STM32F3, STM32F4, STM32H7, STM32L0, etc.)**. - **STM32F/L/H/G/WB/MP1 (Nucleo-64 L053R8,Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32Fx, STM32H7, STM32Lx, STM32Gx, STM32WB, STM32MP1, etc.) having 64K+ Flash program memory.** @@ -3119,9 +3170,18 @@ Sometimes, the library will only work if you update the board core to the latest - **Teensy LC** - **Teensy++ 2.0 and Teensy 2.0** - - **Arduino AVR boards** such as : - - **Arduino Uno / Nano, Mega / Mini / Arduino Ethernet, Fio, BT, LilyPad, Pro, Pro Mini, NG, UNO Wifi, etc.** + - **Arduino, Adafruit, Sparkfun, Generic AVR boards** such as : + - Arduino Uno / Mega / Duemilanove / Diecimila / LilyPad / Mini / Fio / Nano, etc. + - **Arduino ATMega 16U4, 32U4** such as AVR Leonardo, Leonardo ETH, YUN, Esplora, LILYPAD_USB, AVR_ROBOT_CONTROL, AVR_ROBOT_MOTOR, AVR_INDUSTRIAL101, etc. + - **Adafruit ATMega 32U4** such as AVR_FLORA8, AVR_FEATHER32U4, AVR_CIRCUITPLAY, AVR_ITSYBITSY32U4_5V, AVR_ITSYBITSY32U4_3V, AVR_BLUEFRUITMICRO, AVR_ADAFRUIT32U4, etc. + - **Adafruit ATMega 328(P)** such as AVR_METRO, AVR_FEATHER328P, AVR_PROTRINKET5, AVR_PROTRINKET3, AVR_PROTRINKET5FTDI, AVR_PROTRINKET3FTDI, etc. + - **Generic or Sparkfun AVR ATmega_32U4** such as **AVR_MAKEYMAKEY, AVR_PROMICRO, etc.** + - **Generic or Sparkfun AVR ATmega_328(P)** such as **ARDUINO_REDBOT, ARDUINO_AVR_DIGITAL_SANDBOX, etc.** + - **Generic or Sparkfun AVR ATmega128RFA1** such as **ATMEGA128RFA1_DEV_BOARD, etc.** + - **Arduino Nano-33-BLE** + + - **Arduino SAM DUE**. --- --- diff --git a/library.json b/library.json index 9e821689..6000823d 100644 --- a/library.json +++ b/library.json @@ -1,7 +1,7 @@ { "name": "TimerInterrupt_Generic", - "version": "1.3.2", - "keywords": "timing,device,control,timer,interrupt,hardware,avr,esp8266,esp32,due,sam-due,samd,nrf52,teensy,stm32,mission-critical,accuracy,precise,non-blocking,isr,isr-based,hardware-timer,mbed,nano-33-ble", + "version": "1.4.0", + "keywords": "timing,device,control,timer,interrupt,hardware,avr,mega, nano, uno, leonardo, yun, yun-mini, esplora, gemma, atmega, feather, adafruit, 16u4, 32u4, atmega328p, atmega128, atmega168, atmega2560, atmega1280, atmega16u4, atmega32u4, atmegang, atmega8,esp8266,esp32,due,sam-due,samd,samd21,samd51,nrf52,teensy,stm32,mission-critical,accuracy,precise,non-blocking,isr,isr-based,hardware-timer,mbed,nano-33-ble,adafruit,sparkfun,arduino,generic", "description": "This library enables you to use Interrupt from Hardware Timers on supported boards such as AVR, ESP8266, ESP32, SAMD, SAM DUE, nRF52, STM32F/L/H/G/WB/MP1, Teensy, Nano-33-BLE, etc. These hardware timers, using interrupt, still work even if other functions are blocking. It now supports 16 ISR-based timers, while consuming only 1 Hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.", "authors": { diff --git a/library.properties b/library.properties index c6f3fd6c..a0f42e93 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=TimerInterrupt_Generic -version=1.3.2 +version=1.4.0 author=Khoi Hoang maintainer=Khoi Hoang sentence=This library enables you to use Interrupt from Hardware Timers on supported Arduino boards such as AVR, ESP8266, ESP32, SAMD, SAM DUE, nRF52, STM32F/L/H/G/WB/MP1, Teensy, Nano-33-BLE, etc. diff --git a/src/AVRTimerInterrupt_Generic.h b/src/AVRTimerInterrupt_Generic.h index efa25a7f..06102e34 100644 --- a/src/AVRTimerInterrupt_Generic.h +++ b/src/AVRTimerInterrupt_Generic.h @@ -26,7 +26,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -35,6 +35,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ @@ -48,7 +49,7 @@ #endif #ifndef TIMER_INTERRUPT_VERSION - #define TIMER_INTERRUPT_VERSION "TimerInterrupt v1.2.0" + #define TIMER_INTERRUPT_VERSION "TimerInterrupt v1.4.1" #endif #include @@ -513,7 +514,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask) | _prescalerIndex; //prescalarbits; @@ -774,7 +779,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask); @@ -819,7 +828,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask) | _prescalerIndex; //prescalarbits; @@ -937,6 +950,47 @@ class TimerInterrupt }; // class TimerInterrupt +////////////////////////////////////////////// + +// To be sure not used Timers are disabled +#if !defined(USE_TIMER_1) + #define USE_TIMER_1 false +#endif + +#if !defined(USE_TIMER_2) + #define USE_TIMER_2 false +#elif ( USE_TIMER_2 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_2 + #define USE_TIMER_2 false + #warning Timer2 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_3) + #define USE_TIMER_3 false +#elif ( USE_TIMER_3 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_3 + #define USE_TIMER_3 false + #warning Timer3 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_4) + #define USE_TIMER_4 false +#elif ( USE_TIMER_4 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_4 + #define USE_TIMER_4 false + #warning Timer4 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_5) + #define USE_TIMER_5 false +#elif ( USE_TIMER_5 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_5 + #define USE_TIMER_5 false + #warning Timer5 is disabled for ATMEGA_32U4 +#endif + +////////////////////////////////////////////// + #if USE_TIMER_1 #ifndef TIMER1_INSTANTIATED // To force pre-instatiate only once diff --git a/src/ESP32TimerInterrupt_Generic.h b/src/ESP32TimerInterrupt_Generic.h index c2d7f0ec..2d1bc728 100644 --- a/src/ESP32TimerInterrupt_Generic.h +++ b/src/ESP32TimerInterrupt_Generic.h @@ -25,7 +25,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src/ESP8266TimerInterrupt_Generic.h b/src/ESP8266TimerInterrupt_Generic.h index a5ca60d6..c7b445e2 100644 --- a/src/ESP8266TimerInterrupt_Generic.h +++ b/src/ESP8266TimerInterrupt_Generic.h @@ -24,7 +24,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -33,6 +33,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src/ISR_Timer-Impl_Generic.h b/src/ISR_Timer-Impl_Generic.h index 9bb82bca..02602a58 100644 --- a/src/ISR_Timer-Impl_Generic.h +++ b/src/ISR_Timer-Impl_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src/ISR_Timer_Generic.h b/src/ISR_Timer_Generic.h index 416c5005..2c741330 100644 --- a/src/ISR_Timer_Generic.h +++ b/src/ISR_Timer_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -36,7 +37,7 @@ #define ISR_TIMER_GENERIC_H #if !defined(TIMER_INTERRUPT_GENERIC_VERSION) - #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.3.2" + #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.4.0" #endif #include diff --git a/src/NRF52TimerInterrupt_Generic.h b/src/NRF52TimerInterrupt_Generic.h index 626af0aa..e8673800 100644 --- a/src/NRF52TimerInterrupt_Generic.h +++ b/src/NRF52TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* nRF52 has 5 Hardware TIMERs: NRF_TIMER0-NRF_TIMER4 diff --git a/src/NRF52_MBED_TimerInterrupt_Generic.h b/src/NRF52_MBED_TimerInterrupt_Generic.h index bc05ab92..0b6fd798 100644 --- a/src/NRF52_MBED_TimerInterrupt_Generic.h +++ b/src/NRF52_MBED_TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Based on BlynkTimer.h Author: Volodymyr Shymanskyy - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* nRF52 has 5 Hardware TIMERs: NRF_TIMER0-NRF_TIMER4 diff --git a/src/SAMDTimerInterrupt_Generic.h b/src/SAMDTimerInterrupt_Generic.h index 43cc7549..af1f9d8b 100644 --- a/src/SAMDTimerInterrupt_Generic.h +++ b/src/SAMDTimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* SAMD21 @@ -61,18 +62,47 @@ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD21G18A__) ) + #define TIMER_INTERRUPT_USING_SAMD21 true + + #if defined(ARDUINO_QWIIC_MICRO) + #define BOARD_NAME "Sparkfun SAMD21_QWIIC_MICRO" + #warning BOARD_NAME == Sparkfun SAMD21_QWIIC_MICRO + #endif + + #if !defined(BOARD_NAME) + #define BOARD_NAME "Unknown SAMD21" + #endif + #warning Using SAMD21 Hardware Timer #elif ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) ) #define TIMER_INTERRUPT_USING_SAMD51 true + + #if defined(ARDUINO_SAMD51_THING_PLUS) + #define BOARD_NAME "Sparkfun SAMD51_THING_PLUS" + #warning BOARD_NAME == Sparkfun SAMD51_THING_PLUS + #elif defined(ARDUINO_SAMD51_MICROMOD) + #define BOARD_NAME "Sparkfun SAMD51_MICROMOD" + #warning BOARD_NAME == Sparkfun SAMD51_MICROMOD + #endif + + #if !defined(BOARD_NAME) + #define BOARD_NAME "Unknown SAMD51" + #endif + #warning Using SAMD51 Hardware Timer #else #error Unknown board #endif +// Specific for SAMD21 SparkFun RedBoard Turbo +#if !defined(Serial) && defined(ARDUINO_SAMD_ZERO) + #define Serial SerialUSB +#endif + #include "Arduino.h" -#define SAMD_TIMER_INTERRUPT_VERSION "SAMDTimerInterrupt v1.2.0" +#define SAMD_TIMER_INTERRUPT_VERSION "SAMDTimerInterrupt v1.3.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src/SAMDUETimerInterrupt_Generic.h b/src/SAMDUETimerInterrupt_Generic.h index d65e764b..854850df 100644 --- a/src/SAMDUETimerInterrupt_Generic.h +++ b/src/SAMDUETimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src/STM32TimerInterrupt_Generic.h b/src/STM32TimerInterrupt_Generic.h index e601e57d..b166a981 100644 --- a/src/STM32TimerInterrupt_Generic.h +++ b/src/STM32TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src/TeensyTimerInterrupt_Generic.h b/src/TeensyTimerInterrupt_Generic.h index dcbfffc8..64c1fb84 100644 --- a/src/TeensyTimerInterrupt_Generic.h +++ b/src/TeensyTimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src/TimerInterrupt_Generic.h b/src/TimerInterrupt_Generic.h index 64e03511..ce0db254 100644 --- a/src/TimerInterrupt_Generic.h +++ b/src/TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD ********************************************************************************************************************************/ #pragma once @@ -36,30 +37,91 @@ #define TIMERINTERRUPT_GENERIC_H #if !defined(TIMER_INTERRUPT_GENERIC_VERSION) - #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.3.2" + #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.4.0" #endif #include "TimerInterrupt_Generic_Debug.h" -#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) +/////////////////////////////// AVR /////////////////////////////// +#if ( defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \ + defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \ + defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \ + defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \ + defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || \ + defined(ARDUINO_AVR_DUEMILANOVE) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Arduino AVR" + +#elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ + defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) #define TIMER_INTERRUPT_USING_AVR true - #include "AVRTimerInterrupt_Generic.h" + #define BOARD_TYPE "Adafruit AVR ATMega328(P)" + #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + +#elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ + defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ + defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Arduino AVR ATMega32U4" + #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. Only Timer1 is available + +#elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ + defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Adafruit AVR ATMega32U4" + #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc.. Only Timer1 is available + +#elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ + defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" + #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. Only Timer1 is available + +#elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" + #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. + +#elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" + #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. + +#elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) + #error These AVR boards are not supported! Please check your Tools->Board setting. + +/////////////////////////////// ESP8266 /////////////////////////////// #elif ( defined(ESP8266) || ESP8266 ) #define TIMER_INTERRUPT_USING_ESP8266 true - #include "ESP8266TimerInterrupt_Generic.h" + +/////////////////////////////// ESP32 /////////////////////////////// #elif ( defined(ESP32) || ESP32 ) - #define TIMER_INTERRUPT_USING_ESP32 true - #include "ESP32TimerInterrupt_Generic.h" + #define TIMER_INTERRUPT_USING_ESP32 true + +/////////////////////////////// Nano-33-BLE /////////////////////////////// #elif ( ARDUINO_ARCH_NRF52840 && TARGET_NAME == ARDUINO_NANO33BLE ) #warning Using ARDUINO_NANO33BLE - #define TIMER_INTERRUPT_USING_NANO33BLE true - #include "NRF52_MBED_TimerInterrupt_Generic.h" + #define TIMER_INTERRUPT_USING_NANO33BLE true + +/////////////////////////////// SAMD /////////////////////////////// #elif ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ @@ -68,34 +130,35 @@ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) #define TIMER_INTERRUPT_USING_SAMD true - #include "SAMDTimerInterrupt_Generic.h" +/////////////////////////////// NRF52 /////////////////////////////// #elif ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) #define TIMER_INTERRUPT_USING_NRF52 true - #include "NRF52TimerInterrupt_Generic.h" - + +/////////////////////////////// SAM DUE /////////////////////////////// + #elif ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) #define TIMER_INTERRUPT_USING_SAMDUE true - #include "SAMDUETimerInterrupt_Generic.h" - +/////////////////////////////// TEENSY /////////////////////////////// + #elif ( defined(CORE_TEENSY) || defined(__IMXRT1062__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) || \ defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK20DX128__) ) #define TIMER_INTERRUPT_USING_TEENSY true - #include "TeensyTimerInterrupt_Generic.h" + +/////////////////////////////// STM32 /////////////////////////////// #elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) #define TIMER_INTERRUPT_USING_STM32 true - #include "STM32TimerInterrupt_Generic.h" #else @@ -103,4 +166,29 @@ #endif +//////////////////////////////////////////////////// + +#if TIMER_INTERRUPT_USING_AVR + #include "AVRTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_ESP8266 + #include "ESP8266TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_ESP32 + #include "ESP32TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_NANO33BLE + #include "NRF52_MBED_TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_SAMD + #include "SAMDTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_NRF52 + #include "NRF52TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_SAMDUE + #include "SAMDUETimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_TEENSY + #include "TeensyTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_STM32 + #include "STM32TimerInterrupt_Generic.h" +#endif + +//////////////////////////////////////////////////// + + #endif // TIMERINTERRUPT_GENERIC_H diff --git a/src/TimerInterrupt_Generic_Debug.h b/src/TimerInterrupt_Generic_Debug.h index b5752c23..3b383c05 100644 --- a/src/TimerInterrupt_Generic_Debug.h +++ b/src/TimerInterrupt_Generic_Debug.h @@ -19,15 +19,16 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 - - Version Modified By Date Comments - ------- ----------- ---------- ----------- - 1.1.0 K Hoang 10/11/2020 Initial Super-Library coding to merge all TimerInterrupt Libraries - 1.2.0 K Hoang 12/11/2020 Add STM32_TimerInterrupt Library - 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. - 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. - 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + Version: 1.4.0 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.1.0 K Hoang 10/11/2020 Initial Super-Library coding to merge all TimerInterrupt Libraries + 1.2.0 K Hoang 12/11/2020 Add STM32_TimerInterrupt Library + 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. + 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. + 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src_cpp/AVRTimerInterrupt_Generic.h b/src_cpp/AVRTimerInterrupt_Generic.h index c42df775..06102e34 100644 --- a/src_cpp/AVRTimerInterrupt_Generic.h +++ b/src_cpp/AVRTimerInterrupt_Generic.h @@ -26,7 +26,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -35,6 +35,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ @@ -48,7 +49,7 @@ #endif #ifndef TIMER_INTERRUPT_VERSION - #define TIMER_INTERRUPT_VERSION "TimerInterrupt v1.1.2" + #define TIMER_INTERRUPT_VERSION "TimerInterrupt v1.4.1" #endif #include @@ -513,7 +514,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask) | _prescalerIndex; //prescalarbits; @@ -774,7 +779,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask); @@ -819,7 +828,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask) | _prescalerIndex; //prescalarbits; @@ -937,6 +950,47 @@ class TimerInterrupt }; // class TimerInterrupt +////////////////////////////////////////////// + +// To be sure not used Timers are disabled +#if !defined(USE_TIMER_1) + #define USE_TIMER_1 false +#endif + +#if !defined(USE_TIMER_2) + #define USE_TIMER_2 false +#elif ( USE_TIMER_2 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_2 + #define USE_TIMER_2 false + #warning Timer2 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_3) + #define USE_TIMER_3 false +#elif ( USE_TIMER_3 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_3 + #define USE_TIMER_3 false + #warning Timer3 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_4) + #define USE_TIMER_4 false +#elif ( USE_TIMER_4 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_4 + #define USE_TIMER_4 false + #warning Timer4 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_5) + #define USE_TIMER_5 false +#elif ( USE_TIMER_5 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_5 + #define USE_TIMER_5 false + #warning Timer5 is disabled for ATMEGA_32U4 +#endif + +////////////////////////////////////////////// + #if USE_TIMER_1 #ifndef TIMER1_INSTANTIATED // To force pre-instatiate only once diff --git a/src_cpp/ESP32TimerInterrupt_Generic.h b/src_cpp/ESP32TimerInterrupt_Generic.h index 47b17ff0..2d1bc728 100644 --- a/src_cpp/ESP32TimerInterrupt_Generic.h +++ b/src_cpp/ESP32TimerInterrupt_Generic.h @@ -25,7 +25,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -45,7 +46,7 @@ #error This code is designed to run on ESP32 platform, not Arduino nor ESP8266! Please check your Tools->Board setting. #endif -#define ESP32_TIMER_INTERRUPT_VERSION "ESP32TimerInterrupt v1.1.1" +#define ESP32_TIMER_INTERRUPT_VERSION "ESP32TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/ESP8266TimerInterrupt_Generic.h b/src_cpp/ESP8266TimerInterrupt_Generic.h index a93ada52..c7b445e2 100644 --- a/src_cpp/ESP8266TimerInterrupt_Generic.h +++ b/src_cpp/ESP8266TimerInterrupt_Generic.h @@ -24,7 +24,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -33,6 +33,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -44,7 +45,7 @@ #error This code is designed to run on ESP8266 and ESP8266-based boards! Please check your Tools->Board setting. #endif -#define ESP8266_TIMER_INTERRUPT_VERSION "ESP8266TimerInterrupt v1.1.1" +#define ESP8266_TIMER_INTERRUPT_VERSION "ESP8266TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/ISR_Timer_Generic.cpp b/src_cpp/ISR_Timer_Generic.cpp index 1d850ab1..b52b4a00 100644 --- a/src_cpp/ISR_Timer_Generic.cpp +++ b/src_cpp/ISR_Timer_Generic.cpp @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #include "ISR_Timer_Generic.h" diff --git a/src_cpp/ISR_Timer_Generic.h b/src_cpp/ISR_Timer_Generic.h index 179e835d..e064bd1a 100644 --- a/src_cpp/ISR_Timer_Generic.h +++ b/src_cpp/ISR_Timer_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -36,7 +37,7 @@ #define ISR_TIMER_GENERIC_H #if !defined(TIMER_INTERRUPT_GENERIC_VERSION) - #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.3.2" + #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.4.0" #endif #include diff --git a/src_cpp/NRF52TimerInterrupt_Generic.h b/src_cpp/NRF52TimerInterrupt_Generic.h index be7a5e49..e8673800 100644 --- a/src_cpp/NRF52TimerInterrupt_Generic.h +++ b/src_cpp/NRF52TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* nRF52 has 5 Hardware TIMERs: NRF_TIMER0-NRF_TIMER4 @@ -82,7 +83,7 @@ #include #include "nrf_timer.h" -#define NRF52_TIMER_INTERRUPT_VERSION "NRF52TimerInterrupt v1.1.1" +#define NRF52_TIMER_INTERRUPT_VERSION "NRF52TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/NRF52_MBED_TimerInterrupt_Generic.h b/src_cpp/NRF52_MBED_TimerInterrupt_Generic.h index 389b69ac..0b6fd798 100644 --- a/src_cpp/NRF52_MBED_TimerInterrupt_Generic.h +++ b/src_cpp/NRF52_MBED_TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Based on BlynkTimer.h Author: Volodymyr Shymanskyy - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* nRF52 has 5 Hardware TIMERs: NRF_TIMER0-NRF_TIMER4 @@ -82,7 +83,7 @@ // It's better to replace with the new one later. But be careful not to chain break anything #include "hal/nrf_timer.h" -#define NRF52_MBED_TIMER_INTERRUPT_VERSION "NRF52_MBED_TimerInterrupt v1.1.1" +#define NRF52_MBED_TIMER_INTERRUPT_VERSION "NRF52_MBED_TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/SAMDTimerInterrupt_Generic.h b/src_cpp/SAMDTimerInterrupt_Generic.h index 870c7838..af1f9d8b 100644 --- a/src_cpp/SAMDTimerInterrupt_Generic.h +++ b/src_cpp/SAMDTimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* SAMD21 @@ -61,18 +62,47 @@ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD21G18A__) ) + #define TIMER_INTERRUPT_USING_SAMD21 true + + #if defined(ARDUINO_QWIIC_MICRO) + #define BOARD_NAME "Sparkfun SAMD21_QWIIC_MICRO" + #warning BOARD_NAME == Sparkfun SAMD21_QWIIC_MICRO + #endif + + #if !defined(BOARD_NAME) + #define BOARD_NAME "Unknown SAMD21" + #endif + #warning Using SAMD21 Hardware Timer #elif ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) ) #define TIMER_INTERRUPT_USING_SAMD51 true + + #if defined(ARDUINO_SAMD51_THING_PLUS) + #define BOARD_NAME "Sparkfun SAMD51_THING_PLUS" + #warning BOARD_NAME == Sparkfun SAMD51_THING_PLUS + #elif defined(ARDUINO_SAMD51_MICROMOD) + #define BOARD_NAME "Sparkfun SAMD51_MICROMOD" + #warning BOARD_NAME == Sparkfun SAMD51_MICROMOD + #endif + + #if !defined(BOARD_NAME) + #define BOARD_NAME "Unknown SAMD51" + #endif + #warning Using SAMD51 Hardware Timer #else #error Unknown board #endif +// Specific for SAMD21 SparkFun RedBoard Turbo +#if !defined(Serial) && defined(ARDUINO_SAMD_ZERO) + #define Serial SerialUSB +#endif + #include "Arduino.h" -#define SAMD_TIMER_INTERRUPT_VERSION "SAMDTimerInterrupt v1.1.1" +#define SAMD_TIMER_INTERRUPT_VERSION "SAMDTimerInterrupt v1.3.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/SAMDUETimerInterrupt_Generic.h b/src_cpp/SAMDUETimerInterrupt_Generic.h index daef507d..854850df 100644 --- a/src_cpp/SAMDUETimerInterrupt_Generic.h +++ b/src_cpp/SAMDUETimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -42,7 +43,7 @@ #include "Arduino.h" #include -#define SAMDUE_TIMER_INTERRUPT_VERSION "SAMDUETimerInterrupt v1.1.1" +#define SAMDUE_TIMER_INTERRUPT_VERSION "SAMDUETimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/STM32TimerInterrupt_Generic.h b/src_cpp/STM32TimerInterrupt_Generic.h index 27ae5d5d..b166a981 100644 --- a/src_cpp/STM32TimerInterrupt_Generic.h +++ b/src_cpp/STM32TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -41,7 +42,7 @@ #error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting. #endif -#define STM32_TIMER_INTERRUPT_VERSION "STM32_TimerInterrupt v1.1.1" +#define STM32_TIMER_INTERRUPT_VERSION "STM32_TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/TeensyTimerInterrupt_Generic.h b/src_cpp/TeensyTimerInterrupt_Generic.h index 954aff32..64c1fb84 100644 --- a/src_cpp/TeensyTimerInterrupt_Generic.h +++ b/src_cpp/TeensyTimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -39,7 +40,7 @@ #error This code is designed to run on Teensy platform! Please check your Tools->Board setting. #endif -#define TEENSY_TIMER_INTERRUPT_VERSION "Teensy_TimerInterrupt v1.1.1" +#define TEENSY_TIMER_INTERRUPT_VERSION "Teensy_TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_cpp/TimerInterrupt_Generic.h b/src_cpp/TimerInterrupt_Generic.h index 64e03511..ce0db254 100644 --- a/src_cpp/TimerInterrupt_Generic.h +++ b/src_cpp/TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD ********************************************************************************************************************************/ #pragma once @@ -36,30 +37,91 @@ #define TIMERINTERRUPT_GENERIC_H #if !defined(TIMER_INTERRUPT_GENERIC_VERSION) - #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.3.2" + #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.4.0" #endif #include "TimerInterrupt_Generic_Debug.h" -#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) +/////////////////////////////// AVR /////////////////////////////// +#if ( defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \ + defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \ + defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \ + defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \ + defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || \ + defined(ARDUINO_AVR_DUEMILANOVE) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Arduino AVR" + +#elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ + defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) #define TIMER_INTERRUPT_USING_AVR true - #include "AVRTimerInterrupt_Generic.h" + #define BOARD_TYPE "Adafruit AVR ATMega328(P)" + #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + +#elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ + defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ + defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Arduino AVR ATMega32U4" + #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. Only Timer1 is available + +#elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ + defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Adafruit AVR ATMega32U4" + #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc.. Only Timer1 is available + +#elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ + defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" + #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. Only Timer1 is available + +#elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" + #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. + +#elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" + #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. + +#elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) + #error These AVR boards are not supported! Please check your Tools->Board setting. + +/////////////////////////////// ESP8266 /////////////////////////////// #elif ( defined(ESP8266) || ESP8266 ) #define TIMER_INTERRUPT_USING_ESP8266 true - #include "ESP8266TimerInterrupt_Generic.h" + +/////////////////////////////// ESP32 /////////////////////////////// #elif ( defined(ESP32) || ESP32 ) - #define TIMER_INTERRUPT_USING_ESP32 true - #include "ESP32TimerInterrupt_Generic.h" + #define TIMER_INTERRUPT_USING_ESP32 true + +/////////////////////////////// Nano-33-BLE /////////////////////////////// #elif ( ARDUINO_ARCH_NRF52840 && TARGET_NAME == ARDUINO_NANO33BLE ) #warning Using ARDUINO_NANO33BLE - #define TIMER_INTERRUPT_USING_NANO33BLE true - #include "NRF52_MBED_TimerInterrupt_Generic.h" + #define TIMER_INTERRUPT_USING_NANO33BLE true + +/////////////////////////////// SAMD /////////////////////////////// #elif ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ @@ -68,34 +130,35 @@ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) #define TIMER_INTERRUPT_USING_SAMD true - #include "SAMDTimerInterrupt_Generic.h" +/////////////////////////////// NRF52 /////////////////////////////// #elif ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) #define TIMER_INTERRUPT_USING_NRF52 true - #include "NRF52TimerInterrupt_Generic.h" - + +/////////////////////////////// SAM DUE /////////////////////////////// + #elif ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) #define TIMER_INTERRUPT_USING_SAMDUE true - #include "SAMDUETimerInterrupt_Generic.h" - +/////////////////////////////// TEENSY /////////////////////////////// + #elif ( defined(CORE_TEENSY) || defined(__IMXRT1062__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) || \ defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK20DX128__) ) #define TIMER_INTERRUPT_USING_TEENSY true - #include "TeensyTimerInterrupt_Generic.h" + +/////////////////////////////// STM32 /////////////////////////////// #elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) #define TIMER_INTERRUPT_USING_STM32 true - #include "STM32TimerInterrupt_Generic.h" #else @@ -103,4 +166,29 @@ #endif +//////////////////////////////////////////////////// + +#if TIMER_INTERRUPT_USING_AVR + #include "AVRTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_ESP8266 + #include "ESP8266TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_ESP32 + #include "ESP32TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_NANO33BLE + #include "NRF52_MBED_TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_SAMD + #include "SAMDTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_NRF52 + #include "NRF52TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_SAMDUE + #include "SAMDUETimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_TEENSY + #include "TeensyTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_STM32 + #include "STM32TimerInterrupt_Generic.h" +#endif + +//////////////////////////////////////////////////// + + #endif // TIMERINTERRUPT_GENERIC_H diff --git a/src_cpp/TimerInterrupt_Generic_Debug.h b/src_cpp/TimerInterrupt_Generic_Debug.h index b5752c23..3b383c05 100644 --- a/src_cpp/TimerInterrupt_Generic_Debug.h +++ b/src_cpp/TimerInterrupt_Generic_Debug.h @@ -19,15 +19,16 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 - - Version Modified By Date Comments - ------- ----------- ---------- ----------- - 1.1.0 K Hoang 10/11/2020 Initial Super-Library coding to merge all TimerInterrupt Libraries - 1.2.0 K Hoang 12/11/2020 Add STM32_TimerInterrupt Library - 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. - 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. - 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + Version: 1.4.0 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.1.0 K Hoang 10/11/2020 Initial Super-Library coding to merge all TimerInterrupt Libraries + 1.2.0 K Hoang 12/11/2020 Add STM32_TimerInterrupt Library + 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. + 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. + 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src_h/AVRTimerInterrupt_Generic.h b/src_h/AVRTimerInterrupt_Generic.h index c42df775..06102e34 100644 --- a/src_h/AVRTimerInterrupt_Generic.h +++ b/src_h/AVRTimerInterrupt_Generic.h @@ -26,7 +26,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -35,6 +35,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ @@ -48,7 +49,7 @@ #endif #ifndef TIMER_INTERRUPT_VERSION - #define TIMER_INTERRUPT_VERSION "TimerInterrupt v1.1.2" + #define TIMER_INTERRUPT_VERSION "TimerInterrupt v1.4.1" #endif #include @@ -513,7 +514,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask) | _prescalerIndex; //prescalarbits; @@ -774,7 +779,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask); @@ -819,7 +828,11 @@ class TimerInterrupt // 16 bit timers from here #if defined(TCCR1B) + #if ( TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + if (_timer == 1) + #else else if (_timer == 1) + #endif { TCCR1B = (TCCR1B & andMask) | _prescalerIndex; //prescalarbits; @@ -937,6 +950,47 @@ class TimerInterrupt }; // class TimerInterrupt +////////////////////////////////////////////// + +// To be sure not used Timers are disabled +#if !defined(USE_TIMER_1) + #define USE_TIMER_1 false +#endif + +#if !defined(USE_TIMER_2) + #define USE_TIMER_2 false +#elif ( USE_TIMER_2 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_2 + #define USE_TIMER_2 false + #warning Timer2 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_3) + #define USE_TIMER_3 false +#elif ( USE_TIMER_3 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_3 + #define USE_TIMER_3 false + #warning Timer3 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_4) + #define USE_TIMER_4 false +#elif ( USE_TIMER_4 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_4 + #define USE_TIMER_4 false + #warning Timer4 is disabled for ATMEGA_32U4 +#endif + +#if !defined(USE_TIMER_5) + #define USE_TIMER_5 false +#elif ( USE_TIMER_5 && TIMER_INTERRUPT_USING_ATMEGA_32U4 ) + #undef USE_TIMER_5 + #define USE_TIMER_5 false + #warning Timer5 is disabled for ATMEGA_32U4 +#endif + +////////////////////////////////////////////// + #if USE_TIMER_1 #ifndef TIMER1_INSTANTIATED // To force pre-instatiate only once diff --git a/src_h/ESP32TimerInterrupt_Generic.h b/src_h/ESP32TimerInterrupt_Generic.h index 47b17ff0..2d1bc728 100644 --- a/src_h/ESP32TimerInterrupt_Generic.h +++ b/src_h/ESP32TimerInterrupt_Generic.h @@ -25,7 +25,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -34,6 +34,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -45,7 +46,7 @@ #error This code is designed to run on ESP32 platform, not Arduino nor ESP8266! Please check your Tools->Board setting. #endif -#define ESP32_TIMER_INTERRUPT_VERSION "ESP32TimerInterrupt v1.1.1" +#define ESP32_TIMER_INTERRUPT_VERSION "ESP32TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/ESP8266TimerInterrupt_Generic.h b/src_h/ESP8266TimerInterrupt_Generic.h index a93ada52..c7b445e2 100644 --- a/src_h/ESP8266TimerInterrupt_Generic.h +++ b/src_h/ESP8266TimerInterrupt_Generic.h @@ -24,7 +24,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -33,6 +33,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -44,7 +45,7 @@ #error This code is designed to run on ESP8266 and ESP8266-based boards! Please check your Tools->Board setting. #endif -#define ESP8266_TIMER_INTERRUPT_VERSION "ESP8266TimerInterrupt v1.1.1" +#define ESP8266_TIMER_INTERRUPT_VERSION "ESP8266TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/ISR_Timer-Impl_Generic.h b/src_h/ISR_Timer-Impl_Generic.h index 9bb82bca..02602a58 100644 --- a/src_h/ISR_Timer-Impl_Generic.h +++ b/src_h/ISR_Timer-Impl_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once diff --git a/src_h/ISR_Timer_Generic.h b/src_h/ISR_Timer_Generic.h index 416c5005..2c741330 100644 --- a/src_h/ISR_Timer_Generic.h +++ b/src_h/ISR_Timer_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -36,7 +37,7 @@ #define ISR_TIMER_GENERIC_H #if !defined(TIMER_INTERRUPT_GENERIC_VERSION) - #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.3.2" + #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.4.0" #endif #include diff --git a/src_h/NRF52TimerInterrupt_Generic.h b/src_h/NRF52TimerInterrupt_Generic.h index be7a5e49..e8673800 100644 --- a/src_h/NRF52TimerInterrupt_Generic.h +++ b/src_h/NRF52TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* nRF52 has 5 Hardware TIMERs: NRF_TIMER0-NRF_TIMER4 @@ -82,7 +83,7 @@ #include #include "nrf_timer.h" -#define NRF52_TIMER_INTERRUPT_VERSION "NRF52TimerInterrupt v1.1.1" +#define NRF52_TIMER_INTERRUPT_VERSION "NRF52TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/NRF52_MBED_TimerInterrupt_Generic.h b/src_h/NRF52_MBED_TimerInterrupt_Generic.h index 389b69ac..0b6fd798 100644 --- a/src_h/NRF52_MBED_TimerInterrupt_Generic.h +++ b/src_h/NRF52_MBED_TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Based on BlynkTimer.h Author: Volodymyr Shymanskyy - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* nRF52 has 5 Hardware TIMERs: NRF_TIMER0-NRF_TIMER4 @@ -82,7 +83,7 @@ // It's better to replace with the new one later. But be careful not to chain break anything #include "hal/nrf_timer.h" -#define NRF52_MBED_TIMER_INTERRUPT_VERSION "NRF52_MBED_TimerInterrupt v1.1.1" +#define NRF52_MBED_TIMER_INTERRUPT_VERSION "NRF52_MBED_TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/SAMDTimerInterrupt_Generic.h b/src_h/SAMDTimerInterrupt_Generic.h index 870c7838..af1f9d8b 100644 --- a/src_h/SAMDTimerInterrupt_Generic.h +++ b/src_h/SAMDTimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ /* SAMD21 @@ -61,18 +62,47 @@ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD21G18A__) ) + #define TIMER_INTERRUPT_USING_SAMD21 true + + #if defined(ARDUINO_QWIIC_MICRO) + #define BOARD_NAME "Sparkfun SAMD21_QWIIC_MICRO" + #warning BOARD_NAME == Sparkfun SAMD21_QWIIC_MICRO + #endif + + #if !defined(BOARD_NAME) + #define BOARD_NAME "Unknown SAMD21" + #endif + #warning Using SAMD21 Hardware Timer #elif ( defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) ) #define TIMER_INTERRUPT_USING_SAMD51 true + + #if defined(ARDUINO_SAMD51_THING_PLUS) + #define BOARD_NAME "Sparkfun SAMD51_THING_PLUS" + #warning BOARD_NAME == Sparkfun SAMD51_THING_PLUS + #elif defined(ARDUINO_SAMD51_MICROMOD) + #define BOARD_NAME "Sparkfun SAMD51_MICROMOD" + #warning BOARD_NAME == Sparkfun SAMD51_MICROMOD + #endif + + #if !defined(BOARD_NAME) + #define BOARD_NAME "Unknown SAMD51" + #endif + #warning Using SAMD51 Hardware Timer #else #error Unknown board #endif +// Specific for SAMD21 SparkFun RedBoard Turbo +#if !defined(Serial) && defined(ARDUINO_SAMD_ZERO) + #define Serial SerialUSB +#endif + #include "Arduino.h" -#define SAMD_TIMER_INTERRUPT_VERSION "SAMDTimerInterrupt v1.1.1" +#define SAMD_TIMER_INTERRUPT_VERSION "SAMDTimerInterrupt v1.3.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/SAMDUETimerInterrupt_Generic.h b/src_h/SAMDUETimerInterrupt_Generic.h index daef507d..854850df 100644 --- a/src_h/SAMDUETimerInterrupt_Generic.h +++ b/src_h/SAMDUETimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -42,7 +43,7 @@ #include "Arduino.h" #include -#define SAMDUE_TIMER_INTERRUPT_VERSION "SAMDUETimerInterrupt v1.1.1" +#define SAMDUE_TIMER_INTERRUPT_VERSION "SAMDUETimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/STM32TimerInterrupt_Generic.h b/src_h/STM32TimerInterrupt_Generic.h index 27ae5d5d..b166a981 100644 --- a/src_h/STM32TimerInterrupt_Generic.h +++ b/src_h/STM32TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -41,7 +42,7 @@ #error This code is designed to run on STM32F/L/H/G/WB/MP1 platform! Please check your Tools->Board setting. #endif -#define STM32_TIMER_INTERRUPT_VERSION "STM32_TimerInterrupt v1.1.1" +#define STM32_TIMER_INTERRUPT_VERSION "STM32_TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/TeensyTimerInterrupt_Generic.h b/src_h/TeensyTimerInterrupt_Generic.h index 954aff32..64c1fb84 100644 --- a/src_h/TeensyTimerInterrupt_Generic.h +++ b/src_h/TeensyTimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once @@ -39,7 +40,7 @@ #error This code is designed to run on Teensy platform! Please check your Tools->Board setting. #endif -#define TEENSY_TIMER_INTERRUPT_VERSION "Teensy_TimerInterrupt v1.1.1" +#define TEENSY_TIMER_INTERRUPT_VERSION "Teensy_TimerInterrupt v1.2.0" #ifndef TIMER_INTERRUPT_DEBUG #define TIMER_INTERRUPT_DEBUG 0 diff --git a/src_h/TimerInterrupt_Generic.h b/src_h/TimerInterrupt_Generic.h index 64e03511..ce0db254 100644 --- a/src_h/TimerInterrupt_Generic.h +++ b/src_h/TimerInterrupt_Generic.h @@ -19,7 +19,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 + Version: 1.4.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -28,6 +28,7 @@ 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD ********************************************************************************************************************************/ #pragma once @@ -36,30 +37,91 @@ #define TIMERINTERRUPT_GENERIC_H #if !defined(TIMER_INTERRUPT_GENERIC_VERSION) - #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.3.2" + #define TIMER_INTERRUPT_GENERIC_VERSION "TimerInterrupt_Generic v1.4.0" #endif #include "TimerInterrupt_Generic_Debug.h" -#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) +/////////////////////////////// AVR /////////////////////////////// +#if ( defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \ + defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \ + defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \ + defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \ + defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED) || \ + defined(ARDUINO_AVR_DUEMILANOVE) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Arduino AVR" + +#elif ( defined(ARDUINO_AVR_FEATHER328P) || defined(ARDUINO_AVR_METRO) || defined(ARDUINO_AVR_PROTRINKET5) || defined(ARDUINO_AVR_PROTRINKET3) || \ + defined(ARDUINO_AVR_PROTRINKET5FTDI) || defined(ARDUINO_AVR_PROTRINKET3FTDI) ) #define TIMER_INTERRUPT_USING_AVR true - #include "AVRTimerInterrupt_Generic.h" + #define BOARD_TYPE "Adafruit AVR ATMega328(P)" + #warning Using Adafruit ATMega328(P), such as AVR_FEATHER328P or AVR_METRO. + +#elif ( defined(ARDUINO_AVR_LEONARDO) || defined(ARDUINO_AVR_LEONARDO_ETH) || defined(ARDUINO_AVR_YUN) || defined(ARDUINO_AVR_MICRO) || \ + defined(ARDUINO_AVR_ESPLORA) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || \ + defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_YUNMINI) || defined(ARDUINO_AVR_INDUSTRIAL101) || defined(ARDUINO_AVR_LININO_ONE) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Arduino AVR ATMega32U4" + #warning Using Arduino ATMega32U4, such as Leonardo or Leonardo ETH. Only Timer1 is available + +#elif ( defined(ARDUINO_AVR_FLORA8 ) || defined(ARDUINO_AVR_FEATHER32U4) || defined(ARDUINO_AVR_CIRCUITPLAY) || defined(ARDUINO_AVR_ITSYBITSY32U4_5V) || \ + defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || defined(ARDUINO_AVR_BLUEFRUITMICRO) || defined(ARDUINO_AVR_ADAFRUIT32U4) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Adafruit AVR ATMega32U4" + #warning Using Adafruit ATMega32U4, such as Feather_32u4, AVR_CIRCUITPLAY, etc.. Only Timer1 is available + +#elif ( defined(__AVR_ATmega32U4__) || defined(ARDUINO_AVR_MAKEYMAKEY ) || defined(ARDUINO_AVR_PROMICRO) || defined(ARDUINO_AVR_FIOV3) || \ + defined(ARDUINO_AVR_QDUINOMINI) || defined(ARDUINO_AVR_LILYPAD_ARDUINO_USB_PLUS_BOARD ) ) + #define TIMER_INTERRUPT_USING_AVR true + #if defined(TIMER_INTERRUPT_USING_ATMEGA_32U4) + #undef TIMER_INTERRUPT_USING_ATMEGA_32U4 + #endif + #define TIMER_INTERRUPT_USING_ATMEGA_32U4 true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega32U4" + #warning Using Generic ATMega32U4, such as Sparkfun AVR_MAKEYMAKEY, AVR_PROMICRO, etc. Only Timer1 is available + +#elif ( defined(__AVR_ATmega328P__) || defined(ARDUINO_AVR_DIGITAL_SANDBOX ) || defined(ARDUINO_REDBOT) || defined(ARDUINO_AVR_SERIAL_7_SEGMENT) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega328P" + #warning Using Generic ATMega328P, such as Sparkfun AVR_DIGITAL_SANDBOX, REDBOT, etc. + +#elif ( defined(__AVR_ATmega128RFA1__) || defined(ARDUINO_ATMEGA128RFA1_DEV_BOARD) ) + #define TIMER_INTERRUPT_USING_AVR true + #define BOARD_TYPE "Generic or Sparkfun AVR ATMega128RFA1" + #warning Using Generic ATMega128RFA1, such as Sparkfun ATMEGA128RFA1_DEV_BOARD, etc. + +#elif ( defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_TRINKET3) || defined(ARDUINO_AVR_TRINKET5) ) + #error These AVR boards are not supported! Please check your Tools->Board setting. + +/////////////////////////////// ESP8266 /////////////////////////////// #elif ( defined(ESP8266) || ESP8266 ) #define TIMER_INTERRUPT_USING_ESP8266 true - #include "ESP8266TimerInterrupt_Generic.h" + +/////////////////////////////// ESP32 /////////////////////////////// #elif ( defined(ESP32) || ESP32 ) - #define TIMER_INTERRUPT_USING_ESP32 true - #include "ESP32TimerInterrupt_Generic.h" + #define TIMER_INTERRUPT_USING_ESP32 true + +/////////////////////////////// Nano-33-BLE /////////////////////////////// #elif ( ARDUINO_ARCH_NRF52840 && TARGET_NAME == ARDUINO_NANO33BLE ) #warning Using ARDUINO_NANO33BLE - #define TIMER_INTERRUPT_USING_NANO33BLE true - #include "NRF52_MBED_TimerInterrupt_Generic.h" + #define TIMER_INTERRUPT_USING_NANO33BLE true + +/////////////////////////////// SAMD /////////////////////////////// #elif ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ @@ -68,34 +130,35 @@ || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) #define TIMER_INTERRUPT_USING_SAMD true - #include "SAMDTimerInterrupt_Generic.h" +/////////////////////////////// NRF52 /////////////////////////////// #elif ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) #define TIMER_INTERRUPT_USING_NRF52 true - #include "NRF52TimerInterrupt_Generic.h" - + +/////////////////////////////// SAM DUE /////////////////////////////// + #elif ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) #define TIMER_INTERRUPT_USING_SAMDUE true - #include "SAMDUETimerInterrupt_Generic.h" - +/////////////////////////////// TEENSY /////////////////////////////// + #elif ( defined(CORE_TEENSY) || defined(__IMXRT1062__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) || \ defined(__MKL26Z64__) || defined(__MK20DX256__) || defined(__MK20DX128__) ) #define TIMER_INTERRUPT_USING_TEENSY true - #include "TeensyTimerInterrupt_Generic.h" + +/////////////////////////////// STM32 /////////////////////////////// #elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ defined(STM32WB) || defined(STM32MP1) ) #define TIMER_INTERRUPT_USING_STM32 true - #include "STM32TimerInterrupt_Generic.h" #else @@ -103,4 +166,29 @@ #endif +//////////////////////////////////////////////////// + +#if TIMER_INTERRUPT_USING_AVR + #include "AVRTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_ESP8266 + #include "ESP8266TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_ESP32 + #include "ESP32TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_NANO33BLE + #include "NRF52_MBED_TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_SAMD + #include "SAMDTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_NRF52 + #include "NRF52TimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_SAMDUE + #include "SAMDUETimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_TEENSY + #include "TeensyTimerInterrupt_Generic.h" +#elif TIMER_INTERRUPT_USING_STM32 + #include "STM32TimerInterrupt_Generic.h" +#endif + +//////////////////////////////////////////////////// + + #endif // TIMERINTERRUPT_GENERIC_H diff --git a/src_h/TimerInterrupt_Generic_Debug.h b/src_h/TimerInterrupt_Generic_Debug.h index b5752c23..3b383c05 100644 --- a/src_h/TimerInterrupt_Generic_Debug.h +++ b/src_h/TimerInterrupt_Generic_Debug.h @@ -19,15 +19,16 @@ Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic Licensed under MIT license - Version: 1.3.2 - - Version Modified By Date Comments - ------- ----------- ---------- ----------- - 1.1.0 K Hoang 10/11/2020 Initial Super-Library coding to merge all TimerInterrupt Libraries - 1.2.0 K Hoang 12/11/2020 Add STM32_TimerInterrupt Library - 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. - 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. - 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + Version: 1.4.0 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.1.0 K Hoang 10/11/2020 Initial Super-Library coding to merge all TimerInterrupt Libraries + 1.2.0 K Hoang 12/11/2020 Add STM32_TimerInterrupt Library + 1.3.0 K Hoang 01/12/2020 Add Mbed Mano-33-BLE Library. Add support to AVR UNO, Nano, Arduino Mini, Ethernet, BT. etc. + 1.3.1 K.Hoang 09/12/2020 Add complex examples and board Version String. Fix SAMD bug. + 1.3.2 K.Hoang 06/01/2021 Fix warnings. Optimize examples to reduce memory usage + 1.4.0 K.Hoang 02/04/2021 Add support to Arduino, Adafruit, Sparkfun AVR 32u4, 328P, 128128RFA1 and Sparkfun SAMD *****************************************************************************************************************************/ #pragma once