mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-24 15:23:53 +08:00
9881e6118 Panda for Mazda (#165) 9a15d2f5b fix version newline a8ed7d219 add subaru outback/legacy to subaru safety (#259) bdeb1c953 mazda is #12 14ea4d2e0 merge safety gm in a single file bf1ef875e Add GM passive safety mode (#266) c131fffae fix canflash for pedal (#267) 3397b1527 only allow bootloader entry on debug builds d68356b92 Honda Nidec: fwd stock AEB (#257) 6f532c6d5 Black panda Jenkins (#256) d68508c79 Gpio race condition fix (#263) d69d05fc0 Fixed pedal not initializing (#262) 36067e01c Honda safety: fixed incorrect brake decoding. Due to the specific limit of 255, this change does not affect the safety behavior git-subtree-dir: panda git-subtree-split: 9881e61184ad0417e9e080767f09585a9c777621
51 lines
1.6 KiB
C
51 lines
1.6 KiB
C
#define POWER_SAVE_STATUS_DISABLED 0
|
|
#define POWER_SAVE_STATUS_ENABLED 1
|
|
|
|
int power_save_status = POWER_SAVE_STATUS_DISABLED;
|
|
|
|
void set_power_save_state(int state) {
|
|
|
|
bool is_valid_state = (state == POWER_SAVE_STATUS_ENABLED) || (state == POWER_SAVE_STATUS_DISABLED);
|
|
if (is_valid_state && (state != power_save_status)) {
|
|
bool enable = false;
|
|
if (state == POWER_SAVE_STATUS_ENABLED) {
|
|
puts("enable power savings\n");
|
|
if (board_has_gps()) {
|
|
char UBLOX_SLEEP_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x08\x00\x17\x78";
|
|
uart_ring *ur = get_ring_by_number(1);
|
|
for (unsigned int i = 0; i < sizeof(UBLOX_SLEEP_MSG) - 1U; i++) while (!putc(ur, UBLOX_SLEEP_MSG[i]));
|
|
}
|
|
} else {
|
|
puts("disable power savings\n");
|
|
if (board_has_gps()) {
|
|
char UBLOX_WAKE_MSG[] = "\xb5\x62\x06\x04\x04\x00\x01\x00\x09\x00\x18\x7a";
|
|
uart_ring *ur = get_ring_by_number(1);
|
|
for (unsigned int i = 0; i < sizeof(UBLOX_WAKE_MSG) - 1U; i++) while (!putc(ur, UBLOX_WAKE_MSG[i]));
|
|
}
|
|
enable = true;
|
|
}
|
|
|
|
// Switch CAN transcievers
|
|
current_board->enable_can_transcievers(enable);
|
|
|
|
// Switch EPS/GPS
|
|
if (enable) {
|
|
current_board->set_esp_gps_mode(ESP_GPS_ENABLED);
|
|
} else {
|
|
current_board->set_esp_gps_mode(ESP_GPS_DISABLED);
|
|
}
|
|
|
|
if(hw_type != HW_TYPE_BLACK_PANDA){
|
|
// turn on GMLAN
|
|
set_gpio_output(GPIOB, 14, enable);
|
|
set_gpio_output(GPIOB, 15, enable);
|
|
|
|
// turn on LIN
|
|
set_gpio_output(GPIOB, 7, enable);
|
|
set_gpio_output(GPIOA, 14, enable);
|
|
}
|
|
|
|
power_save_status = state;
|
|
}
|
|
}
|