1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2<HTML> 3<HEAD> 4<META http-equiv="Content-Type" content="text/html; charset=windows-1252"> 5<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder Version 7.0.1.0 for Windows"> 6<META http-equiv="Content-Style-Type" content="text/css"> 7<TITLE>Sleep: Overview</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">Sleep: Overview <IMG src="../../image/NTR.gif" align="middle"><IMG src="../../image/TWL.gif" align="middle"></H1> 12 13<H2>Description</H2> 14<P>To conserve power, the TWL system can enter sleep mode, separate from the normal (active) mode. Normally, games are created to enter sleep mode when the cover is closed and to recover from sleep mode when the cover is opened. This is not a hardware feature. The application detects that the cover was closed and calls a function to put the system to sleep. This document describes sleep-related functions.</P> 15<H2>Causes for Sleep Mode</H2> 16<P>Call the <A href="PM_GoSleepMode.html"><CODE>PM_GoSleepMode</CODE></A> function to enter sleep mode.</P> 17<P>You can specify the following causes for recovery from sleep mode with this command. You can specify several of these items by taking the logical OR of their values. See the <A href="PM_GoSleepMode.html"><CODE>PM_GoSleepMode</CODE></A> function for more information. 18</P> 19<TABLE border=1> 20<TBODY> 21<TR> 22<TH>Platform</TH> 23<TH>Value</TH> 24<TH>Cause of recovery</TH> 25 </TR> 26<TR> 27<TD> 28<CENTER><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></CENTER> 29 </TD> 30<TD><CODE><CODE>PM_TRIGGER_KEY</CODE></TD> 31<TD>A key interrupt</TD> 32 </TR> 33<TR> 34<TD> 35<CENTER><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></CENTER> 36 </TD> 37<TD><CODE>PM_TRIGGER_RTC_ALARM</CODE></TD> 38<TD>An RTC alarm interrupt</TD> 39 </TR> 40<TR> 41<TD> 42<CENTER><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></CENTER> 43 </TD> 44<TD><CODE>PM_TRIGGER_COVER_OPEN</CODE></TD> 45<TD>Opening the cover</TD> 46 </TR> 47<TR> 48<TD> 49<CENTER><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></CENTER> 50 </TD> 51<TD><CODE>PM_TRIGGER_CARD</CODE></TD> 52<TD>A card interrupt or Game Card removal</TD> 53 </TR> 54<TR> 55<TD> 56<CENTER><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></CENTER> 57 </TD> 58<TD><CODE>PM_TRIGGER_CARTRIDGE</CODE> <B><FONT color=#ff0000>(Note 1)</FONT></B></TD> 59<TD>A Game Pak interrupt or remove the Game Pak</TD> 60 </TR> 61<TR> 62<TD> 63<CENTER><IMG src="../../image/BPT.gif"><IMG src="../../image/TWL.gif"></CENTER> 64 </TD> 65<TD><CODE>PM_TRIGGER_SDIO</CODE></TD> 66<TD>SDIO interrupt</TD> 67 </TR> 68 </TBODY> 69</TABLE> 70<P><FONT color=red> <B>Note 1:</B> Waking from sleep upon removal of a Game Pak is prohibited by the programming guidelines.</FONT> </P> 71<H2>Sleep Callback List</H2> 72<P>The sleep callback is defined as follows: <BR> <CODE>typedef void (*PMGenCallback) (void *);</CODE><BR> It is a <CODE>void</CODE> function that takes a single <CODE>void*</CODE> argument.</P> 73<P>The callback invoked immediately after entering sleep mode and the callback invoked immediately after recovering from sleep mode are each stored internally in a list. These are called the pre-sleep and post-sleep callbacks.</P> 74<P><IMG src="sleep_List1.gif" width="340" height="224" border="0"></P> 75<H2>Sleep Callback Registration</H2> 76<P>Callbacks have configurable priority levels. Applications can use priorities ranging from -255 (<CODE>PM_CALLBACK_PRIORITY_MIN</CODE>) to 255 (<CODE>PM_CALLBACK_PRIORITY_MAX</CODE>). The system (such as the SDK library and middleware) can use priorities ranging from -65,535 (<CODE>PM_CALLBACK_PRIORITY_SYSMIN</CODE>) to 65,535 (<CODE>PM_CALLBACK_PRIORITY_SYSMAX</CODE>). These priorities are used only to determine the order of the callback list. Items having smaller values are placed closer to the start of the list.</P> 77<P>Use the <CODE><A href="PM_SetSleepCallbackInfo.html">PM_SetSleepCallbackInfo</A></CODE> function to configure a callback function and its arguments in a callback information structure, and then register that structure to the list.</P> 78<P>It can be registered in one of three ways.</P> 79<UL> 80<LI>The <A href="PM_AppendSleepCallback.html"><CODE>PM_PrependPreSleepCallback</CODE></A> and <A href="PM_AppendSleepCallback.html"><CODE>PM_PrependPostSleepCallback</CODE></A> functions.<BR>Register in the list at priority level -255. If there is already a registered callback with a priority of -255, the new callback will be registered in front of it.<BR>In other words, if you consider it only in terms of the priorities that the application can use, this inserts the new callback at the front of the list.<BR> <BR> 81<LI>The <A href="PM_AppendSleepCallback.html"><CODE>PM_AppendPreSleepCallback</CODE></A> and <A href="PM_AppendSleepCallback.html"><CODE>PM_AppendPostSleepCallback</CODE></A> functions.<BR>Register in the list at priority level 255. If there is already a registered callback with a priority of 255, the new callback will be registered behind it.<BR>In other words, if you consider it only in terms of the priorities that the application can use, this inserts the new callback at the end of the list.<BR> <BR> 82<LI>The <A href="PM_AppendSleepCallback.html"><CODE>PM_InsertPreSleepCallback</CODE></A> and <A href="PM_AppendSleepCallback.html"><CODE>PM_InsertPostSleepCallback</CODE></A> functions.<BR>Specifies a priority level and registers in the appropriate position. It will be registered behind any other items with the same priority.<BR> 83</UL> 84<P>These specifications are the same as the exit callback, so see <B>Exit Callback Registration</B> in <A href="about_exit.html">Overview (Hardware Reset and Shutdown)</A>.</P> 85<H2>Sleep Callback Removal</H2> 86<P>The configured callbacks can be removed using the <A href="PM_DeleteSleepCallback.html"><CODE>PM_DeletePreSleepCallback</CODE></A> and <A href="PM_DeleteSleepCallback.html"><CODE>PM_DeletePostSleepCallback</CODE></A> functions.</P> 87<H2>Sleep Callback Display (For Debugging)</H2> 88<P>The <CODE><A href="PM_DumpSleepCallback.html">PM_DumpSleepCallback</A></CODE> function is used in debugging to display the list of callbacks. It will not do anything in FINALROM builds.</P> 89<H2>Preparations for Powering Down in Sleep Mode</H2> 90<P>It is difficult to perform the same shutdown processing (make the same guarantees) in sleep mode as in active mode because the overall system state is different. Necessary processing must therefore be done in advance when entering sleep mode, rather than during sleep mode.</P> 91<P>Consequently, a sudden power disruption during sleep mode does not have any ill effects on the TWL system. The resulting behavior is the same as if the Power Button was pressed in active mode.</P> 92<H2>Registered Sleep Callbacks</H2> 93<P>Sleep callbacks registered by the SDK run the processes described below.</P> 94<P>Pre-sleep callbacks are as follows.</P> 95<UL> 96<LI>Stop the Rumble feature (if necessary). 97<LI>Put the camera into standby mode. 98<LI>Stop the DSP. 99<LI>Wait until the process terminates during IIR filter configuration. Restore the speaker volume if a value has been saved by the <A href="../../snd/sndex/SNDEX_SetIgnoreHWVolume.html"><CODE>SNDEX_SetIgnoreHWVolume</CODE></A> function. 100<LI>Flash NAND memory. 101<LI>Disconnect from access points and stop any active TWL wireless communications. 102</UL> 103<P>Post-sleep callbacks are as follows.</P> 104<UL> 105<LI>Synchronize the software clock, which shifted while in sleep mode, with the real-time clock. 106</UL> 107<H2>Revision History</H2> 108<P>2009/02/03 Added a description of the process in SNDEX for the shutdown callback to be registered.<BR> 2008/09/13 Initial version.</P> 109<hr><p>CONFIDENTIAL</p></body> 110</HTML> 111