From 7d9787d530bc4c05f354f682cf1d2aa140eb9160 Mon Sep 17 00:00:00 2001 From: zhuguangqing Date: Mon, 27 Aug 2018 13:18:09 -0600 Subject: [PATCH] drivers/power: PM: Add pm_querystate function --- drivers/power/pm_changestate.c | 19 +++++++++++++++++++ include/nuttx/power/pm.h | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/power/pm_changestate.c b/drivers/power/pm_changestate.c index 92c75a770f..28280958d0 100644 --- a/drivers/power/pm_changestate.c +++ b/drivers/power/pm_changestate.c @@ -213,4 +213,23 @@ int pm_changestate(int domain, enum pm_state_e newstate) return ret; } +/**************************************************************************** + * Name: pm_querystate + * + * Description: + * This function returns the current power management state. + * + * Input Parameters: + * domain - The PM domain to check + * + * Returned Value: + * The current power management state. + * + ****************************************************************************/ + +enum pm_state_e pm_querystate(int domain) +{ + return g_pmglobals.domain[domain].state; +} + #endif /* CONFIG_PM */ diff --git a/include/nuttx/power/pm.h b/include/nuttx/power/pm.h index 2be7594f11..09daee2533 100644 --- a/include/nuttx/power/pm.h +++ b/include/nuttx/power/pm.h @@ -550,6 +550,22 @@ enum pm_state_e pm_checkstate(int domain); int pm_changestate(int domain, enum pm_state_e newstate); +/**************************************************************************** + * Name: pm_querystate + * + * Description: + * This function returns the current power management state. + * + * Input Parameters: + * domain - The PM domain to check + * + * Returned Value: + * The current power management state. + * + ****************************************************************************/ + +enum pm_state_e pm_querystate(int domain); + #undef EXTERN #ifdef __cplusplus } @@ -575,6 +591,7 @@ int pm_changestate(int domain, enum pm_state_e newstate); # define pm_relax(domain,state) # define pm_checkstate(domain) (0) # define pm_changestate(domain,state) +# define pm_querystate(domain) (0) #endif /* CONFIG_PM */ #endif /* __INCLUDE_NUTTX_POWER_PM_H */