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

Commit 49ce263

Browse files
authored
v1.5.0 to fix multiple-definitions linker error
### Releases v1.5.0 1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories 2. Avoid deprecated functions. 3. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project. 4. Optimize library code by using `reference-passing` instead of `value-passing` 5. Update all examples
1 parent 360bedb commit 49ce263

22 files changed

+1033
-1512
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.15) or Platform.io version
18-
* `ESP32` Core Version (e.g. ESP32 core v1.0.6)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `ESP32` Core Version (e.g. ESP32 core v2.0.2)
1919
* `ESP32-S2` Board type (e.g. ESP32S2_DEV Module, ESP32_S2_Saola, etc.)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -27,11 +27,11 @@ Please ensure to specify the following:
2727
### Example
2828

2929
```
30-
Arduino IDE version: 1.8.15
31-
ESP32 Core Version 1.0.6
30+
Arduino IDE version: 1.8.19
31+
ESP32 Core Version 2.0.2
3232
ESP32S2_DEV Module
3333
OS: Ubuntu 20.04 LTS
34-
Linux xy-Inspiron-3593 5.4.0-73-generic #82-Ubuntu SMP Wed Apr 14 17:39:42 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
34+
Linux xy-Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3535
3636
Context:
3737
I encountered a crash while using TimerInterrupt.

README.md

Lines changed: 398 additions & 737 deletions
Large diffs are not rendered by default.

changelog.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ESP32_S2_TimerInterrupt Library
2+
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/ESP32_S2_TimerInterrupt.svg?)](https://www.ardu-badge.com/ESP32_S2_TimerInterrupt)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/ESP32_S2_TimerInterrupt.svg)](https://github.com/khoih-prog/ESP32_S2_TimerInterrupt/releases)
5+
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/ESP32_S2_TimerInterrupt/blob/master/LICENSE)
6+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
7+
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/ESP32_S2_TimerInterrupt.svg)](http://github.com/khoih-prog/ESP32_S2_TimerInterrupt/issues)
8+
9+
---
10+
---
11+
12+
## Table of Contents
13+
14+
* [Changelog](#changelog)
15+
* [Releases v1.5.0](#releases-v150)
16+
* [Releases v1.4.0](#releases-v140)
17+
* [Releases v1.3.0](#releases-v130)
18+
19+
---
20+
---
21+
22+
## Changelog
23+
24+
### Releases v1.5.0
25+
26+
1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
27+
2. Avoid deprecated functions.
28+
3. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project.
29+
4. Optimize library code by using `reference-passing` instead of `value-passing`
30+
5. Update all examples
31+
32+
33+
### Releases v1.4.0
34+
35+
1. Fix compiler errors due to conflict to some libraries.
36+
2. Add complex examples.
37+
38+
### Releases v1.3.0
39+
40+
1. Initial coding to support ESP32-S2
41+
2. Sync with [ESP32TimerInterrupt library v1.3.0](https://github.com/khoih-prog/ESP32TimerInterrupt)
42+

examples/Argument_None/Argument_None.ino

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@
1616
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1717
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1818
This important feature is absolutely necessary for mission-critical tasks.
19-
20-
Based on SimpleTimer - A timer library for Arduino.
21-
22-
Copyright (c) 2010 OTTOTECNICA Italy
23-
24-
Based on BlynkTimer.h
25-
Author: Volodymyr Shymanskyy
26-
27-
Version: 1.4.0
28-
29-
Version Modified By Date Comments
30-
------- ----------- ---------- -----------
31-
1.3.0 K Hoang 06/05/2019 Initial coding. Sync with ESP32TimerInterrupt v1.3.0
32-
1.4.0 K.Hoang 01/06/2021 Add complex examples. Fix compiler errors due to conflict to some libraries.
3319
*****************************************************************************************************************************/
3420

3521
/*
@@ -53,64 +39,40 @@
5339
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
5440
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
5541
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
56-
#define TIMER_INTERRUPT_DEBUG 1
42+
#define TIMER_INTERRUPT_DEBUG 0
5743
#define _TIMERINTERRUPT_LOGLEVEL_ 4
5844

5945
#include "ESP32_S2_TimerInterrupt.h"
6046

6147
#ifndef LED_BUILTIN
62-
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
48+
#define LED_BUILTIN 2 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
6349
#endif
6450

6551
#define PIN_D1 1 // Pin D1 mapped to pin GPIO1 of ESP32-S2
6652

6753

68-
void IRAM_ATTR TimerHandler0(void * timerNo)
69-
{
70-
/////////////////////////////////////////////////////////
71-
// Always call this for ESP32-S2 before processing ISR
72-
TIMER_ISR_START(timerNo);
73-
/////////////////////////////////////////////////////////
74-
54+
bool IRAM_ATTR TimerHandler0(void * timerNo)
55+
{
7556
static bool toggle0 = false;
7657
static bool started = false;
7758

78-
#if (TIMER_INTERRUPT_DEBUG > 0)
79-
Serial.print("ITimer0: millis() = "); Serial.println(millis());
80-
#endif
81-
8259
//timer interrupt toggles pin LED_BUILTIN
8360
digitalWrite(LED_BUILTIN, toggle0);
8461
toggle0 = !toggle0;
85-
86-
/////////////////////////////////////////////////////////
87-
// Always call this for ESP32-S2 after processing ISR
88-
TIMER_ISR_END(timerNo);
89-
/////////////////////////////////////////////////////////
62+
63+
return true;
9064
}
9165

92-
void IRAM_ATTR TimerHandler1(void * timerNo)
66+
bool IRAM_ATTR TimerHandler1(void * timerNo)
9367
{
94-
/////////////////////////////////////////////////////////
95-
// Always call this for ESP32-S2 before processing ISR
96-
TIMER_ISR_START(timerNo);
97-
/////////////////////////////////////////////////////////
98-
9968
static bool toggle1 = false;
10069
static bool started = false;
101-
102-
#if (TIMER_INTERRUPT_DEBUG > 0)
103-
Serial.print("ITimer1: millis() = "); Serial.println(millis());
104-
#endif
10570

10671
//timer interrupt toggles outputPin
10772
digitalWrite(PIN_D1, toggle1);
10873
toggle1 = !toggle1;
10974

110-
/////////////////////////////////////////////////////////
111-
// Always call this for ESP32-S2 after processing ISR
112-
TIMER_ISR_END(timerNo);
113-
/////////////////////////////////////////////////////////
75+
return true;
11476
}
11577

11678
#define TIMER0_INTERVAL_MS 1000

examples/Change_Interval/Change_Interval.ino

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@
1616
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
1717
Therefore, their executions are not blocked by bad-behaving functions / tasks.
1818
This important feature is absolutely necessary for mission-critical tasks.
19-
20-
Based on SimpleTimer - A timer library for Arduino.
21-
22-
Copyright (c) 2010 OTTOTECNICA Italy
23-
24-
Based on BlynkTimer.h
25-
Author: Volodymyr Shymanskyy
26-
27-
Version: 1.4.0
28-
29-
Version Modified By Date Comments
30-
------- ----------- ---------- -----------
31-
1.3.0 K Hoang 06/05/2019 Initial coding. Sync with ESP32TimerInterrupt v1.3.0
32-
1.4.0 K.Hoang 01/06/2021 Add complex examples. Fix compiler errors due to conflict to some libraries.
3319
*****************************************************************************************************************************/
3420

3521
/*
@@ -53,7 +39,7 @@
5339
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
5440
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
5541
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
56-
#define TIMER_INTERRUPT_DEBUG 1
42+
#define TIMER_INTERRUPT_DEBUG 0
5743
#define _TIMERINTERRUPT_LOGLEVEL_ 4
5844

5945
#include "ESP32_S2_TimerInterrupt.h"
@@ -67,56 +53,32 @@
6753
volatile uint32_t Timer0Count = 0;
6854
volatile uint32_t Timer1Count = 0;
6955

70-
void IRAM_ATTR TimerHandler0(void * timerNo)
71-
{
72-
/////////////////////////////////////////////////////////
73-
// Always call this for ESP32-S2 before processing ISR
74-
TIMER_ISR_START(timerNo);
75-
/////////////////////////////////////////////////////////
76-
56+
bool IRAM_ATTR TimerHandler0(void * timerNo)
57+
{
7758
static bool toggle0 = false;
7859

7960
// Flag for checking to be sure ISR is working as Serial.print is not OK here in ISR
8061
Timer0Count++;
8162

82-
#if (TIMER_INTERRUPT_DEBUG > 0)
83-
Serial.print("ITimer0: millis() = "); Serial.println(millis());
84-
#endif
85-
8663
//timer interrupt toggles pin LED_BUILTIN
8764
digitalWrite(LED_BUILTIN, toggle0);
8865
toggle0 = !toggle0;
8966

90-
/////////////////////////////////////////////////////////
91-
// Always call this for ESP32-S2 after processing ISR
92-
TIMER_ISR_END(timerNo);
93-
/////////////////////////////////////////////////////////
67+
return true;
9468
}
9569

96-
void IRAM_ATTR TimerHandler1(void * timerNo)
70+
bool IRAM_ATTR TimerHandler1(void * timerNo)
9771
{
98-
/////////////////////////////////////////////////////////
99-
// Always call this for ESP32-S2 before processing ISR
100-
TIMER_ISR_START(timerNo);
101-
/////////////////////////////////////////////////////////
102-
10372
static bool toggle1 = false;
10473

10574
// Flag for checking to be sure ISR is working as Serial.print is not OK here in ISR
10675
Timer1Count++;
10776

108-
#if (TIMER_INTERRUPT_DEBUG > 0)
109-
Serial.print("ITimer1: millis() = "); Serial.println(millis());
110-
#endif
111-
11277
//timer interrupt toggles PIN_D1
11378
digitalWrite(PIN_D1, toggle1);
11479
toggle1 = !toggle1;
11580

116-
/////////////////////////////////////////////////////////
117-
// Always call this for ESP32-S2 after processing ISR
118-
TIMER_ISR_END(timerNo);
119-
/////////////////////////////////////////////////////////
81+
return true;
12082
}
12183

12284
void printResult(uint32_t currTime)

0 commit comments

Comments
 (0)