From 32075ef9d8a80ca07807f057d98d211f8992d0db Mon Sep 17 00:00:00 2001 From: ligd Date: Sun, 27 Jan 2019 11:19:26 -0600 Subject: [PATCH] drivers/power/pm_activity.c: Add pm_staycount API for get stay numbers. This function is currently not used and a waste of FLASH space. --- drivers/power/pm_activity.c | 30 ++++++++++++++++++++++++++++++ include/nuttx/power/pm.h | 20 ++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/power/pm_activity.c b/drivers/power/pm_activity.c index 806be27382..9e2f2a0512 100644 --- a/drivers/power/pm_activity.c +++ b/drivers/power/pm_activity.c @@ -222,4 +222,34 @@ void pm_relax(int domain, enum pm_state_e state) leave_critical_section(flags); } +/**************************************************************************** + * Name: pm_staycount + * + * Description: + * This function is called to get current stay count. + * + * Input Parameters: + * domain - The domain of the PM activity + * state - The state want to relax. + * + * Returned Value: + * Current pm stay count + * + * Assumptions: + * This function may be called from an interrupt handler. + * + ****************************************************************************/ + +uint32_t pm_staycount(int domain, enum pm_state_e state) +{ + FAR struct pm_domain_s *pdom; + + /* Get a convenience pointer to minimize all of the indexing */ + + DEBUGASSERT(domain >= 0 && domain < CONFIG_PM_NDOMAINS); + pdom = &g_pmglobals.domain[domain]; + + return pdom->stay[state]; +} + #endif /* CONFIG_PM */ diff --git a/include/nuttx/power/pm.h b/include/nuttx/power/pm.h index 0928264ba8..dc670d7f04 100644 --- a/include/nuttx/power/pm.h +++ b/include/nuttx/power/pm.h @@ -491,6 +491,26 @@ void pm_stay(int domain, enum pm_state_e state); void pm_relax(int domain, enum pm_state_e state); +/**************************************************************************** + * Name: pm_staycount + * + * Description: + * This function is called to get current stay count. + * + * Input Parameters: + * domain - The domain of the PM activity + * state - The state want to relax. + * + * Returned Value: + * Current pm stay count + * + * Assumptions: + * This function may be called from an interrupt handler. + * + ****************************************************************************/ + +uint32_t pm_staycount(int domain, enum pm_state_e state); + /**************************************************************************** * Name: pm_checkstate *