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

Commit 4d529e7

Browse files
authored
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
1 parent 4849056 commit 4d529e7

File tree

38 files changed

+306
-304
lines changed

38 files changed

+306
-304
lines changed

examples/AVR/Argument_Complex/Argument_Complex.ino

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@
2626
Licensed under MIT license
2727
*****************************************************************************************************************************/
2828

29-
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \
30-
defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \
31-
defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \
32-
defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \
33-
defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED)
34-
35-
#else
36-
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
37-
#endif
38-
3929
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
4030
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
4131
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
@@ -50,6 +40,10 @@
5040

5141
#include "TimerInterrupt_Generic.h"
5242

43+
#if !(TIMER_INTERRUPT_USING_AVR)
44+
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
45+
#endif
46+
5347
struct pinStruct
5448
{
5549
unsigned int Pin1;
@@ -99,7 +93,8 @@ void setup()
9993
Serial.begin(115200);
10094
while (!Serial);
10195

102-
Serial.println(F("\nStarting Argument_Complex on Arduino AVR board"));
96+
Serial.print(F("\nStarting Argument_Complex on "));
97+
Serial.println(BOARD_TYPE);
10398
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
10499
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
105100

examples/AVR/Argument_None/Argument_None.ino

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@
2626
Licensed under MIT license
2727
*****************************************************************************************************************************/
2828

29-
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \
30-
defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \
31-
defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \
32-
defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \
33-
defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED)
34-
35-
#else
36-
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
37-
#endif
38-
3929
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
4030
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
4131
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
@@ -50,6 +40,11 @@
5040

5141
#include "TimerInterrupt_Generic.h"
5242

43+
#if !(TIMER_INTERRUPT_USING_AVR)
44+
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
45+
#endif
46+
#define TIMER1_INTERVAL_MS 1000
47+
5348
void TimerHandler1()
5449
{
5550
static bool toggle1 = false;
@@ -66,6 +61,10 @@ void TimerHandler1()
6661
toggle1 = !toggle1;
6762
}
6863

64+
#if USE_TIMER_2
65+
66+
#define TIMER2_INTERVAL_MS 2000
67+
6968
void TimerHandler2()
7069
{
7170
static bool toggle2 = false;
@@ -82,16 +81,15 @@ void TimerHandler2()
8281
toggle2 = !toggle2;
8382
}
8483

85-
#define TIMER1_INTERVAL_MS 1000
86-
87-
#define TIMER2_INTERVAL_MS 2000
84+
#endif
8885

8986
void setup()
9087
{
9188
Serial.begin(115200);
9289
while (!Serial);
9390

94-
Serial.println(F("\nStarting Argument_None on Arduino AVR board"));
91+
Serial.print(F("\nStarting Argument_None on "));
92+
Serial.println(BOARD_TYPE);
9593
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
9694
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
9795

@@ -110,6 +108,8 @@ void setup()
110108
else
111109
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
112110

111+
#if USE_TIMER_2
112+
113113
// Select Timer 1-2 for UNO, 0-5 for MEGA
114114
// Timer 2 is 8-bit timer, only for higher frequency
115115
ITimer2.init();
@@ -120,6 +120,7 @@ void setup()
120120
}
121121
else
122122
Serial.println(F("Can't set ITimer2. Select another freq. or timer"));
123+
#endif
123124
}
124125

125126
void loop()

examples/AVR/Argument_Simple/Argument_Simple.ino

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@
2626
Licensed under MIT license
2727
*****************************************************************************************************************************/
2828

29-
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \
30-
defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \
31-
defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \
32-
defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \
33-
defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED)
34-
35-
#else
36-
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
37-
#endif
38-
3929
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
4030
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
4131
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
@@ -50,6 +40,10 @@
5040

5141
#include "TimerInterrupt_Generic.h"
5242

43+
#if !(TIMER_INTERRUPT_USING_AVR)
44+
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
45+
#endif
46+
5347
unsigned int outputPin1 = LED_BUILTIN;
5448
unsigned int outputPin2 = A0;
5549

@@ -74,6 +68,8 @@ void TimerHandler1(unsigned int outputPin = LED_BUILTIN)
7468
toggle1 = !toggle1;
7569
}
7670

71+
#if USE_TIMER_2
72+
7773
void TimerHandler2(unsigned int outputPin = LED_BUILTIN)
7874
{
7975
static bool toggle2 = false;
@@ -90,6 +86,8 @@ void TimerHandler2(unsigned int outputPin = LED_BUILTIN)
9086
toggle2 = !toggle2;
9187
}
9288

89+
#endif
90+
9391
#define TIMER1_INTERVAL_MS 1000
9492

9593
#define TIMER2_INTERVAL_MS 2000
@@ -99,7 +97,8 @@ void setup()
9997
Serial.begin(115200);
10098
while (!Serial);
10199

102-
Serial.println(F("\nStarting Argument_Simple on Arduino AVR board"));
100+
Serial.print(F("\nStarting Argument_Simple on "));
101+
Serial.println(BOARD_TYPE);
103102
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
104103
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
105104

@@ -125,6 +124,8 @@ void setup()
125124
else
126125
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
127126

127+
#if USE_TIMER_2
128+
128129
ITimer2.init();
129130

130131
if (ITimer2.attachInterruptInterval(TIMER2_INTERVAL_MS, TimerHandler2, outputPin2))
@@ -138,6 +139,7 @@ void setup()
138139
}
139140
else
140141
Serial.println(F("Can't set ITimer2. Select another freq. or timer"));
142+
#endif
141143
}
142144

143145
void loop()

examples/AVR/Change_Interval/Change_Interval.ino

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@
3838
or the entire sequence of your code which accesses the data.
3939
*/
4040

41-
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \
42-
defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \
43-
defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \
44-
defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \
45-
defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED)
46-
47-
#else
48-
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
49-
#endif
5041

5142
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
5243
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
@@ -62,6 +53,10 @@
6253

6354
#include "TimerInterrupt_Generic.h"
6455

56+
#if !(TIMER_INTERRUPT_USING_AVR)
57+
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
58+
#endif
59+
6560
//#ifndef LED_BUILTIN
6661
// #define LED_BUILTIN 13
6762
//#endif
@@ -70,7 +65,6 @@
7065
#define LED_BLUE 7
7166
#endif
7267

73-
7468
#define TIMER1_INTERVAL_MS 100UL
7569
#define TIMER2_INTERVAL_MS 200UL
7670

@@ -96,6 +90,8 @@ void TimerHandler1()
9690
toggle1 = !toggle1;
9791
}
9892

93+
#if USE_TIMER_2
94+
9995
void TimerHandler2()
10096
{
10197
static bool toggle2 = false;
@@ -108,6 +104,8 @@ void TimerHandler2()
108104
toggle2 = !toggle2;
109105
}
110106

107+
#endif
108+
111109
void setup()
112110
{
113111
pinMode(LED_BUILTIN, OUTPUT);
@@ -116,7 +114,8 @@ void setup()
116114
Serial.begin(115200);
117115
while (!Serial);
118116

119-
Serial.println(F("\nStarting Change_Interval on Arduino AVR board"));
117+
Serial.print(F("\nStarting Change_Interval on "));
118+
Serial.println(BOARD_TYPE);
120119
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
121120
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
122121

@@ -135,6 +134,8 @@ void setup()
135134
else
136135
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
137136

137+
#if USE_TIMER_2
138+
138139
// Select Timer 1-2 for UNO, 0-5 for MEGA
139140
// Timer 2 is 8-bit timer, only for higher frequency
140141
ITimer2.init();
@@ -145,6 +146,7 @@ void setup()
145146
}
146147
else
147148
Serial.println(F("Can't set ITimer2. Select another freq. or timer"));
149+
#endif
148150
}
149151

150152
#define CHECK_INTERVAL_MS 10000L
@@ -173,10 +175,14 @@ void loop()
173175
// bool setInterval(unsigned long interval, timer_callback callback, unsigned long duration)
174176

175177
ITimer1.setInterval(TIMER1_INTERVAL_MS * (multFactor + 1), TimerHandler1);
178+
179+
Serial.print(F("Changing Interval, Timer1 = ")); Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));
180+
181+
#if USE_TIMER_2
176182
ITimer2.setInterval(TIMER2_INTERVAL_MS * (multFactor + 1), TimerHandler2);
177183

178-
Serial.print(F("Changing Interval, Timer1 = ")); Serial.print(TIMER1_INTERVAL_MS * (multFactor + 1));
179-
Serial.print(F(", Timer2 = ")); Serial.println(TIMER2_INTERVAL_MS * (multFactor + 1));
184+
Serial.print(F("Changing Interval, Timer2 = ")); Serial.println(TIMER2_INTERVAL_MS * (multFactor + 1));
185+
#endif
180186

181187
lastChangeTime = currTime;
182188
}

examples/AVR/FakeAnalogWrite/FakeAnalogWrite.ino

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,14 @@
4545
written
4646
*/
4747

48-
#if !(defined(__AVR_ATmega8__) || defined(__AVR_ATmega128__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || \
49-
defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega644A__) || \
50-
defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || \
51-
defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_BT) || \
52-
defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_NG) || defined(ARDUINO_AVR_UNO_WIFI_DEV_ED))
53-
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
54-
#endif
55-
5648
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
5749
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
5850
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
5951
#define TIMER_INTERRUPT_DEBUG 0
6052
#define _TIMERINTERRUPT_LOGLEVEL_ 0
6153

62-
#define USE_TIMER_1 false
63-
#define USE_TIMER_2 true
54+
#define USE_TIMER_1 true
55+
#define USE_TIMER_2 false
6456
#define USE_TIMER_3 false
6557
#define USE_TIMER_4 false
6658
#define USE_TIMER_5 false
@@ -69,6 +61,10 @@
6961

7062
#include "TimerInterrupt_Generic.h"
7163

64+
#if !(TIMER_INTERRUPT_USING_AVR)
65+
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
66+
#endif
67+
7268
#ifndef LED_BUILTIN
7369
#define LED_BUILTIN 13
7470
#endif
@@ -85,8 +81,8 @@ float mappingTable[MAPPING_TABLE_SIZE] =
8581
230.395, 236.136, 241.206, 245.680, 249.781, 253.509
8682
};
8783

88-
#define TIMER2_FREQUENCY_HZ 10000UL
89-
#define TIMER2_INTERVAL_US (1000000UL / TIMER2_FREQUENCY_HZ)
84+
#define TIMER1_FREQUENCY_HZ 10000UL
85+
#define TIMER1_INTERVAL_US (1000000UL / TIMER1_FREQUENCY_HZ)
9086

9187
volatile uint32_t startMillis = 0;
9288

@@ -110,7 +106,7 @@ void TimerHandler()
110106
}
111107

112108
// Toggle LED every LED_TOGGLE_INTERVAL_MS = 500ms = 0.5s
113-
if (++timeRun == ((LED_TOGGLE_INTERVAL_MS * TIMER2_FREQUENCY_HZ) / 1000) )
109+
if (++timeRun == ((LED_TOGGLE_INTERVAL_MS * TIMER1_FREQUENCY_HZ) / 1000) )
114110
{
115111
timeRun = 0;
116112

@@ -199,19 +195,20 @@ void setup()
199195
Serial.begin(115200);
200196
while (!Serial);
201197

202-
Serial.println(F("\nStarting FakeAnalogWrite on Arduino AVR board"));
198+
Serial.print(F("\nStarting FakeAnalogWrite on "));
199+
Serial.println(BOARD_TYPE);
203200
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
204201
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
205202

206-
ITimer2.init();
203+
ITimer1.init();
207204

208-
//if (ITimer2.attachInterruptInterval(TIMER2_INTERVAL_MS, TimerHandler))
209-
if (ITimer2.attachInterrupt(TIMER2_FREQUENCY_HZ, TimerHandler))
205+
//if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler))
206+
if (ITimer1.attachInterrupt(TIMER1_FREQUENCY_HZ, TimerHandler))
210207
{
211-
Serial.print(F("Starting ITimer2 OK, millis() = ")); Serial.println(millis());
208+
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
212209
}
213210
else
214-
Serial.println(F("Can't set ITimer2. Select another freq. or timer"));
211+
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
215212

216213
// Just to demonstrate, don't use too many ISR Timers if not absolutely necessary
217214
// You can use up to 16 timer for each ISR_Timer

0 commit comments

Comments
 (0)