#include <nitro/spi.h>
u32 PM_GetBattery( PMBattery* batteryBuf );
| batteryBuf | Buffer storing the remaining battery life for the battery pack. |
A value of PM_RESULT_SUCCESS indicates that the command was run successfully.
PM_RESULT_BUSY indicates that the SPI was occupied by other processing and unable to process this function.
Information on the remaining battery life will be placed in batteryBuf when the command is run successfully. A value of PM_BATTERY_HIGH indicates that there is a certain amount of remaining battery life, and PM_BATTERY_LOW indicates that the remaining battery life is low.
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.
If this function is called from the ARM9, a command will be sent to the ARM7 using PXI. Upon receiving this command, the ARM7 will check the remaining battery life and return it to the ARM9.
On NITRO, the ARM7 gets information on the remaining battery life from the PMIC. It will return a result that indicates one of two levels: either the voltage detected by the VDET terminal is greater than the threshold, or it is lower.
On TWL, the ARM7 gets information on the remaining battery life from the microprocessor. Specifically, the ARM7 gets a value equivalent to that of the PM_GetBatteryLevel function and returns a two-level result based on whether the result is between 0 to 1 or 2 to 5.
| Value Stored in batteryBuf | Description | How to Get Data When Using NITRO Hardware LED Status |
How to Get Data When Using TWL Hardware LED Status |
|---|---|---|---|
PM_BATTERY_HIGH |
There is remaining battery capacity. | VDET terminal's detection voltage is greater than or equal to threshold. ■ Lights green. |
The PM_GetBatteryLevel function returns a value in the range of 2-5.■ Lights blue or ■ lights red. |
PM_BATTERY_LOW |
The remaining battery capacity is low. | VDET terminal's detection voltage is greater than or equal to threshold. ■ Lights red. |
The PM_GetBatteryLevel function returns a value in the range of 0-1■■ Flashes red. |
The color and lit/flashing status of the LED cannot be controlled by applications.
When the remaining battery life is close to the threshold, the color of the power indicator LED may change temporarily when entering sleep mode. For example, when running on NITRO hardware, the LED may temporarily return to green when entering sleep mode with the LED lit red.
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 within 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 sent 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_GetBattery( ... ) != PM_RESULT_SUCCESS )
{
}
(On NITRO)
Reads value of the PMIC register PMIC_STAT.
This function detects whether the voltage of the PMIC VDET terminal is above or below the threshold.
(On TWL)
Returns a two-level result based on the remaining battery life obtained by the microprocessor.
2008/08/23 Ended the use of PM_RESULT_ERROR and elaborated about PM_RESULT_BUSY.
2008/06/12 Described how to get data with TWL hardware.
2005/07/07 Elaborated about the PM_RESULT_ERROR return value.
2004/08/09 Initial version.
CONFIDENTIAL