add legacy reset line support (#2625)
* add legacy reset line support * clean up names Co-authored-by: Comma Device <device@comma.ai>albatross
parent
54afae7147
commit
57cd8c38b7
|
@ -9,18 +9,30 @@
|
|||
|
||||
#include "panda.h"
|
||||
|
||||
#ifdef QCOM2
|
||||
bool is_legacy_panda_reset() {
|
||||
FILE *file = fopen("/persist/LEGACY_PANDA_RESET", "r");
|
||||
if(file) {
|
||||
fclose(file);
|
||||
}
|
||||
return (file != NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
void panda_set_power(bool power){
|
||||
#ifdef QCOM2
|
||||
int err = 0;
|
||||
bool is_legacy = is_legacy_panda_reset();
|
||||
|
||||
err += gpio_init(GPIO_STM_RST_N, true);
|
||||
err += gpio_init(GPIO_STM_BOOT0, true);
|
||||
|
||||
err += gpio_set(GPIO_STM_RST_N, false);
|
||||
err += gpio_set(GPIO_STM_RST_N, is_legacy ? false : true);
|
||||
err += gpio_set(GPIO_STM_BOOT0, false);
|
||||
|
||||
usleep(100*1000); // 100 ms
|
||||
|
||||
err += gpio_set(GPIO_STM_RST_N, power);
|
||||
err += gpio_set(GPIO_STM_RST_N, is_legacy ? power : (!power));
|
||||
assert(err == 0);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ from common.gpio import GPIO_HUB_RST_N, GPIO_STM_BOOT0, GPIO_STM_RST_N, gpio_ini
|
|||
from panda import BASEDIR, Panda, PandaDFU, build_st
|
||||
from selfdrive.swaglog import cloudlog
|
||||
|
||||
def is_legacy_panda_reset():
|
||||
return os.path.isfile("/persist/LEGACY_PANDA_RESET")
|
||||
|
||||
def set_panda_power(power=True):
|
||||
if not TICI:
|
||||
|
@ -16,12 +18,12 @@ def set_panda_power(power=True):
|
|||
gpio_init(GPIO_STM_RST_N, True)
|
||||
gpio_init(GPIO_STM_BOOT0, True)
|
||||
|
||||
gpio_set(GPIO_STM_RST_N, False)
|
||||
gpio_set(GPIO_STM_RST_N, False if is_legacy_panda_reset() else True)
|
||||
gpio_set(GPIO_HUB_RST_N, True)
|
||||
|
||||
time.sleep(0.1)
|
||||
|
||||
gpio_set(GPIO_STM_RST_N, power)
|
||||
gpio_set(GPIO_STM_RST_N, power if is_legacy_panda_reset() else (not power))
|
||||
|
||||
|
||||
def get_firmware_fn():
|
||||
|
|
Loading…
Reference in New Issue