9
0
Fork 0

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
This commit is contained in:
patacongo 2012-07-12 14:12:18 +00:00
parent 09745d279b
commit bbee631349
6 changed files with 49 additions and 66 deletions

View File

@ -810,10 +810,48 @@ Where <subdir> 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

View File

@ -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

View File

@ -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 */

View File

@ -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 */

View File

@ -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();

View File

@ -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) */