# 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 and writes the backlight state in the address indicated by top and bottom. The saved values are as follows.

`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 here. When a null pointer is specified, it does not write the backlight state that corresponds to that display.

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 the `OS_Init` function.

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

## Internal Operation

This function reads the `PMIC_CTL` value of the PMIC register.

## See Also

`PM_Init`
`PMSetBackLight`

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