# PM_GetAmp

## Syntax

      #include <nitro/spi.h>

      u32 PM_GetAmp( PMAmpSwitch* swBuf );

## Arguments

swBuf | Buffer that saves the results of getting the amp switch setting.

## 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 settings of the programmable gain amp switch.

The value of the `PMAmpSwitch` enumerated type is saved in the swBuf argument. It can take any one of the following values.

Value stored in swBuf | Amp State
--- | ---
``PM_AMP_ON`` | Amp is ON.
``PM_AMP_OFF`` | Amp is OFF.

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 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 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_GetAmp( ... ) != PM_RESULT_SUCCESS )
> {
> }`

## Internal Operation

Reads the value of the PMIC register `OP_CTL`.

## See Also

`PM_Init`
`PM_SetAmp*`

## Revision History

2009/06/03 Removed a description of the `PM_Init` function (because `OS_Init` is now required).
2008/12/05 Added a cautionary note concerning use when interrupts are prohibited.
2008/08/23 Mentioned `PM_RESULT_BUSY`.
2005/07/07 Mentioned the `PM_RESULT_ERROR` return value.
2004/08/09 Initial version.

CONFIDENTIAL