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_attr.h"
|
||||||
#include "esp_freertos_hooks.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
|
//We use just a static array here because it's not expected many components will need
|
||||||
//an idle or tick hook.
|
//an idle or tick hook.
|
||||||
#define MAX_HOOKS 8
|
#define MAX_HOOKS 8
|
||||||
|
@ -41,20 +45,21 @@ void IRAM_ATTR esp_vApplicationTickHook()
|
||||||
|
|
||||||
void esp_vApplicationIdleHook()
|
void esp_vApplicationIdleHook()
|
||||||
{
|
{
|
||||||
bool doWait=true;
|
bool can_go_idle=true;
|
||||||
bool r;
|
|
||||||
int n;
|
|
||||||
int core = xPortGetCoreID();
|
int core = xPortGetCoreID();
|
||||||
for (n=0; n<MAX_HOOKS; n++) {
|
for (int n = 0; n < MAX_HOOKS; n++) {
|
||||||
if (idle_cb[core][n]!=NULL) {
|
if (idle_cb[core][n] != NULL && !idle_cb[core][n]()) {
|
||||||
r=idle_cb[core][n]();
|
can_go_idle = false;
|
||||||
if (!r) doWait=false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doWait) {
|
if (!can_go_idle) {
|
||||||
//Wait for whatever interrupt comes next... this should save some power.
|
return;
|
||||||
asm("waiti 0");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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)
|
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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_ENABLE
|
||||||
|
call4 esp_pm_impl_isr_hook
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XT_INTEXC_HOOKS
|
#ifdef XT_INTEXC_HOOKS
|
||||||
/* Call interrupt hook if present to (pre)handle interrupts. */
|
/* Call interrupt hook if present to (pre)handle interrupts. */
|
||||||
movi a4, _xt_intexc_hooks
|
movi a4, _xt_intexc_hooks
|
||||||
|
|
Loading…
Reference in a new issue