# PM_GetAmp

## Syntax

      #include <nitro/spi.h>

      u32 PM_GetAmp( PMAmpSwitch* swBuf );

## Arguments

swBuf | Buffer that saves the obtained results of the amp switch settings.

## 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` enumerator type is saved in the swBuf argument and can contain either 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. 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_GetAmp( ... ) != PM_RESULT_SUCCESS )
> {
> }`

## Internal Operation

Reads the PMIC register `OP_CTL` value.

## See Also

`PM_Init`
`PM_SetAmp*`

## Revision History

2008/12/05 Added note about use in interrupt-prohibited states.
2008/08/23 Made reference to `PM_RESULT_BUSY`.
2005/07/07 Added a reference to the `PM_RESULT_ERROR` return value..
2004/08/09 Initial version.

CONFIDENTIAL