# PM_GetACAdapter

## Syntax

      #include <twl/spi.h>

      u32 PM_GetACAdapter( BOOL *isConnectedBuf );

## Arguments

isConnectedBuf | Region that stores whether power is being supplied through the AC adapter.

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

If `PM_RESULT_ERROR`, this function could not be used. This error means that this function was called during operation in NITRO mode. It will not be returned in any other situation.

On success, this function will store in the address indicated by isConnectedBuf whether the AC adapter is connected and electricity is flowing to the DC connector. This is a Boolean value that is `TRUE` when they are connected and `FALSE` otherwise.

## Description

Determines whether the AC adapter is plugged into the DC connector and electricity is flowing.

The isConnectedBuf argument is a pointer to a `BOOL`-type value that contains the results. If `TRUE`, the AC adapter is connected and current is flowing through it, but you cannot determine that the battery is recharging simply by knowing that there is current flowing through the connected AC adapter. This will be `TRUE` even if there is a connection and the battery is not being charged because it is already at full capacity. This will be `FALSE` if the AC adapter has been connected but there is no current flowing through it (such as when it has not been plugged into an outlet).

This function uses PXI to send the command that performs the corresponding operation in the ARM7 processor. The ARM7 side that receives that command is executed by operating the PMIC. 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 only operates on TWL hardware running in TWL mode.It cannot be used on NITRO hardware or TWL hardware running in NITRO mode. In such cases it will return `PM_RESULT_ERROR`.

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

## See Also

`PM_Init`
`PM_GetBattery`
`PM_GetBatteryLevel`

## Revision History

2008/08/23 Added information about `PM_RESULT_BUSY`.
2008/01/24 Initial version.

CONFIDENTIAL