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

Commit d068df5

Browse files
authored
v1.2.0 to fix multiple-definitions linker error
### Releases v1.2.0 1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories 2. Add support to `ESP32_C3` 3. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project 4. Improve accuracy by using `double`, instead of `uint32_t` for `dutycycle`, `period` 5. Update examples accordingly
1 parent e09a132 commit d068df5

20 files changed

+1502
-1464
lines changed

CONTRIBUTING.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ 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.0)
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, etc.)
1920
* `ESP32-S2` Board type (e.g. ESP32S2_DEV Module, ESP32_S2_Saola, etc.)
21+
* `ESP32-C3` Board type (e.g. ESP32C3_DEV Module, etc.)
2022
* Contextual information (e.g. what you were trying to achieve)
2123
* Simplest possible steps to reproduce
2224
* Anything that might be relevant in your opinion, such as:
@@ -27,11 +29,11 @@ Please ensure to specify the following:
2729
### Example
2830

2931
```
30-
Arduino IDE version: 1.8.16
31-
ESP32 core v2.0.0
32+
Arduino IDE version: 1.8.19
33+
ESP32 core v2.0.2
3234
ESP32S2_DEV Module
3335
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
36+
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
3537
3638
Context:
3739
I encountered a crash while using TimerInterrupt.

README.md

+244-318
Large diffs are not rendered by default.

changelog.md

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.2.0](#releases-v120)
1516
* [Releases v1.1.1](#releases-v111)
1617
* [Releases v1.1.0](#releases-v110)
1718
* [Releases v1.0.1](#releases-v101)
@@ -22,6 +23,14 @@
2223

2324
## Changelog
2425

26+
### Releases v1.2.0
27+
28+
1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
29+
2. Add support to `ESP32_C3`
30+
3. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project
31+
4. Improve accuracy by using `double`, instead of `uint32_t` for `dutycycle`, `period`
32+
5. Update examples accordingly
33+
2534
### Releases v1.1.1
2635

2736
1. Fix examples to not use GPIO1/TX0 for core v2.0.1+

examples/ISR_16_PWMs_Array/ISR_16_PWMs_Array.ino

+26-13
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
Therefore, their executions are not blocked by bad-behaving functions / tasks.
2121
This important feature is absolutely necessary for mission-critical tasks.
2222
*****************************************************************************************************************************/
23+
2324
#if !defined( ESP32 )
2425
#error This code is designed to run on ESP32 platform, not Arduino nor ESP8266! Please check your Tools->Board setting.
25-
#elif ( ARDUINO_ESP32C3_DEV )
26-
#error This code is not designed to run on ESP32-C3 platform! Please check your Tools->Board setting.
26+
2727
#endif
2828

2929
// These define's must be placed at the beginning before #include "ESP32_PWM.h"
@@ -33,6 +33,7 @@
3333

3434
#define USING_MICROS_RESOLUTION true //false
3535

36+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
3637
#include "ESP32_PWM.h"
3738

3839
#ifndef LED_BUILTIN
@@ -66,7 +67,11 @@ bool IRAM_ATTR TimerHandler(void * timerNo)
6667

6768
//////////////////////////////////////////////////////
6869

69-
#define NUMBER_ISR_PWMS 16
70+
#if ( ARDUINO_ESP32C3_DEV )
71+
#define NUMBER_ISR_PWMS 4
72+
#else
73+
#define NUMBER_ISR_PWMS 16
74+
#endif
7075

7176
#define PIN_D0 0 // Pin D0 mapped to pin GPIO0/BOOT/ADC11/TOUCH1 of ESP32
7277
#define PIN_D1 1 // Pin D1 mapped to pin GPIO1/TX0 of ESP32
@@ -99,32 +104,40 @@ bool IRAM_ATTR TimerHandler(void * timerNo)
99104

100105
// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
101106
// Can't use PIN_D1 for core v2.0.1+
102-
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =
107+
108+
#if ( ARDUINO_ESP32C3_DEV )
109+
uint32_t PWM_Pin[] =
110+
// Bad pins to use: PIN_D12-PIN_D24
111+
{
112+
LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5
113+
};
114+
#else
115+
uint32_t PWM_Pin[] =
103116
{
104117
PIN_D24, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
105118
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
106119
};
120+
#endif
107121

108122
// You can assign any interval for any timer here, in microseconds
109-
uint32_t PWM_Period[NUMBER_ISR_PWMS] =
123+
double PWM_Period[] =
110124
{
111-
1000000L, 500000L, 333333L, 250000L, 200000L, 166667L, 142857L, 125000L,
112-
111111L, 100000L, 66667L, 50000L, 40000L, 33333L, 25000L, 20000L
125+
1000000.0, 500000.0, 333333.333, 250000.0, 200000.0, 166666.666, 142857.143, 125000.0,
126+
111111.111, 100000.0, 66666.666, 50000.0, 40000.0, 33333.333, 25000.0, 20000.0
113127
};
114128

115129
// You can assign any interval for any timer here, in Hz
116-
double PWM_Freq[NUMBER_ISR_PWMS] =
130+
double PWM_Freq[] =
117131
{
118132
1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
119133
9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f
120134
};
121135

122-
123136
// You can assign any interval for any timer here, in milliseconds
124-
uint32_t PWM_DutyCycle[NUMBER_ISR_PWMS] =
137+
double PWM_DutyCycle[] =
125138
{
126-
5, 10, 20, 30, 40, 45, 50, 55,
127-
60, 65, 70, 75, 80, 85, 90, 95
139+
5.00, 10.00, 20.00, 30.00, 40.00, 45.00, 50.00, 55.00,
140+
60.00, 65.00, 70.00, 75.00, 80.00, 85.00, 90.00, 95.00
128141
};
129142

130143
typedef void (*irqCallback) ();
@@ -197,7 +210,7 @@ void doingSomething15()
197210
{
198211
}
199212

200-
irqCallback irqCallbackStartFunc[NUMBER_ISR_PWMS] =
213+
irqCallback irqCallbackStartFunc[] =
201214
{
202215
doingSomething0, doingSomething1, doingSomething2, doingSomething3,
203216
doingSomething4, doingSomething5, doingSomething6, doingSomething7,

0 commit comments

Comments
 (0)