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 4849056 commit 4d529e7
Show file tree
Hide file tree
Showing 38 changed files with 306 additions and 304 deletions.
17 changes: 6 additions & 11 deletions examples/AVR/Argument_Complex/Argument_Complex.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
Licensed under MIT license
*****************************************************************************************************************************/

#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)

#else
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
Expand All @@ -50,6 +40,10 @@

#include "TimerInterrupt_Generic.h"

#if !(TIMER_INTERRUPT_USING_AVR)
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

struct pinStruct
{
unsigned int Pin1;
Expand Down Expand Up @@ -99,7 +93,8 @@ void setup()
Serial.begin(115200);
while (!Serial);

Serial.println(F("\nStarting Argument_Complex on Arduino AVR board"));
Serial.print(F("\nStarting Argument_Complex on "));
Serial.println(BOARD_TYPE);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

Expand Down
29 changes: 15 additions & 14 deletions examples/AVR/Argument_None/Argument_None.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
Licensed under MIT license
*****************************************************************************************************************************/

#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)

#else
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
Expand All @@ -50,6 +40,11 @@

#include "TimerInterrupt_Generic.h"

#if !(TIMER_INTERRUPT_USING_AVR)
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif
#define TIMER1_INTERVAL_MS 1000

void TimerHandler1()
{
static bool toggle1 = false;
Expand All @@ -66,6 +61,10 @@ void TimerHandler1()
toggle1 = !toggle1;
}

#if USE_TIMER_2

#define TIMER2_INTERVAL_MS 2000

void TimerHandler2()
{
static bool toggle2 = false;
Expand All @@ -82,16 +81,15 @@ void TimerHandler2()
toggle2 = !toggle2;
}

#define TIMER1_INTERVAL_MS 1000

#define TIMER2_INTERVAL_MS 2000
#endif

void setup()
{
Serial.begin(115200);
while (!Serial);

Serial.println(F("\nStarting Argument_None on Arduino AVR board"));
Serial.print(F("\nStarting Argument_None on "));
Serial.println(BOARD_TYPE);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

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

#if USE_TIMER_2

// Select Timer 1-2 for UNO, 0-5 for MEGA
// Timer 2 is 8-bit timer, only for higher frequency
ITimer2.init();
Expand All @@ -120,6 +120,7 @@ void setup()
}
else
Serial.println(F("Can't set ITimer2. Select another freq. or timer"));
#endif
}

void loop()
Expand Down
24 changes: 13 additions & 11 deletions examples/AVR/Argument_Simple/Argument_Simple.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
Licensed under MIT license
*****************************************************************************************************************************/

#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)

#else
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
Expand All @@ -50,6 +40,10 @@

#include "TimerInterrupt_Generic.h"

#if !(TIMER_INTERRUPT_USING_AVR)
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

unsigned int outputPin1 = LED_BUILTIN;
unsigned int outputPin2 = A0;

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

#if USE_TIMER_2

void TimerHandler2(unsigned int outputPin = LED_BUILTIN)
{
static bool toggle2 = false;
Expand All @@ -90,6 +86,8 @@ void TimerHandler2(unsigned int outputPin = LED_BUILTIN)
toggle2 = !toggle2;
}

#endif

#define TIMER1_INTERVAL_MS 1000

#define TIMER2_INTERVAL_MS 2000
Expand All @@ -99,7 +97,8 @@ void setup()
Serial.begin(115200);
while (!Serial);

Serial.println(F("\nStarting Argument_Simple on Arduino AVR board"));
Serial.print(F("\nStarting Argument_Simple on "));
Serial.println(BOARD_TYPE);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

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

#if USE_TIMER_2

ITimer2.init();

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

void loop()
Expand Down
32 changes: 19 additions & 13 deletions examples/AVR/Change_Interval/Change_Interval.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,6 @@
or the entire sequence of your code which accesses the data.
*/

#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)

#else
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

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

#include "TimerInterrupt_Generic.h"

#if !(TIMER_INTERRUPT_USING_AVR)
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

//#ifndef LED_BUILTIN
// #define LED_BUILTIN 13
//#endif
Expand All @@ -70,7 +65,6 @@
#define LED_BLUE 7
#endif


#define TIMER1_INTERVAL_MS 100UL
#define TIMER2_INTERVAL_MS 200UL

Expand All @@ -96,6 +90,8 @@ void TimerHandler1()
toggle1 = !toggle1;
}

#if USE_TIMER_2

void TimerHandler2()
{
static bool toggle2 = false;
Expand All @@ -108,6 +104,8 @@ void TimerHandler2()
toggle2 = !toggle2;
}

#endif

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Expand All @@ -116,7 +114,8 @@ void setup()
Serial.begin(115200);
while (!Serial);

Serial.println(F("\nStarting Change_Interval on Arduino AVR board"));
Serial.print(F("\nStarting Change_Interval on "));
Serial.println(BOARD_TYPE);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

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

#if USE_TIMER_2

// Select Timer 1-2 for UNO, 0-5 for MEGA
// Timer 2 is 8-bit timer, only for higher frequency
ITimer2.init();
Expand All @@ -145,6 +146,7 @@ void setup()
}
else
Serial.println(F("Can't set ITimer2. Select another freq. or timer"));
#endif
}

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

ITimer1.setInterval(TIMER1_INTERVAL_MS * (multFactor + 1), TimerHandler1);

Serial.print(F("Changing Interval, Timer1 = ")); Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));

#if USE_TIMER_2
ITimer2.setInterval(TIMER2_INTERVAL_MS * (multFactor + 1), TimerHandler2);

Serial.print(F("Changing Interval, Timer1 = ")); Serial.print(TIMER1_INTERVAL_MS * (multFactor + 1));
Serial.print(F(", Timer2 = ")); Serial.println(TIMER2_INTERVAL_MS * (multFactor + 1));
Serial.print(F("Changing Interval, Timer2 = ")); Serial.println(TIMER2_INTERVAL_MS * (multFactor + 1));
#endif

lastChangeTime = currTime;
}
Expand Down
35 changes: 16 additions & 19 deletions examples/AVR/FakeAnalogWrite/FakeAnalogWrite.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,14 @@
written
*/

#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))
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
#define TIMER_INTERRUPT_DEBUG 0
#define _TIMERINTERRUPT_LOGLEVEL_ 0

#define USE_TIMER_1 false
#define USE_TIMER_2 true
#define USE_TIMER_1 true
#define USE_TIMER_2 false
#define USE_TIMER_3 false
#define USE_TIMER_4 false
#define USE_TIMER_5 false
Expand All @@ -69,6 +61,10 @@

#include "TimerInterrupt_Generic.h"

#if !(TIMER_INTERRUPT_USING_AVR)
#error This is designed only for Arduino AVR board! Please check your Tools->Board setting.
#endif

#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#endif
Expand All @@ -85,8 +81,8 @@ float mappingTable[MAPPING_TABLE_SIZE] =
230.395, 236.136, 241.206, 245.680, 249.781, 253.509
};

#define TIMER2_FREQUENCY_HZ 10000UL
#define TIMER2_INTERVAL_US (1000000UL / TIMER2_FREQUENCY_HZ)
#define TIMER1_FREQUENCY_HZ 10000UL
#define TIMER1_INTERVAL_US (1000000UL / TIMER1_FREQUENCY_HZ)

volatile uint32_t startMillis = 0;

Expand All @@ -110,7 +106,7 @@ void TimerHandler()
}

// Toggle LED every LED_TOGGLE_INTERVAL_MS = 500ms = 0.5s
if (++timeRun == ((LED_TOGGLE_INTERVAL_MS * TIMER2_FREQUENCY_HZ) / 1000) )
if (++timeRun == ((LED_TOGGLE_INTERVAL_MS * TIMER1_FREQUENCY_HZ) / 1000) )
{
timeRun = 0;

Expand Down Expand Up @@ -199,19 +195,20 @@ void setup()
Serial.begin(115200);
while (!Serial);

Serial.println(F("\nStarting FakeAnalogWrite on Arduino AVR board"));
Serial.print(F("\nStarting FakeAnalogWrite on "));
Serial.println(BOARD_TYPE);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

ITimer2.init();
ITimer1.init();

//if (ITimer2.attachInterruptInterval(TIMER2_INTERVAL_MS, TimerHandler))
if (ITimer2.attachInterrupt(TIMER2_FREQUENCY_HZ, TimerHandler))
//if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS, TimerHandler))
if (ITimer1.attachInterrupt(TIMER1_FREQUENCY_HZ, TimerHandler))
{
Serial.print(F("Starting ITimer2 OK, millis() = ")); Serial.println(millis());
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer2. Select another freq. or timer"));
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));

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

0 comments on commit 4d529e7

Please sign in to comment.