Turn on fan if panda is enumerated but not receiving heartbeat (#553)

* fix linter

* Turn on fan if panda is enumerated but not receiving heartbeat

* Upped to 50%
master
robbederks 2020-06-11 18:14:41 -07:00 committed by GitHub
parent abeafb6256
commit d6668fe4ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -957,6 +957,11 @@ void OTG_FS_IRQ_Handler(void) {
NVIC_EnableIRQ(OTG_FS_IRQn);
}
bool usb_enumerated(void) {
// This relies on the USB being suspended after no activity for 3ms. Seems pretty stable
return (!(USBx_DEVICE->DSTS & USB_OTG_DSTS_SUSPSTS));
}
// ***************************** USB init *****************************
void usb_init(void) {

View File

@ -697,7 +697,6 @@ void TIM1_BRK_TIM9_IRQ_Handler(void) {
// Tick fan driver
fan_tick();
//puts("Fan speed: "); puth((unsigned int) fan_rpm); puts("rpm\n");
// set green LED to be controls allowed
current_board->set_led(LED_GREEN, controls_allowed);
@ -725,9 +724,15 @@ void TIM1_BRK_TIM9_IRQ_Handler(void) {
set_power_save_state(POWER_SAVE_STATUS_ENABLED);
}
// Also disable fan and IR when the heartbeat goes missing
current_board->set_fan_power(0U);
// Also disable IR when the heartbeat goes missing
current_board->set_ir_power(0U);
// If enumerated but no heartbeat (phone up, boardd not running), turn the fan on to cool the device
if(usb_enumerated()){
current_board->set_fan_power(50U);
} else {
current_board->set_fan_power(0U);
}
}
// enter CDP mode when car starts to ensure we are charging a turned off EON