Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
khoih-prog authored Apr 3, 2021
1 parent 4d529e7 commit 7487d1c
Show file tree
Hide file tree
Showing 43 changed files with 772 additions and 166 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
122 changes: 91 additions & 31 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -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":
{
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TimerInterrupt_Generic
version=1.3.2
version=1.4.0
author=Khoi Hoang <[email protected]>
maintainer=Khoi Hoang <[email protected]>
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.
Expand Down
58 changes: 56 additions & 2 deletions src/AVRTimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
*****************************************************************************************************************************/


Expand All @@ -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 <avr/interrupt.h>
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/ESP32TimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/ESP8266TimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/ISR_Timer-Impl_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/ISR_Timer_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand All @@ -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 <stddef.h>
Expand Down
3 changes: 2 additions & 1 deletion src/NRF52TimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/NRF52_MBED_TimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Based on BlynkTimer.h
Author: Volodymyr Shymanskyy
Version: 1.3.2
Version: 1.4.0
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
34 changes: 32 additions & 2 deletions src/SAMDTimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/SAMDUETimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/STM32TimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/TeensyTimerInterrupt_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
------- ----------- ---------- -----------
Expand All @@ -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
Expand Down
Loading

0 comments on commit 7487d1c

Please sign in to comment.