summaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-09-04 19:24:27 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-09-04 19:24:27 +0000
commit7e1e02b8a0fc6f448892b82203a4a77606eb83c9 (patch)
tree3e508a03b68f2a4f31a8d2d3f0c4499a6ba40f12 /nuttx/arch
parent6729d8d258aa6a8734779d5143aafaf56fe073b4 (diff)
downloadpx4-nuttx-7e1e02b8a0fc6f448892b82203a4a77606eb83c9.tar.gz
px4-nuttx-7e1e02b8a0fc6f448892b82203a4a77606eb83c9.tar.bz2
px4-nuttx-7e1e02b8a0fc6f448892b82203a4a77606eb83c9.zip
Add a basic power management framework
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3936 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/sim/src/up_head.c11
-rw-r--r--nuttx/arch/sim/src/up_idle.c21
2 files changed, 32 insertions, 0 deletions
diff --git a/nuttx/arch/sim/src/up_head.c b/nuttx/arch/sim/src/up_head.c
index e1d8c943b..431d417de 100644
--- a/nuttx/arch/sim/src/up_head.c
+++ b/nuttx/arch/sim/src/up_head.c
@@ -47,6 +47,7 @@
#include <nuttx/init.h>
#include <nuttx/arch.h>
+#include <nuttx/pm.h>
/****************************************************************************
* Private Data
@@ -60,6 +61,16 @@ static jmp_buf sim_abort;
int main(int argc, char **argv, char **envp)
{
+ /* Power management should be initialized early in the (simulated) boot
+ * sequence.
+ */
+
+#ifdef CONFIG_PM
+ pm_initialize();
+#endif
+
+ /* Then start NuttX */
+
if (setjmp(sim_abort) == 0)
{
os_start();
diff --git a/nuttx/arch/sim/src/up_idle.c b/nuttx/arch/sim/src/up_idle.c
index 32efaa11b..f1d9974d2 100644
--- a/nuttx/arch/sim/src/up_idle.c
+++ b/nuttx/arch/sim/src/up_idle.c
@@ -40,7 +40,10 @@
#include <nuttx/config.h>
#include <time.h>
+
#include <nuttx/arch.h>
+#include <nuttx/pm.h>
+
#include "up_internal.h"
/****************************************************************************
@@ -103,6 +106,24 @@ void up_idle(void)
uipdriver_loop();
#endif
+ /* Fake some power management stuff for testing purposes */
+
+#ifdef CONFIG_PM
+ {
+ static enum pm_state_e state = PM_NORMAL;
+ enum pm_state_e newstate;
+
+ newstate = pm_checkstate();
+ if (newstate != state)
+ {
+ if (pm_changestate(newstate) == OK)
+ {
+ state = newstate;
+ }
+ }
+ }
+#endif
+
/* Wait a bit so that the sched_process_timer() is called close to the
* correct rate.
*/