I'm working on a small mobile-phone sized gadget and I'm trying to implement a tactile momentary power button that is controllable from the MCU (Press to turn on, press again to turn off). I struggle finding a simple and elegant circuit for this. This one is almost there, but it can't be used to turn off the gadget without a dual pole switch.
PWR_ENABLE is an active high signal that turns on power to the MCU.
When power is off, PWR_ENABLE is pulled low by Q20 being enabled (R32 holds Q20's gate high, Q19's gate is low because MCU is unpowered). When button SW4 is pressed, Q20 is disabled, allowing PWR_ENABLE to be pulled high. As soon as MCU comes up, it asserts POWER_HOLD pin high, which keeps the gate of Q20 pulled to ground. To shut power off, MCU sets POWER_HOLD low, gate of Q20 goes back high, pulling PWR_ENABLE low, power turns off.
This is all good, however I would like to let the user turn off the device with a long press on SW4. The best would be a signal from SW4 so the MCU can do housekeeping before turning off. Trouble is that the gate of Q20 is at ground potential when power is on, so I can't simply get a signal back straight from SW4.
In OFF state, a press should pull PWR_ENABLE high. In ON-state, a press should NOT pull PWR_ENABLE low but trigger the MCU, which in turn pulls PWR_ENABLE low (after saving settings etc).
I've come up with the circuit below, but it seems overly complicated. Can anyone see an elegant way to simplify? The goal is to get a signal back to the MCU that the user requests a power down.