In example code below, I configured 2 pins to wake up MSPM0G3 from shutdown mode if the pin logic value is high (GPIO_PRESSURE_SWITCH_PRESSURE_SWITCH_PIN, GPIO_CURRENT_OVERLOAD_CURRENT_OVERLOAD_PIN).
I need to read pin value after waking up to identify the wake up cause and turn on the leds.
I run example code and observed behavior as below.
If I send PRESSURE_SWITCH signal to wake up MSPM0G3, MSPM0G3 wake up but RED led is not turned on. It seems that DL_GPIO_readPins() not return high value (I still keep PRESSURE_SWITCH signal high).
If I send CURRENT_OVERLOAD signal to wake up MSPM0G3, MSPM0G3 wake up and GREEN led is turned on. In this case, it work properly.
I think that RED led is not turned on because I read pin value immediately after DL_SYSCTL_releaseShutdownIO(). Is it correct?
Do we need to add delay after releasing IO (DL_SYSCTL_releaseShutdownIO())?
How much time do we need to delay?
int main(void)
{
volatile DL_SYSCTL_RESET_CAUSE rstCause;
SYSCFG_DL_init();
rstCause = DL_SYSCTL_getResetCause();
if (DL_SYSCTL_RESET_CAUSE_BOR_WAKE_FROM_SHUTDOWN == rstCause)
{
/* Release IO after Shutdown before initializing any peripherals */
DL_SYSCTL_releaseShutdownIO();
if (DL_GPIO_readPins(GPIO_PRESSURE_SWITCH_PORT, GPIO_PRESSURE_SWITCH_PRESSURE_SWITCH_PIN))
{
DL_GPIO_togglePins(User_Led_PORT, User_Led_PIN_R_LED_PIN);
delayMs(2000);
}
else if (DL_GPIO_readPins(GPIO_CURRENT_OVERLOAD_PORT, GPIO_CURRENT_OVERLOAD_CURRENT_OVERLOAD_PIN))
{
DL_GPIO_togglePins(User_Led_PORT, User_Led_PIN_G_LED_PIN);
delayMs(2000);
}
}
/*
* Configure Shutdown wake-up pin to wake-up when pin is set
* to high before changing power policy to SHUTDOWN
*/
DL_GPIO_initDigitalInputFeatures(GPIO_PRESSURE_SWITCH_PRESSURE_SWITCH_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_ON_1);
DL_GPIO_initDigitalInputFeatures(GPIO_CURRENT_OVERLOAD_CURRENT_OVERLOAD_IOMUX,
DL_GPIO_INVERSION_DISABLE, DL_GPIO_RESISTOR_NONE,
DL_GPIO_HYSTERESIS_DISABLE, DL_GPIO_WAKEUP_ON_1);
DL_SYSCTL_setPowerPolicySHUTDOWN();
while (1)
{
__WFI(); /* Enter selected power policy */
}
}

