sched:cpuload_oneshot: add pm callcacks
Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
This commit is contained in:
parent
8634e8de64
commit
1c2583eaad
@ -31,6 +31,7 @@
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/lib/xorshift128.h>
|
||||
#include <nuttx/power/pm.h>
|
||||
#include <nuttx/timers/oneshot.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
@ -98,6 +99,9 @@ struct sched_oneshot_s
|
||||
int32_t maxdelay;
|
||||
int32_t error;
|
||||
#endif
|
||||
#ifdef CONFIG_PM
|
||||
struct pm_callback_s pm_cb;
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -225,6 +229,24 @@ static void nxsched_oneshot_callback(FAR struct oneshot_lowerhalf_s *lower,
|
||||
nxsched_oneshot_start();
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
static void nxsched_oneshot_pmnotify(FAR struct pm_callback_s *cb,
|
||||
int domain, enum pm_state_e pmstate)
|
||||
{
|
||||
if (domain == PM_IDLE_DOMAIN)
|
||||
{
|
||||
if (pmstate == PM_RESTORE)
|
||||
{
|
||||
nxsched_oneshot_start();
|
||||
}
|
||||
else
|
||||
{
|
||||
ONESHOT_CANCEL(g_sched_oneshot.oneshot, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -281,6 +303,13 @@ void nxsched_oneshot_extclk(FAR struct oneshot_lowerhalf_s *lower)
|
||||
g_sched_oneshot.prng.z = g_sched_oneshot.prng.x << 25;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM
|
||||
/* Register pm notify */
|
||||
|
||||
g_sched_oneshot.pm_cb.notify = nxsched_oneshot_pmnotify;
|
||||
pm_register(&g_sched_oneshot.pm_cb);
|
||||
#endif
|
||||
|
||||
/* Then start the oneshot */
|
||||
|
||||
g_sched_oneshot.oneshot = lower;
|
||||
|
Loading…
Reference in New Issue
Block a user