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

Commit 3cdaf91

Browse files
authored
v1.4.2 to add support to Seeeduino nRF52
### 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
1 parent 6d7b435 commit 3cdaf91

29 files changed

+852
-508
lines changed

CONTRIBUTING.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1515
Please ensure to specify the following:
1616

1717
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18-
* `NRF52` Core Version (e.g. Adafruit NRF52 core v1.3.0)
18+
* `NRF52` Core Version (e.g. Adafruit NRF52 core v1.3.0, Seeed nRF52 core v1.0.0)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
2121
* Anything that might be relevant in your opinion, such as:
@@ -27,26 +27,46 @@ Please ensure to specify the following:
2727

2828
```
2929
Arduino IDE version: 1.8.19
30-
Arduino NRF52 Core Version 1.3.0
30+
Adafruit NRF52 Core Version 1.3.0
31+
NRF52840_ITSYBITSY
3132
OS: Ubuntu 20.04 LTS
32-
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
33+
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
3334
3435
Context:
35-
I encountered a crash while trying to use the Timer Interrupt.
36+
I encountered a crash while using this library
3637
3738
Steps to reproduce:
3839
1. ...
3940
2. ...
4041
3. ...
4142
4. ...
4243
```
44+
45+
---
46+
4347
### Sending Feature Requests
4448

4549
Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.
4650

4751
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.
4852

53+
---
54+
4955
### Sending Pull Requests
5056

5157
Pull Requests with changes and fixes are also welcome!
5258

59+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
60+
61+
1. Change directory to the library GitHub
62+
63+
```
64+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/NRF52_TimerInterrupt_GitHub/
65+
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_TimerInterrupt_GitHub$
66+
```
67+
68+
2. Issue astyle command
69+
70+
```
71+
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_TimerInterrupt_GitHub$ bash utils/restyle.sh
72+
```

changelog.md

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

1414
* [Changelog](#changelog)
15+
* [Releases v1.4.2](#releases-v142)
1516
* [Releases v1.4.1](#releases-v141)
1617
* [Releases v1.4.0](#releases-v140)
1718
* [Releases v1.3.0](#releases-v130)
@@ -26,6 +27,12 @@
2627

2728
## Changelog
2829

30+
### Releases v1.4.2
31+
32+
1. Add support to Seeeduino nRF52840-based boards such as **Seeed_XIAO_NRF52840 and Seeed_XIAO_NRF52840_SENSE**, etc. using Seeeduino `nRF52` core
33+
2. Add astyle using `allman` style. Restyle the library
34+
3. Update all examples
35+
2936
### Releases v1.4.1
3037

3138
1. Add support to `Sparkfun Pro nRF52840 Mini`

examples/Argument_None/Argument_None.ino

+31-21
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
or the entire sequence of your code which accesses the data.
2626
*/
2727

28-
#if !(defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
29-
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || \
30-
defined(NRF52840_CLUE) || defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || \
31-
defined(NRF52840_LED_GLASSES) || defined(MDBT50Q_RX) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )
32-
#error This code is designed to run on Adafruit nRF52 platform! Please check your Tools->Board setting.
33-
#endif
34-
3528
// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
3629
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
3730
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
@@ -47,11 +40,19 @@
4740
//#endif
4841

4942
#ifndef LED_BLUE_PIN
50-
#define LED_BLUE_PIN 7
43+
#if defined(LED_BLUE)
44+
#define LED_BLUE_PIN LED_BLUE
45+
#else
46+
#define LED_BLUE_PIN 7
47+
#endif
5148
#endif
5249

53-
#ifndef LED_RED
54-
#define LED_RED 8
50+
#ifndef LED_GREEN_PIN
51+
#if defined(LED_GREEN)
52+
#define LED_GREEN_PIN LED_GREEN
53+
#else
54+
#define LED_GREEN_PIN 8
55+
#endif
5556
#endif
5657

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

7576
void printResult(uint32_t currTime)
7677
{
77-
Serial.print(F("Time = ")); Serial.print(currTime);
78-
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
79-
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
78+
Serial.print(F("Time = "));
79+
Serial.print(currTime);
80+
Serial.print(F(", Timer0Count = "));
81+
Serial.print(Timer0Count);
82+
Serial.print(F(", Timer1Count = "));
83+
Serial.println(Timer1Count);
8084
}
8185

8286
void TimerHandler0()
@@ -97,7 +101,7 @@ void TimerHandler1()
97101

98102
// Flag for checking to be sure ISR is working as Serial.print is not OK here in ISR
99103
Timer1Count++;
100-
104+
101105
//timer interrupt toggles outputPin
102106
digitalWrite(LED_BLUE_PIN, toggle1);
103107
toggle1 = !toggle1;
@@ -107,28 +111,34 @@ void setup()
107111
{
108112
pinMode(LED_BUILTIN, OUTPUT);
109113
pinMode(LED_BLUE_PIN, OUTPUT);
110-
114+
111115
Serial.begin(115200);
112-
while (!Serial);
116+
117+
while (!Serial && millis() < 5000);
113118

114119
delay(100);
115-
116-
Serial.print(F("\nStarting Argument_None on ")); Serial.println(BOARD_NAME);
120+
121+
Serial.print(F("\nStarting Argument_None on "));
122+
Serial.println(BOARD_NAME);
117123
Serial.println(NRF52_TIMER_INTERRUPT_VERSION);
118-
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
124+
Serial.print(F("CPU Frequency = "));
125+
Serial.print(F_CPU / 1000000);
126+
Serial.println(F(" MHz"));
119127

120128
// Interval in microsecs
121129
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
122130
{
123-
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
131+
Serial.print(F("Starting ITimer0 OK, millis() = "));
132+
Serial.println(millis());
124133
}
125134
else
126135
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
127136

128137
// Interval in microsecs
129138
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
130139
{
131-
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
140+
Serial.print(F("Starting ITimer1 OK, millis() = "));
141+
Serial.println(millis());
132142
}
133143
else
134144
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));

examples/Change_Interval/Change_Interval.ino

+37-25
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
or the entire sequence of your code which accesses the data.
2626
*/
2727

28-
#if !(defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
29-
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || \
30-
defined(NRF52840_CLUE) || defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || \
31-
defined(NRF52840_LED_GLASSES) || defined(MDBT50Q_RX) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )
32-
#error This code is designed to run on Adafruit nRF52 platform! Please check your Tools->Board setting.
33-
#endif
34-
3528
// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
3629
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
3730
// Don't define _TIMERINTERRUPT_LOGLEVEL_ > 0. Only for special ISR debugging only. Can hang the system.
@@ -47,11 +40,19 @@
4740
//#endif
4841

4942
#ifndef LED_BLUE_PIN
50-
#define LED_BLUE_PIN 7
43+
#if defined(LED_BLUE)
44+
#define LED_BLUE_PIN LED_BLUE
45+
#else
46+
#define LED_BLUE_PIN 7
47+
#endif
5148
#endif
5249

53-
#ifndef LED_RED
54-
#define LED_RED 8
50+
#ifndef LED_GREEN_PIN
51+
#if defined(LED_GREEN)
52+
#define LED_GREEN_PIN LED_GREEN
53+
#else
54+
#define LED_GREEN_PIN 8
55+
#endif
5556
#endif
5657

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

7273
void printResult(uint32_t currTime)
7374
{
74-
Serial.print(F("Time = ")); Serial.print(currTime);
75-
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
76-
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
75+
Serial.print(F("Time = "));
76+
Serial.print(currTime);
77+
Serial.print(F(", Timer0Count = "));
78+
Serial.print(Timer0Count);
79+
Serial.print(F(", Timer1Count = "));
80+
Serial.println(Timer1Count);
7781
}
7882

7983
void TimerHandler0()
@@ -94,7 +98,7 @@ void TimerHandler1()
9498

9599
// Flag for checking to be sure ISR is working as Serial.print is not OK here in ISR
96100
Timer1Count++;
97-
101+
98102
//timer interrupt toggles outputPin
99103
digitalWrite(LED_BLUE_PIN, toggle1);
100104
toggle1 = !toggle1;
@@ -104,28 +108,34 @@ void setup()
104108
{
105109
pinMode(LED_BUILTIN, OUTPUT);
106110
pinMode(LED_BLUE_PIN, OUTPUT);
107-
111+
108112
Serial.begin(115200);
109-
while (!Serial);
113+
114+
while (!Serial && millis() < 5000);
110115

111116
delay(100);
112-
113-
Serial.print(F("\nStarting Change_Interval on ")); Serial.println(BOARD_NAME);
117+
118+
Serial.print(F("\nStarting Change_Interval on "));
119+
Serial.println(BOARD_NAME);
114120
Serial.println(NRF52_TIMER_INTERRUPT_VERSION);
115-
Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));
116-
121+
Serial.print(F("CPU Frequency = "));
122+
Serial.print(F_CPU / 1000000);
123+
Serial.println(F(" MHz"));
124+
117125
// Interval in microsecs
118126
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
119127
{
120-
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
128+
Serial.print(F("Starting ITimer0 OK, millis() = "));
129+
Serial.println(millis());
121130
}
122131
else
123132
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
124133

125134
// Interval in microsecs
126135
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
127136
{
128-
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
137+
Serial.print(F("Starting ITimer1 OK, millis() = "));
138+
Serial.println(millis());
129139
}
130140
else
131141
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
@@ -152,12 +162,14 @@ void loop()
152162
{
153163
//setInterval(unsigned long interval, timerCallback callback)
154164
multFactor = (multFactor + 1) % 2;
155-
165+
156166
ITimer0.setInterval(TIMER0_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler0);
157167
ITimer1.setInterval(TIMER1_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler1);
158168

159-
Serial.print(F("Changing Interval, Timer0 = ")); Serial.print(TIMER0_INTERVAL_MS * (multFactor + 1));
160-
Serial.print(F(", Timer1 = ")); Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));
169+
Serial.print(F("Changing Interval, Timer0 = "));
170+
Serial.print(TIMER0_INTERVAL_MS * (multFactor + 1));
171+
Serial.print(F(", Timer1 = "));
172+
Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));
161173

162174
lastChangeTime = currTime;
163175
}

0 commit comments

Comments
 (0)