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

Commit

Permalink
v1.4.2 to add support to Seeeduino nRF52
Browse files Browse the repository at this point in the history
### Releases v1.4.2

1. Add support to Seeeduino nRF52840-based boards such as **Seeed_XIAO_NRF52840 and Seeed_XIAO_NRF52840_SENSE**, etc. using Seeeduino `nRF52` core
2. Add astyle using `allman` style. Restyle the library
3. Update all examples
  • Loading branch information
khoih-prog authored Oct 26, 2022
1 parent 6d7b435 commit 3cdaf91
Show file tree
Hide file tree
Showing 29 changed files with 852 additions and 508 deletions.
28 changes: 24 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* `NRF52` Core Version (e.g. Adafruit NRF52 core v1.3.0)
* `NRF52` Core Version (e.g. Adafruit NRF52 core v1.3.0, Seeed nRF52 core v1.0.0)
* 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,26 +27,46 @@ Please ensure to specify the following:

```
Arduino IDE version: 1.8.19
Arduino NRF52 Core Version 1.3.0
Adafruit NRF52 Core Version 1.3.0
NRF52840_ITSYBITSY
OS: Ubuntu 20.04 LTS
Linux xy-Inspiron-3593 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-52-generic #58~20.04.1-Ubuntu SMP Thu Oct 13 13:09:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
I encountered a crash while trying to use the Timer Interrupt.
I encountered a crash while using this library
Steps to reproduce:
1. ...
2. ...
3. ...
4. ...
```

---

### Sending Feature Requests

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/NRF52_TimerInterrupt/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.

---

### Sending Pull Requests

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/NRF52_TimerInterrupt_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_TimerInterrupt_GitHub$
```

2. Issue astyle command

```
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_TimerInterrupt_GitHub$ bash utils/restyle.sh
```
7 changes: 7 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.4.2](#releases-v142)
* [Releases v1.4.1](#releases-v141)
* [Releases v1.4.0](#releases-v140)
* [Releases v1.3.0](#releases-v130)
Expand All @@ -26,6 +27,12 @@

## Changelog

### Releases v1.4.2

1. Add support to Seeeduino nRF52840-based boards such as **Seeed_XIAO_NRF52840 and Seeed_XIAO_NRF52840_SENSE**, etc. using Seeeduino `nRF52` core
2. Add astyle using `allman` style. Restyle the library
3. Update all examples

### Releases v1.4.1

1. Add support to `Sparkfun Pro nRF52840 Mini`
Expand Down
52 changes: 31 additions & 21 deletions examples/Argument_None/Argument_None.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
or the entire sequence of your code which accesses the data.
*/

#if !(defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || \
defined(NRF52840_CLUE) || defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || \
defined(NRF52840_LED_GLASSES) || defined(MDBT50Q_RX) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )
#error This code is designed to run on Adafruit nRF52 platform! Please check your Tools->Board setting.
#endif

// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
Expand All @@ -47,11 +40,19 @@
//#endif

#ifndef LED_BLUE_PIN
#define LED_BLUE_PIN 7
#if defined(LED_BLUE)
#define LED_BLUE_PIN LED_BLUE
#else
#define LED_BLUE_PIN 7
#endif
#endif

#ifndef LED_RED
#define LED_RED 8
#ifndef LED_GREEN_PIN
#if defined(LED_GREEN)
#define LED_GREEN_PIN LED_GREEN
#else
#define LED_GREEN_PIN 8
#endif
#endif

#define TIMER0_INTERVAL_MS 1000 //1000
Expand All @@ -74,9 +75,12 @@ volatile uint32_t Timer1Count = 0;

void printResult(uint32_t currTime)
{
Serial.print(F("Time = ")); Serial.print(currTime);
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
Serial.print(F("Time = "));
Serial.print(currTime);
Serial.print(F(", Timer0Count = "));
Serial.print(Timer0Count);
Serial.print(F(", Timer1Count = "));
Serial.println(Timer1Count);
}

void TimerHandler0()
Expand All @@ -97,7 +101,7 @@ void TimerHandler1()

// Flag for checking to be sure ISR is working as Serial.print is not OK here in ISR
Timer1Count++;

//timer interrupt toggles outputPin
digitalWrite(LED_BLUE_PIN, toggle1);
toggle1 = !toggle1;
Expand All @@ -107,28 +111,34 @@ void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_BLUE_PIN, OUTPUT);

Serial.begin(115200);
while (!Serial);

while (!Serial && millis() < 5000);

delay(100);

Serial.print(F("\nStarting Argument_None on ")); Serial.println(BOARD_NAME);

Serial.print(F("\nStarting Argument_None on "));
Serial.println(BOARD_NAME);
Serial.println(NRF52_TIMER_INTERRUPT_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
Serial.print(F("CPU Frequency = "));
Serial.print(F_CPU / 1000000);
Serial.println(F(" MHz"));

// Interval in microsecs
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
{
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
Serial.print(F("Starting ITimer0 OK, millis() = "));
Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));

// Interval in microsecs
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
{
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
Serial.print(F("Starting ITimer1 OK, millis() = "));
Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
Expand Down
62 changes: 37 additions & 25 deletions examples/Change_Interval/Change_Interval.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@
or the entire sequence of your code which accesses the data.
*/

#if !(defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || \
defined(NRF52840_CLUE) || defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || \
defined(NRF52840_LED_GLASSES) || defined(MDBT50Q_RX) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )
#error This code is designed to run on Adafruit nRF52 platform! Please check your Tools->Board setting.
#endif

// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
Expand All @@ -47,11 +40,19 @@
//#endif

#ifndef LED_BLUE_PIN
#define LED_BLUE_PIN 7
#if defined(LED_BLUE)
#define LED_BLUE_PIN LED_BLUE
#else
#define LED_BLUE_PIN 7
#endif
#endif

#ifndef LED_RED
#define LED_RED 8
#ifndef LED_GREEN_PIN
#if defined(LED_GREEN)
#define LED_GREEN_PIN LED_GREEN
#else
#define LED_GREEN_PIN 8
#endif
#endif

#define TIMER0_INTERVAL_MS 500 //1000
Expand All @@ -71,9 +72,12 @@ NRF52Timer ITimer1(NRF_TIMER_3);

void printResult(uint32_t currTime)
{
Serial.print(F("Time = ")); Serial.print(currTime);
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
Serial.print(F("Time = "));
Serial.print(currTime);
Serial.print(F(", Timer0Count = "));
Serial.print(Timer0Count);
Serial.print(F(", Timer1Count = "));
Serial.println(Timer1Count);
}

void TimerHandler0()
Expand All @@ -94,7 +98,7 @@ void TimerHandler1()

// Flag for checking to be sure ISR is working as Serial.print is not OK here in ISR
Timer1Count++;

//timer interrupt toggles outputPin
digitalWrite(LED_BLUE_PIN, toggle1);
toggle1 = !toggle1;
Expand All @@ -104,28 +108,34 @@ void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
pinMode(LED_BLUE_PIN, OUTPUT);

Serial.begin(115200);
while (!Serial);

while (!Serial && millis() < 5000);

delay(100);

Serial.print(F("\nStarting Change_Interval on ")); Serial.println(BOARD_NAME);

Serial.print(F("\nStarting Change_Interval on "));
Serial.println(BOARD_NAME);
Serial.println(NRF52_TIMER_INTERRUPT_VERSION);
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

Serial.print(F("CPU Frequency = "));
Serial.print(F_CPU / 1000000);
Serial.println(F(" MHz"));

// Interval in microsecs
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
{
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
Serial.print(F("Starting ITimer0 OK, millis() = "));
Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));

// Interval in microsecs
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
{
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
Serial.print(F("Starting ITimer1 OK, millis() = "));
Serial.println(millis());
}
else
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
Expand All @@ -152,12 +162,14 @@ void loop()
{
//setInterval(unsigned long interval, timerCallback callback)
multFactor = (multFactor + 1) % 2;

ITimer0.setInterval(TIMER0_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler0);
ITimer1.setInterval(TIMER1_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler1);

Serial.print(F("Changing Interval, Timer0 = ")); Serial.print(TIMER0_INTERVAL_MS * (multFactor + 1));
Serial.print(F(", Timer1 = ")); Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));
Serial.print(F("Changing Interval, Timer0 = "));
Serial.print(TIMER0_INTERVAL_MS * (multFactor + 1));
Serial.print(F(", Timer1 = "));
Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));

lastChangeTime = currTime;
}
Expand Down
Loading

0 comments on commit 3cdaf91

Please sign in to comment.