From bbee631349798208d720085b41eea752a9db0503 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 12 Jul 2012 14:12:18 +0000 Subject: [PATCH] STM32: remove pm_unregister buttons. Initialize PM buttons only once git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4935 7fd9a85b-ad96-42d3-883c-3090e2eb8679 --- nuttx/configs/stm3210e-eval/README.txt | 40 ++++++++++++++++++- nuttx/configs/stm3210e-eval/pm/defconfig | 4 ++ .../stm3210e-eval/src/stm3210e-internal.h | 12 ------ nuttx/configs/stm3210e-eval/src/up_idle.c | 30 -------------- nuttx/configs/stm3210e-eval/src/up_pm.c | 6 +++ .../configs/stm3210e-eval/src/up_pmbuttons.c | 23 ----------- 6 files changed, 49 insertions(+), 66 deletions(-) diff --git a/nuttx/configs/stm3210e-eval/README.txt b/nuttx/configs/stm3210e-eval/README.txt index c46f73811..d7df1ef9b 100755 --- a/nuttx/configs/stm3210e-eval/README.txt +++ b/nuttx/configs/stm3210e-eval/README.txt @@ -810,10 +810,48 @@ Where is one of the following: This is a configuration that is used to test STM32 power management, i.e., to test that the board can go into lower and lower states of power usage as a result of inactivity. This configuration is based on the nsh2 - configuration with modifications for testing power management. + configuration with modifications for testing power management. This + configuration should provide some guideline for power management in your + STM32 application. CONFIG_STM32_CODESOURCERYW=y : CodeSourcery under Windows + CONFIG_PM_CUSTOMINIT and CONFIG_IDLE_CUSTOM are necessary parts of the + PM configuration: + + CONFIG_PM_CUSTOMINIT=y + + CONFIG_PM_CUSTOMINIT moves the PM initialization from arch/arm/src/stm32/stm32_pminitialiaze.c + to configs/stm3210-eval/src/up_pm.c. This allows us to support board- + specific PM initialization. + + CONFIG_IDLE_CUSTOM=y + + The bulk of the PM activities occur in the IDLE loop. The IDLE loop is + special because it is what runs when there is no other task running. Therefore + when the IDLE executes, we can be assure that nothing else is going on; this + is the ideal condition for doing reduced power management. + + The configuration CONFIG_IDLE_CUSTOM allows us to "steal" the normal STM32 + IDLE loop (of arch/arm/src/stm32/stm32_idle.c) and replace this with our own + custom IDLE loop (at configs/stm3210-eval/src/up_idle.c). + + Here are some additional things to note in the configuration: + + CONFIG_PM_BUTTONS=y + + CONFIG_PM_BUTTONS enables button support for PM testing. Buttons can drive + EXTI interrupts and EXTI interrrupts can be used to wakeup for certain reduced + power modes (STOP mode). The use of the buttons here is for PM testing purposes + only; buttons would normally be part the application code and CONFIG_PM_BUTTONS + would not be defined. + + CONFIG_RTC_ALARM=y + + The RTC alarm is used to wake up from STOP mode and to transition to + STANDBY mode. This used of the RTC alarm could conflict with other uses of + the RTC alarm in your application. + RIDE ---- This configuration builds a trivial bring-up binary. It is diff --git a/nuttx/configs/stm3210e-eval/pm/defconfig b/nuttx/configs/stm3210e-eval/pm/defconfig index d5b0a75f9..5c1d57c84 100644 --- a/nuttx/configs/stm3210e-eval/pm/defconfig +++ b/nuttx/configs/stm3210e-eval/pm/defconfig @@ -473,6 +473,10 @@ CONFIG_IDLE_CUSTOM=y # Board/Application-Specific Power Management Configuration. # These settings are probably not meaningful outside of this configuration # +# Button support can be built into the configs/stm3210e-eval/pm configuration +# to support PM testing. These would not be part of a normal, operational +# configuration. +# CONFIG_PM_BUTTONS=y CONFIG_PM_IRQBUTTONS_MIN=0 CONFIG_PM_IRQBUTTONS_MAX=7 diff --git a/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h b/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h index d0ff66cf4..33a8750f9 100644 --- a/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h +++ b/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h @@ -317,18 +317,6 @@ void up_ledpminitialize(void); void up_pmbuttons(void); #endif -/************************************************************************************ - * Name: up_unregisterbuttons - * - * Description: - * Un-register button handlers - * - ************************************************************************************/ - -#if defined(CONFIG_PM) && defined(CONFIG_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS) -void up_unregisterbuttons(void); -#endif - #endif /* __ASSEMBLY__ */ #endif /* __CONFIGS_STM3210E_EVAL_SRC_STM3210E_INTERNAL_H */ diff --git a/nuttx/configs/stm3210e-eval/src/up_idle.c b/nuttx/configs/stm3210e-eval/src/up_idle.c index f68574bd8..bc5be2bdc 100644 --- a/nuttx/configs/stm3210e-eval/src/up_idle.c +++ b/nuttx/configs/stm3210e-eval/src/up_idle.c @@ -150,41 +150,11 @@ static void up_idlepm(void) case PM_IDLE: { - /* The wake-up event is really dependent upon the application - * an resources provided by the application. However, - * CONFIG_PM_BUTTONS may defined to support PM testing. - */ - -#ifdef CONFIG_PM_BUTTONS - /* Check if the buttons have already been registered */ - - up_unregisterbuttons(); - - /* Initialize the buttons to wake up the system from the idle - * mode - */ - - up_pmbuttons(); -#endif } break; case PM_STANDBY: { - /* The wake-up event is really dependent upon the application - * an resources provided by the application. However, - * CONFIG_PM_BUTTONS may defined to support PM testing. - */ - -#ifdef CONFIG_PM_BUTTONS - /* Check if the buttons have already been registered */ - - up_unregisterbuttons(); - - /* Configure all the buttons as wakeup EXTI */ - - up_pmbuttons(); -#endif #ifdef CONFIG_RTC_ALARM /* Configure the RTC alarm to Auto Wake the system */ diff --git a/nuttx/configs/stm3210e-eval/src/up_pm.c b/nuttx/configs/stm3210e-eval/src/up_pm.c index 069a0cb5f..dd8a79b1c 100644 --- a/nuttx/configs/stm3210e-eval/src/up_pm.c +++ b/nuttx/configs/stm3210e-eval/src/up_pm.c @@ -93,6 +93,12 @@ void up_pminitialize(void) pm_initialize(); +#ifdef CONFIG_PM_BUTTONS + /* Initialize the buttons to wake up the system from low power modes */ + + up_pmbuttons(); +#endif + /* Initialize the LED PM */ up_ledpminitialize(); diff --git a/nuttx/configs/stm3210e-eval/src/up_pmbuttons.c b/nuttx/configs/stm3210e-eval/src/up_pmbuttons.c index 0a214d709..5892ce626 100644 --- a/nuttx/configs/stm3210e-eval/src/up_pmbuttons.c +++ b/nuttx/configs/stm3210e-eval/src/up_pmbuttons.c @@ -281,10 +281,6 @@ static void button_handler(int id, int irq) */ pm_activity(CONFIG_PM_BUTTON_ACTIVITY); - - /* Un-register button handlers */ - - up_unregisterbuttons(); } #if MIN_BUTTON < 1 @@ -387,23 +383,4 @@ void up_pmbuttons(void) #endif } -/**************************************************************************** - * Name: up_unregisterbuttons - * - * Description: - * Un-register button handlers - * - ****************************************************************************/ - -void up_unregisterbuttons(void) -{ -#ifdef CONFIG_ARCH_IRQBUTTONS -int i; - for (i = CONFIG_PM_IRQBUTTONS_MIN; i <= CONFIG_PM_IRQBUTTONS_MAX; i++) - { - (void)up_irqbutton(i, NULL); - } -#endif -} - #endif /* defined(CONFIG_PM) && defined(CONFIG_IDLE_CUSTOM) && defined(CONFIG_PM_BUTTONS) */