Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f010d88221 | ||
|
|
b99aafc23a | ||
|
|
f2ca9ced6e | ||
|
|
45f0418bfe |
@@ -35,24 +35,27 @@ If applicable, add screenshots to help explain your problem.
|
||||
|
||||
Please ensure to specify the following:
|
||||
|
||||
* Arduino IDE version (e.g. 1.8.13) or Platform.io version
|
||||
* `ESP8266`,`ESP32` or `STM32` Core Version (e.g. ESP8266 core v2.7.4, ESP32 v1.0.5 or STM32 v1.9.0)
|
||||
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
|
||||
* `RP2040` Core Version (e.g. RP2040 core v2.5.4)
|
||||
* `RP2040` Board type (e.g. RASPBERRY_PI_PICO, RASPBERRY_PI_PICO_W, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, 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:
|
||||
* Operating system (Windows, Ubuntu, etc.) and the output of `uname -a`
|
||||
* Network configuration
|
||||
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```
|
||||
Arduino IDE version: 1.8.13
|
||||
ESP32 Core Version 1.0.5
|
||||
Arduino IDE version: 1.8.19
|
||||
RP2040 core v2.5.4
|
||||
RASPBERRY_PI_PICO Module
|
||||
OS: Ubuntu 20.04 LTS
|
||||
Linux xy-Inspiron-3593 5.4.0-66-generic #74-Ubuntu SMP Wed Jan 27 22:54:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
|
||||
Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
|
||||
|
||||
Context:
|
||||
I encountered an endless loop while trying to connect to Local WiFi.
|
||||
I encountered a crash while using this library
|
||||
|
||||
Steps to reproduce:
|
||||
1. ...
|
||||
|
||||
+6
-5
@@ -15,8 +15,8 @@ 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.19) or Platform.io version
|
||||
* `RP2040` Core Version (e.g. RP2040 core v1.9.14)
|
||||
* `RP2040` Board type (e.g. RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc.)
|
||||
* `RP2040` Core Version (e.g. RP2040 core v2.5.4)
|
||||
* `RP2040` Board type (e.g. RASPBERRY_PI_PICO, RASPBERRY_PI_PICO_W, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, 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:
|
||||
@@ -28,13 +28,13 @@ Please ensure to specify the following:
|
||||
|
||||
```
|
||||
Arduino IDE version: 1.8.19
|
||||
RP2040 core v1.9.14
|
||||
RP2040 core v2.5.4
|
||||
RASPBERRY_PI_PICO Module
|
||||
OS: Ubuntu 20.04 LTS
|
||||
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
|
||||
Linux xy-Inspiron-3593 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
|
||||
|
||||
Context:
|
||||
I encountered a crash while using TimerInterrupt.
|
||||
I encountered a crash while using this library
|
||||
|
||||
Steps to reproduce:
|
||||
1. ...
|
||||
@@ -51,3 +51,4 @@ There are usually some outstanding feature requests in the [existing issues list
|
||||
### Sending Pull Requests
|
||||
|
||||
Pull Requests with changes and fixes are also welcome!
|
||||
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
[](https://www.ardu-badge.com/RPI_PICO_TimerInterrupt)
|
||||
[](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/releases)
|
||||
[](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/blob/master/LICENSE)
|
||||
[](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/blob/main/LICENSE)
|
||||
[](#Contributing)
|
||||
[](http://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues)
|
||||
|
||||
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
|
||||
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
@@ -74,6 +77,8 @@
|
||||
|
||||
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
|
||||
|
||||
---
|
||||
|
||||
### Why do we need this [RPI_PICO_TimerInterrupt library](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt)
|
||||
|
||||
## Features
|
||||
@@ -117,7 +122,7 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
|
||||
|
||||
### Currently supported Boards
|
||||
|
||||
1. RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, Nano_RP2040_Connect, GENERIC_RP2040**, etc.
|
||||
1. RP2040-based boards such as **RASPBERRY_PI_PICO, RASPBERRY_PI_PICO_W, ADAFRUIT_FEATHER_RP2040, Nano_RP2040_Connect, GENERIC_RP2040**, etc., using [`arduino-pico core`](https://github.com/earlephilhower/arduino-pico)
|
||||
|
||||
---
|
||||
|
||||
@@ -135,7 +140,7 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
|
||||
## Prerequisites
|
||||
|
||||
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [](https://github.com/arduino/Arduino/releases/latest)
|
||||
2. [`Earle Philhower's arduino-pico core v1.9.14+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [](https://github.com/earlephilhower/arduino-pico/releases/latest)
|
||||
2. [`Earle Philhower's arduino-pico core v2.5.4+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [](https://github.com/earlephilhower/arduino-pico/releases/latest)
|
||||
3. To use with certain example
|
||||
- [`SimpleTimer library`](https://github.com/jfturcot/SimpleTimer) for [ISR_Timers_Array_Simple](examples/ISR_Timers_Array_Simple) and [ISR_16_Timers_Array_Complex](examples/ISR_16_Timers_Array_Complex) examples.
|
||||
|
||||
@@ -155,15 +160,15 @@ You can also use this link [ page.
|
||||
2. Download the latest release `RPI_PICO_TimerInterrupt-master.zip`.
|
||||
3. Extract the zip file to `RPI_PICO_TimerInterrupt-master` directory
|
||||
4. Copy whole `RPI_PICO_TimerInterrupt-master` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
|
||||
2. Download the latest release `RPI_PICO_TimerInterrupt-main.zip`.
|
||||
3. Extract the zip file to `RPI_PICO_TimerInterrupt-main` directory
|
||||
4. Copy whole `RPI_PICO_TimerInterrupt-main` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
|
||||
|
||||
### VS Code & PlatformIO
|
||||
|
||||
1. Install [VS Code](https://code.visualstudio.com/)
|
||||
2. Install [PlatformIO](https://platformio.org/platformio-ide)
|
||||
3. Install [**RPI_PICO_TimerInterrupt** library](https://platformio.org/lib/show/12177/RPI_PICO_TimerInterrupt) or [**RPI_PICO_TimerInterrupt** library](https://platformio.org/lib/show/12273/RPI_PICO_TimerInterrupt) by using [Library Manager](https://platformio.org/lib/show/12177/RPI_PICO_TimerInterrupt/installation). Search for **RPI_PICO_TimerInterrupt** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
|
||||
3. Install [**RPI_PICO_TimerInterrupt** library](https://registry.platformio.org/libraries/khoih-prog/RPI_PICO_TimerInterrupt) by using [Library Manager](https://registry.platformio.org/libraries/khoih-prog/RPI_PICO_TimerInterrupt/installation). Search for **RPI_PICO_TimerInterrupt** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22)
|
||||
4. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html)
|
||||
|
||||
|
||||
@@ -443,152 +448,8 @@ void setup()
|
||||
|
||||
### Example [ISR_Timers_Array_Simple](examples/ISR_Timers_Array_Simple)
|
||||
|
||||
```
|
||||
// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
|
||||
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
|
||||
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
|
||||
#define TIMER_INTERRUPT_DEBUG 1
|
||||
#define _TIMERINTERRUPT_LOGLEVEL_ 4
|
||||
https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/blob/f2ca9ced6ef985653cb234a3268b237b0fa257f1/examples/ISR_Timers_Array_Simple/ISR_Timers_Array_Simple.ino#L23-L166
|
||||
|
||||
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
|
||||
#include "RPi_Pico_TimerInterrupt.h"
|
||||
|
||||
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
|
||||
#include "RPi_Pico_ISR_Timer.h"
|
||||
|
||||
#include <SimpleTimer.h> // https://github.com/jfturcot/SimpleTimer
|
||||
|
||||
// Init RPI_PICO_Timer
|
||||
RPI_PICO_Timer ITimer1(1);
|
||||
|
||||
RPI_PICO_ISR_Timer ISR_timer;
|
||||
|
||||
#ifndef LED_BUILTIN
|
||||
#define LED_BUILTIN 25
|
||||
#endif
|
||||
|
||||
#define LED_TOGGLE_INTERVAL_MS 1000L
|
||||
|
||||
// You have to use longer time here if having problem because Arduino AVR clock is low, 16MHz => lower accuracy.
|
||||
// Tested OK with 1ms when not much load => higher accuracy.
|
||||
#define TIMER_INTERVAL_MS 1L
|
||||
|
||||
volatile uint32_t startMillis = 0;
|
||||
|
||||
volatile uint32_t deltaMillis2s = 0;
|
||||
volatile uint32_t deltaMillis5s = 0;
|
||||
|
||||
volatile uint32_t previousMillis2s = 0;
|
||||
volatile uint32_t previousMillis5s = 0;
|
||||
|
||||
|
||||
bool TimerHandler(struct repeating_timer *t)
|
||||
{
|
||||
static bool toggle = false;
|
||||
static int timeRun = 0;
|
||||
|
||||
ISR_timer.run();
|
||||
|
||||
// Toggle LED every LED_TOGGLE_INTERVAL_MS = 2000ms = 2s
|
||||
if (++timeRun == ((LED_TOGGLE_INTERVAL_MS) / TIMER_INTERVAL_MS) )
|
||||
{
|
||||
timeRun = 0;
|
||||
|
||||
//timer interrupt toggles pin LED_BUILTIN
|
||||
digitalWrite(LED_BUILTIN, toggle);
|
||||
toggle = !toggle;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void doingSomething2s()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
deltaMillis2s = currentMillis - previousMillis2s;
|
||||
previousMillis2s = currentMillis;
|
||||
}
|
||||
|
||||
void doingSomething5s()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
|
||||
deltaMillis5s = currentMillis - previousMillis5s;
|
||||
previousMillis5s = currentMillis;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
#define SIMPLE_TIMER_MS 2000L
|
||||
|
||||
// Init SimpleTimer
|
||||
SimpleTimer simpleTimer;
|
||||
|
||||
// Here is software Timer, you can do somewhat fancy stuffs without many issues.
|
||||
// But always avoid
|
||||
// 1. Long delay() it just doing nothing and pain-without-gain wasting CPU power.Plan and design your code / strategy ahead
|
||||
// 2. Very long "do", "while", "for" loops without predetermined exit time.
|
||||
void simpleTimerDoingSomething2s()
|
||||
{
|
||||
static unsigned long previousMillis = startMillis;
|
||||
|
||||
unsigned long currMillis = millis();
|
||||
|
||||
Serial.print(F("SimpleTimer : programmed ")); Serial.print(SIMPLE_TIMER_MS);
|
||||
Serial.print(F("ms, current time ms : ")); Serial.print(currMillis);
|
||||
Serial.print(F(", Delta ms : ")); Serial.println(currMillis - previousMillis);
|
||||
|
||||
Serial.print(F("Timer2s actual : ")); Serial.println(deltaMillis2s);
|
||||
Serial.print(F("Timer5s actual : ")); Serial.println(deltaMillis5s);
|
||||
|
||||
previousMillis = currMillis;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial);
|
||||
|
||||
Serial.print(F("\nStarting ISR_Timers_Array_Simple on ")); Serial.println(BOARD_NAME);
|
||||
Serial.println(RPI_PICO_TIMER_INTERRUPT_VERSION);
|
||||
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
|
||||
|
||||
if (ITimer1.attachInterruptInterval(TIMER_INTERVAL_MS * 1000, TimerHandler))
|
||||
{
|
||||
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
|
||||
}
|
||||
else
|
||||
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
|
||||
|
||||
previousMillis5s = previousMillis2s = millis();
|
||||
|
||||
ISR_timer.setInterval(2000L, doingSomething2s);
|
||||
ISR_timer.setInterval(5000L, doingSomething5s);
|
||||
|
||||
// You need this timer for non-critical tasks. Avoid abusing ISR if not absolutely necessary.
|
||||
simpleTimer.setInterval(SIMPLE_TIMER_MS, simpleTimerDoingSomething2s);
|
||||
}
|
||||
|
||||
#define BLOCKING_TIME_MS 10000L
|
||||
|
||||
void loop()
|
||||
{
|
||||
// This unadvised blocking task is used to demonstrate the blocking effects onto the execution and accuracy to Software timer
|
||||
// You see the time elapse of ISR_Timer still accurate, whereas very unaccurate for Software Timer
|
||||
// The time elapse for 2000ms software timer now becomes 3000ms (BLOCKING_TIME_MS)
|
||||
// While that of ISR_Timer is still prefect.
|
||||
delay(BLOCKING_TIME_MS);
|
||||
|
||||
// You need this Software timer for non-critical tasks. Avoid abusing ISR if not absolutely necessary
|
||||
// You don't need to and never call ISR_Timer.run() here in the loop(). It's already handled by ISR timer.
|
||||
simpleTimer.run();
|
||||
}
|
||||
```
|
||||
---
|
||||
---
|
||||
|
||||
@@ -603,7 +464,7 @@ While software timer, **programmed for 2s, is activated after more than 10.000s
|
||||
```
|
||||
|
||||
Starting ISR_Timers_Array_Simple on RASPBERRY_PI_PICO
|
||||
RPi_Pico_TimerInterrupt v1.2.0
|
||||
RPi_Pico_TimerInterrupt v1.3.0
|
||||
CPU Frequency = 125 MHz
|
||||
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 1000.00
|
||||
[TISR] _count = 0-1000
|
||||
@@ -628,7 +489,7 @@ The following is the sample terminal output when running example [TimerInterrupt
|
||||
|
||||
```
|
||||
Starting TimerInterruptTest on RASPBERRY_PI_PICO
|
||||
RPi_Pico_TimerInterrupt v1.2.0
|
||||
RPi_Pico_TimerInterrupt v1.3.0
|
||||
CPU Frequency = 125 MHz
|
||||
[TISR] _timerNo = 0, Clock (Hz) = 1000000.00, _fre (Hz) = 1.00
|
||||
[TISR] _count = 0-1000000
|
||||
@@ -672,7 +533,7 @@ The following is the sample terminal output when running example [Change_Interva
|
||||
|
||||
```
|
||||
Starting Change_Interval on RASPBERRY_PI_PICO
|
||||
RPi_Pico_TimerInterrupt v1.2.0
|
||||
RPi_Pico_TimerInterrupt v1.3.0
|
||||
CPU Frequency = 125 MHz
|
||||
[TISR] _timerNo = 0, Clock (Hz) = 1000000.00, _fre (Hz) = 0.50
|
||||
[TISR] _count = 0-2000000
|
||||
@@ -753,7 +614,7 @@ The following is the sample terminal output when running example [SwitchDebounce
|
||||
|
||||
```
|
||||
Starting SwitchDebounce on RASPBERRY_PI_PICO
|
||||
RPi_Pico_TimerInterrupt v1.2.0
|
||||
RPi_Pico_TimerInterrupt v1.3.0
|
||||
CPU Frequency = 125 MHz
|
||||
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 50.00
|
||||
[TISR] _count = 0-20000
|
||||
@@ -778,7 +639,7 @@ The following is the sample terminal output when running example [ISR_Timers_Arr
|
||||
|
||||
```
|
||||
Starting ISR_Timers_Array_Simple on RASPBERRY_PI_PICO
|
||||
RPi_Pico_TimerInterrupt v1.2.0
|
||||
RPi_Pico_TimerInterrupt v1.3.0
|
||||
CPU Frequency = 125 MHz
|
||||
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 1000.00
|
||||
[TISR] _count = 0-1000
|
||||
@@ -801,7 +662,7 @@ The following is the sample terminal output when running example [ISR_16_Timers_
|
||||
|
||||
```
|
||||
Starting ISR_16_Timers_Array_Complex on RASPBERRY_PI_PICO
|
||||
RPi_Pico_TimerInterrupt v1.2.0
|
||||
RPi_Pico_TimerInterrupt v1.3.0
|
||||
CPU Frequency = 125 MHz
|
||||
[TISR] _timerNo = 1, Clock (Hz) = 1000000.00, _fre (Hz) = 100.00
|
||||
[TISR] _count = 0-10000
|
||||
@@ -997,7 +858,7 @@ Submit issues to: [RPI_PICO_TimerInterrupt issues](https://github.com/khoih-prog
|
||||
6. Add support to new boards (**ADAFRUIT_ITSYBITSY_RP2040, ADAFRUIT_QTPY_RP2040, ADAFRUIT_STEMMAFRIEND_RP2040, ADAFRUIT_TRINKEYQT_RP2040, ADAFRUIT_MACROPAD_RP2040, SPARKFUN_PROMICRO_RP2040, Nano_RP2040_Connect, etc.**) using the arduino-pico core
|
||||
7. Fix `multiple-definitions` linker error
|
||||
8. Optimize library code by using `reference-passing` instead of `value-passing`
|
||||
|
||||
9. Fix severe bug affecting time between the starts. Check [Enable fixed timing between timer calls (vs fixed time btw. end of timer call and next call as implemented) #3](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues/3)
|
||||
|
||||
---
|
||||
---
|
||||
@@ -1006,6 +867,14 @@ Submit issues to: [RPI_PICO_TimerInterrupt issues](https://github.com/khoih-prog
|
||||
|
||||
Many thanks for everyone for bug reporting, new feature suggesting, testing and contributing to the development of this library.
|
||||
|
||||
1. [AndreasOKircher](https://github.com/AndreasOKircher) to report issue [Enable fixed timing between timer calls (vs fixed time btw. end of timer call and next call as implemented) #3](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues/3) leading to version v1.3.0 to fix `severe bug` affecting time between the starts
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/AndreasOKircher"><img src="https://github.com/AndreasOKircher.png" width="100px;" alt="AndreasOKircher"/><br /><sub><b>AndreasOKircher</b></sub></a><br /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
---
|
||||
|
||||
@@ -1022,7 +891,7 @@ If you want to contribute to this project:
|
||||
|
||||
### License
|
||||
|
||||
- The library is licensed under [MIT](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/blob/master/LICENSE)
|
||||
- The library is licensed under [MIT](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/blob/main/LICENSE)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
## Table of Contents
|
||||
|
||||
* [Changelog](#changelog)
|
||||
* [Releases v1.3.0](#releases-v130)
|
||||
* [Releases v1.2.0](#releases-v120)
|
||||
* [Releases v1.1.1](#releases-v111)
|
||||
* [Releases v1.1.0](#releases-v110)
|
||||
@@ -24,6 +25,11 @@
|
||||
|
||||
## Changelog
|
||||
|
||||
### Releases v1.3.0
|
||||
|
||||
1. Fix severe bug affecting time between the starts. Check [Enable fixed timing between timer calls (vs fixed time btw. end of timer call and next call as implemented) #3](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues/3)
|
||||
|
||||
|
||||
### Releases v1.2.0
|
||||
|
||||
1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "RPi_Pico_TimerInterrupt.h"
|
||||
|
||||
#ifndef LED_BUILTIN
|
||||
#define LED_BUILTIN 25 // Pin LED_BUILTIN mapped to pin GPIO25 of RPI_PICO, control on-board LED
|
||||
#define LED_BUILTIN 25
|
||||
#endif
|
||||
|
||||
#define PIN_D1 1 // Pin D1 mapped to pin GPIO1 of RPI_PICO
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "RPi_Pico_TimerInterrupt.h"
|
||||
|
||||
#ifndef LED_BUILTIN
|
||||
#define LED_BUILTIN 25 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
|
||||
#define LED_BUILTIN 25
|
||||
#endif
|
||||
|
||||
#define PIN_D1 1 // Pin D1 mapped to pin GPIO1 of RPI_PICO
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include "RPi_Pico_TimerInterrupt.h"
|
||||
|
||||
#ifndef LED_BUILTIN
|
||||
#define LED_BUILTIN 25 // Pin D2 mapped to pin GPIO2/ADC12 of ESP32, control on-board LED
|
||||
#define LED_BUILTIN 25
|
||||
#endif
|
||||
|
||||
#define PIN_D1 1 // Pin D1 mapped to pin GPIO1 of RPI_PICO
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "RPI_PICO_TimerInterrupt",
|
||||
"version": "1.2.0",
|
||||
"keywords": "timing, device, control, timer, interrupt, hardware, isr, isr-based, hardware-timer, mission-critical, accuracy, precise, non-blocking, raspberry-pico, rpi-pico, pico, rp2040, arduino-pico",
|
||||
"version": "1.3.0",
|
||||
"keywords": "timing, device, control, timer, interrupt, hardware, isr, isr-based, hardware-timer, mission-critical, accuracy, non-blocking, raspberry-pico, rpi-pico, pico, rp2040, arduino-pico, rp2040w, raspberry-pico-w, pico-w",
|
||||
"description": "This library enables you to use Interrupt from Hardware Timers on RP2040-based boards such as RASPBERRY_PI_PICO. 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.",
|
||||
"authors":
|
||||
{
|
||||
@@ -12,7 +12,7 @@
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "//https://github.com/khoih-prog/RPI_PICO_TimerInterrupt"
|
||||
"url": "https://github.com/khoih-prog/RPI_PICO_TimerInterrupt"
|
||||
},
|
||||
"homepage": "https://github.com/khoih-prog/RPI_PICO_TimerInterrupt",
|
||||
"export": {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
name=RPI_PICO_TimerInterrupt
|
||||
version=1.2.0
|
||||
version=1.3.0
|
||||
author=Khoi Hoang <khoih.prog@gmail.com>
|
||||
maintainer=Khoi Hoang <khoih.prog@gmail.com>
|
||||
sentence=This library enables you to use Interrupt from Hardware Timers on RP2040-based boards such as RASPBERRY_PI_PICO
|
||||
|
||||
@@ -38,7 +38,10 @@ upload_speed = 921600
|
||||
;monitor_port = COM11
|
||||
|
||||
; Checks for the compatibility with frameworks and dev/platforms
|
||||
; To adjust as necessary
|
||||
lib_compat_mode = strict
|
||||
lib_ldf_mode = chain+
|
||||
;lib_ldf_mode = deep+
|
||||
|
||||
lib_deps =
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.2.0
|
||||
Version: 1.3.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -33,7 +33,8 @@
|
||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
||||
1.1.0 K Hoang 10/00/2021 Add support to new boards using the arduino-pico core
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error.
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -43,11 +44,15 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
RPI_PICO_ISR_Timer::RPI_PICO_ISR_Timer()
|
||||
: numTimers (-1)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::init()
|
||||
{
|
||||
unsigned long current_millis = millis(); //elapsed();
|
||||
@@ -61,6 +66,8 @@ void RPI_PICO_ISR_Timer::init()
|
||||
numTimers = 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::run()
|
||||
{
|
||||
uint8_t i;
|
||||
@@ -136,6 +143,7 @@ void RPI_PICO_ISR_Timer::run()
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// find the first available slot
|
||||
// return -1 if none found
|
||||
@@ -160,6 +168,7 @@ int RPI_PICO_ISR_Timer::findFirstFreeSlot()
|
||||
return -1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setupTimer(const unsigned long& d, void* f, void* p, bool h, const unsigned& n)
|
||||
{
|
||||
@@ -194,37 +203,50 @@ int RPI_PICO_ISR_Timer::setupTimer(const unsigned long& d, void* f, void* p, boo
|
||||
return freeTimer;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimer(const unsigned long& d, timer_callback f, const unsigned& n)
|
||||
{
|
||||
return setupTimer(d, (void *)f, NULL, false, n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimer(const unsigned long& d, timer_callback_p f, void* p, const unsigned& n)
|
||||
{
|
||||
return setupTimer(d, (void *)f, p, true, n);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setInterval(const unsigned long& d, timer_callback f)
|
||||
{
|
||||
return setupTimer(d, (void *)f, NULL, false, RPI_PICO_RUN_FOREVER);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setInterval(const unsigned long& d, timer_callback_p f, void* p)
|
||||
{
|
||||
return setupTimer(d, (void *)f, p, true, RPI_PICO_RUN_FOREVER);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimeout(const unsigned long& d, timer_callback f)
|
||||
{
|
||||
return setupTimer(d, (void *)f, NULL, false, RPI_PICO_RUN_ONCE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int RPI_PICO_ISR_Timer::setTimeout(const unsigned long& d, timer_callback_p f, void* p)
|
||||
{
|
||||
return setupTimer(d, (void *)f, p, true, RPI_PICO_RUN_ONCE);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
bool RPI_PICO_ISR_Timer::changeInterval(const unsigned& numTimer, const unsigned long& d)
|
||||
{
|
||||
if (numTimer >= RPI_PICO_MAX_TIMERS)
|
||||
@@ -251,6 +273,8 @@ bool RPI_PICO_ISR_Timer::changeInterval(const unsigned& numTimer, const unsigned
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::deleteTimer(const unsigned& timerId)
|
||||
{
|
||||
if (timerId >= RPI_PICO_MAX_TIMERS)
|
||||
@@ -282,6 +306,8 @@ void RPI_PICO_ISR_Timer::deleteTimer(const unsigned& timerId)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// function contributed by code@rowansimms.com
|
||||
void RPI_PICO_ISR_Timer::restartTimer(const unsigned& numTimer)
|
||||
{
|
||||
@@ -299,6 +325,7 @@ void RPI_PICO_ISR_Timer::restartTimer(const unsigned& numTimer)
|
||||
rp2040.resumeOtherCore();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
bool RPI_PICO_ISR_Timer::isEnabled(const unsigned& numTimer)
|
||||
{
|
||||
@@ -310,6 +337,7 @@ bool RPI_PICO_ISR_Timer::isEnabled(const unsigned& numTimer)
|
||||
return timer[numTimer].enabled;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::enable(const unsigned& numTimer)
|
||||
{
|
||||
@@ -321,6 +349,7 @@ void RPI_PICO_ISR_Timer::enable(const unsigned& numTimer)
|
||||
timer[numTimer].enabled = true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::disable(const unsigned& numTimer)
|
||||
{
|
||||
@@ -332,6 +361,8 @@ void RPI_PICO_ISR_Timer::disable(const unsigned& numTimer)
|
||||
timer[numTimer].enabled = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::enableAll()
|
||||
{
|
||||
// Enable all timers with a callback assigned (used)
|
||||
@@ -351,6 +382,8 @@ void RPI_PICO_ISR_Timer::enableAll()
|
||||
rp2040.resumeOtherCore();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::disableAll()
|
||||
{
|
||||
// Disable all timers with a callback assigned (used)
|
||||
@@ -371,6 +404,8 @@ void RPI_PICO_ISR_Timer::disableAll()
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void RPI_PICO_ISR_Timer::toggle(const unsigned& numTimer)
|
||||
{
|
||||
if (numTimer >= RPI_PICO_MAX_TIMERS)
|
||||
@@ -381,11 +416,14 @@ void RPI_PICO_ISR_Timer::toggle(const unsigned& numTimer)
|
||||
timer[numTimer].enabled = !timer[numTimer].enabled;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
unsigned RPI_PICO_ISR_Timer::getNumTimers()
|
||||
{
|
||||
return numTimers;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // ISR_TIMER_GENERIC_IMPL_H
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.2.0
|
||||
Version: 1.3.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -33,7 +33,8 @@
|
||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
||||
1.1.0 K Hoang 10/00/2021 Add support to new boards using the arduino-pico core
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error.
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.2.0
|
||||
Version: 1.3.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -33,7 +33,8 @@
|
||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
||||
1.1.0 K Hoang 10/00/2021 Add support to new boards using the arduino-pico core
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error.
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -41,6 +42,8 @@
|
||||
#ifndef ISR_TIMER_GENERIC_HPP
|
||||
#define ISR_TIMER_GENERIC_HPP
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) ) && !defined(ARDUINO_ARCH_MBED)
|
||||
#if defined(USING_RPI_PICO_TIMER_INTERRUPT)
|
||||
#undef USING_RPI_PICO_TIMER_INTERRUPT
|
||||
@@ -50,16 +53,20 @@
|
||||
#error This code is intended to run on the non-mbed RP2040 arduino-pico platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef RPI_PICO_TIMER_INTERRUPT_VERSION
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.2.0"
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.3.0"
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MAJOR 1
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MINOR 2
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MINOR 3
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_PATCH 0
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1002000
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1003000
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "TimerInterrupt_Generic_Debug.h"
|
||||
|
||||
#include <stddef.h>
|
||||
@@ -83,9 +90,10 @@
|
||||
typedef void (*timer_callback)();
|
||||
typedef void (*timer_callback_p)(void *);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
class RPI_PICO_ISR_Timer
|
||||
{
|
||||
|
||||
public:
|
||||
// maximum number of timers
|
||||
#define RPI_PICO_MAX_TIMERS 16
|
||||
@@ -199,6 +207,7 @@ class RPI_PICO_ISR_Timer
|
||||
volatile int numTimers;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // ISR_TIMER_GENERIC_HPP
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.2.0
|
||||
Version: 1.3.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -34,7 +34,8 @@
|
||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
||||
1.1.0 K Hoang 10/00/2021 Add support to new boards using the arduino-pico core
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error.
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -51,20 +52,26 @@
|
||||
#error This code is intended to run on the non-mbed RP2040 arduino-pico platform! Please check your Tools->Board setting.
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef RPI_PICO_TIMER_INTERRUPT_VERSION
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.2.0"
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION "RPi_Pico_TimerInterrupt v1.3.0"
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MAJOR 1
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MINOR 2
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_MINOR 3
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_PATCH 0
|
||||
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1002000
|
||||
#define RPI_PICO_TIMER_INTERRUPT_VERSION_INT 1003000
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef TIMER_INTERRUPT_DEBUG
|
||||
#define TIMER_INTERRUPT_DEBUG 0
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -74,6 +81,8 @@
|
||||
|
||||
#include "TimerInterrupt_Generic_Debug.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
To enable an alarm:
|
||||
• Enable the interrupt at the timer with a write to the appropriate alarm bit in INTE: i.e. (1 << 0) for ALARM0
|
||||
@@ -94,6 +103,7 @@ typedef RPI_PICO_TimerInterrupt RPI_PICO_Timer;
|
||||
|
||||
typedef bool (*pico_timer_callback) (struct repeating_timer *t);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
class RPI_PICO_TimerInterrupt
|
||||
{
|
||||
@@ -103,7 +113,7 @@ class RPI_PICO_TimerInterrupt
|
||||
|
||||
pico_timer_callback _callback; // pointer to the callback function
|
||||
float _frequency; // Timer frequency
|
||||
uint64_t _timerCount; // count to activate timer, in us
|
||||
int64_t _timerCount; // count to activate timer, in us
|
||||
|
||||
struct repeating_timer _timer;
|
||||
|
||||
@@ -114,6 +124,8 @@ class RPI_PICO_TimerInterrupt
|
||||
_timerNo = timerNo;
|
||||
_callback = NULL;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TIM_CLOCK_FREQ ( (float) 1000000.0f )
|
||||
|
||||
@@ -133,7 +145,7 @@ class RPI_PICO_TimerInterrupt
|
||||
// select timer frequency is 1MHz for better accuracy. We don't use 16-bit prescaler for now.
|
||||
// Will use later if very low frequency is needed.
|
||||
_frequency = frequency;
|
||||
_timerCount = (uint64_t) TIM_CLOCK_FREQ / frequency;
|
||||
_timerCount = (int64_t) (TIM_CLOCK_FREQ / frequency);
|
||||
|
||||
TISR_LOGWARN5(F("_timerNo = "), _timerNo, F(", Clock (Hz) = "), TIM_CLOCK_FREQ, F(", _fre (Hz) = "), _frequency);
|
||||
TISR_LOGWARN3(F("_count = "), (uint32_t) (_timerCount >> 32) , F("-"), (uint32_t) (_timerCount));
|
||||
@@ -143,10 +155,18 @@ class RPI_PICO_TimerInterrupt
|
||||
// static bool add_repeating_timer_us(int64_t delay_us, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out);
|
||||
// static bool add_repeating_timer_ms(int64_t delay_ms, repeating_timer_callback_t callback, void *user_data, repeating_timer_t *out);
|
||||
// bool cancel_repeating_timer (repeating_timer_t *timer);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Important Notes
|
||||
// delay_ms the repeat delay in milliseconds; if >0 then this is the delay between one callback ending and the next
|
||||
// starting; if <0 then this is the negative of the time between the starts of the callbacks.
|
||||
// The value of 0 is treated as 1 microsecond
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
cancel_repeating_timer(&_timer);
|
||||
add_repeating_timer_us(_timerCount, _callback, NULL, &_timer);
|
||||
|
||||
// Use negative value to select time between the starts of the callbacks
|
||||
add_repeating_timer_us(-(_timerCount), _callback, NULL, &_timer);
|
||||
|
||||
TISR_LOGWARN1(F("add_repeating_timer_us = "), _timerCount);
|
||||
TISR_LOGWARN1(F("add_repeating_timer_us between starts = "), _timerCount);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -158,6 +178,8 @@ class RPI_PICO_TimerInterrupt
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
|
||||
// No params and duration now. To be added in the future by adding similar functions here
|
||||
bool setInterval(const unsigned long& interval, pico_timer_callback callback)
|
||||
@@ -165,11 +187,15 @@ class RPI_PICO_TimerInterrupt
|
||||
return setFrequency((float) (1000000.0f / interval), callback);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
bool attachInterrupt(const float& frequency, pico_timer_callback callback)
|
||||
{
|
||||
return setFrequency(frequency, callback);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// interval (in microseconds) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
|
||||
// No params and duration now. To be added in the future by adding similar functions here
|
||||
bool attachInterruptInterval(const unsigned long& interval, pico_timer_callback callback)
|
||||
@@ -177,45 +203,62 @@ class RPI_PICO_TimerInterrupt
|
||||
return setFrequency( (float) ( 1000000.0f / interval), callback);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void detachInterrupt()
|
||||
{
|
||||
cancel_repeating_timer(&_timer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
void disableTimer()
|
||||
{
|
||||
cancel_repeating_timer(&_timer);
|
||||
}
|
||||
|
||||
// Duration (in milliseconds). Duration = 0 or not specified => run indefinitely
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// Duration (in microseconds). Duration = 0 or not specified => run indefinitely
|
||||
void reattachInterrupt()
|
||||
{
|
||||
add_repeating_timer_us(_timerCount, _callback, NULL, &_timer);
|
||||
add_repeating_timer_us(-(_timerCount), _callback, NULL, &_timer);
|
||||
}
|
||||
|
||||
// Duration (in milliseconds). Duration = 0 or not specified => run indefinitely
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// Duration (in microseconds). Duration = 0 or not specified => run indefinitely
|
||||
void enableTimer()
|
||||
{
|
||||
add_repeating_timer_us(_timerCount, _callback, NULL, &_timer);
|
||||
add_repeating_timer_us(-(_timerCount), _callback, NULL, &_timer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// Just stop clock source, clear the count
|
||||
void stopTimer()
|
||||
{
|
||||
cancel_repeating_timer(&_timer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// Just reconnect clock source, start current count from 0
|
||||
void restartTimer()
|
||||
{
|
||||
cancel_repeating_timer(&_timer);
|
||||
add_repeating_timer_us(_timerCount, _callback, NULL, &_timer);
|
||||
add_repeating_timer_us(-(_timerCount), _callback, NULL, &_timer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
int8_t getTimer() __attribute__((always_inline))
|
||||
{
|
||||
return _timerNo;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
}; // class RPI_PICO_TimerInterrupt
|
||||
|
||||
#endif // RPI_PICO_TIMERINTERRUPT_H
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
Based on BlynkTimer.h
|
||||
Author: Volodymyr Shymanskyy
|
||||
|
||||
Version: 1.2.0
|
||||
Version: 1.3.0
|
||||
|
||||
Version Modified By Date Comments
|
||||
------- ----------- ---------- -----------
|
||||
@@ -33,7 +33,8 @@
|
||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
||||
1.1.0 K Hoang 10/00/2021 Add support to new boards using the arduino-pico core
|
||||
1.1.1 K Hoang 22/10/2021 Fix platform in library.json for PIO
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error.
|
||||
1.2.0 K.Hoang 21/01/2022 Fix `multiple-definitions` linker error
|
||||
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||
*****************************************************************************************************************************/
|
||||
|
||||
#pragma once
|
||||
@@ -41,12 +42,16 @@
|
||||
#ifndef TIMERINTERRUPT_GENERIC_DEBUG_H
|
||||
#define TIMERINTERRUPT_GENERIC_DEBUG_H
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef TIMERINTERRUPT_DEBUG_PORT
|
||||
#define TISR_DBG_PORT TIMERINTERRUPT_DEBUG_PORT
|
||||
#else
|
||||
#define TISR_DBG_PORT Serial
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
// Change _TIMERINTERRUPT_LOGLEVEL_ to set tracing and logging verbosity
|
||||
// 0: DISABLED: no logging
|
||||
// 1: ERROR: errors
|
||||
|
||||
Reference in New Issue
Block a user