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

Commit

Permalink
v1.2.0 to fix multiple-definitions linker error
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
khoih-prog authored Jan 30, 2022
1 parent e09a132 commit d068df5
Show file tree
Hide file tree
Showing 20 changed files with 1,502 additions and 1,464 deletions.
12 changes: 7 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p

Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.16) or Platform.io version
* `ESP32` Core Version (e.g. ESP32 core v2.0.0)
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `ESP32` Core Version (e.g. ESP32 core v2.0.2)
* `ESP32` Board type (e.g. ESP32_DEV Module, etc.)
* `ESP32-S2` Board type (e.g. ESP32S2_DEV Module, ESP32_S2_Saola, etc.)
* `ESP32-C3` Board type (e.g. ESP32C3_DEV Module, etc.)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
Expand All @@ -27,11 +29,11 @@ Please ensure to specify the following:
### Example

```
Arduino IDE version: 1.8.16
ESP32 core v2.0.0
Arduino IDE version: 1.8.19
ESP32 core v2.0.2
ESP32S2_DEV Module
OS: Ubuntu 20.04 LTS
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
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
Context:
I encountered a crash while using TimerInterrupt.
Expand Down
562 changes: 244 additions & 318 deletions README.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## Table of Contents

* [Changelog](#changelog)
* [Releases v1.2.0](#releases-v120)
* [Releases v1.1.1](#releases-v111)
* [Releases v1.1.0](#releases-v110)
* [Releases v1.0.1](#releases-v101)
Expand All @@ -22,6 +23,14 @@

## Changelog

### 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

### Releases v1.1.1

1. Fix examples to not use GPIO1/TX0 for core v2.0.1+
Expand Down
39 changes: 26 additions & 13 deletions examples/ISR_16_PWMs_Array/ISR_16_PWMs_Array.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
Therefore, their executions are not blocked by bad-behaving functions / tasks.
This important feature is absolutely necessary for mission-critical tasks.
*****************************************************************************************************************************/

#if !defined( ESP32 )
#error This code is designed to run on ESP32 platform, not Arduino nor ESP8266! Please check your Tools->Board setting.
#elif ( ARDUINO_ESP32C3_DEV )
#error This code is not designed to run on ESP32-C3 platform! Please check your Tools->Board setting.

#endif

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

#define USING_MICROS_RESOLUTION true //false

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

#ifndef LED_BUILTIN
Expand Down Expand Up @@ -66,7 +67,11 @@ bool IRAM_ATTR TimerHandler(void * timerNo)

//////////////////////////////////////////////////////

#define NUMBER_ISR_PWMS 16
#if ( ARDUINO_ESP32C3_DEV )
#define NUMBER_ISR_PWMS 4
#else
#define NUMBER_ISR_PWMS 16
#endif

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

// You can assign pins here. Be carefull to select good pin to use or crash, e.g pin 6-11
// Can't use PIN_D1 for core v2.0.1+
uint32_t PWM_Pin[NUMBER_ISR_PWMS] =

#if ( ARDUINO_ESP32C3_DEV )
uint32_t PWM_Pin[] =
// Bad pins to use: PIN_D12-PIN_D24
{
LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5
};
#else
uint32_t PWM_Pin[] =
{
PIN_D24, LED_BUILTIN, PIN_D3, PIN_D4, PIN_D5, PIN_D12, PIN_D13, PIN_D14,
PIN_D15, PIN_D16, PIN_D17, PIN_D18, PIN_D19, PIN_D21, PIN_D22, PIN_D23
};
#endif

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

// You can assign any interval for any timer here, in Hz
double PWM_Freq[NUMBER_ISR_PWMS] =
double PWM_Freq[] =
{
1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f,
9.0f, 10.0f, 15.0f, 20.0f, 25.0f, 30.0f, 40.0f, 50.0f
};


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

typedef void (*irqCallback) ();
Expand Down Expand Up @@ -197,7 +210,7 @@ void doingSomething15()
{
}

irqCallback irqCallbackStartFunc[NUMBER_ISR_PWMS] =
irqCallback irqCallbackStartFunc[] =
{
doingSomething0, doingSomething1, doingSomething2, doingSomething3,
doingSomething4, doingSomething5, doingSomething6, doingSomething7,
Expand Down
Loading

0 comments on commit d068df5

Please sign in to comment.