# PM_GetBattery

## C Specification

      #include <nitro/spi.h>

      u32 PM_GetBattery( PMBattery* batteryBuf );

## Arguments

batteryBuf | Buffer storing the remaining battery life for the battery pack.

## Return Values

The `PM_RESULT_SUCCESS` return value indicates that the execution of the command has succeeded. The `PM_RESULT_ERROR` return value indicates that an error has occurred with the ARM7 processor.

This function gets and saves whether the detected voltage of the VDET terminal in the address that is indicated by the `batteryBuf` argument is higher or lower than the threshold. This argument enables you to know the approximate remaining battery capacity of the battery pack. The saved values are as follows:

`PM_BATTERY_HIGH` | There is remaining battery capacity.
`PM_BATTERY_LOW ` | The remaining battery capacity is low.

These values correspond to the color (green or red) of the power lamp on the NITRO unit.

Note: Even when the remaining battery capacity is low and the power lamp is red, the lamp may blink green when the unit is in the sleep mode.

## Description

This function checks the remaining battery capacity of the battery pack.

The `batteryBuf` argument is a pointer to the `PMBattery` type, and the results are stored here.

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, initialize the PM library by using the `PM_Init()` function. The `PM_Init()` function has to be called only once. Also, when you call `OS_Init()`, there is no need to call `PM_Init()` separately since it is called from within `OS_Init()`.)

Note: If `PM_RESULT_ERROR` was returned as the return value, it is usually an unrecoverable error. It might be returned when ARM7 is not ready or the variable region was destroyed. If this is returned there may be a problem in the program.

## Internal Operation

Reads the PMIC register PMIC_STAT value. This function detects whether the voltage of the PMIC VDET terminal is above or below the threshold.

## See Also

`PM_Init`

## Revision History

07/07/2005 Referred to the return value, `PM_RESULT_ERROR`.
08/09/2004 Initial version.