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

Commit

Permalink
v1.13.0 to update to use latest versions
Browse files Browse the repository at this point in the history
### Major Releases v1.13.0

1. Update to use latest versions of the following libraries
- [ESP32_New_TimerInterrupt](https://github.com/khoih-prog/ESP32_New_TimerInterrupt)
- [MBED_RPI_PICO_TimerInterrupt](https://github.com/khoih-prog/MBED_RPI_PICO_TimerInterrupt)
- [megaAVR_TimerInterrupt](https://github.com/khoih-prog/megaAVR_TimerInterrupt)
- [NRF52_TimerInterrupt](https://github.com/khoih-prog/NRF52_TimerInterrupt)
- [NRF52_MBED_TimerInterrupt](https://github.com/khoih-prog/NRF52_MBED_TimerInterrupt)
2. Modify ESP32 examples to avoid using `LED_BUILTIN` / `GPIO2` as it can cause crash in some boards, such as `ESP32_C3`
3. Use `allman astyle` and add `utils`
4. Update `Packages_Patches`
  • Loading branch information
khoih-prog authored Nov 17, 2022
1 parent b8471a3 commit 4a045a4
Show file tree
Hide file tree
Showing 41 changed files with 4,322 additions and 3,844 deletions.
77 changes: 41 additions & 36 deletions examples/SAMD/Argument_None/Argument_None.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Argument_None.ino
For SAMD boards
Written by Khoi Hoang
Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic
Licensed under MIT license
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
unsigned long miliseconds), you just consume only one SAMD timer and avoid conflicting with other cores' tasks.
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
Expand Down Expand Up @@ -33,7 +33,7 @@
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
#endif

/////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -62,7 +62,7 @@
#include "TimerInterrupt_Generic.h"

#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#define LED_BUILTIN 13
#endif

volatile uint32_t preMillisTimer = 0;
Expand All @@ -76,19 +76,19 @@ volatile uint32_t preMillisTimer = 0;
volatile uint32_t preMillisTimer1 = 0;

#if USING_TIMER_TC3
#define SELECTED_TIMER TIMER_TC3
#define SELECTED_TIMER TIMER_TC3
#elif USING_TIMER_TC4
#define SELECTED_TIMER TIMER_TC4
#define SELECTED_TIMER TIMER_TC4
#elif USING_TIMER_TC5
#define SELECTED_TIMER TIMER_TC5
#define SELECTED_TIMER TIMER_TC5
#elif USING_TIMER_TCC
#define SELECTED_TIMER TIMER_TCC
#define SELECTED_TIMER TIMER_TCC
#elif USING_TIMER_TCC1
#define SELECTED_TIMER TIMER_TCC1
#define SELECTED_TIMER TIMER_TCC1
#elif USING_TIMER_TCC2
#define SELECTED_TIMER TIMER_TCC
#define SELECTED_TIMER TIMER_TCC
#else
#error You have to select 1 Timer
#error You have to select 1 Timer
#endif

// Init selected SAMD timer
Expand All @@ -98,39 +98,44 @@ SAMDTimer ITimer(SELECTED_TIMER);

void TimerHandler()
{
static bool toggle = false;
static bool toggle = false;

//Serial.println(toggle? "ON" : "OFF");
//Serial.println(toggle? "ON" : "OFF");

//timer interrupt toggles pin LED_BUILTIN
digitalWrite(LED_BUILTIN, toggle);
toggle = !toggle;
//timer interrupt toggles pin LED_BUILTIN
digitalWrite(LED_BUILTIN, toggle);
toggle = !toggle;
}

//////////////////////////////////////////////

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
while (!Serial && millis() < 5000);

delay(100);

Serial.print(F("\nStarting Argument_None on ")); Serial.println(BOARD_NAME);
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

// Interval in millisecs
if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
{
preMillisTimer = millis();
Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(preMillisTimer);
}
else
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);

while (!Serial && millis() < 5000);

delay(100);

Serial.print(F("\nStarting Argument_None on "));
Serial.println(BOARD_NAME);
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = "));
Serial.print(F_CPU / 1000000);
Serial.println(F(" MHz"));

// Interval in millisecs
if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
{
preMillisTimer = millis();
Serial.print(F("Starting ITimer OK, millis() = "));
Serial.println(preMillisTimer);
}
else
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
}

//////////////////////////////////////////////
Expand Down
91 changes: 48 additions & 43 deletions examples/SAMD/Argument_None_uS/Argument_None_uS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Argument_None_uS.ino
For SAMD boards
Written by Khoi Hoang
Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic
Licensed under MIT license
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
unsigned long miliseconds), you just consume only one SAMD timer and avoid conflicting with other cores' tasks.
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
Expand Down Expand Up @@ -33,7 +33,7 @@
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
#endif

/////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -62,7 +62,7 @@
#include "TimerInterrupt_Generic.h"

#ifndef LED_BUILTIN
#define LED_BUILTIN 13
#define LED_BUILTIN 13
#endif

// TC3, TC4, TC5 max permissible TIMER_INTERVAL_MS is 1398.101 ms, larger will overflow, therefore not permitted
Expand All @@ -76,19 +76,19 @@ volatile uint32_t preMillisTimer = 0;
// SAMD51 Hardware Timer only TC3

#if USING_TIMER_TC3
#define SELECTED_TIMER TIMER_TC3
#define SELECTED_TIMER TIMER_TC3
#elif USING_TIMER_TC4
#define SELECTED_TIMER TIMER_TC4
#define SELECTED_TIMER TIMER_TC4
#elif USING_TIMER_TC5
#define SELECTED_TIMER TIMER_TC5
#define SELECTED_TIMER TIMER_TC5
#elif USING_TIMER_TCC
#define SELECTED_TIMER TIMER_TCC
#define SELECTED_TIMER TIMER_TCC
#elif USING_TIMER_TCC1
#define SELECTED_TIMER TIMER_TCC1
#define SELECTED_TIMER TIMER_TCC1
#elif USING_TIMER_TCC2
#define SELECTED_TIMER TIMER_TCC
#define SELECTED_TIMER TIMER_TCC
#else
#error You have to select 1 Timer
#error You have to select 1 Timer
#endif

// Init selected SAMD timer
Expand All @@ -98,44 +98,49 @@ SAMDTimer ITimer(SELECTED_TIMER);

void TimerHandler()
{
static bool toggle = false;
static uint32_t count = 0;

// Blink once every 1000 interrupt times => ( 1000 * TIMER_INTERVAL_US )
if (++count >= 1000)
{
count = 0;
//timer interrupt toggles pin LED_BUILTIN
digitalWrite(LED_BUILTIN, toggle);
toggle = !toggle;
}
static bool toggle = false;
static uint32_t count = 0;

// Blink once every 1000 interrupt times => ( 1000 * TIMER_INTERVAL_US )
if (++count >= 1000)
{
count = 0;
//timer interrupt toggles pin LED_BUILTIN
digitalWrite(LED_BUILTIN, toggle);
toggle = !toggle;
}
}

//////////////////////////////////////////////

void setup()
{
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
while (!Serial && millis() < 5000);

delay(100);

Serial.print(F("\nStarting Argument_None_uS on ")); Serial.println(BOARD_NAME);
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

// Interval in millisecs
//if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
if (ITimer.attachInterruptInterval(TIMER_INTERVAL_US, TimerHandler))
{
preMillisTimer = millis();
Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(preMillisTimer);
}
else
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);

while (!Serial && millis() < 5000);

delay(100);

Serial.print(F("\nStarting Argument_None_uS on "));
Serial.println(BOARD_NAME);
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
Serial.print(F("CPU Frequency = "));
Serial.print(F_CPU / 1000000);
Serial.println(F(" MHz"));

// Interval in millisecs
//if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
if (ITimer.attachInterruptInterval(TIMER_INTERVAL_US, TimerHandler))
{
preMillisTimer = millis();
Serial.print(F("Starting ITimer OK, millis() = "));
Serial.println(preMillisTimer);
}
else
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
}

//////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 4a045a4

Please sign in to comment.