#include <twl/spi.h>
u32 PM_GetAmpGainLevel( u8* levelBuf );
levelBuf | 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.
It saves a u8
value in levelBuf. The values it can obtain are in the range of 0 to 119 (120 levels).
Value Stored in levelBuf | Gain |
---|---|
0 | 10.5 dB |
1 | 11.0 dB |
2 | 11.5 dB |
: | : |
n | 10.5 + (n x 0.5) dB |
: | : |
119 | 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.
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_GetAmpGainLevel( ... ) != 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
and PM_GetAmpGainLevel
(this function). 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 function is explained in this reference page; it is new, has been added for the TWL system, and can get 120 gain levels.
The PM_GetAmpGain
function can get four levels and is usable in any mode.
The PM_GetAmpGainLevel
function can get 120 levels and is usable only in TWL hybrid and TWL limited mode. The CODEC mode decides whether 120 levels are actually configured internally. The codec is configured with 120 levels when it is running in TWL mode (this should always be TWL mode).
If 4 levels have been configured internally, this function gets a setting value that corresponds to 120 levels. On the other hand, if 120 levels have been configured internally and the PM_GetAmpGain
function attempts to get a 4-level value, the 120 levels are divided into 4 sections from which an approximate 4-level value is returned.
The following table shows the 120-level values obtained from the PM_GetAmpGainLevel
function when 4 levels are configured internally.
Configured Value | Gain (120 Levels) |
---|---|
PM_AMPGAIN_20 |
31 (26.0 dB) |
PM_AMPGAIN_40 |
43 (32.0 dB) |
PM_AMPGAIN_80 |
55 (38.0 dB) |
PM_AMPGAIN_160 |
67 (44.0 dB) |
The values 31, 43, 55, and 67 are given the constant definitions PM_AMPGAIN_LEVEL_DS0
, PM_AMPGAIN_LEVEL_DS1
, PM_AMPGAIN_LEVEL_DS2
, and PM_AMPGAIN_LEVEL_DS3
, respectively.
On NITRO hardware, reads the value of the PMIC register PGA_GAIN
. On TWL hardware, reads the codec value.
PM_Init
PM_SetAmpGainLevel*
PM_GetAmpGain
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 Split off from PM_GetAmpGain
.
CONFIDENTIAL