Without VUSB (indicated by PWR) the 6k2 pull-down will enforce the low level.
So only the combination PWR && !CHG will provide the actual charging status.
So on U3 /CHG means active LOW pin? I am glad you can read these schematics.
As you say it is tri-state battery, powered & not charging, powered & charging. Good explanation.
Thanks for clarifying this! I am still figuring out how to apply it to detect whether there is USB power or not, while operating on battery. digitalRead(CHG) and digitalRead(PWR) are both 0 with battery plugged in, whether USB is plugged in or not. Should I be approaching this in a different way?
Based on that if you have both battery and usb you’ll see the usb is only used to charge the battery, then it runs off battery for awhile. That surprised me, I thought it’d charge the battery and then run off the USB but that’s not what the above is showing in my testing.
–April update: I think the battery part of the above is wrong. It appears to use USB and not battery, when USB is available, thus onBatteryPower = !hasUsbPower; is what I use now. The part that tripped me up before is the voltage is different between USB only and USB + charged battery.
Is it possible to do conditional compilation based on what the target board is? Some sort of #if .... #endif to check power one way for xenon and another for boron? I’d really like to have one code base to roll out on both boards if possible.