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

Commit

Permalink
v1.4.1 to add support to Seeeduino nRF52
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
khoih-prog authored Oct 26, 2022
1 parent 771b336 commit 340ccc2
Show file tree
Hide file tree
Showing 23 changed files with 460 additions and 208 deletions.
30 changes: 26 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +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
* Arduino `mbed` Core Version (e.g. Arduino `mbed` core v1.3.2 or Arduino `mbed_nano` core v2.6.1 )
* `nRF52840 mbed` Core Version (e.g. Arduino mbed_nano core v3.4.1, Seeeduino mbed core v2.7.2)
* `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.)
* 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,12 +28,13 @@ Please ensure to specify the following:

```
Arduino IDE version: 1.8.19
Arduino mbed_nano` core v2.6.1
Arduino mbed_nano core v3.4.1
Nano_33_BLE board
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-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. ...
Expand All @@ -41,12 +43,32 @@ Steps to reproduce:
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_MBED_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_MBED_TimerInterrupt_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_MBED_TimerInterrupt_GitHub$
```

2. Issue astyle command

```
xy@xy-Inspiron-3593:~/Arduino/xy/NRF52_MBED_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.1](#releases-v141)
* [Releases v1.4.0](#releases-v140)
* [Releases v1.3.0](#releases-v130)
* [Releases v1.2.1](#releases-v121)
Expand All @@ -25,6 +26,12 @@

## Changelog

### 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

### Releases v1.4.0

1. Fix `multiple-definitions` linker error. Drop `src_cpp` and `src_h` directories
Expand Down
39 changes: 27 additions & 12 deletions examples/Argument_None/Argument_None.ino
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@
//#endif

#ifndef LED_BLUE_PIN
#define LED_BLUE_PIN D7
#if defined(LEDB)
#define LED_BLUE_PIN LEDB
#else
#define LED_BLUE_PIN D7
#endif
#endif

#ifndef LED_RED_PIN
#define LED_RED_PIN D8
#if defined(LEDR)
#define LED_RED_PIN LEDR
#else
#define LED_RED_PIN D8
#endif
#endif

#define TIMER0_INTERVAL_MS 500 //1000
Expand All @@ -73,9 +81,12 @@ NRF52_MBED_Timer 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 @@ -96,7 +107,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 @@ -106,27 +117,31 @@ 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_MBED_TIMER_INTERRUPT_VERSION);

// 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
43 changes: 30 additions & 13 deletions examples/Change_Interval/Change_Interval.ino
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

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

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

#ifndef LED_BLUE_PIN
#define LED_BLUE_PIN D7
#if defined(LEDB)
#define LED_BLUE_PIN LEDB
#else
#define LED_BLUE_PIN D7
#endif
#endif

#ifndef LED_RED_PIN
#define LED_RED_PIN D8
#if defined(LEDR)
#define LED_RED_PIN LEDR
#else
#define LED_RED_PIN D8
#endif
#endif

#define TIMER0_INTERVAL_MS 500 //1000
Expand All @@ -73,9 +81,12 @@ NRF52_MBED_Timer 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 Down Expand Up @@ -108,25 +119,29 @@ void setup()
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_MBED_TIMER_INTERRUPT_VERSION);

// 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 Expand Up @@ -157,9 +172,11 @@ void loop()
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 340ccc2

Please sign in to comment.