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=utf-8">
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_SetBackLight*</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">PM_SetBackLight* <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>u32 PM_SetBackLight( PMLCDTarget target, PMBackLightSwitch sw );
17
18u32 PM_SetBackLightAsync( PMLCDTarget target, PMBackLightSwitch sw, PMCallback callback, void* arg );
19  </CODE></PRE>
20</DL>
21<H2>Arguments</H2>
22<TABLE border="1" width="100%">
23  <TBODY>
24    <TR>
25<TD width="13%"><EM><STRONG>target</STRONG></EM></TD>
26<TD width="87%">Screen that is the target of operation.</TD>
27    </TR>
28    <TR>
29<TD width="13%"><EM><STRONG>sw</STRONG></EM></TD>
30<TD width="87%">Backlight switch.</TD>
31    </TR>
32    <TR>
33<TD><EM><STRONG>callback</STRONG></EM></TD>
34<TD>Callback that is called when the command finishes.</TD>
35    </TR>
36    <TR>
37<TD><EM><STRONG>arg</STRONG></EM></TD>
38<TD>Argument that is used when calling the callback.</TD>
39    </TR>
40  </TBODY>
41</TABLE>
42<H2>Return Values</H2>
43<P>If <CODE>PM_RESULT_SUCCESS</CODE>, the command execution has succeeded (for synchronous functions), or the command was successfully sent to the ARM7 processor (for asynchronous functions).</P>
44<P>If <CODE>PM_INVALID_COMMAND</CODE>, the argument that was passed is invalid.</P>
45<P>If <CODE>PM_RESULT_BUSY</CODE>, the SPI was occupied by other processing and unable to process this function.</P>
46<H2>Description</H2>
47<P>Toggles the specified screen's backlight switch.</P>
48<P>The <CODE>target</CODE> argument is a <code>PMLCDTarget</code> enumerator type that can contain either one of the following values.
49</P>
50<TABLE border="1">
51  <TBODY>
52    <TR>
53<TH>Value of <SPAN class="argument">target</SPAN></TH>
54<TH>Targeted LCD</TH>
55    </TR>
56    <TR>
57<TD><CODE>PM_LCD_TOP</CODE></TD>
58<TD>Top screen</TD>
59    </TR>
60    <TR>
61<TD><CODE>PM_LCD_BOTTOM</CODE></TD>
62<TD>Bottom screen</TD>
63    </TR>
64    <TR>
65<TD><CODE>PM_LCD_ALL</CODE></TD>
66<TD>Top and bottom screens</TD>
67    </TR>
68  </TBODY>
69</TABLE>
70<P><BR> The <SPAN class="argument">sw</SPAN> argument is a <code>PMBackLightSwitch</code> enumerator type value that specifies one of the following values.
71</P>
72<TABLE border="1">
73  <TBODY>
74    <TR>
75<TH>Value of <SPAN class="argument">sw</SPAN></TH>
76<TH>Backlight Operation</TH>
77    </TR>
78    <TR>
79<TD><CODE>PM_BACKLIGHT_OFF</CODE></TD>
80<TD>Turns the backlight OFF.</TD>
81    </TR>
82    <TR>
83<TD><CODE>PM_BACKLIGHT_ON</CODE></TD>
84<TD>Turns the backlight ON.</TD>
85    </TR>
86  </TBODY>
87</TABLE>
88<P><BR> This function performs the operation that is specified by <SPAN class="argument">sw</SPAN> on the screen that is specified by the <SPAN class="argument">target</SPAN> argument.</P>
89
90<P><FONT color="#ff0000">This function can be used from an interrupt handler. This function cannot be used in interrupt-prohibited states other than interrupt handlers.</FONT></P>
91<P><BR> <BR> <B>Prohibition against turning the backlight on and off at high speed</B></P>
92<P>In certain PMIC accessories, PMIC protection features will activate if a lit backlight is turned off and then on again within an extremely short period of time. This causes the TWL system to shut down.<FONT color="#ff0000">There should be a 16 msec interval or longer when when turning the backlight on and off.</FONT>In other words, it is acceptable to switch once per frame.</P>
93<P><BR> <BR> <B>Asynchronous Functions</B></P>
94<P>This function uses PXI to send the command that performs the corresponding operation in the ARM7 processor. The ARM7 side that receives that command is executed by operating the PMIC. Therefore, this function may not operate instantly after you call it. A synchronous function that waits for the operation to finish, as well as an asynchronous function that only sends commands to the ARM7, are provided. Use either of the functions depending on your operational requirements. (The asynchronous function has &quot;Async&quot; appended to the function name.))</P>
95<P>When an asynchronous function is called, the specified <SPAN class="argument">callback</SPAN> is called when processing on the ARM7 finishes. The callback type <CODE>PMCallback</CODE> is defined by:</P>
96<BLOCKQUOTE> <CODE><code>typedef void ( *PMCallback )( u32 result, void* arg )</code>;</CODE></BLOCKQUOTE>
97<P> This callback is called from within the PXI interrupt handler.</P>
98<P>The callback's first argument, <SPAN class="argument">result</SPAN>, indicates the result of the command. This is either <code>PM_RESULT_SUCCESS</code> or <code>PM_RESULT_BUSY</code>. The second argument in the callback returns the value <SPAN class="argument">arg</SPAN>.</P>
99<P><BR> <BR> <B>About <CODE>PM_RESULT_BUSY</CODE></B></P>
100<P>The SPI is used for various other processes besides power management. If you call this function while another process is using it, this function sends a command to the ARM7. There, the SPI is determined to be BUSY, and <CODE>PM_RESULT_BUSY</CODE> is dispatched to the ARM9 without actually processing this function. Likewise, if you call this function while another PM process is running, that fact is determined on the ARM9, and this function returns <CODE>PM_RESULT_BUSY</CODE>. (In this case, the determination is made before notification is sent to the ARM7.)</P>
101<P>Accordingly, if you want to ensure that this function succeeds, make it loop until it succeeds as shown below. (This example does not take into account mistakes such as wrong arguments.)</P>
102<BLOCKQUOTE style="background-color:#ffffcc"><B>Example</B><BR> <CODE>while( PPM_SetBackLight( ... ) != PM_RESULT_SUCCESS )<BR> {<BR> }</CODE></BLOCKQUOTE>
103<P>When using the <CODE>Async</CODE> version of this function, you could do this with code similar to the following.</P>
104<BLOCKQUOTE style="background-color:#ffffcc"><B>Example:</B><BR>
105<PRE>
106void setResult( u32 result, void* arg )
107{
108  if ( arg )
109  {
110    *(u32*)arg = result;
111  }
112}
113
114while(1)
115{
116  volatile u32 result = PM_RESULT_NONE; //A value that will not be returned
117
118  while ( PM_SetSetBackLightAsync(..., setResult, (void*)&amp;result ) != PM_RESULT_SUCCESS )
119  {
120  }
121
122  // Some other process
123  otherProcess();
124
125  // Wait for completion
126  while( result == PM_RESULT_NONE )
127  {
128  }
129
130  // Exit the loop on success
131  if ( result == PM_RESULT_SUCCESS )
132  {
133    break;
134  }
135}</PRE></BLOCKQUOTE>
136<H2>Internal Operation</H2>
137<P>Controls the PMIC_CTL value of the PMIC register.</P>
138<H2>See Also</H2>
139<P><A href="PM_Init.html"><CODE>PM_Init</CODE></A><BR> <A href="PM_GetBackLight.html"><CODE>PM_GetBackLight</CODE></A></P>
140<H2>Revision History</H2>
141<P>2010/06/16 Added a note that a 16 msec time interval or longer is required between turning the backlight on and off.<BR> 2009/06/03 Deleted description of the <CODE>PM_Init</CODE> function. (This is because the <CODE>OS_Init</CODE> function is required.)<BR> 2008/08/23 Discontinued PM_RESULT_ERROR and cited PM_RESULT_BUSY<BR> 2005/07/07 Cited the return value PM_RESULT_ERROR<BR> 2005/06/02 Added note about the caller of the callback<BR> 2004/08/04 Initial version</P>
142<hr><p>CONFIDENTIAL</p></body>
143</HTML>