Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Power Manager driver

Low Power Manager provides API to handle the device power modes. It also supports run-time switching between multiple power modes. Each power mode is described by configuration structures with multiple power-related options. Low Power Manager provides a notification mechanism for registered callbacks and API for static and dynamic callback registration.

Power Manager Overview

The Power Manager driver is developed on top of the SMC HAL, PMC HAL, and RCM HAL.

This is an example to initialize the Power Manager:

~~~~~{.c}

#include "fsl_power_manager.h"

/* Definition of power manager callback 
power_manager_error_code_t callback0(power_manager_callback_type_t type,
    power_manager_user_config_t * configPtr,
    power_manager_callback_data_t * dataPtr)
{

    power_manager_error_code_t ret = kPowerManagerError;

    ...
    ...
    ...

    return ret;
}

...
...
...
...
...
/* Main function 
int main(void)
{
    /* Callback configuration 
    user_callback_data_t callbackData0;

    power_manager_static_callback_user_config_t callbackCfg0 = { callback0,
            kPowerManagerCallbackBeforeAfter,
            (power_manager_callback_data_t*) &callbackData0 };

    power_manager_static_callback_user_config_t * callbacks[] =
            { &callbackCfg0 };


    /* Power modes configurations 
    power_manager_user_config_t vlprConfig;
    power_manager_user_config_t stopConfig;

    power_manager_user_config_t *powerConfigs[] = {&vlprConfig, &stopConfig};

    /* Definition of transition to and out these power modes 
    vlprConfig.mode = kPowerManagerVlpr;
    vlprConfig.policy = kPowerManagerPolicyAgreement;
    vlprConfig.sleepOnExitValue = false;
    vlprConfig.sleepOnExitOption = false;

    stopConfig = vlprConfig;
    stopConfig.mode = kPowerManagerStop;

    /* Calling of init method 
    POWER_SYS_Init(&powerConfigs, 2U, &callbacks, 1U);
}

~~~~~{.c}

This is an example to switch into a desired power mode:

~~~~~{.c}

#include "fsl_power_manager.h"

/* Index into array containing configuration of very low power run mode - vlpr 
#define MODE_VLPR 0U

/* Initialization 
power_manager_user_config_t vlprConfig;
...
...
...
power_manager_user_config_t *powerConfigs[1] = {&vlprConfig};

/* Switch to required power mode 
power_manager_error_code_t ret = POWER_SYS_SetMode(MODE_VLPR);

if (ret != kPowerManagerSuccess) 
{
    printf("POWER_SYS_SetMode(powerMode5) returns : %u\n\r",ret);
}

~~~~~{.c}