Am 17.11.2020 um 21:41 schrieb Nick Elsmore <nicholaselsmore@gmail.com>:
If I remember correctly the driver only starts charging if USB becomes plugged in but not
if it *is* plugged in.
But what happens if USB remains plugged in and the charger stops charging after the
battery is fully charged.
Or what happens if USB is already connected while boot? Is this detected as a "plug in"
event?
I think there is no code that looks and decides when to trigger charging a second or
third time to keep the battery full (which may drain during operation).
Can someone review the code for this?
I don't understand why we need to use the watchdog timer on the charger. The hardware state machine in the charger can handle all that is required to safely charge the battery without runtime interaction from the host CPU.
The host should just configure the required settings at startup and leave the thing alone. In this case, the watchdog should simply be disabled. I have read some drivers for similar charger chips which behave this way as well.
However, one feature of the bq24 I am not particularly familiar with is the OTG support, perhaps this affects this behavior (I need to read up more on how this works in the bq24).
If the driver is not trying to handle the USB detection and control the bq24 manually, the bq24 will properly detect a valid supply on VBUS and enter the appropriate charge mode (precharge, fast, termination) depending on the battery voltage.
I see no reason to duplicate behavior which already exists in hardware.
In fact, I think this is the cause for a lot of the existing issues in the driver.