Skip to content

Commit dead887

Browse files
committed
add software_timer example
1 parent 88a2b7a commit dead887

File tree

3 files changed

+60
-2
lines changed

3 files changed

+60
-2
lines changed

libraries/Bluefruit52Lib/examples/Hardware/hw_systick/hw_systick.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extern "C"
3030
*/
3131
void SysTick_Handler(void)
3232
{
33-
ledToggle(LED_BLUE);
33+
ledToggle(LED_RED);
3434
}
3535

3636
} // extern C
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*********************************************************************
2+
This is an example for our nRF52 based Bluefruit LE modules
3+
4+
Pick one up today in the adafruit shop!
5+
6+
Adafruit invests time and resources providing this open source code,
7+
please support Adafruit and open-source hardware by purchasing
8+
products from Adafruit!
9+
10+
MIT license, check LICENSE for more information
11+
All text above, and the splash screen below must be included in
12+
any redistribution
13+
*********************************************************************/
14+
#include <Arduino.h>
15+
16+
/* SoftwareTimer is a helper class that uses FreeRTOS software timer
17+
* to invoke callback. Its periodic timing is flexible as opposed to
18+
* hardware timer and cannot be faster than rtos's tick which is configured
19+
* at ~1 ms interval.
20+
*
21+
* If you need an strict interval timing, or faster frequency, check out
22+
* the hw_systick sketch example that use hardware systick timer.
23+
*
24+
* http://www.freertos.org/RTOS-software-timer.html
25+
*/
26+
SoftwareTimer blinkTimer;
27+
28+
29+
void setup()
30+
{
31+
// Configure the timer with 1000 ms interval, with our callback
32+
blinkTimer.begin(1000, blink_timer_callback);
33+
34+
// Start the timer
35+
blinkTimer.start();
36+
}
37+
38+
void loop()
39+
{
40+
// do nothing here
41+
}
42+
43+
44+
/**
45+
* Software Timer callback is invoked via a built-in FreeRTOS thread with
46+
* minimal stack size. Therefore it should be as simple as possible. If
47+
* a periodically heavy task is needed, please use Scheduler.startLoop() to
48+
* create a dedicated task for it.
49+
*
50+
* More information http://www.freertos.org/RTOS-software-timer.html
51+
*/
52+
void blink_timer_callback(TimerHandle_t xTimerID)
53+
{
54+
// freeRTOS timer ID, ignored if not used
55+
(void) xTimerID;
56+
57+
digitalToggle(LED_RED);
58+
}

libraries/Bluefruit52Lib/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Adafruit BLE Libraries for Bluefruit52
2-
version=0.8.4
2+
version=0.8.5
33
author=Adafruit
44
maintainer=Adafruit <[email protected]>
55
sentence=Arduino library for nRF52-based Adafruit Bluefruit LE modules

0 commit comments

Comments
 (0)