diff --git a/changelog.md b/changelog.md index c1b67780..96eeebfb 100644 --- a/changelog.md +++ b/changelog.md @@ -3,7 +3,8 @@ ### Core - Add HardwarePWM class to support up to 12 channels and compatible with Neopixel library -- Enable FreeRTOS's Idle hook to call waitForEvent() +- Add waitForEvent() as alias to __WFE() instruction +- Enable FreeRTOS's Idle hook, add rtos_idle_callback() as optional callback for user - Add mutex to prevent uart conflict #### New Example @@ -25,7 +26,7 @@ - change BLECentral startScanning()/stopScanning()/connect() return type from `err_t` to `bool` - change BLECharacteristic notify() return type from `err_t` to `bool` - change BLEHid report function return type from `err_t` to `bool` - - change BLEMid send/sendSplit + - change BLEMid send/sendSplit return type from `err_t` to `bool` - New BLE Serivce - Apple Notification Center Service (ANCS) - Central BLE UART diff --git a/cores/nRF5/Arduino.h b/cores/nRF5/Arduino.h index 5f2aef27..a968ec19 100644 --- a/cores/nRF5/Arduino.h +++ b/cores/nRF5/Arduino.h @@ -113,6 +113,8 @@ uint32_t setLoopStacksize(void); // Hint instruction to tell CPU go to low power mode #define waitForEvent() __WFE() +extern 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 dbfecee1..e4f1cfbf 100644 --- a/cores/nRF5/rtos.cpp +++ b/cores/nRF5/rtos.cpp @@ -82,18 +82,15 @@ 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); } - extern "C" { void vApplicationIdleHook( void ) { - // Enter low-power mode will turn of hardware PWM - // Only go there if no PWM device is active. - if ( !(PWM0.begun() || PWM1.begun() || PWM2.begun() ) ) - { - waitForEvent(); - } + // Internal background task + + // Weak symbol do nothing if is not implementation + rtos_idle_callback(); } }