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>PM_GoSleepMode</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">PM_GoSleepMode <IMG src="../../image/NTR.gif" width="24" height="12" border="0" align=middle><IMG src="../../image/TWL.gif" width="24" height="12" border="0" align=middle></H1>
12<H2>Syntax</H2>
13<DL>
14  <DD>
15  <PRE><CODE>#include &lt;nitro/spi.h&gt;</CODE></PRE>
16  <PRE><CODE>void PM_GoSleepMode( PMWakeUpTrigger trigger, PMLogic logic, u16 keyPattern );
17  </CODE></PRE>
18</DL>
19<H2>Arguments</H2>
20<TABLE border="1" width="100%">
21  <TBODY>
22    <TR>
23<TD width="13%"><EM><STRONG>trigger</STRONG></EM></TD>
24<TD width="87%">Trigger to recover from sleep state.</TD>
25    </TR>
26    <TR>
27<TD width="13%"><EM><STRONG>logic</STRONG></EM></TD>
28<TD width="87%">Key combination logic when recovering with a  key interrupt.</TD>
29    </TR>
30    <TR>
31<TD width="13%"><EM><STRONG>keyPattern</STRONG></EM></TD>
32<TD width="87%">Key when recovering with a key interrupt.</TD>
33    </TR>
34  </TBODY>
35</TABLE>
36<H2>Return Values</H2>
37<P>None.</P>
38<H2>Description</H2>
39<P>Transitions both ARM9 and ARM7 to sleep state.</P>
40<BLOCKQUOTE style="background-color:#ffcccc"><B><FONT color="#ff0000"><B>Note:</B><BR> - The Programming Guidelines prohibit the system from entering sleep mode while wireless communication is still turned ON.<BR> Be sure to turn it OFF.</FONT></B><BR> <BR> <FONT color="#ff0000"><B> - Entering sleep mode while the DSP is loaded is prohibited. <BR>Always shut down operations. (Be sure to call the <A href="../../dsp/g711/DSP_UnloadG711.html"><CODE>DSP_UnloadG711</CODE></A> function.)</B><BR> <BR> <B>- Do not call from the interrupt handler.</B><BR></FONT></BLOCKQUOTE>
41<P>This function sends a sleep command to the ARM7, and the ARM9 itself enters a halted state as well through the <A href="../../os/system/OS_Halt.html"><CODE>OS_Halt</CODE></A> function. The <SPAN class="argument">trigger</SPAN> argument is a <CODE>PMWakeUpTrigger</CODE> enum type that specifies a trigger to recover from the sleep state. The trigger can specify multiple items by getting a logical OR. The following items can be specified.
42</P>
43<TABLE border="1">
44  <TBODY>
45    <TR>
46<TH>Platform</TH>
47<TH>Value</TH>
48<TH>Cause of Recovery</TH>
49    </TR>
50    <TR>
51      <TD><center><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></center></TD>
52<TD><CODE>PM_TRIGGER_KEY</CODE></TD>
53<TD>A key interrupt</TD>
54    </TR>
55    <TR>
56      <TD><center><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></center></TD>
57<TD><CODE>PM_TRIGGER_RTC_ALARM</CODE></TD>
58<TD>An RTC alarm interrupt</TD>
59    </TR>
60    <TR>
61      <TD><center><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></center></TD>
62<TD><CODE>PM_TRIGGER_COVER_OPEN</CODE></TD>
63<TD>Opening the cover</TD>
64    </TR>
65    <TR>
66      <TD><center><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></center></TD>
67<TD><CODE>PM_TRIGGER_CARD</CODE></TD>
68<TD>A card interrupt or Game Card removal</TD>
69    </TR>
70    <TR>
71      <TD><center><IMG src="../../image/NTR.gif"><IMG src="../../image/TWL.gif"></center></TD>
72<TD><CODE>PM_TRIGGER_CARTRIDGE</CODE> <B><FONT color="#ff0000">(Note 1)</FONT></B></TD>
73<TD>A Game Pak interrupt or Game Pak removal</TD>
74    </TR>
75    <TR>
76      <TD><center><IMG src="../../image/BPT.gif"><IMG src="../../image/TWL.gif"></center></TD>
77<TD><CODE>PM_TRIGGER_SDIO</CODE></TD>
78<TD>SDIO interrupt</TD>
79    </TR>
80  </TBODY>
81</TABLE>
82<FONT color="red"> <B>Note 1:</B> Waking from sleep upon removal of a Game Pak is prohibited by the programming guidelines.</FONT>
83<BLOCKQUOTE style="background-color:#ffffcc;"><B>Example:</B> To enter sleep mode and recover by opening the cover or removing the Game Card, use <CODE>PM_GoSleepMode( PM_TRIGGER_COVER_OPEN | PM_TRIGGER_CARD ,0 ,0 );</CODE></BLOCKQUOTE>
84<P>In terms of the hardware specification, these recovery triggers are level triggers, not edge triggers. For example, strictly speaking, <CODE>PM_TRIGGER_CARTRIDGE</CODE> does not detect when a Game Pak is removed, but rather that no Game Pak is inserted, and then returns. (More specifically, it detects the status of the <CODE>OS_IE_CARTRIDGE_IREQ</CODE> interrupt in operation.) Therefore, if you try to enter sleep mode with <CODE>PM_TRIGGER_CARTRIDGE</CODE> as the recovery trigger while no Game Pak is inserted (the system determines this as already removed), it recovers immediately.</P>
85<P>However, Game Card and Game Pak interrupts check (inside 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.</P>
86<P><B><BR> <BR> Recovery by a Key Interrupt</B></P>
87<P>When you include key interrupt in recovery trigger, specify the keys to trigger recovery and their combination logic with <SPAN class="argument">keyPattern</SPAN> and <SPAN class="argument">logic</SPAN>. The combination logic is either <CODE>PM_PAD_LOGIC_AND</CODE> (when input is from <I>all</I> keys), or <CODE>PM_PAD_LOGIC_OR</CODE> (when input is from <I>any</I> key). For example, to make recovery possible only by pressing the A Button and START at the same time:</P>
88<P><CODE>PM_GoSleepMode( PM_TRIGGER_KEY, <FONT color="#ff3300">PM_PAD_LOGIC_AND</FONT>, PAD_BUTTON_A | PAD_BUTTON_START );</CODE></P>
89<P>To make recovery possible by pushing either the A button or START:</P>
90<P><CODE>PM_GoSleepMode( PM_TRIGGER_KEY, <FONT color="#ff3300">PM_PAD_LOGIC_OR</FONT>, PAD_BUTTON_A | PAD_BUTTON_START );</CODE></P>
91<P>&nbsp; </P>
92<P>When you do not include a key interrupt in the recovery trigger, specifications for <SPAN class="argument">keyPattern</SPAN> and <SPAN class="argument">logic</SPAN> are meaningless. Also, when there is only one key assignment, the combination logic <SPAN class="argument">logic</SPAN> may be either <CODE>PM_PAD_LOGIC_AND</CODE> or <CODE>PM_PAD_LOGIC_OR</CODE>.</P>
93<P><B><BR> <BR> Recovery by an SDIO Interrupt</B></P>
94<P>SDIO interrupts can be used for recovery on the TWL platform. This interrupt is provided for future extensions and assumes that a supported device has been plugged into the SD card slot. This can also be used with wireless communications. This should not usually be specified.</P>
95<P><BR> <BR> <B>Callback Functions</B></P>
96<P>It is possible to set callback functions to be 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 the <code>PM_GoSleepMode</code> function, and the function that is called after awakening from sleep mode is called at the end of <code>PM_GoSleepMode</code>. This is equivalent to calling these functions before and after <code>PM_GoSleepMode</code>.</P>
97<P>The callback function is a <code>PMSleepCallback</code> type (a function type that retains one <code>void*</code> argument and no 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.</P>
98<P>When registering a callback, specify with the callback function and the callback information including the arguments. For more information, see the reference for the <a href="PM_AppendSleepCallback.html"><CODE>PM_AppendPreSleepCallback</CODE></a> function.</P>
99<P><BR> <BR> <B>Calls from an Interrupt Handler</B></P>
100<P>The <CODE>PM_GoSleepMode</CODE> function <FONT color="#ff0000">does not expect to be called from an interrupt handler</FONT>. Do not call it from an interrupt handler.</P>
101<P><B><BR></B><BR> <B>Possible Delays</B></P>
102<P>The <CODE>PM_GoSleepMode</CODE> function internally calls several PM functions. When the SPI is occupied by another device and therefore BUSY, this function continues calling the PM functions until they succeed. As a result, the time at which the system actually enters sleep mode may be delayed from the time this function is called.</P>
103<H2>See Also</H2>
104<P><A href="PM_Init.html"><CODE>PM_Init</CODE></A><BR> <A href="PM_AppendSleepCallback.html"><CODE>PM_AppendPreSleepCallback</CODE></A><BR> <A href="PM_AppendSleepCallback.html"><CODE>PM_PrependPreSleepCallback</CODE></A><BR> <A href="PM_AppendSleepCallback.html"><CODE>PM_AppendPostSleepCallback</CODE></A><BR> <A href="PM_AppendSleepCallback.html"><CODE>PM_PrependPostSleepCallback</CODE></A><BR> <A href="PM_DeleteSleepCallback.html"><CODE>PM_DeletePreSleepCallback</CODE></A><BR> <A href="PM_DeleteSleepCallback.html"><CODE>PM_DeletePostSleepCallback</CODE></A><BR> <A href="PM_SetSleepCallbackInfo.html"><CODE>PM_SetSleepCallbackInfo</CODE></A></P>
105
106<H2>Revision History</H2>
107<P>2009/06/03 Removed a description of the <CODE>PM_Init</CODE> function (because <CODE>OS_Init</CODE> is now required). <BR>2008/09/11 Indicated that sleep was prohibited when using the DSP.<BR> 2008/08/23 Indicated the possibility for delays.<BR> 2008/03/13 Added the SDIO trigger and denoted that calls from an interrupt handler are not possible.<BR> 2006/05/16 Modified the description of Game Pak removal as a cause for restoring.<BR> 2005/09/14 Changed the <CODE>PM_SetSleepCallback</CODE> function to the <CODE>PM_SetSleepCallbackInfo</CODE> function.<BR> 2005/03/08 Standardized Japanese terminology for &quot;interrupt.&quot;<br> 2004/10/06 Revised to allow registration of multiple callbacks.<BR> 2004/10/05 Added more information on callbacks.<BR> 2004/08/07 Separated combination logic into an argument.<BR> 2004/08/02 Initial version.</P>
108<hr><p>CONFIDENTIAL</p></body>
109</HTML>