From 8c1df559f7c2786e758fd9e6592fefe1242460a7 Mon Sep 17 00:00:00 2001 From: rbiasini Date: Mon, 30 Sep 2019 21:48:30 -0700 Subject: [PATCH] turn on CDP when ignition switches on (#281) --- board/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/board/main.c b/board/main.c index d0cef3c7d89f9f..17b39a6c1eeb04 100644 --- a/board/main.c +++ b/board/main.c @@ -720,6 +720,7 @@ int main(void) { #endif #ifdef EON + bool ignition_prev = false; // have to save power if (hw_type == HW_TYPE_WHITE_PANDA) { current_board->set_esp_gps_mode(ESP_GPS_DISABLED); @@ -747,6 +748,13 @@ int main(void) { uint64_t cnt = 0; for (cnt=0;;cnt++) { + #ifdef EON + // set CDP mode on rising edge of ignition to start charging EON again in case we turned charging off + if (current_board->check_ignition() && !ignition_prev) { + current_board->set_usb_power_mode(USB_POWER_CDP); + } + ignition_prev = current_board->check_ignition(); + #endif if (power_save_status == POWER_SAVE_STATUS_DISABLED) { int div_mode = ((usb_power_mode == USB_POWER_DCP) ? 4 : 1);