From d229f8dcd38cbaabbd1a2d6048fface10fafb1ad Mon Sep 17 00:00:00 2001 From: rbiasini Date: Tue, 19 Nov 2019 18:41:59 -0800 Subject: [PATCH] =?UTF-8?q?ESP=20forced=20off=20in=20EON=20build.=20this?= =?UTF-8?q?=20prevents=20ESP=20to=20be=20turned=20on=20when=20e=E2=80=A6?= =?UTF-8?q?=20(#387)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ESP forced off in EON build. this prevents ESP to be turned on when exiting power mode: 0.5W power save! Also, boardd does not need to set ESP to off anymore * don't touch ESP uart * Refactored ESP/GPS initting * Fixed white detection --- board/board.h | 4 +++- board/boards/black.h | 3 +++ board/boards/grey.h | 10 +++++++++- board/boards/uno.h | 3 +++ board/boards/white.h | 15 ++++++++++++++- board/gpio.h | 7 ------- board/main.c | 6 ------ 7 files changed, 32 insertions(+), 16 deletions(-) diff --git a/board/board.h b/board/board.h index 5629a841d3f5fd..30e1fa4d17a51e 100644 --- a/board/board.h +++ b/board/board.h @@ -19,7 +19,9 @@ void detect_board_type(void) { #ifdef PANDA - // SPI lines floating: white (TODO: is this reliable?) + // SPI lines floating: white (TODO: is this reliable? Not really, we have to enable ESP/GPS to be able to detect this on the UART) + set_gpio_output(GPIOC, 14, 1); + set_gpio_output(GPIOC, 5, 1); if((detect_with_pull(GPIOA, 4, PULL_DOWN)) || (detect_with_pull(GPIOA, 5, PULL_DOWN)) || (detect_with_pull(GPIOA, 6, PULL_DOWN)) || (detect_with_pull(GPIOA, 7, PULL_DOWN))){ hw_type = HW_TYPE_WHITE_PANDA; current_board = &board_white; diff --git a/board/boards/black.h b/board/boards/black.h index c88791163a086d..c79fc2103e189d 100644 --- a/board/boards/black.h +++ b/board/boards/black.h @@ -162,6 +162,9 @@ void black_init(void) { set_gpio_mode(GPIOC, 0, MODE_ANALOG); set_gpio_mode(GPIOC, 3, MODE_ANALOG); + // Set default state of GPS + current_board->set_esp_gps_mode(ESP_GPS_ENABLED); + // C10: OBD_SBU1_RELAY (harness relay driving output) // C11: OBD_SBU2_RELAY (harness relay driving output) set_gpio_mode(GPIOC, 10, MODE_OUTPUT); diff --git a/board/boards/grey.h b/board/boards/grey.h index 03479a9782799c..3dcb730a582e06 100644 --- a/board/boards/grey.h +++ b/board/boards/grey.h @@ -3,10 +3,18 @@ // ////////// // // Most hardware functionality is similar to white panda + +void grey_init(void) { + white_grey_common_init(); + + // Set default state of GPS + current_board->set_esp_gps_mode(ESP_GPS_ENABLED); +} + const board board_grey = { .board_type = "Grey", .harness_config = &white_harness_config, - .init = white_init, + .init = grey_init, .enable_can_transciever = white_enable_can_transciever, .enable_can_transcievers = white_enable_can_transcievers, .set_led = white_set_led, diff --git a/board/boards/uno.h b/board/boards/uno.h index ffce05a0f5b7fc..779ef5091e7fd0 100644 --- a/board/boards/uno.h +++ b/board/boards/uno.h @@ -156,6 +156,9 @@ void uno_init(void) { set_gpio_mode(GPIOC, 0, MODE_ANALOG); set_gpio_mode(GPIOC, 3, MODE_ANALOG); + // Set default state of GPS + current_board->set_esp_gps_mode(ESP_GPS_ENABLED); + // C10: OBD_SBU1_RELAY (harness relay driving output) // C11: OBD_SBU2_RELAY (harness relay driving output) set_gpio_mode(GPIOC, 10, MODE_OUTPUT); diff --git a/board/boards/white.h b/board/boards/white.h index 0fce9d682bbb9d..7b2f91595af792 100644 --- a/board/boards/white.h +++ b/board/boards/white.h @@ -78,11 +78,13 @@ void white_set_esp_gps_mode(uint8_t mode) { set_gpio_output(GPIOC, 14, 0); set_gpio_output(GPIOC, 5, 0); break; +#ifndef EON case ESP_GPS_ENABLED: // ESP ON set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 1); break; +#endif case ESP_GPS_BOOTMODE: set_gpio_output(GPIOC, 14, 1); set_gpio_output(GPIOC, 5, 0); @@ -240,7 +242,7 @@ void white_set_phone_power(bool enabled){ UNUSED(enabled); } -void white_init(void) { +void white_grey_common_init(void) { common_init_gpio(); // C3: current sense @@ -318,6 +320,17 @@ void white_init(void) { } } +void white_init(void) { + white_grey_common_init(); + + // Set default state of ESP + #ifdef EON + current_board->set_esp_gps_mode(ESP_GPS_DISABLED); + #else + current_board->set_esp_gps_mode(ESP_GPS_ENABLED); + #endif +} + const harness_configuration white_harness_config = { .has_harness = false }; diff --git a/board/gpio.h b/board/gpio.h index f33196e8fa37da..322b0be9d06abe 100644 --- a/board/gpio.h +++ b/board/gpio.h @@ -59,13 +59,6 @@ void early(void) { detect_configuration(); detect_board_type(); - #ifdef PANDA - // enable the ESP, disable ESP boot mode - // dont disable on grey panda - current_board->set_esp_gps_mode(ESP_GPS_ENABLED); - #endif - - if (enter_bootloader_mode == ENTER_BOOTLOADER_MAGIC) { #ifdef PANDA current_board->set_esp_gps_mode(ESP_GPS_DISABLED); diff --git a/board/main.c b/board/main.c index 5319accfdd3b7c..89bdf6ad82eae6 100644 --- a/board/main.c +++ b/board/main.c @@ -774,12 +774,6 @@ int main(void) { spi_init(); #endif -#ifdef EON - // have to save power - if (hw_type == HW_TYPE_WHITE_PANDA) { - current_board->set_esp_gps_mode(ESP_GPS_DISABLED); - } -#endif // 1hz timer_init(TIM9, 1464); NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);