From 616450c525a7c1ef508f70f30e29547a606139aa Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 1 Dec 2022 20:04:30 -0800 Subject: [PATCH] tres bootkick (#1183) * tres: bootkick * replace usb enum Co-authored-by: Comma Device --- board/boards/tres.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/board/boards/tres.h b/board/boards/tres.h index 0b757c631f..0bced4c732 100644 --- a/board/boards/tres.h +++ b/board/boards/tres.h @@ -6,6 +6,25 @@ void tres_set_ir_power(uint8_t percentage){ pwm_set(TIM3, 4, percentage); } +void tres_set_bootkick(bool enabled){ + set_gpio_output(GPIOA, 0, !enabled); +} + +bool tres_ignition_prev = false; +void tres_board_tick(bool ignition, bool usb_enum, bool heartbeat_seen) { + UNUSED(usb_enum); + if (ignition && !tres_ignition_prev) { + // enable bootkick on rising edge of ignition + tres_set_bootkick(true); + } else if (heartbeat_seen) { + // disable once openpilot is up + tres_set_bootkick(false); + } else { + + } + tres_ignition_prev = ignition; +} + void tres_init(void) { // Enable USB 3.3V LDO for USB block register_set_bits(&(PWR->CR3), PWR_CR3_USBREGEN); @@ -14,6 +33,8 @@ void tres_init(void) { red_chiplet_init(); + tres_set_bootkick(true); + // SOM debugging UART gpio_uart7_init(); uart_init(&uart_ring_som_debug, 115200); @@ -36,7 +57,7 @@ void tres_init(void) { const board board_tres = { .board_type = "Tres", - .board_tick = unused_board_tick, + .board_tick = tres_board_tick, .harness_config = &red_chiplet_harness_config, .has_gps = false, .has_hw_gmlan = false,