Why is DPIN_PWR deactivated at initialization?
In the factory code as well as in the great hexbright library by David Hilton, I can see this snippet:
// We just powered on! That means either we got plugged
// into USB, or the user is pressing the power button.
To me it looks wrong. We're first setting the pin mode to INPUT, i.e. DDB0 is set to 0 and then write LOW, i.e. PORTB0 is set to 0. According to the ATmega168 specs, this means that the pin is in Hi-Z state, i.e. it acts as if it was unconnected, so as soon as you release the switch, pin 1 on the MIC5353 must get low (through R18 and R19). Admittedly this is 20kΩ, so not a very reliable current sink, but since there's no other connection, the logical level should be low.
Am I wrong to assume that the code works only because initially the power switch is held (so the EN pin is driven high through D3) and when you release it, the discharge time for C19 is long enough (a few milliseconds) to let the Hexbright program turn DPIN_PWR on?
Is this a good question?