PM_GetAmpGain

Syntax

#include <nitro/spi.h>
u32 PM_GetAmpGain( PMAmpGain* gainBuf );
  

Arguments

gainBuf Buffer to store the obtained results for settings values that determine the amp gain.

Return Values

If PM_RESULT_SUCCESS, the command was run successfully.

If PM_RESULT_BUSY, the SPI was occupied by other processing and unable to process this function.

Description

Gets the current setting for the programmable amp gain.

A PMAmpGain enumerated type value is saved in gainBuf. It will be one of the following four values.

Value Stored in gainBuf Gain
PM_AMPGAIN_20 26.0 dB (20x)
PM_AMPGAIN_40 32.0 dB (40x)
PM_AMPGAIN_80 38.0 dB (80x)
PM_AMPGAIN_160 44.0 dB (160x)

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.

When gain is configured to 120 levels internally, this function returns a value corresponding to the internally set value, as shown below.

Value Stored in gainBuf Gain (120 Levels)
PM_AMPGAIN_20 0-36 (10.5-28.5 dB)
PM_AMPGAIN_40 37-48 (29.0-34.5 dB)
PM_AMPGAIN_80 49-60 (35.0-40.5 dB)
PM_AMPGAIN_160 61-119 (41.0-70.0 dB)

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.

This function can be used from an interrupt handler. This function cannot be used in interrupt-prohibited states other than interrupt handlers.



About PM_RESULT_BUSY

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 PM_RESULT_BUSY 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 PM_RESULT_BUSY. (In this case, the determination is made before notification is sent to the ARM7.)

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.)

Example:
while( PM_GetAmpGain( ... ) != PM_RESULT_SUCCESS )
{
}



Differences Between the PM_GetAmpGain and PM_GetAmpGainLevel Functions

There are two types of functions to get the gain settings: PM_GetAmpGain (this function) and PM_GetAmpGainLevel. 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 PM_GetAmpGainLevel function.

Internal Operation

On NITRO hardware, reads the value of the PMIC register PGA_GAIN. On TWL hardware, reads the codec value.

See Also

PM_Init
PM_SetAmpGain*
PM_GetAmpGainLevel*

Revision History

2009/06/03 Removed a description of the PM_Init function (because OS_Init is now required).
2008/08/23 Mentioned PM_RESULT_BUSY.
2008/05/01 Added support for 120 amp gain levels.
2005/07/07 Mentioned the PM_RESULT_ERROR return value.
2004/08/09 Initial version.


CONFIDENTIAL