From 06d5e7224a1778d9646cd6747d56992120a8d141 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 4 Jul 2012 23:19:59 +0000 Subject: [PATCH] STM32 PM update git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4908 42af7a65-404d-4744-a932-0658087f49c3 --- configs/lpc4330-xplorer/ostest/defconfig | 2 +- configs/stm3210e-eval/src/stm3210e-internal.h | 26 +++++----- configs/stm3210e-eval/src/up_idle.c | 47 ++++++++++++++++++- configs/stm3210e-eval/src/up_pm.c | 5 ++ configs/stm3210e-eval/src/up_pmbuttons.c | 4 +- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/configs/lpc4330-xplorer/ostest/defconfig b/configs/lpc4330-xplorer/ostest/defconfig index 6d6bd7b67fe..bd894902d96 100644 --- a/configs/lpc4330-xplorer/ostest/defconfig +++ b/configs/lpc4330-xplorer/ostest/defconfig @@ -122,7 +122,7 @@ CONFIG_LPC43_USART3=n CONFIG_LPC43_CAN1=n CONFIG_LPC43_CAN2=n CONFIG_LPC43_SPI=n -CONFIG_LPC43_SSP0=y +CONFIG_LPC43_SSP0=n CONFIG_LPC43_SSP1=n CONFIG_LPC43_I2C0=n CONFIG_LPC43_I2C1=n diff --git a/configs/stm3210e-eval/src/stm3210e-internal.h b/configs/stm3210e-eval/src/stm3210e-internal.h index ddfbee428e0..0f31b6201e7 100644 --- a/configs/stm3210e-eval/src/stm3210e-internal.h +++ b/configs/stm3210e-eval/src/stm3210e-internal.h @@ -179,18 +179,6 @@ void weak_function stm32_spiinitialize(void); void weak_function stm32_usbinitialize(void); -/************************************************************************************ - * Name: up_ledpminitialize - * - * Description: - * Register the LEDs to receive power management event callbacks - * - ************************************************************************************/ - -#ifdef CONFIG_PM -void up_ledpminitialize(void); -#endif - /************************************************************************************ * Name: stm32_extcontextsave * @@ -304,6 +292,18 @@ void stm32_deselectlcd(void); #endif /* CONFIG_STM32_FSMC */ +/************************************************************************************ + * Name: up_ledpminitialize + * + * Description: + * Register the LEDs to receive power management event callbacks + * + ************************************************************************************/ + +#if defined(CONFIG_PM) && defined(CONFIG_ARCH_LEDS) +void up_ledpminitialize(void); +#endif + /************************************************************************************ * Name: up_pmbuttons * @@ -314,7 +314,7 @@ void stm32_deselectlcd(void); ************************************************************************************/ #if defined(CONFIG_PM) && defined(CONFIG_IDLE_CUSTOM) -EXTERN void up_pmbuttons(void); +void up_pmbuttons(void); #endif /************************************************************************************ diff --git a/configs/stm3210e-eval/src/up_idle.c b/configs/stm3210e-eval/src/up_idle.c index 27784056bf5..456a92db817 100644 --- a/configs/stm3210e-eval/src/up_idle.c +++ b/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 ****************************************************************************/ diff --git a/configs/stm3210e-eval/src/up_pm.c b/configs/stm3210e-eval/src/up_pm.c index 8fa8b283d40..069a0cb5f96 100644 --- a/configs/stm3210e-eval/src/up_pm.c +++ b/configs/stm3210e-eval/src/up_pm.c @@ -45,6 +45,7 @@ #include "up_internal.h" #include "stm32_pm.h" +#include "stm3210e-internal.h" #ifdef CONFIG_PM @@ -91,6 +92,10 @@ void up_pminitialize(void) /* Then initialize the NuttX power management subsystem proper */ pm_initialize(); + + /* Initialize the LED PM */ + + up_ledpminitialize(); } #endif /* CONFIG_PM */ diff --git a/configs/stm3210e-eval/src/up_pmbuttons.c b/configs/stm3210e-eval/src/up_pmbuttons.c index 527f4616395..62dc45f1e43 100644 --- a/configs/stm3210e-eval/src/up_pmbuttons.c +++ b/configs/stm3210e-eval/src/up_pmbuttons.c @@ -51,13 +51,13 @@ #include "nvic.h" #include "stm32_pwr.h" #include "stm32_pm.h" +#include "stm3210e-internal.h" #if defined(CONFIG_PM) && defined(CONFIG_IDLE_CUSTOM) /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ - /* Configuration ************************************************************/ #ifndef CONFIG_ARCH_BUTTONS @@ -124,6 +124,8 @@ # define CONFIG_PM_BUTTON_ACTIVITY 10 #endif +/* Miscellaneous Definitions ************************************************/ + #ifndef MIN # define MIN(a,b) (a < b ? a : b) #endif