freertos: add frequency switching hooks to ISR and idle task
This commit is contained in:
parent
42d51a4224
commit
535695f0b9
2 changed files with 19 additions and 10 deletions
|
@ -20,6 +20,10 @@
|
|||
#include "esp_attr.h"
|
||||
#include "esp_freertos_hooks.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_pm.h"
|
||||
#include "pm_impl.h"
|
||||
|
||||
//We use just a static array here because it's not expected many components will need
|
||||
//an idle or tick hook.
|
||||
#define MAX_HOOKS 8
|
||||
|
@ -41,20 +45,21 @@ void IRAM_ATTR esp_vApplicationTickHook()
|
|||
|
||||
void esp_vApplicationIdleHook()
|
||||
{
|
||||
bool doWait=true;
|
||||
bool r;
|
||||
int n;
|
||||
bool can_go_idle=true;
|
||||
int core = xPortGetCoreID();
|
||||
for (n=0; n<MAX_HOOKS; n++) {
|
||||
if (idle_cb[core][n]!=NULL) {
|
||||
r=idle_cb[core][n]();
|
||||
if (!r) doWait=false;
|
||||
for (int n = 0; n < MAX_HOOKS; n++) {
|
||||
if (idle_cb[core][n] != NULL && !idle_cb[core][n]()) {
|
||||
can_go_idle = false;
|
||||
}
|
||||
}
|
||||
if (doWait) {
|
||||
//Wait for whatever interrupt comes next... this should save some power.
|
||||
asm("waiti 0");
|
||||
if (!can_go_idle) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_impl_idle_hook();
|
||||
#endif
|
||||
asm("waiti 0");
|
||||
}
|
||||
|
||||
esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid)
|
||||
|
|
|
@ -206,6 +206,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
call4 esp_pm_impl_isr_hook
|
||||
#endif
|
||||
|
||||
#ifdef XT_INTEXC_HOOKS
|
||||
/* Call interrupt hook if present to (pre)handle interrupts. */
|
||||
movi a4, _xt_intexc_hooks
|
||||
|
|
Loading…
Reference in a new issue