I am looking for a reliable way to know at the wake-up, which VLLS state the MCU was in?
I am selectively going to set the MCU to VLLS0 and VLLS3. At wake up, I need to know which VLLS mode is the MCU recovering from.
Some API reference will be much helpful.
The settings in the SMC register are retained through all VLLSx recovery resets. The settings in the control fields that you chose before entering VLLS0 or VLLS3 are unchanged and can be used during reset recovery to determine the entry state.
For the latest Kinetis K82, as an example, if the RCM_SRS0_WAKEUP bit is set then check the SMC_STOPCTRL_LLSM value.
Also you should put a trap just after the WFI to check the STOPA bit SMC_PMCTRL register to see if the low power mode entry was aborted due to a pending interrupt.
All this is covered in detail in the Application Note AN4503.
See AN4503: Power Management for Kinetis MCUs for further details http://cache.freescale.com/files/32bit/doc/app_note/AN4503.pdf