From c093286b1dcb235d45540babf49c38acdcf82170 Mon Sep 17 00:00:00 2001 From: robbederks Date: Wed, 11 Dec 2019 13:42:25 +0100 Subject: [PATCH] Add bootkick after re-enabling phone power (#401) --- board/boards/uno.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/board/boards/uno.h b/board/boards/uno.h index 80baf1aab517a7..1545a3f2dbcddf 100644 --- a/board/boards/uno.h +++ b/board/boards/uno.h @@ -1,6 +1,8 @@ // ///////////// // // Uno + Harness // // ///////////// // +#define BOOTKICK_TIME 3U +uint8_t bootkick_timer = 0U; void uno_enable_can_transciever(uint8_t transciever, bool enabled) { switch (transciever){ @@ -48,6 +50,15 @@ void uno_set_gps_load_switch(bool enabled) { set_gpio_output(GPIOC, 12, enabled); } +void uno_set_bootkick(bool enabled){ + set_gpio_output(GPIOB, 14, !enabled); +} + +void uno_bootkick(void) { + bootkick_timer = BOOTKICK_TIME; + uno_set_bootkick(true); +} + void uno_set_phone_power(bool enabled){ set_gpio_output(GPIOB, 4, enabled); } @@ -61,6 +72,7 @@ void uno_set_usb_power_mode(uint8_t mode) { break; case USB_POWER_CDP: uno_set_phone_power(true); + uno_bootkick(); valid = true; break; default: @@ -125,12 +137,11 @@ void uno_set_can_mode(uint8_t mode){ } } -void uno_set_bootkick(bool enabled){ - set_gpio_output(GPIOB, 14, !enabled); -} - void uno_usb_power_mode_tick(uint32_t uptime){ - if(uptime == 3U){ + UNUSED(uptime); + if(bootkick_timer != 0U){ + bootkick_timer--; + } else { uno_set_bootkick(false); } } @@ -234,7 +245,7 @@ void uno_init(void) { } // Bootkick phone - uno_set_bootkick(true); + uno_bootkick(); } const harness_configuration uno_harness_config = {