From 66f63ed1f30dc55cce19f2883d8ebe66dd7fb91e Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 4 Jul 2012 23:19:59 +0000 Subject: STM32 PM update git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4908 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/configs/stm3210e-eval/src/up_idle.c | 47 +++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'nuttx/configs/stm3210e-eval/src/up_idle.c') diff --git a/nuttx/configs/stm3210e-eval/src/up_idle.c b/nuttx/configs/stm3210e-eval/src/up_idle.c index 27784056b..456a92db8 100644 --- a/nuttx/configs/stm3210e-eval/src/up_idle.c +++ b/nuttx/configs/stm3210e-eval/src/up_idle.c @@ -53,11 +53,12 @@ #include "stm32_pm.h" #include "stm32_rcc.h" #include "up_internal.h" +#include "stm3210e-internal.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ - +/* Configuration ************************************************************/ /* Does the board support an IDLE LED to indicate that the board is in the * IDLE state? */ @@ -70,6 +71,22 @@ # define END_IDLE() #endif +/* Values for the RTC Alarm to wake up from the PM_STANDBY mode */ + +#ifndef CONFIG_PM_ALARM_SEC +# define CONFIG_PM_ALARM_SEC 1 +#endif + +#ifndef CONFIG_PM_ALARM_NSEC +# define CONFIG_PM_ALARM_NSEC 0 +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static void up_alarmcb(void); + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -85,11 +102,12 @@ #ifdef CONFIG_PM static void up_idlepm(void) { + struct timespec alarmtime; static enum pm_state_e oldstate = PM_NORMAL; enum pm_state_e newstate; irqstate_t flags; int ret; - + /* Decide, which power saving level can be obtained */ newstate = pm_checkstate(); @@ -150,6 +168,18 @@ static void up_idlepm(void) up_pmbuttons(); + /* Configure the RTC alarm to Auto Wake the system */ + + alarmtime.tv_sec = CONFIG_PM_ALARM_SEC; + alarmtime.tv_nsec = CONFIG_PM_ALARM_NSEC; + + ret = up_rtc_setalarm(&alarmtime, &up_alarmcb); + if (ret < 0) + { + lldbg("The alarm is already set to %d seconds \n", + alarmtime.tv_sec); + } + /* Call the STM32 stop mode */ stm32_pmstop(true); @@ -173,6 +203,19 @@ static void up_idlepm(void) # define up_idlepm() #endif + +/************************************************************************************ + * Name: up_alarmcb + * + * Description: + * RTC alarm service routine + * + ************************************************************************************/ + +static void up_alarmcb(void) +{ +} + /**************************************************************************** * Public Functions ****************************************************************************/ -- cgit v1.2.3