Slight reqork of QC logic to bring back older style + mix in another compatability hack

This commit is contained in:
Ben V. Brown
2020-04-04 13:16:28 +11:00
parent baa9ff66a8
commit eef2fb8148

View File

@@ -233,10 +233,25 @@ void startQC(uint16_t divisor) {
// Delay 1.25 seconds
uint8_t enteredQC = 0;
vTaskDelay(125);
// Check if D- is low to spot a QC charger
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET)
for (uint16_t i = 0; i < 200 && enteredQC == 0; i++) {
vTaskDelay(1); //10mS pause
if (i > 130) {
if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET) {
enteredQC = 1;
}
if (i == 140) {
//For some marginal QC chargers, we try adding a pulldown
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Pin = GPIO_PIN_11;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
}
}
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pin = GPIO_PIN_11;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
if (enteredQC) {
// We have a QC capable charger
QC_Seek9V();