Hello,
has anyone experience in using the LowPowerManagement of MQX on the K60? I have problems registering the drivers in the LPM. Can anyone give me an example how to register the serial driver for the LPM?
Thanks,
Tobias
The serial driver should already be registered in the BSP (if you updated the driver to the new drivers included with 3.8/3.8.1) But to do it for your own stuff is pretty straighforward as you can see in the code I've attached
So a couple items to keep in mind though:
static uint_32 mainLpmRegHandle; static LPM_NOTIFICATION_RESULT mainLpmCallback(LPM_NOTIFICATION_STRUCT_PTR notification, pointer data ) { if (LPM_NOTIFICATION_TYPE_PRE == notification->NOTIFICATION_TYPE) { if(notification->OPERATION_MODE == LPM_OPERATION_MODE_RUN) { /* Do wakeup stuff - like sending wake-up events to sleeping tasks */ } else if( notification->OPERATION_MODE == LPM_OPERATION_MODE_STOP || notification->OPERATION_MODE == LPM_OPERATION_MODE_SLEEP) { /* By this point tasks that are working with hardware should have been stopped manually and this will now turn off power sources to hardware */ #ifdef ENABLE_WATCHDOG _watchdog_stop(); #endif } } return LPM_NOTIFICATION_RESULT_OK; }
void main_task(uint_32 initial_data) {
// ...
#if MQX_ENABLE_LOW_POWER { LPM_REGISTRATION_STRUCT registration; registration.CLOCK_CONFIGURATION_CALLBACK = NULL; registration.OPERATION_MODE_CALLBACK = mainLpmCallback; registration.DEPENDENCY_LEVEL = 29; _lpm_register_driver (®istration, NULL, &mainLpmRegHandle); } #endif
// ... /* Sleep */ _lpm_set_operation_mode (LPM_OPERATION_MODE_STOP); //Or _lpm_set_operation_mode(LPM_OPERATION_MODE_SLEEP); /* Run */ _lpm_set_operation_mode (LPM_OPERATION_MODE_RUN);
// ...
}
Hello Tobias,
what particular problems are you copying with? What have you done so far, share some code snippets,provide more info.
Regards,
MartinK