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_GetAmpGain</TITLE> 8<LINK rel="stylesheet" href="../../css/nitro.css" type="text/css"> 9</HEAD> 10<BODY> 11<H1 align="left">PM_GetAmpGain <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 <nitro/spi.h></CODE></PRE> 16 <PRE><CODE>u32 PM_GetAmpGain( PMAmpGain* gainBuf ); 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>gainBuf</STRONG></EM></TD> 24<TD width="87%">Buffer to store the obtained results for settings values that determine the amp gain.</TD> 25 </TR> 26 </TBODY> 27</TABLE> 28<H2>Return Values</H2> 29<P>If <CODE>PM_RESULT_SUCCESS</CODE>, the command was run successfully.</P> 30<P>If <CODE>PM_RESULT_BUSY</CODE>, the SPI was occupied by other processing and unable to process this function.</P> 31<H2>Description</H2> 32<P>Gets the current setting for the programmable amp gain.</P> 33<P>A <CODE>PMAmpGain</CODE> enumerated type value is saved in <SPAN class="argument">gainBuf</SPAN>. It will be one of the following four values. 34</P> 35<TABLE border="1"> 36 <TBODY> 37 <TR> 38<TH width="267">Value Stored in <SPAN class="argument">gainBuf</SPAN></TH> 39<TH width="471">Gain </TH> 40 </TR> 41 <TR> 42<TD width="267"><CODE><CODE>PM_AMPGAIN_20</CODE></CODE></TD> 43<TD width="471"> 26.0 dB (20x)</TD> 44 </TR> 45 <TR> 46<TD width="267"><CODE><CODE>PM_AMPGAIN_40</CODE></CODE></TD> 47<TD width="471"> 32.0 dB (40x)</TD> 48 </TR> 49 <TR> 50<TD width="267"><CODE><CODE>PM_AMPGAIN_80</CODE></CODE></TD> 51<TD width="471"> 38.0 dB (80x)</TD> 52 </TR> 53 <TR> 54<TD width="267"><CODE><CODE>PM_AMPGAIN_160</CODE></CODE></TD> 55<TD width="471"> 44.0 dB (160x)</TD> 56 </TR> 57 </TBODY> 58</TABLE> 59<P>This function uses PXI to send a command to execute the operation in question on the ARM7 processor. Once it receives that command, the ARM7 executes it by manipulating the PMIC.</P> 60<P>When gain is configured to 120 levels internally, this function returns a value corresponding to the internally set value, as shown below. 61</P> 62<TABLE border="1"> 63 <TBODY> 64 <TR> 65<TH width="272">Value Stored in <SPAN class="argument">gainBuf</SPAN></TH> 66<TH width="466">Gain (120 Levels) </TH> 67 </TR> 68 <TR> 69<TD width="272"><CODE><CODE>PM_AMPGAIN_20</CODE></CODE></TD> 70<TD width="466"> 0-36 (10.5-28.5 dB)</TD> 71 </TR> 72 <TR> 73<TD width="272"><CODE><CODE>PM_AMPGAIN_40</CODE></CODE></TD> 74<TD width="466"> 37-48 (29.0-34.5 dB)</TD> 75 </TR> 76 <TR> 77<TD width="272"><CODE><CODE>PM_AMPGAIN_80</CODE></CODE></TD> 78<TD width="466"> 49-60 (35.0-40.5 dB)</TD> 79 </TR> 80 <TR> 81<TD width="272"><CODE><CODE>PM_AMPGAIN_160</CODE></CODE></TD> 82<TD width="466"> 61-119 (41.0-70.0 dB)</TD> 83 </TR> 84 </TBODY> 85</TABLE> 86<P>This function uses PXI to send a command to execute the operation in question on the ARM7 processor. Once it receives that command, the ARM7 executes it by manipulating the PMIC. Therefore, this function may not operate instantly after you call it.</P> 87<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> 88<P><BR> <BR> <B>About <CODE>PM_RESULT_BUSY</CODE></B></P> 89<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> 90<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> 91<BLOCKQUOTE style="background-color:#ffffcc"><B>Example:</B><BR> <CODE>while( PM_GetAmpGain( ... ) != PM_RESULT_SUCCESS )<BR> {<BR> }</CODE></BLOCKQUOTE> 92 93<P><BR> <BR> <B>Differences Between the <CODE>PM_GetAmpGain</CODE> and <A href="PM_GetAmpGainLevel.html"><CODE>PM_GetAmpGainLevel</CODE></A> Functions</B></P> 94<P>There are two types of functions to get the gain settings: <CODE>PM_GetAmpGain</CODE> (this function) and <A href="PM_GetAmpGainLevel.html"><CODE>PM_GetAmpGainLevel</CODE></A>. The former has existed since the old Nintendo DS system and can get four gain levels. (Four gain levels can be set as well.) The latter is a new function added for the TWL system and can get 120 gain levels. See the <A href="PM_GetAmpGainLevel.html"><CODE>PM_GetAmpGainLevel</CODE></A> function.</P> 95<H2>Internal Operation</H2> 96<P>On NITRO hardware, reads the value of the PMIC register <CODE>PGA_GAIN</CODE>. On TWL hardware, reads the codec value.</P> 97<H2>See Also</H2> 98<P><A href="PM_Init.html"><CODE>PM_Init</CODE></A><BR> <A href="PM_SetAmpGain.html"><CODE>PM_SetAmpGain*</CODE></A><BR> <A href="PM_GetAmpGainLevel.html"><CODE>PM_GetAmpGainLevel*</CODE></A></P> 99<H2>Revision History</H2> 100<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 Mentioned <CODE>PM_RESULT_BUSY</CODE>. <BR>2008/05/01 Added support for 120 amp gain levels. <BR>2005/07/07 Mentioned the <CODE>PM_RESULT_ERROR</CODE> return value. <BR>2004/08/09 Initial version.</P> 101<hr><p>CONFIDENTIAL</p></body> 102</HTML>