Skip to content

Commit

Permalink
ESP forced off in EON build. this prevents ESP to be turned on when e… (
Browse files Browse the repository at this point in the history
commaai#387)

* 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
  • Loading branch information
rbiasini authored Nov 20, 2019
1 parent 8a044b3 commit d229f8d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
4 changes: 3 additions & 1 deletion board/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions board/boards/black.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion board/boards/grey.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions board/boards/uno.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 14 additions & 1 deletion board/boards/white.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
};
Expand Down
7 changes: 0 additions & 7 deletions board/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 0 additions & 6 deletions board/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d229f8d

Please sign in to comment.