Skip to content

Commit

Permalink
Add bootkick after re-enabling phone power (commaai#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbederks authored Dec 11, 2019
1 parent eadb0db commit c093286
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions board/boards/uno.h
Original file line number Diff line number Diff line change
@@ -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){
Expand Down Expand Up @@ -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);
}
Expand All @@ -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:
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -234,7 +245,7 @@ void uno_init(void) {
}

// Bootkick phone
uno_set_bootkick(true);
uno_bootkick();
}

const harness_configuration uno_harness_config = {
Expand Down

0 comments on commit c093286

Please sign in to comment.