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_SetAmpGain*</TITLE>
8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css">
9</HEAD>
10<BODY>
11<H1 align="left">PM_SetAmpGain* <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_SetAmpGain( PMAmpGain val );
17
18u32 PM_SetAmpGainAsync( PMAmpGain val, 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>val</STRONG></EM></TD>
26<TD width="87%">Setting value that determines the amp gain.</TD>
27    </TR>
28    <TR>
29<TD><EM><STRONG>callback</STRONG></EM></TD>
30<TD>Callback that is called when the command finishes.</TD>
31    </TR>
32    <TR>
33<TD><EM><STRONG>arg</STRONG></EM></TD>
34<TD>Argument that is used when calling the callback.</TD>
35    </TR>
36  </TBODY>
37</TABLE>
38<H2>Return Values</H2>
39<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>
40<P>If <CODE>PM_RESULT_BUSY</CODE>, the SPI was occupied by other processing and unable to process this function.</P>
41<H2>Description</H2>
42<P>Sets the programmable amp gain.</P>
43<P>The <SPAN class="argument">val</SPAN> argument is a <code>PMAmpGain</code> enumerator type value that can contain one of the following values.
44</P>
45<TABLE border="1">
46  <TBODY>
47    <TR>
48<TH width="336"><B><I>val</I></B></TH>
49<TH width="501">Gain to Set</TH>
50    </TR>
51    <TR>
52<TD width="336"><CODE>PM_AMPGAIN_20</CODE></TD>
53<TD width="501"> 26.0 dB (20x)</TD>
54    </TR>
55    <TR>
56<TD width="336"><CODE>PM_AMPGAIN_40, PM_AMPGAIN_DEFAULT</CODE></TD>
57<TD width="501"> 32.0 dB (40x)</TD>
58    </TR>
59    <TR>
60<TD width="336"><CODE>PM_AMPGAIN_80</CODE></TD>
61<TD width="501"> 38.0 dB (80x)</TD>
62    </TR>
63    <TR>
64<TD width="336"><CODE>PM_AMPGAIN_160</CODE></TD>
65<TD width="501"> 44.0 dB (160x)</TD>
66    </TR>
67  </TBODY>
68</TABLE>
69<P><BR> <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>
70<P><BR> <BR> <B>Asynchronous Functions</B></P>
71<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>
72<P>When an asynchronous function is called, the specified <SPAN class="argument">callback</SPAN> is called when processing on the ARM7 side finishes. The callback type <CODE>PMCallback</CODE> is defined by:</P>
73<BLOCKQUOTE> <CODE><code>typedef void ( *PMCallback )( u32 result, void* arg )</code>;</CODE></BLOCKQUOTE>
74<P> This callback is called from within the PXI interrupt handler.</P>
75<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>
76<P><BR> <BR> <B>About <CODE>PM_RESULT_BUSY</CODE></B></P>
77<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>
78<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>
79<BLOCKQUOTE style="background-color:#ffffcc"><B>Example</B><BR> <CODE>while( PM_SetAmpGain( ... ) != PM_RESULT_SUCCESS )<BR> {<BR> }</CODE></BLOCKQUOTE>
80<P>When using the <CODE>Async</CODE> version of this function, you could do this with code similar to the following.</P>
81<BLOCKQUOTE style="background-color:#ffffcc"><B>Example</B><BR> <CODE>void setResult( u32 result, void* arg )<BR> {<BR> if ( arg )<BR> {<BR> *(u32*)arg = result;<BR> }<BR> }<BR> <BR> while(1)<BR> {<BR> volatile u32 result = PM_RESULT_NONE; // Value that is not returned as a result<BR> <BR> while ( PM_SetAmpGainAsync(..., setResult, (void*)&amp;result ) != PM_RESULT_SUCCESS )<BR> {<BR> }<BR> <BR> // Some other process<BR> otherProcess();<BR> <BR> // Wait for processing to finish<BR> while( result == PM_RESULT_NONE )<BR> {<BR> }<BR> <BR> // Exit from the loop on success<BR> if ( result == PM_RESULT_SUCCESS )<BR> {<BR> break;<BR> }<BR> }</CODE></BLOCKQUOTE>
82<P><BR> <BR> <B>About <CODE>PM_AMPGAIN_DEFAULT</CODE></B>
83<P>The <CODE>PM_AMPGAIN_DEFAULT</CODE> setting of 40x is the default value configured by the hardware when the <CODE>PM_SetAmpGain*</CODE> functions have not been used; it is not necessarily the recommended setting.
84
85<P><BR> <BR> <B>Differences Between the <A href="PM_SetAmpGain.html"><CODE>PM_SetAmpGain*</CODE></A> and <CODE><A href="PM_SetAmpGainLevel.html">PM_SetAmpGainLevel*</A></CODE> Functions</B>
86
87
88<P>In TWL mode, the CODEC can set the amp gain precisely to one of 120 levels, instead of 4 levels. See the <A href="PM_SetAmpGainLevel.html"><CODE>PM_SetAmpGainLevel</CODE></A> function for more information.
89
90<H2>Internal Operation</H2>
91<P>On NITRO hardware, this function manipulates the PMIC register PGA_GAIN. On TWL hardware it manipulates the CODEC.</P>
92<H2>See Also</H2>
93<P><A href="PM_Init.html"><CODE>PM_Init</CODE></A><BR> <A href="PM_SetAmp.html"><CODE>PM_SetAmp*</CODE></A><BR> <A href="PM_SetAmpGainLevel.html"><CODE>PM_SetAmpGainLevel*</CODE></A><BR> <A href="PM_GetAmpGain.html"><CODE>PM_GetAmpGain</CODE></A></P>
94<H2>Revision History</H2>
95<P>2009/06/03 Removed a description of the <CODE>PM_Init</CODE> function (because <CODE>OS_Init</CODE> is now required). <BR>2008/08/23 Discontinued use of <CODE>PM_RESULT_ERROR</CODE> and mentioned <CODE>PM_RESULT_BUSY</CODE>. <BR>2008/05/01 Added information on <CODE>PM_SetAmpGainLevel*</CODE>. <BR>2006/01/25 Added the <CODE>PM_AMPGAIN_DEFAULT</CODE> setting value. <BR>2005/07/07 Mentioned the <CODE>PM_RESULT_ERROR</CODE> return value. <BR>2005/06/02 Explicitly stated where the callback is invoked. <BR>2004/07/31 Initial version.</P>
96<hr><p>CONFIDENTIAL</p></body>
97</HTML>