#include <nitro/spi.h>
void PM_GoSleepMode(
PMWakeUpTrigger trigger,
PMLogic logic,
u16 keyPattern );
Switches to sleep state for both ARM9 and ARM7.
Sends a sleep command to ARM7. The ARM9 also enters hold mode with OS_Halt().
trigger is a PMWakeUpTrigger enumerated type, and specifies a recovery trigger from the sleep state.
The trigger can specify multiple items by getting the logical sum. The following items can be specified.
| PM_TRIGGER_KEY | Generates key interrupt |
| PM_TRIGGER_RTC_ALARM | Generates RTC alarm interrupt |
| PM_TRIGGER_COVER_OPEN | Opens the cover |
| PM_TRIGGER_CARD | Generates card interrupt or remove Game Card |
| PM_TRIGGER_CARTRIDGE | Generates card interrupt or remove cartridge |
Example: When recovering from sleep mode by opening the cover, removing the Game Pak, or removing the Game Card:
PM_GoSleepMode( PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD | PM_TRIGGER_CARTRIDGE );
Regarding the hardware specification, these return causes are level triggers, not edge triggers. For example, strictly speaking, PM_TRIGGER_CARTRIDGE does not detect when a Game Pak is removed, but rather that no Game Pak is present, and then returns. Therefore, if you try to enter sleep mode with PM_TRIGGER_CARTRIDGE as the recovery trigger while no Game Pak is inserted (already removed), it recovers immediately.
However, Game Card and Game Pak interrupts check (within the function) whether a Game Card or Game Pak is actually inserted. As a result, when you try to insert a recovery trigger while no Game Card or Game Pak is inserted, that trigger is discarded.
When you include key interrupt in recovery trigger, specify with keyPattern and logic the keys for recovery, and their combination logic.
Combination logic is either PM_PAD_LOGIC_AND (performed by all key input), or PM_PAD_LOGIC_OR (performed by any key input). For example, to make recovery
possible only by pressing the A button and the START button at the same time:
PM_GoSleepMode( PM_TRIGGER_KEY, PM_PAD_LOGIC_AND, PAD_BUTTON_A | PAD_BUTTON_START );
To make recovery possible by pushing either the A button or the START button:
PM_GoSleepMode( PM_TRIGGER_KEY, PM_PAD_LOGIC_OR, PAD_BUTTON_A | PAD_BUTTON_START );
When you do not include a key interrupt in the recovery trigger, keyPattern and logic assignments have no meaning. Also, when there is only one key assignment, combination logic may be either PM_PAD_LOGIC_AND or PM_PAD_LOGIC_OR.
When using this function, initialize the PM library in advance with PM_Init(). (Calling once is enough. Also, when you call OS_Init(), this function is called from within that function so you do not need to call it separately.)
It is possible to set the callback functions that are called before entering sleep mode and after awakening from sleep mode. The callback function that is called when entering sleep mode is called at the beginning of PM_GoSleepMode(), and the function that is called after awakening from sleep mode is called at the end of PM_GoSleepMode(), so that it is virtually the same as calling these functions before and after PM_GoSleepMode().
The callback function is a PMSleepCallback type (a function type that retains one void* argument, and that does not have the return values), and multiple functions can be registered. The registered functions are called in order, so pay special attention when registering functions that must be performed in a specific order.
When registering a callback, specify with a callback function or the callback information that includes its argument. For more information, see PM_AppendPreSleepCallback().
trigger |
triggers recovery from sleep state |
logic |
key combination logic when recovering by key interrupt |
keyPattern |
key when recovering by key interrupt |
None.
PM_Init, PM_AppendPreSleepCallback, PM_PrependPreSleepCallback, PM_AppendPostSleepCallback, PM_PrependPostSleepCallback, PM_DeletePreSleepCallback, PM_DeletePostSleepCallback, PM_SetSleepCallback
10/06/2004 Corrected callbacks to allow registration of multiple callbacks
10/05/2004 Added description regarding callbacks
08/07/2004 Separated combination logic in Arguments
08/02/2004 Initial version