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

Commit 9d49f3b

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

26 files changed

+1696
-1530
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.13) or Platform.io version
18-
* `Teensyduino` Core Version (e.g. Teensy core v1.53)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `Teensyduino` Core Version (e.g. Teensy core v1.56)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
2121
* Anything that might be relevant in your opinion, such as:
@@ -26,10 +26,10 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.13
30-
Teensyduino Core Version 1.53
29+
Arduino IDE version: 1.8.19
30+
Teensyduino Core Version 1.56
3131
OS: Ubuntu 20.04 LTS
32-
Linux xy-Inspiron-3593 5.4.0-51-generic #56-Ubuntu SMP Mon Oct 5 14:28:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
32+
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
3333
3434
Context:
3535
I encountered a crash while trying to use the Timer Interrupt.

README.md

Lines changed: 67 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
## Table of Contents
1313

14+
* [Important Change from v1.3.0](#Important-Change-from-v130)
1415
* [Why do we need this Teensy_TimerInterrupt library](#why-do-we-need-this-teensy_timerinterrupt-library)
1516
* [Features](#features)
1617
* [Why using ISR-based Hardware Timer Interrupt is better](#why-using-isr-based-hardware-timer-interrupt-is-better)
@@ -57,6 +58,7 @@
5758
* [ 8. TimerInterruptLEDDemo](examples/TimerInterruptLEDDemo)
5859
* [ 9. **Change_Interval**](examples/Change_Interval)
5960
* [ 10. **ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex)
61+
* [ 11. **multiFileProject**](examples/multiFileProject) **New**
6062
* [Example ISR_16_Timers_Array_Complex](#example-isr_16_timers_array_complex)
6163
* [Debug Terminal Output Samples](#debug-terminal-output-samples)
6264
* [1. ISR_16_Timers_Array on Teensy 4.1](#1-isr_16_timers_array-on-teensy-41)
@@ -66,7 +68,6 @@
6668
* [5. ISR_16_Timers_Array_Complex on Teensy 4.1](#5-isr_16_timers_array_complex-on-teensy-41)
6769
* [Debug](#debug)
6870
* [Troubleshooting](#troubleshooting)
69-
* [Releases](#releases)
7071
* [Issues](#issues)
7172
* [TO DO](#to-do)
7273
* [DONE](#done)
@@ -78,6 +79,10 @@
7879
---
7980
---
8081

82+
### Important Change from v1.3.0
83+
84+
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
85+
8186
### Why do we need this [Teensy_TimerInterrupt library](https://github.com/khoih-prog/Teensy_TimerInterrupt)
8287

8388
### Features
@@ -129,7 +134,7 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
129134

130135
1. **Teensy boards** such as :
131136

132-
- **Teensy 4.1, 4.0**
137+
- **Teensy 4.1, 4.0, Teensy MicroMod**
133138
- **Teensy 3.6, 3.5, 3.2/3.1, 3.0**
134139
- **Teensy LC**
135140
- **Teensy++ 2.0 and Teensy 2.0**
@@ -145,37 +150,13 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
145150
---
146151
---
147152

148-
## Changelog
149-
150-
### Releases v1.2.0
151-
152-
1. Add better debug feature.
153-
2. Optimize code and examples to reduce RAM usage
154-
3. Add Table of Contents
155-
156-
### Releases v1.1.1
157-
158-
1. Add example [**Change_Interval**](examples/Change_Interval) and [**ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex)
159-
2. Bump up version to sync with other TimerInterrupt Libraries. Modify Version String.
160-
161-
### Releases v1.0.1
162-
163-
1. Add complicated example [ISR_16_Timers_Array](examples/ISR_16_Timers_Array) utilizing and demonstrating the full usage of 16 independent ISR Timers.
164-
165-
### Releases v1.0.0
166-
167-
1. Permit up to 16 super-long-time, super-accurate ISR-based timers to avoid being blocked
168-
2. Using cpp code besides Impl.h code to use if Multiple-Definition linker error.
169-
170-
---
171-
---
172153

173154
## Prerequisites
174155

175-
1. [`Arduino IDE 1.8.13+` for Arduino](https://www.arduino.cc/en/Main/Software)
176-
2. [`Teensy Core 1.53+`](https://www.pjrc.com/teensy/td_download.html) for Teensy.
156+
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)
157+
2. [`Teensy Core 1.56+`](https://www.pjrc.com/teensy/td_download.html) for Teensy.
177158
3. To use with certain example,
178-
- [`SimpleTimer library`](https://github.com/schinken/SimpleTimer) for [ISR_16_Timers_Array example](examples/ISR_16_Timers_Array).
159+
- [`SimpleTimer library`](https://github.com/jfturcot/SimpleTimer) for [ISR_16_Timers_Array example](examples/ISR_16_Timers_Array).
179160

180161
---
181162
---
@@ -210,18 +191,20 @@ Another way to install is to:
210191

211192
#### 1. For Teensy boards
212193

213-
**To be able to compile and run on Teensy boards**, you have to copy the file [Teensy boards.txt](Packages_Patches/hardware/teensy/avr/boards.txt) into Teensy hardware directory (./arduino-1.8.13/hardware/teensy/avr/boards.txt).
194+
**To be able to compile and run on Teensy boards**, you have to copy the file [Teensy boards.txt](Packages_Patches/hardware/teensy/avr/boards.txt) into Teensy hardware directory (./arduino-1.8.19/hardware/teensy/avr/boards.txt).
214195

215-
Supposing the Arduino version is 1.8.13. This file must be copied into the directory:
196+
Supposing the Arduino version is 1.8.19. These files must be copied into the directory:
216197

217-
- `./arduino-1.8.13/hardware/teensy/avr/boards.txt`
218-
- `./arduino-1.8.13/hardware/teensy/avr/cores/teensy3/Stream.h`
219-
- `./arduino-1.8.13/hardware/teensy/avr/cores/teensy4/Stream.h`
198+
- `./arduino-1.8.19/hardware/teensy/avr/boards.txt`
199+
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy/Stream.h`
200+
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy3/Stream.h`
201+
- `./arduino-1.8.19/hardware/teensy/avr/cores/teensy4/Stream.h`
220202

221203
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
222204
This file must be copied into the directory:
223205

224206
- `./arduino-x.yy.zz/hardware/teensy/avr/boards.txt`
207+
- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h`
225208
- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h`
226209
- `./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h`
227210

@@ -298,24 +281,28 @@ To add UDP Multicast support, necessary for the [**UPnP_Generic library**](https
298281

299282
### HOWTO Fix `Multiple Definitions` Linker Error
300283

301-
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
284+
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
302285

303-
1. **scr_h** for new h-only files
304-
2. **src_cpp** for standard h/cpp files
286+
You can include `.hpp`
287+
288+
```
289+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
290+
#include "TeensyTimerInterrupt.hpp" //https://github.com/khoih-prog/Teensy_TimerInterrupt
305291
306-
besides the standard **src** directory.
292+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
293+
#include "Teensy_ISR_Timer.hpp" //https://github.com/khoih-prog/Teensy_TimerInterrupt
294+
```
307295

308-
To use the **old standard cpp** way, locate this library' directory, then just
296+
in many files. But be sure to use the following `.h` files **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
309297

310-
1. **Delete the all the files in src directory.**
311-
2. **Copy all the files in src_cpp directory into src.**
312-
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
298+
```
299+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
300+
#include "TeensyTimerInterrupt.h" //https://github.com/khoih-prog/Teensy_TimerInterrupt
313301
314-
To re-use the **new h-only** way, just
302+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
303+
#include "Teensy_ISR_Timer.h" //https://github.com/khoih-prog/Teensy_TimerInterrupt
304+
```
315305

316-
1. **Delete the all the files in src directory.**
317-
2. **Copy the files in src_h directory into src.**
318-
3. Close then reopen the application code in Arduino IDE, etc. to recompile from scratch.
319306

320307
---
321308
---
@@ -525,8 +512,8 @@ void setup()
525512
7. [TimerInterruptTest](examples/TimerInterruptTest)
526513
8. [TimerInterruptLEDDemo](examples/TimerInterruptLEDDemo)
527514
9. [**Change_Interval**](examples/Change_Interval). New
528-
10. [**ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex). New
529-
515+
10. [**ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex).
516+
11. [**multiFileProject**](examples/multiFileProject). **New**
530517

531518
---
532519
---
@@ -543,12 +530,15 @@ void setup()
543530
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
544531
// Don't define TIMER_INTERRUPT_DEBUG > 2. Only for special ISR debugging only. Can hang the system.
545532
#define TIMER_INTERRUPT_DEBUG 0
546-
#define _TIMERINTERRUPT_LOGLEVEL_ 0
533+
#define _TIMERINTERRUPT_LOGLEVEL_ 3
547534
535+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
548536
#include "TeensyTimerInterrupt.h"
537+
538+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
549539
#include "Teensy_ISR_Timer.h"
550540
551-
#include <SimpleTimer.h> // https://github.com/schinken/SimpleTimer
541+
#include <SimpleTimer.h> // https://github.com/jfturcot/SimpleTimer
552542
553543
#ifndef LED_BUILTIN
554544
#define LED_BUILTIN 13
@@ -874,11 +864,12 @@ While software timer, **programmed for 2s, is activated after 10.000s in loop()!
874864
In this example, 16 independent ISR Timers are used and utilized just one Hardware Timer. The Timer Intervals and Function Pointers are stored in arrays to facilitate the code modification.
875865

876866
```
877-
Starting ISR_16_Timers_Array on Teensy 4.0/4.1
878-
Teensy_TimerInterrupt v1.2.0
867+
Starting TimerInterruptTest on Teensy 4.1
868+
TeensyTimerInterrupt v1.3.0
879869
CPU Frequency = 600 MHz
880-
TEENSY_TIMER_1, F_BUS_ACTUAL (MHz) = 150, request interval = 1000, actual interval (us) = 999
881-
Prescale = 2, _timerCount = 18750
870+
[TISR] TEENSY_TIMER_1: F_BUS_ACTUAL (MHz) = 150
871+
[TISR] Request interval = 1000, actual interval (us) = 999
872+
[TISR] Prescale = 2, _timerCount = 18750
882873
Starting ITimer OK, millis() = 1241
883874
1s: Delta ms = 1000, ms = 2241
884875
1s: Delta ms = 1000, ms = 3241
@@ -948,11 +939,12 @@ simpleTimerDoingSomething2s: Delta programmed ms = 2000, actual = 10000
948939
The following is the sample terminal output when running example [**TimerInterruptTest**](examples/TimerInterruptTest) on **Teensy 4.1** to demonstrate how to start/stop and the accuracy of Hardware Timers.
949940

950941
```
951-
Starting TimerInterruptTest on Teensy 4.0/4.1
952-
Teensy_TimerInterrupt v1.2.0
942+
Starting TimerInterruptTest on Teensy 4.1
943+
TeensyTimerInterrupt v1.3.0
953944
CPU Frequency = 600 MHz
954-
TEENSY_TIMER_1, F_BUS_ACTUAL (MHz) = 150, request interval = 30000, actual interval (us) = 29999
955-
Prescale = 7, _timerCount = 17578
945+
[TISR] TEENSY_TIMER_1: F_BUS_ACTUAL (MHz) = 150
946+
[TISR] Request interval = 50000, actual interval (us) = 49998
947+
[TISR] Prescale = 7, _timerCount = 29296
956948
Starting ITimer0 OK, millis() = 1128
957949
Stop ITimer0, millis() = 5001
958950
TeensyTimerInterrupt:stopTimer TEENSY_TIMER_1
@@ -991,11 +983,12 @@ TeensyTimerInterrupt:stopTimer TEENSY_TIMER_1
991983
The following is the sample terminal output when running example [**Argument_None**](examples/Argument_None) on **Teensy4.1** to demonstrate the accuracy of Hardware Timers.
992984

993985
```
994-
Starting Argument_None on Teensy 4.0/4.1
995-
Teensy_TimerInterrupt v1.2.0
986+
Starting Argument_None on Teensy 4.1
987+
TeensyTimerInterrupt v1.3.0
996988
CPU Frequency = 600 MHz
997-
TEENSY_TIMER_1, F_BUS_ACTUAL (MHz) = 150, request interval = 50000, actual interval (us) = 49998
998-
Prescale = 7, _timerCount = 29296
989+
[TISR] TEENSY_TIMER_1: F_BUS_ACTUAL (MHz) = 150
990+
[TISR] Request interval = 50000, actual interval (us) = 49998
991+
[TISR] Prescale = 7, _timerCount = 29296
999992
Starting ITimer0 OK, millis() = 629
1000993
ITimer0: millis() = 629, delta = 629
1001994
ITimer0: millis() = 679, delta = 50
@@ -1039,9 +1032,12 @@ ITimer0: millis() = 2179, delta = 50
10391032
The following is the sample terminal output when running example [Change_Interval](examples/Change_Interval) on **Teensy4.1** to demonstrate how to change Timer Interval on-the-fly
10401033

10411034
```
1042-
Starting Change_Interval on Teensy 4.0/4.1
1043-
Teensy_TimerInterrupt v1.2.0
1035+
Starting Change_Interval on Teensy 4.1
1036+
TeensyTimerInterrupt v1.3.0
10441037
CPU Frequency = 600 MHz
1038+
[TISR] TEENSY_TIMER_1: F_BUS_ACTUAL (MHz) = 150
1039+
[TISR] Request interval = 10000, actual interval (us) = 9999
1040+
[TISR] Prescale = 5, _timerCount = 23437
10451041
Starting ITimer OK, millis() = 1432
10461042
Time = 10001, TimerCount = 857
10471043
Time = 20002, TimerCount = 1857
@@ -1071,11 +1067,12 @@ While software timer, **programmed for 2s, is activated after 10.000s in loop()!
10711067
In this example, 16 independent ISR Timers are used, yet utilized just one Hardware Timer. The Timer Intervals and Function Pointers are stored in arrays to facilitate the code modification.
10721068

10731069
```
1074-
Starting ISR_16_Timers_Array_Complex on Teensy 4.0/4.1
1075-
Teensy_TimerInterrupt v1.1.1
1070+
Starting ISR_16_Timers_Array_Complex on Teensy 4.1
1071+
TeensyTimerInterrupt v1.3.0
10761072
CPU Frequency = 600 MHz
1077-
TEENSY_TIMER_1, F_BUS_ACTUAL (MHz) = 150, request interval = 10000, actual interval (us) = 9999
1078-
Prescale = 5, _timerCount = 23437
1073+
[TISR] TEENSY_TIMER_1: F_BUS_ACTUAL (MHz) = 150
1074+
[TISR] Request interval = 10000, actual interval (us) = 9999
1075+
[TISR] Prescale = 5, _timerCount = 23437
10791076
Starting ITimer OK, millis() = 1247
10801077
SimpleTimer : 2s, ms = 11247, Dms : 10000
10811078
Timer : 0, programmed : 5000, actual : 5000
@@ -1242,39 +1239,6 @@ Sometimes, the library will only work if you update the board core to the latest
12421239
---
12431240
---
12441241

1245-
## Releases
1246-
1247-
### Releases v1.2.0
1248-
1249-
1. Add better debug feature.
1250-
2. Optimize code and examples to reduce RAM usage
1251-
3. Add Table of Contents
1252-
1253-
### Releases v1.1.1
1254-
1255-
1. Add example [**Change_Interval**](examples/Change_Interval) and [**ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex)
1256-
2. Bump up version to sync with other TimerInterrupt Libraries. Modify Version String.
1257-
1258-
### Releases v1.0.1
1259-
1260-
1. Add complicated example [ISR_16_Timers_Array](examples/ISR_16_Timers_Array) utilizing and demonstrating the full usage of 16 independent ISR Timers.
1261-
1262-
### Releases v1.0.0
1263-
1264-
1. Permit up to 16 super-long-time, super-accurate ISR-based timers to avoid being blocked
1265-
2. Using cpp code besides Impl.h code to use if Multiple-Definition linker error.
1266-
1267-
#### Supported Boards
1268-
1269-
1. **Teensy boards** such as :
1270-
1271-
- **Teensy 4.1, 4.0**
1272-
- **Teensy 3.6, 3.5, 3.2/3.1, 3.0**
1273-
- **Teensy LC**
1274-
- **Teensy++ 2.0 and Teensy 2.0**
1275-
1276-
---
1277-
---
12781242

12791243
### Issues
12801244

@@ -1296,6 +1260,8 @@ Submit issues to: [Teensy_TimerInterrupt issues](https://github.com/khoih-prog/T
12961260
3. Longer time interval
12971261
4. Similar features for remaining Arduino boards such as AVR, ESP32, ESP8266, STM32, SAM-DUE, SAMD21/SAMD51, mbed-nRF52, nRF52, etc.
12981262
5. Add Table of Contents
1263+
6. Fix `multiple-definitions` linker error
1264+
7. Optimize library code by using `reference-passing` instead of `value-passing`
12991265

13001266
---
13011267
---

changelog.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Teensy_TimerInterrupt Library
2+
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/Teensy_TimerInterrupt.svg?)](https://www.ardu-badge.com/Teensy_TimerInterrupt)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/Teensy_TimerInterrupt.svg)](https://github.com/khoih-prog/Teensy_TimerInterrupt/releases)
5+
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/Teensy_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/Teensy_TimerInterrupt.svg)](http://github.com/khoih-prog/Teensy_TimerInterrupt/issues)
8+
9+
---
10+
---
11+
12+
## Table of Contents
13+
14+
* [Changelog](#changelog)
15+
* [Releases v1.3.0](#releases-v130)
16+
* [Releases v1.2.0](#releases-v120)
17+
* [Releases v1.1.1](#releases-v111)
18+
* [Releases v1.0.1](#releases-v101)
19+
* [Releases v1.0.0](#releases-v100)
20+
21+
---
22+
---
23+
24+
## Changelog
25+
26+
### Releases v1.3.0
27+
28+
1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
29+
2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project.
30+
3. Optimize library code by using `reference-passing` instead of `value-passing`
31+
4. Update all examples
32+
33+
### Releases v1.2.0
34+
35+
1. Add better debug feature.
36+
2. Optimize code and examples to reduce RAM usage
37+
3. Add Table of Contents
38+
39+
### Releases v1.1.1
40+
41+
1. Add example [**Change_Interval**](examples/Change_Interval) and [**ISR_16_Timers_Array_Complex**](examples/ISR_16_Timers_Array_Complex)
42+
2. Bump up version to sync with other TimerInterrupt Libraries. Modify Version String.
43+
44+
### Releases v1.0.1
45+
46+
1. Add complicated example [ISR_16_Timers_Array](examples/ISR_16_Timers_Array) utilizing and demonstrating the full usage of 16 independent ISR Timers.
47+
48+
### Releases v1.0.0
49+
50+
1. Permit up to 16 super-long-time, super-accurate ISR-based timers to avoid being blocked
51+
2. Using cpp code besides Impl.h code to use if Multiple-Definition linker error.
52+

0 commit comments

Comments
 (0)