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

Commit 4a045a4

Browse files
authored
v1.13.0 to update to use latest versions
### 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`
1 parent b8471a3 commit 4a045a4

File tree

41 files changed

+4322
-3844
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4322
-3844
lines changed

examples/SAMD/Argument_None/Argument_None.ino

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
Argument_None.ino
33
For SAMD boards
44
Written by Khoi Hoang
5-
5+
66
Built by Khoi Hoang https://github.com/khoih-prog/TimerInterrupt_Generic
77
Licensed under MIT license
8-
8+
99
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
1010
unsigned long miliseconds), you just consume only one SAMD timer and avoid conflicting with other cores' tasks.
1111
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
@@ -33,7 +33,7 @@
3333
|| defined(__SAMD21E15A__) || defined(__SAMD21E16A__) || defined(__SAMD21E17A__) || defined(__SAMD21E18A__) \
3434
|| defined(__SAMD21G15A__) || defined(__SAMD21G16A__) || defined(__SAMD21G17A__) || defined(__SAMD21G18A__) \
3535
|| defined(__SAMD21J15A__) || defined(__SAMD21J16A__) || defined(__SAMD21J17A__) || defined(__SAMD21J18A__) )
36-
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
36+
#error This code is designed to run on SAMD21/SAMD51 platform! Please check your Tools->Board setting.
3737
#endif
3838

3939
/////////////////////////////////////////////////////////////////
@@ -62,7 +62,7 @@
6262
#include "TimerInterrupt_Generic.h"
6363

6464
#ifndef LED_BUILTIN
65-
#define LED_BUILTIN 13
65+
#define LED_BUILTIN 13
6666
#endif
6767

6868
volatile uint32_t preMillisTimer = 0;
@@ -76,19 +76,19 @@ volatile uint32_t preMillisTimer = 0;
7676
volatile uint32_t preMillisTimer1 = 0;
7777

7878
#if USING_TIMER_TC3
79-
#define SELECTED_TIMER TIMER_TC3
79+
#define SELECTED_TIMER TIMER_TC3
8080
#elif USING_TIMER_TC4
81-
#define SELECTED_TIMER TIMER_TC4
81+
#define SELECTED_TIMER TIMER_TC4
8282
#elif USING_TIMER_TC5
83-
#define SELECTED_TIMER TIMER_TC5
83+
#define SELECTED_TIMER TIMER_TC5
8484
#elif USING_TIMER_TCC
85-
#define SELECTED_TIMER TIMER_TCC
85+
#define SELECTED_TIMER TIMER_TCC
8686
#elif USING_TIMER_TCC1
87-
#define SELECTED_TIMER TIMER_TCC1
87+
#define SELECTED_TIMER TIMER_TCC1
8888
#elif USING_TIMER_TCC2
89-
#define SELECTED_TIMER TIMER_TCC
89+
#define SELECTED_TIMER TIMER_TCC
9090
#else
91-
#error You have to select 1 Timer
91+
#error You have to select 1 Timer
9292
#endif
9393

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

9999
void TimerHandler()
100100
{
101-
static bool toggle = false;
101+
static bool toggle = false;
102102

103-
//Serial.println(toggle? "ON" : "OFF");
103+
//Serial.println(toggle? "ON" : "OFF");
104104

105-
//timer interrupt toggles pin LED_BUILTIN
106-
digitalWrite(LED_BUILTIN, toggle);
107-
toggle = !toggle;
105+
//timer interrupt toggles pin LED_BUILTIN
106+
digitalWrite(LED_BUILTIN, toggle);
107+
toggle = !toggle;
108108
}
109109

110110
//////////////////////////////////////////////
111111

112112
void setup()
113113
{
114-
pinMode(LED_BUILTIN, OUTPUT);
115-
116-
Serial.begin(115200);
117-
while (!Serial && millis() < 5000);
118-
119-
delay(100);
120-
121-
Serial.print(F("\nStarting Argument_None on ")); Serial.println(BOARD_NAME);
122-
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
123-
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
124-
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
125-
126-
// Interval in millisecs
127-
if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
128-
{
129-
preMillisTimer = millis();
130-
Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(preMillisTimer);
131-
}
132-
else
133-
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
114+
pinMode(LED_BUILTIN, OUTPUT);
115+
116+
Serial.begin(115200);
117+
118+
while (!Serial && millis() < 5000);
119+
120+
delay(100);
121+
122+
Serial.print(F("\nStarting Argument_None on "));
123+
Serial.println(BOARD_NAME);
124+
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
125+
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
126+
Serial.print(F("CPU Frequency = "));
127+
Serial.print(F_CPU / 1000000);
128+
Serial.println(F(" MHz"));
129+
130+
// Interval in millisecs
131+
if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
132+
{
133+
preMillisTimer = millis();
134+
Serial.print(F("Starting ITimer OK, millis() = "));
135+
Serial.println(preMillisTimer);
136+
}
137+
else
138+
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
134139
}
135140

136141
//////////////////////////////////////////////

examples/SAMD/Argument_None_uS/Argument_None_uS.ino

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

3939
/////////////////////////////////////////////////////////////////
@@ -62,7 +62,7 @@
6262
#include "TimerInterrupt_Generic.h"
6363

6464
#ifndef LED_BUILTIN
65-
#define LED_BUILTIN 13
65+
#define LED_BUILTIN 13
6666
#endif
6767

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

7878
#if USING_TIMER_TC3
79-
#define SELECTED_TIMER TIMER_TC3
79+
#define SELECTED_TIMER TIMER_TC3
8080
#elif USING_TIMER_TC4
81-
#define SELECTED_TIMER TIMER_TC4
81+
#define SELECTED_TIMER TIMER_TC4
8282
#elif USING_TIMER_TC5
83-
#define SELECTED_TIMER TIMER_TC5
83+
#define SELECTED_TIMER TIMER_TC5
8484
#elif USING_TIMER_TCC
85-
#define SELECTED_TIMER TIMER_TCC
85+
#define SELECTED_TIMER TIMER_TCC
8686
#elif USING_TIMER_TCC1
87-
#define SELECTED_TIMER TIMER_TCC1
87+
#define SELECTED_TIMER TIMER_TCC1
8888
#elif USING_TIMER_TCC2
89-
#define SELECTED_TIMER TIMER_TCC
89+
#define SELECTED_TIMER TIMER_TCC
9090
#else
91-
#error You have to select 1 Timer
91+
#error You have to select 1 Timer
9292
#endif
9393

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

9999
void TimerHandler()
100100
{
101-
static bool toggle = false;
102-
static uint32_t count = 0;
103-
104-
// Blink once every 1000 interrupt times => ( 1000 * TIMER_INTERVAL_US )
105-
if (++count >= 1000)
106-
{
107-
count = 0;
108-
//timer interrupt toggles pin LED_BUILTIN
109-
digitalWrite(LED_BUILTIN, toggle);
110-
toggle = !toggle;
111-
}
101+
static bool toggle = false;
102+
static uint32_t count = 0;
103+
104+
// Blink once every 1000 interrupt times => ( 1000 * TIMER_INTERVAL_US )
105+
if (++count >= 1000)
106+
{
107+
count = 0;
108+
//timer interrupt toggles pin LED_BUILTIN
109+
digitalWrite(LED_BUILTIN, toggle);
110+
toggle = !toggle;
111+
}
112112
}
113113

114114
//////////////////////////////////////////////
115115

116116
void setup()
117117
{
118-
pinMode(LED_BUILTIN, OUTPUT);
119-
120-
Serial.begin(115200);
121-
while (!Serial && millis() < 5000);
122-
123-
delay(100);
124-
125-
Serial.print(F("\nStarting Argument_None_uS on ")); Serial.println(BOARD_NAME);
126-
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
127-
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
128-
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
129-
130-
// Interval in millisecs
131-
//if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
132-
if (ITimer.attachInterruptInterval(TIMER_INTERVAL_US, TimerHandler))
133-
{
134-
preMillisTimer = millis();
135-
Serial.print(F("Starting ITimer OK, millis() = ")); Serial.println(preMillisTimer);
136-
}
137-
else
138-
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
118+
pinMode(LED_BUILTIN, OUTPUT);
119+
120+
Serial.begin(115200);
121+
122+
while (!Serial && millis() < 5000);
123+
124+
delay(100);
125+
126+
Serial.print(F("\nStarting Argument_None_uS on "));
127+
Serial.println(BOARD_NAME);
128+
Serial.println(SAMD_TIMER_INTERRUPT_VERSION);
129+
Serial.println(TIMER_INTERRUPT_GENERIC_VERSION);
130+
Serial.print(F("CPU Frequency = "));
131+
Serial.print(F_CPU / 1000000);
132+
Serial.println(F(" MHz"));
133+
134+
// Interval in millisecs
135+
//if (ITimer.attachInterruptInterval_MS(TIMER_INTERVAL_MS, TimerHandler))
136+
if (ITimer.attachInterruptInterval(TIMER_INTERVAL_US, TimerHandler))
137+
{
138+
preMillisTimer = millis();
139+
Serial.print(F("Starting ITimer OK, millis() = "));
140+
Serial.println(preMillisTimer);
141+
}
142+
else
143+
Serial.println(F("Can't set ITimer. Select another freq. or timer"));
139144
}
140145

141146
//////////////////////////////////////////////

0 commit comments

Comments
 (0)