I am new to SLEEP modes. Using PSoC5LP, the product has four pushbuttons on it which fire an ISR.
When I put this thing to sleep, and a button is pressed, it goes to the ISR.
In that ISR, it's the same ISR that the project normally uses to interpret button presses - how do I determine that I am waking up, versus normal operation?
I will be putting all peripherals (ADC, UART, SPIM, PMWs) to sleep before putting the PSoC itself into sleep mode. So when it wakes up, I have to wake up everything else, restore clocks, etc.
Obviously I don't want to do all of that during normal use, when the PSoC is not sleeping.
Thanks in advance.
You can set a flag (FLAG =1) before putting the device to sleep in the main. Inside the ISR, you can check the flag status. If the flag is set (if (FLAG==1)) which means that the device was in sleep mode, you can wake up the peripherals else there is no need to do so. At the end of the ISR you can again reset the flag (FLAG = 0) and clear the interrupt.