System: make sure that the power source being USB host is well detected#2310
System: make sure that the power source being USB host is well detected#2310XuGuohui wants to merge 2 commits into
Conversation
| } else { | ||
| src = POWER_SOURCE_UNKNOWN; | ||
| // Do not update power source if power is good and in DPDM | ||
| if (!pwr_good || !power.isInDPDM()) { |
There was a problem hiding this comment.
Should be this be !power.isInDPDM() && !pwr_good?
| // FIXME: maybe introduce a new flag? | ||
| #if HAL_PLATFORM_POWER_WORKAROUND_USB_HOST_VIN_SOURCE | ||
| static system_tick_t lastRun = 0; | ||
| static uint8_t dpdmRetry = 0; |
There was a problem hiding this comment.
Move these into the class member variables.
| if (power.isInDPDM()) { | ||
| return; | ||
| } | ||
| power.enableDPDM(); |
There was a problem hiding this comment.
This is going to cause dips to 100mA current temporarily and may cause for example the modem to brownout if there is no battery attached.
See #2215 for some additional info.
We should probably opt to just reporting USB_HOST and configuring the PMIC manually as needed (i.e. lowering the input current limit to 500mA) and avoiding re-running DPDM as much as possible.
|
|
||
| if (millis() - lastRun >= DPDM_PERIOD) { | ||
| lastRun = millis(); | ||
| if (g_powerSource == POWER_SOURCE_VIN && HAL_USB_Get_State(nullptr) >= HAL_USB_STATE_POWERED) { |
There was a problem hiding this comment.
what other states are caught by HAL_USB_Get_State(nullptr) >= HAL_USB_STATE_POWERED? Can you make this more explicit such as a switch/case statement?
|
There are cases where the status register is showing 0x24 and the device is being powered through USB. Is there something not configured completely for USB detection? |
Problem
This issue can be easily replicated on Tracker.
VIN, instead ofUSB HostIf there is a power source attached to the DC jack, pluging back USB cable won't update the power source either.
Solution
When it detects the power source is
VINand the USB peripheral is powered, try to run DPDM in the system power management loop to make sure the USB host is correctly reported by PMICSteps to Test
As steps to replicate the issue.
Example App
References
Completeness