I'd like to know how can a power-on/power-off system for a battery operated device with GPIO inputs can be designed that has the following features:
- When MCU is off, pressing and holding down a switch for 4 seconds should only turn it on
- This switch must be usable as a GPIO input pin to the mcu after it turns on
- Pressing and holding again the same switch for 4 seconds should turn the system off by either cutting off the power supply or controlling a Shutdown signal to the regulator.
The last part can be easily done by having a timer run in the mcu and check the duration of press everytime there is an interrupt generated, and then asserting the shutdown signal of the voltage regulator when ready. But I'm not getting ideas for 4 second turn on, and at the same time be usable as a GPIO after power on. Subsequent short press on this switch should not turn off the system. Any thoughts ?