diff --git a/cores/nRF5/Arduino.h b/cores/nRF5/Arduino.h index ab0810b5..631bac7a 100644 --- a/cores/nRF5/Arduino.h +++ b/cores/nRF5/Arduino.h @@ -111,6 +111,7 @@ uint32_t setLoopStacksize(void); #define portModeRegister(port) ( &(NRF_GPIO->DIRSET) ) #define digitalPinHasPWM(P) ( true ) +void rtos_idle_callback(void) ATTR_WEAK; /* * digitalPinToTimer(..) is AVR-specific and is not defined for nRF52 * architecture. If you need to check if a pin supports PWM you must diff --git a/cores/nRF5/rtos.cpp b/cores/nRF5/rtos.cpp index fb3f96e8..216d3236 100644 --- a/cores/nRF5/rtos.cpp +++ b/cores/nRF5/rtos.cpp @@ -82,9 +82,6 @@ bool SchedulerRTOS::startLoop(taskfunc_t task, const char* name, uint32_t stack_ return pdPASS == xTaskCreate( _redirect_task, name, stack_size, (void*) task, TASK_PRIO_NORMAL, &handle); } -void rtos_idle_callback(void) ATTR_WEAK; -void rtos_idle_callback(void) {} - extern "C" { @@ -92,11 +89,15 @@ void vApplicationIdleHook( void ) { // Internal background task - // Weak symbol do nothing if is not implementation - rtos_idle_callback(); - - // All done. Instruct CPU to enter low-power state until an event/interrupt occurred - waitForEvent(); + // User callback is not defined. Go to low-power mode + if ( rtos_idle_callback ) + { + rtos_idle_callback(); + }else + { + // instruct CPU to enter low-power state until an event/interrupt occurred + waitForEvent(); + } } -} +} // extern C