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
parent
abeafb6256
commit
d6668fe4ef
|
@ -957,6 +957,11 @@ void OTG_FS_IRQ_Handler(void) {
|
||||||
NVIC_EnableIRQ(OTG_FS_IRQn);
|
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 *****************************
|
// ***************************** USB init *****************************
|
||||||
|
|
||||||
void usb_init(void) {
|
void usb_init(void) {
|
||||||
|
|
11
board/main.c
11
board/main.c
|
@ -697,7 +697,6 @@ void TIM1_BRK_TIM9_IRQ_Handler(void) {
|
||||||
|
|
||||||
// Tick fan driver
|
// Tick fan driver
|
||||||
fan_tick();
|
fan_tick();
|
||||||
//puts("Fan speed: "); puth((unsigned int) fan_rpm); puts("rpm\n");
|
|
||||||
|
|
||||||
// set green LED to be controls allowed
|
// set green LED to be controls allowed
|
||||||
current_board->set_led(LED_GREEN, 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);
|
set_power_save_state(POWER_SAVE_STATUS_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also disable fan and IR when the heartbeat goes missing
|
// Also disable IR when the heartbeat goes missing
|
||||||
current_board->set_fan_power(0U);
|
|
||||||
current_board->set_ir_power(0U);
|
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
|
// enter CDP mode when car starts to ensure we are charging a turned off EON
|
||||||
|
|
Loading…
Reference in New Issue