From e84fd5402752ae003f777adb0dde80fd8d781f6d Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Sep 2017 15:48:15 +0700 Subject: [PATCH] added suspendLoop for low power --- changelog.md | 3 ++- cores/nRF5/Arduino.h | 1 + cores/nRF5/main.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 7f34c691..8d1d3f1e 100644 --- a/changelog.md +++ b/changelog.md @@ -5,7 +5,8 @@ ### Core - Make FreeRTOS run in tickless mode -- Added systemOff() to enter hibernate mode +- Added systemOff() to enter System Off mode +- Added suspendLoop() to disable loop() task to further save power - Correct waitForEvent() function with SoftDevice enabled and disabled. - Added RotaryEncoder support for both Hardware and Software Encoder. - Ada Callback task is started along with loop task, used as worker thread to defer interrupt callback. diff --git a/cores/nRF5/Arduino.h b/cores/nRF5/Arduino.h index d871a8c4..9a0880ef 100644 --- a/cores/nRF5/Arduino.h +++ b/cores/nRF5/Arduino.h @@ -35,6 +35,7 @@ void yield( void ) ; void setup( void ) ; void loop( void ) ; +void suspendLoop(void); uint32_t setLoopStacksize(void); #include "WVariant.h" diff --git a/cores/nRF5/main.cpp b/cores/nRF5/main.cpp index 9a3d5316..df93cb61 100644 --- a/cores/nRF5/main.cpp +++ b/cores/nRF5/main.cpp @@ -32,6 +32,8 @@ void Bluefruit_printInfo() {} #include "SEGGER_SYSVIEW.h" #endif +static TaskHandle_t _loopHandle; + // Weak empty variant initialization function. // May be redefined by variant files. @@ -92,7 +94,6 @@ int main( void ) #endif // Create a task for loop() - TaskHandle_t _loopHandle; xTaskCreate( loop_task, "loop", _loopStacksize, NULL, TASK_PRIO_LOW, &_loopHandle); // Initialize callback task @@ -105,3 +106,8 @@ int main( void ) return 0; } + +void suspendLoop(void) +{ + vTaskSuspend(_loopHandle); +}