Skip to content

Commit 565e79b

Browse files
authored
Merge pull request #983 from lukash/pvd-hardening
Pvd hardening
2 parents cb79df8 + 31c92af commit 565e79b

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎irq_handlers.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ CH_IRQ_HANDLER(TIM2_IRQHandler) {
102102
}
103103

104104
CH_IRQ_HANDLER(PVD_IRQHandler) {
105+
CH_IRQ_PROLOGUE();
106+
105107
if (EXTI_GetITStatus(EXTI_Line16) != RESET) {
106108
// Log the fault. Supply voltage dropped below 2.9V,
107109
// could corrupt an ongoing flash programming
@@ -119,6 +121,8 @@ CH_IRQ_HANDLER(PVD_IRQHandler) {
119121
EXTI_ClearITPendingBit(EXTI_Line16);
120122
EXTI_ClearFlag(EXTI_Line16);
121123
}
124+
125+
CH_IRQ_EPILOGUE();
122126
}
123127

124128
CH_IRQ_HANDLER(NMI_Handler) {

‎motor/mc_interface.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1873,6 +1873,12 @@ void mc_interface_set_fault_info(const char *str, int argn, float arg0, float ar
18731873
}
18741874

18751875
void mc_interface_fault_stop(mc_fault_code fault, bool is_second_motor, bool is_isr) {
1876+
// Interrupts can raise faults before mc_interface_init() starts the fault stop
1877+
// thread (e.g. the PVD early in boot), when there is no motor to stop yet
1878+
if (!fault_stop_tp) {
1879+
return;
1880+
}
1881+
18761882
m_fault_data.fault_code = fault;
18771883
m_fault_data.is_second_motor = is_second_motor;
18781884

0 commit comments

Comments
 (0)