remove unused deepsleep stuff (#1914)

This commit is contained in:
Adeeb Shihadeh 2024-03-22 14:48:49 -07:00 committed by GitHub
parent dd82382d5f
commit a727cecdb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 0 additions and 166 deletions

View File

@ -11,7 +11,6 @@
//#define DEBUG_FAN //#define DEBUG_FAN
#define CAN_INIT_TIMEOUT_MS 500U #define CAN_INIT_TIMEOUT_MS 500U
#define DEEPSLEEP_WAKEUP_DELAY 3U
#define USBPACKET_MAX_SIZE 0x40U #define USBPACKET_MAX_SIZE 0x40U
#define MAX_CAN_MSGS_PER_USB_BULK_TRANSFER 51U #define MAX_CAN_MSGS_PER_USB_BULK_TRANSFER 51U
#define MAX_CAN_MSGS_PER_SPI_BULK_TRANSFER 170U #define MAX_CAN_MSGS_PER_SPI_BULK_TRANSFER 170U

View File

@ -33,7 +33,6 @@
bool check_started(void) { bool check_started(void) {
bool started = current_board->check_ignition() || ignition_can; bool started = current_board->check_ignition() || ignition_can;
ignition_seen |= started;
return started; return started;
} }
@ -292,20 +291,6 @@ void tick_handler(void) {
TICK_TIMER->SR = 0; TICK_TIMER->SR = 0;
} }
void EXTI_IRQ_Handler(void) {
if (check_exti_irq()) {
exti_irq_clear();
clock_init();
set_power_save_state(POWER_SAVE_STATUS_DISABLED);
deepsleep_allowed = false;
heartbeat_counter = 0U;
usb_soft_disconnect(false);
NVIC_EnableIRQ(TICK_TIMER_IRQ);
}
}
int main(void) { int main(void) {
// Init interrupt table // Init interrupt table
init_interrupts(true); init_interrupts(true);
@ -407,18 +392,6 @@ int main(void) {
} }
#endif #endif
} else { } else {
if (deepsleep_allowed && !usb_enumerated && !check_started() && ignition_seen && (heartbeat_counter > 20U)) {
usb_soft_disconnect(true);
fan_set_power(0U);
NVIC_DisableIRQ(TICK_TIMER_IRQ);
delay(512000U);
// Init IRQs for CAN transceiver and ignition line
exti_irq_init();
// STOP mode
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
}
__WFI(); __WFI();
SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk; SCB->SCR &= ~SCB_SCR_SLEEPDEEP_Msk;
} }

View File

@ -374,10 +374,6 @@ int comms_control_handler(ControlPacket_t *req, uint8_t *resp) {
UNUSED(ret); UNUSED(ret);
} }
break; break;
// **** 0xfb: allow highest power saving mode (stop) to be entered
case 0xfb:
deepsleep_allowed = true;
break;
// **** 0xfc: set CAN FD non-ISO mode // **** 0xfc: set CAN FD non-ISO mode
case 0xfc: case 0xfc:
if ((req->param1 < PANDA_CAN_CNT) && current_board->has_canfd) { if ((req->param1 < PANDA_CAN_CNT) && current_board->has_canfd) {

View File

@ -20,10 +20,6 @@ uint32_t heartbeat_counter = 0;
bool heartbeat_lost = false; bool heartbeat_lost = false;
bool heartbeat_disabled = false; // set over USB bool heartbeat_disabled = false; // set over USB
// Enter deep sleep mode
bool deepsleep_allowed = false;
bool ignition_seen = false;
// siren state // siren state
bool siren_enabled = false; bool siren_enabled = false;
uint32_t siren_countdown = 0; // siren plays while countdown > 0 uint32_t siren_countdown = 0; // siren plays while countdown > 0

View File

@ -1,56 +0,0 @@
void EXTI_IRQ_Handler(void);
void exti_irq_init(void) {
SYSCFG->EXTICR[2] &= ~(SYSCFG_EXTICR3_EXTI8_Msk);
if (harness.status == HARNESS_STATUS_FLIPPED) {
// CAN2_RX
current_board->enable_can_transceiver(3U, false);
SYSCFG->EXTICR[2] |= (SYSCFG_EXTICR3_EXTI8_PA);
// IRQ on falling edge for PC3 (SBU2, EXTI3)
SYSCFG->EXTICR[0] &= ~(SYSCFG_EXTICR1_EXTI3_Msk);
SYSCFG->EXTICR[0] |= (SYSCFG_EXTICR1_EXTI3_PC);
EXTI->IMR |= EXTI_IMR_MR3;
EXTI->RTSR &= ~EXTI_RTSR_TR3; // rising edge
EXTI->FTSR |= EXTI_FTSR_TR3; // falling edge
REGISTER_INTERRUPT(EXTI3_IRQn, EXTI_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_EXTI)
NVIC_EnableIRQ(EXTI3_IRQn);
} else {
// CAN0_RX
current_board->enable_can_transceiver(1U, false);
SYSCFG->EXTICR[2] |= (SYSCFG_EXTICR3_EXTI8_PB);
// IRQ on falling edge for PC0 (SBU1, EXTI0)
SYSCFG->EXTICR[0] &= ~(SYSCFG_EXTICR1_EXTI0_Msk);
SYSCFG->EXTICR[0] |= (SYSCFG_EXTICR1_EXTI0_PC);
EXTI->IMR |= EXTI_IMR_MR0;
EXTI->RTSR &= ~EXTI_RTSR_TR0; // rising edge
EXTI->FTSR |= EXTI_FTSR_TR0; // falling edge
REGISTER_INTERRUPT(EXTI0_IRQn, EXTI_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_EXTI)
NVIC_EnableIRQ(EXTI0_IRQn);
}
// CAN0 or CAN2 IRQ on falling edge (EXTI8)
EXTI->IMR |= EXTI_IMR_MR8;
EXTI->RTSR &= ~EXTI_RTSR_TR8; // rising edge
EXTI->FTSR |= EXTI_FTSR_TR8; // falling edge
REGISTER_INTERRUPT(EXTI9_5_IRQn, EXTI_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_EXTI)
NVIC_EnableIRQ(EXTI9_5_IRQn);
}
bool check_exti_irq(void) {
return ((EXTI->PR & EXTI_PR_PR8) || (EXTI->PR & EXTI_PR_PR3) || (EXTI->PR & EXTI_PR_PR0));
}
void exti_irq_clear(void) {
// Clear pending bits
EXTI->PR |= EXTI_PR_PR8;
EXTI->PR |= EXTI_PR_PR0;
EXTI->PR |= EXTI_PR_PR3;
EXTI->PR |= EXTI_PR_PR22;
// Disable all active EXTI IRQs
EXTI->IMR &= ~EXTI_IMR_MR8;
EXTI->IMR &= ~EXTI_IMR_MR0;
EXTI->IMR &= ~EXTI_IMR_MR3;
EXTI->IMR &= ~EXTI_IMR_MR22;
}

View File

@ -65,10 +65,6 @@
#include "stm32f4/lluart.h" #include "stm32f4/lluart.h"
#endif #endif
#if defined(PANDA) && !defined(BOOTSTUB)
#include "stm32f4/llexti.h"
#endif
#ifdef BOOTSTUB #ifdef BOOTSTUB
#include "stm32f4/llflash.h" #include "stm32f4/llflash.h"
#else #else

View File

@ -1,63 +0,0 @@
void EXTI_IRQ_Handler(void);
void exti_irq_init(void) {
if (harness.status == HARNESS_STATUS_FLIPPED) {
// CAN2_RX IRQ on falling edge (EXTI10)
current_board->enable_can_transceiver(3U, false);
SYSCFG->EXTICR[2] &= ~(SYSCFG_EXTICR3_EXTI10_Msk);
SYSCFG->EXTICR[2] |= (SYSCFG_EXTICR3_EXTI10_PG);
EXTI->IMR1 |= EXTI_IMR1_IM10;
EXTI->RTSR1 &= ~EXTI_RTSR1_TR10; // rising edge
EXTI->FTSR1 |= EXTI_FTSR1_TR10; // falling edge
// IRQ on falling edge for PA1 (SBU2, EXTI1)
SYSCFG->EXTICR[0] &= ~(SYSCFG_EXTICR1_EXTI1_Msk);
SYSCFG->EXTICR[0] |= (SYSCFG_EXTICR1_EXTI1_PA);
EXTI->IMR1 |= EXTI_IMR1_IM1;
EXTI->RTSR1 &= ~EXTI_RTSR1_TR1; // rising edge
EXTI->FTSR1 |= EXTI_FTSR1_TR1; // falling edge
REGISTER_INTERRUPT(EXTI1_IRQn, EXTI_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_EXTI)
NVIC_EnableIRQ(EXTI1_IRQn);
REGISTER_INTERRUPT(EXTI15_10_IRQn, EXTI_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_EXTI)
NVIC_EnableIRQ(EXTI15_10_IRQn);
} else {
// CAN0_RX IRQ on falling edge (EXTI8)
current_board->enable_can_transceiver(1U, false);
SYSCFG->EXTICR[2] &= ~(SYSCFG_EXTICR3_EXTI8_Msk);
SYSCFG->EXTICR[2] |= (SYSCFG_EXTICR3_EXTI8_PB);
EXTI->IMR1 |= EXTI_IMR1_IM8;
EXTI->RTSR1 &= ~EXTI_RTSR1_TR8; // rising edge
EXTI->FTSR1 |= EXTI_FTSR1_TR8; // falling edge
// IRQ on falling edge for PC4 (SBU1, EXTI4)
SYSCFG->EXTICR[1] &= ~(SYSCFG_EXTICR2_EXTI4_Msk);
SYSCFG->EXTICR[1] |= (SYSCFG_EXTICR2_EXTI4_PC);
EXTI->IMR1 |= EXTI_IMR1_IM4;
EXTI->RTSR1 &= ~EXTI_RTSR1_TR4; // rising edge
EXTI->FTSR1 |= EXTI_FTSR1_TR4; // falling edge
REGISTER_INTERRUPT(EXTI4_IRQn, EXTI_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_EXTI)
NVIC_EnableIRQ(EXTI4_IRQn);
REGISTER_INTERRUPT(EXTI9_5_IRQn, EXTI_IRQ_Handler, 100U, FAULT_INTERRUPT_RATE_EXTI)
NVIC_EnableIRQ(EXTI9_5_IRQn);
}
}
bool check_exti_irq(void) {
return ((EXTI->PR1 & EXTI_PR1_PR8) || (EXTI->PR1 & EXTI_PR1_PR10) || (EXTI->PR1 & EXTI_PR1_PR1) || (EXTI->PR1 & EXTI_PR1_PR4));
}
void exti_irq_clear(void) {
// Clear pending bits
EXTI->PR1 |= EXTI_PR1_PR8;
EXTI->PR1 |= EXTI_PR1_PR10;
EXTI->PR1 |= EXTI_PR1_PR4;
EXTI->PR1 |= EXTI_PR1_PR1; // works
EXTI->PR1 |= EXTI_PR1_PR19; // works
// Disable all active EXTI IRQs
EXTI->IMR1 &= ~EXTI_IMR1_IM8;
EXTI->IMR1 &= ~EXTI_IMR1_IM10;
EXTI->IMR1 &= ~EXTI_IMR1_IM4;
EXTI->IMR1 &= ~EXTI_IMR1_IM1;
EXTI->IMR1 &= ~EXTI_IMR1_IM19;
}

View File

@ -76,10 +76,6 @@ separate IRQs for RX and TX.
#include "stm32h7/board.h" #include "stm32h7/board.h"
#include "stm32h7/clock.h" #include "stm32h7/clock.h"
#if !defined(BOOTSTUB) && defined(PANDA)
#include "stm32h7/llexti.h"
#endif
#ifdef BOOTSTUB #ifdef BOOTSTUB
#include "stm32h7/llflash.h" #include "stm32h7/llflash.h"
#else #else

View File

@ -751,9 +751,6 @@ class Panda:
def set_power_save(self, power_save_enabled=0): def set_power_save(self, power_save_enabled=0):
self._handle.controlWrite(Panda.REQUEST_OUT, 0xe7, int(power_save_enabled), 0, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xe7, int(power_save_enabled), 0, b'')
def enable_deepsleep(self):
self._handle.controlWrite(Panda.REQUEST_OUT, 0xfb, 0, 0, b'')
def set_safety_mode(self, mode=SAFETY_SILENT, param=0): def set_safety_mode(self, mode=SAFETY_SILENT, param=0):
self._handle.controlWrite(Panda.REQUEST_OUT, 0xdc, mode, param, b'') self._handle.controlWrite(Panda.REQUEST_OUT, 0xdc, mode, param, b'')