PM_AppendPreSleepCallback

C Specification

#include <nitro/spi.h>
void PM_AppendPreSleepCallback( PMSleepCallbackInfo* info );

Arguments

info Pointer to the structure that includes the information of the added callback.

Return Values

None.

Description

Registers callback when switching to sleep mode. Registered at the top of the callback list.

This function allows you to register multiple callbacks. The callback is defined by the void type function that gets one void* type argument, as:

typedef void (*PMSleepCallback)( void* );

This callback function is called from inside PM_GoSleepMode().

When registering, specify the pointer to callback and argument information (as well as the structure that includes information for constructing the list). This structure is defined as follows.

typedef struct PMiSleepCallbackInfo PMSleepCallbackInfo;
struct PMiSleepCallbackInfo
{
PMSleepCallback callback;
void* arg;
PMSleepCallbackInfo* next;
};

The PM_SetSleepCallbackInfo() function for registering callback to callback information is also provided.

Callbacks are executed in order from the top of the list.

In callback registration when switching to sleep mode, PM_AppendPreSleepCallback() is registered at the top of the list and PM_PrependPreSleepCallback() is registered at the end of the list.

In callback registration when returning from sleep mode, PM_AppendPostSleepCallback() is registered at the top of the list and PM_PrependPostSleepCallback() is registered at the end of the list.

(Example)

//---- sleep callback info
PMSleepCallbackinfo c1info;
PMSleepCallbackinfo c2info;


//---- Callback before sleep mode
void myCallback1( void* )
{
OS_Printf( "go to sleep mode.\n" );
}

//---- Callback after sleep mode
void myCallback2( void* )
{
OS_Printf( "now return from sleep mode.\n" );
}

//---- Main
void NitroMain( void )
{
:
//---- set callback to callback info
PM_SetSleepCallbackInfo( &c1info, myCallback1, NULL );
PM_SetSleepCallbackInfo( &c2info, myCallback2, NULL );


//---- set pre-callback for sleep mode
PM_AppendPreSleepCallback( &c1info );

//---- set post-callback for sleep mode
PM_AppendPostSleepCallback( &c2info );

//---- go to sleep mode
PM_GoSleepMode(...);
:
}

See Also

PM_Init, PM_GoSleepMode, PM_AppendPreSleepCallback, PM_PrependPreSleepCallback, PM_AppendPostSleepCallback, PM_PrependPostSleepCallback, PM_DeletePreSleepCallback, PM_DeletePostSleepCallback, PM_SetSleepCallbackInfo

Revision History

09/14/2005 PM_SetSleepCallback was changed to PM_SetSleepCallbackInfo.
06/02/2005 Clarified the Callback call origin.
10/06/2004 Initial version.