Other Parts Discussed in Thread: ENERGIA,
Hi
I am referencing to idle profile non os version application. I want to enter LPDS mode when a GPIO pin (for example, GP28) is set to LOW and wake up by a valid GPIO pin (for example, GP17). However, when I try to drive the pin LOW, it doesn't go into LPDS and still continues to execute the loop. Thus, I would like to confirm if I am missing anything. If I understood correctly, to enter LPDS mode, we need to following steps:
1. I am using Energia IDE to develop my code. In setup(), I include PM Initialization
struct platform_pm_ops lp3p0_pm_ops;
/* Initialize the PM framework */
if (cc_pm_framework_init()){
Serial.println("Error: PM framework init failed");
while(1);
}
/* Get the SOC specific platform operations */
lp3p0_get_pm_ops(&lp3p0_pm_ops);
/* Register PM ops with framework */
if(cc_pm_platform_ops_register(&lp3p0_pm_ops)){
Serial.println("Error: PM framework init failed");
while(1);
}
/* Register the interrupt with the global interrupt handler */
MAP_IntRegister(INT_PRCM, prcm_interrupt_handler);
/* Enable the interrupt */
MAP_IntEnable(INT_PRCM);
2. In loop(), if GP28 is LOW, then I do the following
if (sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0) < 0)
{
Serial.println("Error: unable to configure network power policy\n\r");
while(1);//LOOP_FOREVER();
}
// set up gpio handler
lp3p0_setup_power_policy(1); // 0: POWER_POLICY_SLEEP; 1: POWER_POLICY_STANDBY
// just to clear any pending event
_SlNonOsMainLoopTask();
set_gpio_as_wk_src(0, 0x3, 0); // WK_LPDS = 0x0, GPIO_SRC_WKUP = 0x3, PRCM_LPDS_HIGH_LEVEL = 0x0
cc_idle_task_pm();
3. The functions above are directly from lp3p0_plat_ops.c. However, since I only want to use GPIO as the wake up source, I modify the interrupt handler as follows
void prcm_interrupt_handler() {
int status;
/* Read the interrupt status, also clears the status */
status = MAP_PRCMIntStatus();
if (0 == status) {
/* Invoke the wake from LPDS interrupt handler */
wake_interrupt_handler();
} else {
}
}
May I know if I am missing anything else?
Thanks,
Dennis