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

Commit 2bdbbc3

Browse files
authored
v1.1.0 to fix multiple-definitions linker error
### Releases v1.1.0 1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
1 parent 05e5eb9 commit 2bdbbc3

11 files changed

+271
-207
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ 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.16) or Platform.io version
18-
* `ESP32` Core Version (e.g. ESP32 core v2.0.1)
19-
* `ESP32` Board type (e.g. ESP32_DEV Module, ESP32_S2_DEV, etc.)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `ESP32` Core Version (e.g. ESP32 core v2.0.2)
19+
* `ESP32` Board type (e.g. ESP32_DEV Module, ESP32_S2_DEV, ESP32_C3_DEV, etc.)
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
2222
* Anything that might be relevant in your opinion, such as:
@@ -27,11 +27,11 @@ Please ensure to specify the following:
2727
### Example
2828

2929
```
30-
Arduino IDE version: 1.8.16
31-
ESP32 Core Version 2.0.1
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-90-generic #101-Ubuntu SMP Fri Oct 15 20:00:55 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 ESP32_New_TimerInterrupt.

README.md

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
* [5. ISR_16_Timers_Array on ESP32S2_DEV](#5-isr_16_timers_array-on-esp32s2_dev)
4848
* [Debug](#debug)
4949
* [Troubleshooting](#troubleshooting)
50-
* [Releases](#releases)
5150
* [Issues](#issues)
5251
* [TO DO](#to-do)
5352
* [DONE](#done)
@@ -64,7 +63,7 @@
6463
### Important Notes
6564

6665
1. Avoid using `PIN_D1 (GPIO1)` in your code due to issue with core v2.0.0 and v2.0.1. Check [ESP32 Core v2.0.1 / 2.0.1 RC1 crashes if using pinMode with GPIO1 #5868](https://github.com/espressif/arduino-esp32/issues/5868). Only OK with core v1.0.6-
67-
2. Don't use `float` in `ISR` due to issue with core v2.0.0 and v2.0.1. Only OK with core v1.0.6-.
66+
2. Don't use `float` in `ISR` due to issue with core v2.0.0 and v2.0.1. Check [ESP32 Core v2.0.1 / 2.0.1 RC1 crashes if using float in ISR #5892](https://github.com/espressif/arduino-esp32/issues/5892). Only OK with core v1.0.6-.
6867

6968
### Features
7069

@@ -127,8 +126,8 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
127126

128127
## Prerequisites
129128

130-
1. [`Arduino IDE 1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software)
131-
2. [`ESP32 Core 2.0.1+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards (ESP32, ESP32_S2 and ESP32_C3). [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/).
129+
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
130+
2. [`ESP32 Core 2.0.2+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards (ESP32, ESP32_S2 and ESP32_C3). [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/).
132131

133132
---
134133
---
@@ -167,24 +166,20 @@ Another way to install is to:
167166

168167
### HOWTO Fix `Multiple Definitions` Linker Error
169168

170-
The current library implementation, using **xyz-Impl.h instead of standard xyz.cpp**, possibly creates certain `Multiple Definitions` Linker error in certain use cases. Although it's simple to just modify several lines of code, either in the library or in the application, the library is adding 2 more source directories
169+
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
171170

172-
1. **scr_h** for new h-only files
173-
2. **src_cpp** for standard h/cpp files
171+
You can use
174172

175-
besides the standard **src** directory.
176-
177-
To use the **old standard cpp** way, locate this library' directory, then just
178-
179-
1. **Delete the all the files in src directory.**
180-
2. **Copy all the files in src_cpp directory into src.**
181-
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
173+
```
174+
#include <ESP32_New_ISR_Timer.hpp> //https://github.com/khoih-prog/ESP32_New_TimerInterrupt
175+
```
182176

183-
To re-use the **new h-only** way, just
177+
in many files. But be sure to use the following `#include <ESP32_New_ISR_Timer.h>` **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
184178

185-
1. **Delete the all the files in src directory.**
186-
2. **Copy the files in src_h directory into src.**
187-
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
179+
```
180+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
181+
#include <ESP32_New_ISR_Timer.h> //https://github.com/khoih-prog/ESP32_New_TimerInterrupt
182+
```
188183

189184
---
190185
---
@@ -617,7 +612,7 @@ The following is the sample terminal output when running example [TimerInterrupt
617612
```
618613
619614
Starting TimerInterruptTest on ESP32_DEV
620-
ESP32_New_TimerInterrupt v1.0.1
615+
ESP32_New_TimerInterrupt v1.1.0
621616
CPU Frequency = 240 MHz
622617
[TISR] ESP32_TimerInterrupt: _timerNo = 0 , _fre = 1000000
623618
[TISR] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -650,7 +645,7 @@ The following is the sample terminal output when running example [Change_Interva
650645

651646
```
652647
Starting Change_Interval on ESP32_DEV
653-
ESP32_New_TimerInterrupt v1.0.1
648+
ESP32_New_TimerInterrupt v1.1.0
654649
CPU Frequency = 240 MHz
655650
Starting ITimer0 OK, millis() = 136
656651
Starting ITimer1 OK, millis() = 147
@@ -679,7 +674,7 @@ The following is the sample terminal output when running example [Argument_None]
679674

680675
```
681676
Starting Argument_None on ESP32S2_DEV
682-
ESP32_New_TimerInterrupt v1.0.1
677+
ESP32_New_TimerInterrupt v1.1.0
683678
CPU Frequency = 240 MHz
684679
[TISR] ESP32_S2_TimerInterrupt: _timerNo = 0 , _fre = 1000000
685680
[TISR] TIMER_BASE_CLK = 80000000 , TIMER_DIVIDER = 80
@@ -731,7 +726,7 @@ The following is the sample terminal output when running example [ISR_16_Timers_
731726

732727
```
733728
Starting ISR_16_Timers_Array_Complex on ESP32C3_DEV
734-
ESP32_New_TimerInterrupt v1.0.1
729+
ESP32_New_TimerInterrupt v1.1.0
735730
CPU Frequency = 160 MHz
736731
Starting ITimer OK, millis() = 2187
737732
SimpleTimer : 2, ms : 12193, Dms : 10004
@@ -882,7 +877,7 @@ The following is the sample terminal output when running example [ISR_16_Timers_
882877

883878
```
884879
Starting ISR_16_Timers_Array on ESP32S2_DEV
885-
ESP32_New_TimerInterrupt v1.0.1
880+
ESP32_New_TimerInterrupt v1.1.0
886881
CPU Frequency = 240 MHz
887882
Starting ITimer OK, millis() = 2538
888883
simpleTimerDoingSomething2s: Delta programmed ms = 2000, actual = 10008
@@ -918,20 +913,12 @@ Sometimes, the library will only work if you update the board core to the latest
918913
---
919914
---
920915

921-
## Releases
922-
923-
### Releases v1.0.0
924-
925-
1. Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with [ESP32 core v2.0.0-rc1+](https://github.com/espressif/arduino-esp32/releases/tag/2.0.0-rc1)
926-
927-
928-
---
929-
---
930916

931917
### Issues
932918

933919
Submit issues to: [ESP32_New_TimerInterrupt issues](https://github.com/khoih-prog/ESP32_New_TimerInterrupt/issues)
934920

921+
---
935922
---
936923

937924
## TO DO

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.1.0](#releases-v110)
1516
* [Releases v1.0.1](#releases-v101)
1617
* [Releases v1.0.0](#releases-v100)
1718

@@ -21,6 +22,10 @@
2122

2223
## Changelog
2324

25+
### Releases v1.1.0
26+
27+
1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
28+
2429
### Releases v1.0.1
2530

2631
1. Avoid using `PIN_D1 (GPIO1)` in your code due to issue with core v2.0.0 and v2.0.1. Check [ESP32 Core v2.0.1 / 2.0.1 RC1 crashes if using pinMode with GPIO1 #5868](https://github.com/espressif/arduino-esp32/issues/5868). Only OK with core v1.0.6-

examples/RPM_Measure/RPM_Measure.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ ESP32Timer ITimer0(0);
7373
volatile unsigned long rotationTime = 0;
7474

7575
// Not using float => using RPM = 100 * real RPM
76-
uint32_t RPM = 0;
77-
uint32_t avgRPM = 0;
76+
float RPM = 0;
77+
float avgRPM = 0;
78+
//uint32_t RPM = 0;
79+
//uint32_t avgRPM = 0;
7880

7981
volatile int debounceCounter;
8082

keywords.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ getNumAvailableTimers KEYWORD2
3939
#######################################
4040
# Constants (LITERAL1)
4141
#######################################
42+
43+
ESP32_NEW_TIMERINTERRUPT_VERSION LITERAL1
44+
ESP32_NEW_TIMERINTERRUPT_VERSION_MAJOR LITERAL1
45+
ESP32_NEW_TIMERINTERRUPT_VERSION_MINOR LITERAL1
46+
ESP32_NEW_TIMERINTERRUPT_VERSION_PATCH LITERAL1
47+
ESP32_NEW_TIMERINTERRUPT_VERSION_INT LITERAL1
48+

library.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ESP32_New_TimerInterrupt",
3-
"version": "1.0.1",
4-
"keywords": "timing, device, control, timer, interrupt, timer-interrupt, hardware, isr, isr-based, hardware-timer, isr-timer, isr-based-timer, mission-critical, accuracy, precise, non-blocking, esp32, esp32-s2, esp32-c3",
3+
"version": "1.1.0",
4+
"keywords": "timing, device, control, timer, interrupt, timer-interrupt, hardware, isr, isr-based, hardware-timer, isr-timer, isr-based-timer, mission-critical, accuracy, precise, non-blocking, esp32, esp32-s2, esp32-c3, esp32-s3",
55
"description": "This library enables you to use Interrupt from Hardware Timers on an ESP32, ESP32_S2 or ESP32_C3-based board. It now supports 16 ISR-based timers, while consuming only 1 Hardware Timer. Timers' interval is very long (ulong millisecs). The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions or tasks. This important feature is absolutely necessary for mission-critical tasks. These hardware timers, using interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.",
66
"authors":
77
{
@@ -22,8 +22,9 @@
2222
"tests"
2323
]
2424
},
25+
"license": "MIT",
2526
"frameworks": "*",
2627
"platforms": "espressif32",
2728
"examples": "examples/*/*/*.ino",
28-
"license": "MIT"
29+
"headers": ["ESP32_New_TimerInterrupt.h", "ESP32_New_ISR_Timer.hpp", "ESP32_New_ISR_Timer.h"]
2930
}

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ESP32_New_TimerInterrupt
2-
version=1.0.1
2+
version=1.1.0
33
author=Khoi Hoang <khoih.prog@gmail.com>
44
maintainer=Khoi Hoang <khoih.prog@gmail.com>
55
sentence=This library enables you to use Interrupt from Hardware Timers on an ESP32, ESP32_S2 or ESP32_C3-based board
@@ -9,4 +9,4 @@ url=https://github.com/khoih-prog/ESP32_New_TimerInterrupt
99
architectures=esp32
1010
repository=https://github.com/khoih-prog/ESP32_New_TimerInterrupt
1111
license=MIT
12-
includes=ESP32_New_TimerInterrupt.h,ESP32_New_ISR_Timer.h
12+
includes=ESP32_New_TimerInterrupt.h,ESP32_New_ISR_Timer.hpp,ESP32_New_ISR_Timer.h

src/ESP32_New_ISR_Timer-Impl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@
2727
Based on BlynkTimer.h
2828
Author: Volodymyr Shymanskyy
2929
30-
Version: 1.0.1
30+
Version: 1.1.0
3131
3232
Version Modified By Date Comments
3333
------- ----------- ---------- -----------
3434
1.0.0 K Hoang 15/08/2021 Initial coding for ESP32, ESP32_S2, ESP32_C3 boards with ESP32 core v2.0.0-rc1+
3535
1.0.1 K.Hoang 14/11/2021 Avoid using float and D1 in examples due to issue with core v2.0.0 and v2.0.1
36+
1.1.0 K.Hoang 18/01/2022 Fix `multiple-definitions` linker error.
3637
*****************************************************************************************************************************/
3738

3839
#pragma once

0 commit comments

Comments
 (0)