|
| 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 | +} |
0 commit comments