#include <nitro/spi.h>
u32 PM_GetAmpGain( PMAmpGain* gainBuf );
| gainBuf | Buffer to store the obtained results for settings values that determine the amp gain. |
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.
Gets the current setting for the programmable amp gain.
A PMAmpGain enumerated type value will be 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 will return 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. Before you use this function, use the PM_Init function to initialize the PM library. (The PM_Init function has to be called only once. Also, when you call the OS_Init function, there is no need to call the PM_Init function separately because it is called from inside OS_Init.)
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 notified 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 side 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 make certain that this function will succeed, 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 new; it has been added for the TWL system and can get 120 gain levels. See the PM_GetAmpGainLevel function.
On NITRO hardware, reads the value of the PMIC register PGA_GAIN. On TWL hardware, reads the codec value.
PM_Init
PM_SetAmpGain*
PM_GetAmpGainLevel*
2008/08/23 Elaborated on PM_RESULT_BUSY.
2008/05/01 Added support for 120 amplifier gain levels.
2005/07/07 Added a reference to the PM_RESULT_ERROR return value.
2004/08/09 Initial version.
CONFIDENTIAL