Update README.md and use allman astyle
This commit is contained in:
+29
-4
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
|
|||||||
Please ensure to specify the following:
|
Please ensure to specify the following:
|
||||||
|
|
||||||
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
|
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
|
||||||
* `RP2040` Core Version (e.g. RP2040 core v2.5.4)
|
* `RP2040` Core Version (e.g. RP2040 core v2.6.3)
|
||||||
* `RP2040` Board type (e.g. RASPBERRY_PI_PICO, RASPBERRY_PI_PICO_W, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc.)
|
* `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)
|
* Contextual information (e.g. what you were trying to achieve)
|
||||||
* Simplest possible steps to reproduce
|
* Simplest possible steps to reproduce
|
||||||
@@ -28,27 +28,52 @@ Please ensure to specify the following:
|
|||||||
|
|
||||||
```
|
```
|
||||||
Arduino IDE version: 1.8.19
|
Arduino IDE version: 1.8.19
|
||||||
RP2040 core v2.5.4
|
RP2040 core v2.6.3
|
||||||
RASPBERRY_PI_PICO Module
|
RASPBERRY_PI_PICO Module
|
||||||
OS: Ubuntu 20.04 LTS
|
OS: Ubuntu 20.04 LTS
|
||||||
Linux xy-Inspiron-3593 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
|
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
|
||||||
|
|
||||||
Context:
|
Context:
|
||||||
I encountered a crash while using this library
|
I encountered a crash while using this library
|
||||||
|
|
||||||
Steps to reproduce:
|
Steps to reproduce:
|
||||||
1. ...
|
1. ...
|
||||||
2. ...
|
2. ...
|
||||||
3. ...
|
3. ...
|
||||||
4. ...
|
4. ...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Additional context
|
||||||
|
|
||||||
|
Add any other context about the problem here.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Sending Feature Requests
|
### Sending Feature Requests
|
||||||
|
|
||||||
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
|
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
|
||||||
|
|
||||||
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
|
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Sending Pull Requests
|
### Sending Pull Requests
|
||||||
|
|
||||||
Pull Requests with changes and fixes are also welcome!
|
Pull Requests with changes and fixes are also welcome!
|
||||||
|
|
||||||
|
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
|
||||||
|
|
||||||
|
1. Change directory to the library GitHub
|
||||||
|
|
||||||
|
```
|
||||||
|
xy@xy-Inspiron-3593:~$ cd Arduino/xy/RPI_PICO_TimerInterrupt_GitHub/
|
||||||
|
xy@xy-Inspiron-3593:~/Arduino/xy/RPI_PICO_TimerInterrupt_GitHub$
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Issue astyle command
|
||||||
|
|
||||||
|
```
|
||||||
|
xy@xy-Inspiron-3593:~/Arduino/xy/RPI_PICO_TimerInterrupt_GitHub$ bash utils/restyle.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,13 @@
|
|||||||
[](#Contributing)
|
[](#Contributing)
|
||||||
[](http://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues)
|
[](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://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>
|
<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>
|
||||||
|
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
|
||||||
|
<a href="https://profile-counter.glitch.me/khoih-prog-RPI_PICO_TimerInterrupt/count.svg" title="RPI_PICO_TimerInterrupt Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-RPI_PICO_TimerInterrupt/count.svg" style="height: 30px;width: 200px;"></a>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
---
|
---
|
||||||
@@ -98,11 +103,11 @@ Being ISR-based timers, their executions are not blocked by bad-behaving functio
|
|||||||
This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
|
This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
|
||||||
|
|
||||||
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task
|
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task
|
||||||
in loop(), using delay() function as an example. The elapsed time then is very unaccurate
|
in `loop()`, using delay() function as an example. The elapsed time then is very unaccurate
|
||||||
|
|
||||||
### Why using ISR-based Hardware Timer Interrupt is better
|
### Why using ISR-based Hardware Timer Interrupt is better
|
||||||
|
|
||||||
Imagine you have a system with a **mission-critical** function, measuring water level and control the sump pump or doing something much more important. You normally use a software timer to poll, or even place the function in loop(). But what if another function is **blocking** the loop() or setup().
|
Imagine you have a system with a **mission-critical** function, measuring water level and control the sump pump or doing something much more important. You normally use a software timer to poll, or even place the function in `loop()`. But what if another function is **blocking** the `loop()` or `setup()`.
|
||||||
|
|
||||||
So your function **might not be executed, and the result would be disastrous.**
|
So your function **might not be executed, and the result would be disastrous.**
|
||||||
|
|
||||||
@@ -110,14 +115,15 @@ You'd prefer to have your function called, no matter what happening with other f
|
|||||||
|
|
||||||
The correct choice is to use a Hardware Timer with **Interrupt** to call your function.
|
The correct choice is to use a Hardware Timer with **Interrupt** to call your function.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
Functions using normal software timers, relying on loop() and calling millis(), won't work if the loop() or setup() is blocked by certain operation. For example, certain function is blocking while it's connecting to WiFi or some services.
|
Functions using normal software timers, relying on `loop()` and calling `millis()`, won't work if the `loop()` or `setup()` is blocked by certain operation. For example, certain function is blocking while it's connecting to WiFi or some services.
|
||||||
|
|
||||||
The catch is **your function is now part of an ISR (Interrupt Service Routine), and must be lean / mean, and follow certain rules.** More to read on:
|
The catch is **your function is now part of an ISR (Interrupt Service Routine), and must be lean / mean, and follow certain rules.** More to read on:
|
||||||
|
|
||||||
[**HOWTO Attach Interrupt**](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/)
|
[**HOWTO Attach Interrupt**](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/)
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Currently supported Boards
|
### Currently supported Boards
|
||||||
@@ -140,9 +146,13 @@ The catch is **your function is now part of an ISR (Interrupt Service Routine),
|
|||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [](https://github.com/arduino/Arduino/releases/latest)
|
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 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)
|
2. [`Earle Philhower's arduino-pico core v2.6.3+`](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
|
3. To use with certain example, depending on which Ethernet card you're using:
|
||||||
- [`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.
|
- [`Ethernet_Generic library v2.7.1+`](https://github.com/khoih-prog/Ethernet_Generic) for W5100, W5200 and W5500. [](https://github.com/khoih-prog/Ethernet_Generic/releases/latest)
|
||||||
|
- [`EthernetENC library v2.0.3+`](https://github.com/jandrassy/EthernetENC) for ENC28J60. [](https://github.com/jandrassy/EthernetENC/releases/latest). **New and Better**
|
||||||
|
- [`UIPEthernet library v2.0.12+`](https://github.com/UIPEthernet/UIPEthernet) for ENC28J60. [](https://github.com/UIPEthernet/UIPEthernet/releases/latest)
|
||||||
|
4. To use with certain example
|
||||||
|
- [`SimpleTimer library`](https://github.com/jfturcot/SimpleTimer) for [ISR_16_Timers_Array](examples/ISR_16_Timers_Array) and [ISR_16_Timers_Array_Complex](examples/ISR_16_Timers_Array_Complex) examples.
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
[](#Contributing)
|
[](#Contributing)
|
||||||
[](http://github.com/khoih-prog/RPI_PICO_TimerInterrupt/issues)
|
[](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>
|
||||||
|
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
|
||||||
|
<a href="https://profile-counter.glitch.me/khoih-prog-RPI_PICO_TimerInterrupt/count.svg" title="RPI_PICO_TimerInterrupt Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-RPI_PICO_TimerInterrupt/count.svg" style="height: 30px;width: 200px;"></a>
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,41 @@
|
|||||||
/****************************************************************************************************************************
|
/****************************************************************************************************************************
|
||||||
RPi_Pico_ISR_Timer-Impl.h
|
RPi_Pico_ISR_Timer-Impl.h
|
||||||
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
||||||
Written by Khoi Hoang
|
Written by Khoi Hoang
|
||||||
|
|
||||||
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
||||||
interrupts based on this timebase. It supports the following features:
|
interrupts based on this timebase. It supports the following features:
|
||||||
• A single 64-bit counter, incrementing once per microsecond
|
• A single 64-bit counter, incrementing once per microsecond
|
||||||
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
||||||
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
||||||
|
|
||||||
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
||||||
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
||||||
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
||||||
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
||||||
This important feature is absolutely necessary for mission-critical tasks.
|
This important feature is absolutely necessary for mission-critical tasks.
|
||||||
|
|
||||||
Based on SimpleTimer - A timer library for Arduino.
|
Based on SimpleTimer - A timer library for Arduino.
|
||||||
Author: mromani@ottotecnica.com
|
Author: mromani@ottotecnica.com
|
||||||
Copyright (c) 2010 OTTOTECNICA Italy
|
Copyright (c) 2010 OTTOTECNICA Italy
|
||||||
|
|
||||||
Based on BlynkTimer.h
|
Based on BlynkTimer.h
|
||||||
Author: Volodymyr Shymanskyy
|
Author: Volodymyr Shymanskyy
|
||||||
|
|
||||||
Version: 1.3.1
|
Version: 1.3.1
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
||||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
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.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.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
|
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -181,6 +181,7 @@ int RPI_PICO_ISR_Timer::setupTimer(const float& d, void* f, void* p, bool h, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
freeTimer = findFirstFreeSlot();
|
freeTimer = findFirstFreeSlot();
|
||||||
|
|
||||||
if (freeTimer < 0)
|
if (freeTimer < 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
+27
-27
@@ -1,41 +1,41 @@
|
|||||||
/****************************************************************************************************************************
|
/****************************************************************************************************************************
|
||||||
RPi_Pico_ISR_Timer.h
|
RPi_Pico_ISR_Timer.h
|
||||||
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
||||||
Written by Khoi Hoang
|
Written by Khoi Hoang
|
||||||
|
|
||||||
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
||||||
interrupts based on this timebase. It supports the following features:
|
interrupts based on this timebase. It supports the following features:
|
||||||
• A single 64-bit counter, incrementing once per microsecond
|
• A single 64-bit counter, incrementing once per microsecond
|
||||||
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
||||||
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
||||||
|
|
||||||
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
||||||
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
||||||
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
||||||
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
||||||
This important feature is absolutely necessary for mission-critical tasks.
|
This important feature is absolutely necessary for mission-critical tasks.
|
||||||
|
|
||||||
Based on SimpleTimer - A timer library for Arduino.
|
Based on SimpleTimer - A timer library for Arduino.
|
||||||
Author: mromani@ottotecnica.com
|
Author: mromani@ottotecnica.com
|
||||||
Copyright (c) 2010 OTTOTECNICA Italy
|
Copyright (c) 2010 OTTOTECNICA Italy
|
||||||
|
|
||||||
Based on BlynkTimer.h
|
Based on BlynkTimer.h
|
||||||
Author: Volodymyr Shymanskyy
|
Author: Volodymyr Shymanskyy
|
||||||
|
|
||||||
Version: 1.3.1
|
Version: 1.3.1
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
||||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
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.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.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
|
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
@@ -1,42 +1,42 @@
|
|||||||
|
|
||||||
/****************************************************************************************************************************
|
/****************************************************************************************************************************
|
||||||
RPi_Pico_TimerInterrupt.h
|
RPi_Pico_TimerInterrupt.h
|
||||||
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
||||||
Written by Khoi Hoang
|
Written by Khoi Hoang
|
||||||
|
|
||||||
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
||||||
interrupts based on this timebase. It supports the following features:
|
interrupts based on this timebase. It supports the following features:
|
||||||
• A single 64-bit counter, incrementing once per microsecond
|
• A single 64-bit counter, incrementing once per microsecond
|
||||||
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
||||||
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
||||||
|
|
||||||
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
||||||
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
||||||
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
||||||
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
||||||
This important feature is absolutely necessary for mission-critical tasks.
|
This important feature is absolutely necessary for mission-critical tasks.
|
||||||
|
|
||||||
Based on SimpleTimer - A timer library for Arduino.
|
Based on SimpleTimer - A timer library for Arduino.
|
||||||
Author: mromani@ottotecnica.com
|
Author: mromani@ottotecnica.com
|
||||||
Copyright (c) 2010 OTTOTECNICA Italy
|
Copyright (c) 2010 OTTOTECNICA Italy
|
||||||
|
|
||||||
Based on BlynkTimer.h
|
Based on BlynkTimer.h
|
||||||
Author: Volodymyr Shymanskyy
|
Author: Volodymyr Shymanskyy
|
||||||
|
|
||||||
Version: 1.3.1
|
Version: 1.3.1
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
||||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
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.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.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
|
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
@@ -85,13 +85,13 @@
|
|||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To enable an alarm:
|
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
|
• Enable the interrupt at the timer with a write to the appropriate alarm bit in INTE: i.e. (1 << 0) for ALARM0
|
||||||
• Enable the appropriate timer interrupt at the processor (see Section 2.3.2)
|
• Enable the appropriate timer interrupt at the processor (see Section 2.3.2)
|
||||||
• Write the time you would like the interrupt to fire to ALARM0 (i.e. the current value in TIMERAWL plus your desired
|
• Write the time you would like the interrupt to fire to ALARM0 (i.e. the current value in TIMERAWL plus your desired
|
||||||
alarm time in microseconds). Writing the time to the ALARM register sets the ARMED bit as a side effect.
|
alarm time in microseconds). Writing the time to the ALARM register sets the ARMED bit as a side effect.
|
||||||
Once the alarm has fired, the ARMED bit will be set to 0 . To clear the latched interrupt, write a 1 to the appropriate bit in
|
Once the alarm has fired, the ARMED bit will be set to 0 . To clear the latched interrupt, write a 1 to the appropriate bit in
|
||||||
INTR.
|
INTR.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class RPI_PICO_TimerInterrupt
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define TIM_CLOCK_FREQ ( (float) 1000000.0f )
|
#define TIM_CLOCK_FREQ ( (float) 1000000.0f )
|
||||||
|
|
||||||
// frequency (in hertz) and duration (in milliseconds). Duration = 0 or not specified => run indefinitely
|
// frequency (in hertz) 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
|
// No params and duration now. To be added in the future by adding similar functions here
|
||||||
@@ -149,7 +149,7 @@ class RPI_PICO_TimerInterrupt
|
|||||||
_timerCount = (int64_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_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));
|
TISR_LOGWARN3(F("_count = "), (uint32_t) (_timerCount >> 32), F("-"), (uint32_t) (_timerCount));
|
||||||
|
|
||||||
_callback = callback;
|
_callback = callback;
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +1,41 @@
|
|||||||
/****************************************************************************************************************************
|
/****************************************************************************************************************************
|
||||||
TimerInterrupt_Generic_Debug.h
|
TimerInterrupt_Generic_Debug.h
|
||||||
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
For RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040.
|
||||||
Written by Khoi Hoang
|
Written by Khoi Hoang
|
||||||
|
|
||||||
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
Built by Khoi Hoang https://github.com/khoih-prog/RPI_PICO_TimerInterrupt
|
||||||
Licensed under MIT license
|
Licensed under MIT license
|
||||||
|
|
||||||
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
The RPI_PICO system timer peripheral provides a global microsecond timebase for the system, and generates
|
||||||
interrupts based on this timebase. It supports the following features:
|
interrupts based on this timebase. It supports the following features:
|
||||||
• A single 64-bit counter, incrementing once per microsecond
|
• A single 64-bit counter, incrementing once per microsecond
|
||||||
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
• This counter can be read from a pair of latching registers, for race-free reads over a 32-bit bus.
|
||||||
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
• Four alarms: match on the lower 32 bits of counter, IRQ on match: TIMER_IRQ_0-TIMER_IRQ_3
|
||||||
|
|
||||||
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
Now even you use all these new 16 ISR-based timers,with their maximum interval practically unlimited (limited only by
|
||||||
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
unsigned long miliseconds), you just consume only one RPI_PICO timer and avoid conflicting with other cores' tasks.
|
||||||
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
|
||||||
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
Therefore, their executions are not blocked by bad-behaving functions / tasks.
|
||||||
This important feature is absolutely necessary for mission-critical tasks.
|
This important feature is absolutely necessary for mission-critical tasks.
|
||||||
|
|
||||||
Based on SimpleTimer - A timer library for Arduino.
|
Based on SimpleTimer - A timer library for Arduino.
|
||||||
Author: mromani@ottotecnica.com
|
Author: mromani@ottotecnica.com
|
||||||
Copyright (c) 2010 OTTOTECNICA Italy
|
Copyright (c) 2010 OTTOTECNICA Italy
|
||||||
|
|
||||||
Based on BlynkTimer.h
|
Based on BlynkTimer.h
|
||||||
Author: Volodymyr Shymanskyy
|
Author: Volodymyr Shymanskyy
|
||||||
|
|
||||||
Version: 1.3.1
|
Version: 1.3.1
|
||||||
|
|
||||||
Version Modified By Date Comments
|
Version Modified By Date Comments
|
||||||
------- ----------- ---------- -----------
|
------- ----------- ---------- -----------
|
||||||
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
1.0.0 K Hoang 11/05/2021 Initial coding to support RP2040-based boards such as RASPBERRY_PI_PICO. etc.
|
||||||
1.0.1 K Hoang 18/05/2021 Update README and Packages' Patches to match core arduino-pico core v1.4.0
|
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.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.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
|
1.3.0 K.Hoang 25/09/2022 Fix severe bug affecting time between the starts
|
||||||
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
1.3.1 K.Hoang 29/09/2022 Using float instead of ulong for interval
|
||||||
*****************************************************************************************************************************/
|
*****************************************************************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|||||||
Reference in New Issue
Block a user