PM_GetBattery

# PM_GetBackLight

## Syntax

      #include <nitro/spi.h>

      u32 PM_GetBackLight( PMBackLightSwitch* top, PMBackLightSwitch* bottom );

## Arguments

top | Buffer where the state of the upper screen backlight is written.
bottom | Buffer where the state of the lower screen backlight is written.

## Return Values

If `PM_RESULT_SUCCESS`, the command ran successfully.

If `PM_RESULT_BUSY`, the SPI was occupied by other processing and unable to process this function.

This function gets the backlight states and writes them to the addresses indicated by top and bottom. The saved values are as follows.

Saved Value | Backlight State
--- | ---
`PM_BACKLIGHT_ON` | Backlight is ON.
`PM_BACKLIGHT_OFF` | Backlight is OFF.

## Description

Checks the state of the backlight.

The top and bottom arguments are pointers to the `PMBackLightSwitch` type. The results of this function are stored there. If you specify `NULL` for a pointer, this function does not write the state of the corresponding backlight.

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.

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

## Internal Operation

This function reads the value of the PMIC register PMIC_CTL.

## See Also

`PM_Init`
`PMSetBackLight`

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