#include <nitro/spi.h>
u32 PM_SetBackLight( PMLCDTarget target, PMBackLightSwitch sw );
u32 PM_SetBackLightAsync( PMLCDTarget target, PMBackLightSwitch sw, PMCallback callback, void* arg );
| target | Screen that is the target of operation. |
| sw | Backlight switch. |
| callback | Callback that is called when the command finishes. |
| arg | Argument that is used when calling the callback. |
If PM_RESULT_SUCCESS, the command execution has succeeded (for synchronous functions), or the command was successfully sent to the ARM7 processor (for asynchronous functions).
If PM_INVALID_COMMAND, the argument that was passed is invalid.
If PM_RESULT_BUSY, the SPI was occupied by other processing and unable to process this function.
Toggles the specified screen's backlight switch.
The target argument is a PMLCDTarget enumerator type that can contain either one of the following values.
| Value of target | Targeted LCD |
|---|---|
PM_LCD_TOP |
Top screen |
PM_LCD_BOTTOM |
Bottom screen |
PM_LCD_ALL |
Top and bottom screens |
The sw argument is a PMBackLightSwitch enumerator type value that specifies one of the following values.
| Value of sw | Backlight Operation |
|---|---|
PM_BACKLIGHT_OFF |
Turns the backlight OFF. |
PM_BACKLIGHT_ON |
Turns the backlight ON. |
This function performs the operation that is specified by sw on the screen that is specified by the target argument.
This function can be used from an interrupt handler. This function cannot be used in interrupt-prohibited states other than interrupt handlers.
Prohibition against turning the backlight on and off at high speed
In certain PMIC accessories, PMIC protection features will activate if a lit backlight is turned off and then on again within an extremely short period of time. This causes the TWL system to shut down.There should be a 16 msec interval or longer when when turning the backlight on and off.In other words, it is acceptable to switch once per frame.
Asynchronous Functions
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. Therefore, this function may not operate instantly after you call it. A synchronous function that waits for the operation to finish, as well as an asynchronous function that only sends commands to the ARM7, are provided. Use either of the functions depending on your operational requirements. (The asynchronous function has "Async" appended to the function name.))
When an asynchronous function is called, the specified callback is called when processing on the ARM7 finishes. The callback type PMCallback is defined by:
typedef void ( *PMCallback )( u32 result, void* arg );
This callback is called from within the PXI interrupt handler.
The callback's first argument, result, indicates the result of the command. This is either PM_RESULT_SUCCESS or PM_RESULT_BUSY. The second argument in the callback returns the value arg.
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( PPM_SetBackLight( ... ) != PM_RESULT_SUCCESS )
{
}
When using the Async version of this function, you could do this with code similar to the following.
Example:
void setResult( u32 result, void* arg ) { if ( arg ) { *(u32*)arg = result; } } while(1) { volatile u32 result = PM_RESULT_NONE; //A value that will not be returned while ( PM_SetSetBackLightAsync(..., setResult, (void*)&result ) != PM_RESULT_SUCCESS ) { } // Some other process otherProcess(); // Wait for completion while( result == PM_RESULT_NONE ) { } // Exit the loop on success if ( result == PM_RESULT_SUCCESS ) { break; } }
Controls the PMIC_CTL value of the PMIC register.
2010/06/16 Added a note that a 16 msec time interval or longer is required between turning the backlight on and off.
2009/06/03 Deleted description of the PM_Init function. (This is because the OS_Init function is required.)
2008/08/23 Discontinued PM_RESULT_ERROR and cited PM_RESULT_BUSY
2005/07/07 Cited the return value PM_RESULT_ERROR
2005/06/02 Added note about the caller of the callback
2004/08/04 Initial version
CONFIDENTIAL