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

Commit 340ccc2

Browse files
authored
v1.4.1 to add support to Seeeduino nRF52
### Releases v1.4.1 1. Add support to Seeeduino nRF52840-based boards such as **SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE**, etc. using Seeeduino `mbed` core 2. Add astyle using `allman` style. Restyle the library 3. Update all examples
1 parent 771b336 commit 340ccc2

23 files changed

+460
-208
lines changed

CONTRIBUTING.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ 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-
* Arduino `mbed` Core Version (e.g. Arduino `mbed` core v1.3.2 or Arduino `mbed_nano` core v2.6.1 )
18+
* `nRF52840 mbed` Core Version (e.g. Arduino mbed_nano core v3.4.1, Seeeduino mbed core v2.7.2)
19+
* `nRF52840-based Nano_33_BLE` Board type (e.g. Nano_33_BLE, Nano_33_BLE_Sense, SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE, etc.)
1920
* Contextual information (e.g. what you were trying to achieve)
2021
* Simplest possible steps to reproduce
2122
* Anything that might be relevant in your opinion, such as:
@@ -27,12 +28,13 @@ Please ensure to specify the following:
2728

2829
```
2930
Arduino IDE version: 1.8.19
30-
Arduino mbed_nano` core v2.6.1
31+
Arduino mbed_nano core v3.4.1
32+
Nano_33_BLE board
3133
OS: Ubuntu 20.04 LTS
32-
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
34+
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
3335
3436
Context:
35-
I encountered a crash while trying to use the Timer Interrupt.
37+
I encountered a crash while using this library
3638
3739
Steps to reproduce:
3840
1. ...
@@ -41,12 +43,32 @@ Steps to reproduce:
4143
4. ...
4244
```
4345

46+
---
47+
4448
### Sending Feature Requests
4549

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

4852
There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/NRF52_MBED_TimerInterrupt/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.
4953

54+
---
55+
5056
### Sending Pull Requests
5157

5258
Pull Requests with changes and fixes are also welcome!
59+
60+
Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)
61+
62+
1. Change directory to the library GitHub
63+
64+
```
65+
xy@xy-Inspiron-3593:~$ cd Arduino/xy/NRF52_MBED_TimerInterrupt_GitHub/
66+
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_MBED_TimerInterrupt_GitHub$
67+
```
68+
69+
2. Issue astyle command
70+
71+
```
72+
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_MBED_TimerInterrupt_GitHub$ bash utils/restyle.sh
73+
```
74+

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.4.1](#releases-v141)
1516
* [Releases v1.4.0](#releases-v140)
1617
* [Releases v1.3.0](#releases-v130)
1718
* [Releases v1.2.1](#releases-v121)
@@ -25,6 +26,12 @@
2526

2627
## Changelog
2728

29+
### Releases v1.4.1
30+
31+
1. Add support to Seeeduino nRF52840-based boards such as **SEEED_XIAO_NRF52840 and SEEED_XIAO_NRF52840_SENSE**, etc. using Seeeduino `mbed` core
32+
2. Add astyle using `allman` style. Restyle the library
33+
3. Update all examples
34+
2835
### Releases v1.4.0
2936

3037
1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories

examples/Argument_None/Argument_None.ino

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,19 @@
4444
//#endif
4545

4646
#ifndef LED_BLUE_PIN
47-
#define LED_BLUE_PIN D7
47+
#if defined(LEDB)
48+
#define LED_BLUE_PIN LEDB
49+
#else
50+
#define LED_BLUE_PIN D7
51+
#endif
4852
#endif
4953

5054
#ifndef LED_RED_PIN
51-
#define LED_RED_PIN D8
55+
#if defined(LEDR)
56+
#define LED_RED_PIN LEDR
57+
#else
58+
#define LED_RED_PIN D8
59+
#endif
5260
#endif
5361

5462
#define TIMER0_INTERVAL_MS 500 //1000
@@ -73,9 +81,12 @@ NRF52_MBED_Timer ITimer1(NRF_TIMER_3);
7381

7482
void printResult(uint32_t currTime)
7583
{
76-
Serial.print(F("Time = ")); Serial.print(currTime);
77-
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
78-
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
84+
Serial.print(F("Time = "));
85+
Serial.print(currTime);
86+
Serial.print(F(", Timer0Count = "));
87+
Serial.print(Timer0Count);
88+
Serial.print(F(", Timer1Count = "));
89+
Serial.println(Timer1Count);
7990
}
8091

8192
void TimerHandler0()
@@ -96,7 +107,7 @@ void TimerHandler1()
96107

97108
// Flag for checking to be sure ISR is working as Serial.print is not OK here in ISR
98109
Timer1Count++;
99-
110+
100111
//timer interrupt toggles outputPin
101112
digitalWrite(LED_BLUE_PIN, toggle1);
102113
toggle1 = !toggle1;
@@ -106,27 +117,31 @@ void setup()
106117
{
107118
pinMode(LED_BUILTIN, OUTPUT);
108119
pinMode(LED_BLUE_PIN, OUTPUT);
109-
120+
110121
Serial.begin(115200);
111-
while (!Serial);
122+
123+
while (!Serial && millis() < 5000);
112124

113125
delay(100);
114126

115-
Serial.print(F("\nStarting Argument_None on ")); Serial.println(BOARD_NAME);
127+
Serial.print(F("\nStarting Argument_None on "));
128+
Serial.println(BOARD_NAME);
116129
Serial.println(NRF52_MBED_TIMER_INTERRUPT_VERSION);
117-
130+
118131
// Interval in microsecs
119132
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
120133
{
121-
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
134+
Serial.print(F("Starting ITimer0 OK, millis() = "));
135+
Serial.println(millis());
122136
}
123137
else
124138
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
125139

126140
// Interval in microsecs
127141
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
128142
{
129-
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
143+
Serial.print(F("Starting ITimer1 OK, millis() = "));
144+
Serial.println(millis());
130145
}
131146
else
132147
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));

examples/Change_Interval/Change_Interval.ino

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727

2828
#if !( ARDUINO_ARCH_NRF52840 && TARGET_NAME == ARDUINO_NANO33BLE )
29-
#error This code is designed to run on nRF52-based Nano-33-BLE boards using mbed-RTOS platform! Please check your Tools->Board setting.
29+
#error This code is designed to run on nRF52-based Nano-33-BLE boards using mbed-RTOS platform! Please check your Tools->Board setting.
3030
#endif
3131

3232
// These define's must be placed at the beginning before #include "NRF52TimerInterrupt.h"
@@ -44,11 +44,19 @@
4444
//#endif
4545

4646
#ifndef LED_BLUE_PIN
47-
#define LED_BLUE_PIN D7
47+
#if defined(LEDB)
48+
#define LED_BLUE_PIN LEDB
49+
#else
50+
#define LED_BLUE_PIN D7
51+
#endif
4852
#endif
4953

5054
#ifndef LED_RED_PIN
51-
#define LED_RED_PIN D8
55+
#if defined(LEDR)
56+
#define LED_RED_PIN LEDR
57+
#else
58+
#define LED_RED_PIN D8
59+
#endif
5260
#endif
5361

5462
#define TIMER0_INTERVAL_MS 500 //1000
@@ -73,9 +81,12 @@ NRF52_MBED_Timer ITimer1(NRF_TIMER_3);
7381

7482
void printResult(uint32_t currTime)
7583
{
76-
Serial.print(F("Time = ")); Serial.print(currTime);
77-
Serial.print(F(", Timer0Count = ")); Serial.print(Timer0Count);
78-
Serial.print(F(", Timer1Count = ")); Serial.println(Timer1Count);
84+
Serial.print(F("Time = "));
85+
Serial.print(currTime);
86+
Serial.print(F(", Timer0Count = "));
87+
Serial.print(Timer0Count);
88+
Serial.print(F(", Timer1Count = "));
89+
Serial.println(Timer1Count);
7990
}
8091

8192
void TimerHandler0()
@@ -108,25 +119,29 @@ void setup()
108119
pinMode(LED_BLUE_PIN, OUTPUT);
109120

110121
Serial.begin(115200);
111-
while (!Serial);
122+
123+
while (!Serial && millis() < 5000);
112124

113125
delay(100);
114126

115-
Serial.print(F("\nStarting Change_Interval on ")); Serial.println(BOARD_NAME);
127+
Serial.print(F("\nStarting Change_Interval on "));
128+
Serial.println(BOARD_NAME);
116129
Serial.println(NRF52_MBED_TIMER_INTERRUPT_VERSION);
117130

118131
// Interval in microsecs
119132
if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
120133
{
121-
Serial.print(F("Starting ITimer0 OK, millis() = ")); Serial.println(millis());
134+
Serial.print(F("Starting ITimer0 OK, millis() = "));
135+
Serial.println(millis());
122136
}
123137
else
124138
Serial.println(F("Can't set ITimer0. Select another freq. or timer"));
125139

126140
// Interval in microsecs
127141
if (ITimer1.attachInterruptInterval(TIMER1_INTERVAL_MS * 1000, TimerHandler1))
128142
{
129-
Serial.print(F("Starting ITimer1 OK, millis() = ")); Serial.println(millis());
143+
Serial.print(F("Starting ITimer1 OK, millis() = "));
144+
Serial.println(millis());
130145
}
131146
else
132147
Serial.println(F("Can't set ITimer1. Select another freq. or timer"));
@@ -157,9 +172,11 @@ void loop()
157172
ITimer0.setInterval(TIMER0_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler0);
158173
ITimer1.setInterval(TIMER1_INTERVAL_MS * 1000 * (multFactor + 1), TimerHandler1);
159174

160-
Serial.print(F("Changing Interval, Timer0 = ")); Serial.print(TIMER0_INTERVAL_MS * (multFactor + 1));
161-
Serial.print(F(", Timer1 = ")); Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));
162-
175+
Serial.print(F("Changing Interval, Timer0 = "));
176+
Serial.print(TIMER0_INTERVAL_MS * (multFactor + 1));
177+
Serial.print(F(", Timer1 = "));
178+
Serial.println(TIMER1_INTERVAL_MS * (multFactor + 1));
179+
163180
lastChangeTime = currTime;
164181
}
165182
}

0 commit comments

Comments
 (0)