# PM_SetAutoExit

## Syntax

      #include <twl/spi.h>

      void PM_SetAutoExit( BOOL sw );

## Arguments

sw | Whether to exit automatically.

## Return Values

None.

## Description

Configures whether to proceed automatically to hardware reset or power-off after exit processing has finished.

The TWL console transitions to exit processing when the Power Button is pressed (depending on how long the button is held down, this leads to either hardware reset or power-off) or when a drop in the remaining battery life has been detected (this leads to power-off). When the Power Button is pressed or when the battery level becomes low, this event triggers an interrupt from the microprocessor to the ARM7, and notification is sent to the ARM9. The ARM9 then calls the exit callbacks and notifies the ARM7 when exit preparations are finished. The ARM7 then resets the hardware or turn the power OFF.

Transmission from the ARM7 to the ARM9 is executed only once. In other words, even if the Power Button is pressed again before a message can be sent to the ARM7 indicating that the ARM9 has finished preparation for shutdown, that notification is not sent from the ARM7. As such, the shutdown callback process is not executed again regardless of the time at which the Power Button is pressed.

The `PM_SetAutoExit` function specifies whether the system or the application informs the ARM7 that preparations to exit are complete after the ARM9 has invoked the exit callbacks. The value of the sw argument results in the following.

Value of the sw Argument | Operation
--- | ---
`TRUE` | After the callbacks have been invoked, the system will continue exit processing and either reset the hardware or turn the power OFF. (default)
`FALSE` | After the callbacks have been invoked, the ARM7 will not be notified that exit preparations are complete. This must be done by the application.

When `PM_SetAutoExit( FALSE )` is run, the application must explicitly notify the ARM7 that exit preparations are complete. Call the `PM_ReadyToExit` function as quickly as possible. If the user continuously presses the Power Button, the system is forcibly powered OFF in several seconds as part of hardware specifications. There is also no notification if the shutdown process is entered due to low battery charge.

`PM_GetAutoExit` is the function used to get the auto exit setting value.

## See Also

`PM_GetAutoExit`
`PM_ReadyToExit`

## Revision History

2009/06/03 Removed a description of the `PM_Init` function (because `OS_Init` is now required).
2008/12/11 Noted that the shutdown callback is not invoked twice.
2008/02/07 Initial version.

CONFIDENTIAL