From 4e78acd6be2e5421f035b22e07d7ae21c2acd2a7 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Wed, 6 Aug 2025 20:35:11 -0400 Subject: [PATCH 1/4] split pedal faults --- Core/Inc/fault.h | 5 +++-- Core/Src/pedals.c | 44 +++++++++++++++++++++++++++++++++++-------- Drivers/Embedded-Base | 2 +- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/Core/Inc/fault.h b/Core/Inc/fault.h index 87a9671d..8d006f9e 100644 --- a/Core/Inc/fault.h +++ b/Core/Inc/fault.h @@ -6,8 +6,9 @@ typedef enum { /* START CRIT FAULTS HERE */ - - ONBOARD_PEDAL_FAULT, + ONBOARD_PEDAL_OC_FAULT, + ONBOARD_PEDAL_SC_FAULT, + ONBOARD_PEDAL_DIFF_FAULT, CAN_DISPATCH_FAULT, CAN_ROUTING_FAULT, BMS_CAN_MONITOR_FAULT, diff --git a/Core/Src/pedals.c b/Core/Src/pedals.c index 65c01123..92956e2a 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -164,14 +164,42 @@ bool get_launch_control() } /** - * @brief Callback for pedal fault debouncing. + * @brief Callback for pedal open circuit fault debouncing. * * @param arg The fault message as a char*. */ -void pedal_fault_cb(void *arg) +void pedal_open_circuit_fault_cb(void *arg) { fault_data_t fault_data = { - .fault_id = ONBOARD_PEDAL_FAULT, + .fault_id = ONBOARD_PEDAL_OC_FAULT, + }; + fault_data.diag = (char *)arg; + queue_fault(&fault_data); +} + +/** + * @brief Callback for pedal short circuit fault debouncing. + * + * @param arg The fault message as a char*. + */ +void pedal_short_circuit_fault_cb(void *arg) +{ + fault_data_t fault_data = { + .fault_id = ONBOARD_PEDAL_SC_FAULT, + }; + fault_data.diag = (char *)arg; + queue_fault(&fault_data); +} + +/** + * @brief Callback for pedal difference fault debouncing. + * + * @param arg The fault message as a char*. + */ +void pedal_difference_fault_cb(void *arg) +{ + fault_data_t fault_data = { + .fault_id = ONBOARD_PEDAL_DIFF_FAULT, }; fault_data.diag = (char *)arg; queue_fault(&fault_data); @@ -202,14 +230,14 @@ bool calc_pedal_faults(float accel1, float accel2, float accel1_norm, bool open_circuit = accel1 > MAX_VOLTS_UNSCALED - APPS_THRESHOLD_BUF || accel2 > MAX_VOLTS_UNSCALED - APPS_THRESHOLD_BUF; debounce(open_circuit, &oc_fault_timer, PEDAL_FAULT_TIME, - &pedal_fault_cb, + &pedal_open_circuit_fault_cb, "Pedal open circuit fault - max acceleration value"); /* Pedal short circuit to gnd */ bool short_circuit = accel1 < MIN_APPS1_VOLTS - APPS_THRESHOLD_BUF || accel2 < MIN_APPS2_VOLTS - APPS_THRESHOLD_BUF; debounce(short_circuit, &sc_fault_timer, PEDAL_FAULT_TIME, - &pedal_fault_cb, + &pedal_short_circuit_fault_cb, "Pedal grounded circuit fault - no acceleration value"); /* Pedal difference fault evaluation */ @@ -221,7 +249,7 @@ bool calc_pedal_faults(float accel1, float accel2, float accel1_norm, PEDAL_DIFF_THRESH; debounce(pedals_too_diff, &diff_fault_timer, PEDAL_FAULT_TIME, - &pedal_fault_cb, + &pedal_difference_fault_cb, "Pedal short fault - pedal values are too different"); if (open_circuit || short_circuit || pedals_too_diff) { @@ -252,14 +280,14 @@ bool calc_brake_faults(float brake1, float brake2) brake1 > BRAKE_SENSOR_IRREGULAR_HIGH + BRAKE_THRESHOLD_BUF || brake2 > BRAKE_SENSOR_IRREGULAR_HIGH + BRAKE_THRESHOLD_BUF; debounce(open_circuit, &oc_fault_timer, BRAKE_FAULT_TIME, - &pedal_fault_cb, "Brake open circuit fault - max brake value"); + &pedal_open_circuit_fault_cb, "Brake open circuit fault - max brake value"); /* Pedal short circuit to gnd */ bool short_circuit = brake1 < BRAKE_SENSOR_IRREGULAR_LOW - BRAKE_THRESHOLD_BUF || brake2 < BRAKE_SENSOR_IRREGULAR_LOW - BRAKE_THRESHOLD_BUF; debounce(short_circuit, &sc_fault_timer, BRAKE_FAULT_TIME, - &pedal_fault_cb, + &pedal_short_circuit_fault_cb, "Brake grounded circuit fault - 0 brake value"); if (open_circuit || short_circuit) { diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index c7704a99..f6e18795 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit c7704a998b12cca8d2a7c3880d5b3562ccae41df +Subproject commit f6e1879508244c94621595c8b35a1197f2e88230 From 401f31d5e847f0e52fae6ac78b0c57d9d8ca0740 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Thu, 7 Aug 2025 08:21:12 -0400 Subject: [PATCH 2/4] full pedal fault names --- Core/Inc/fault.h | 6 +++--- Core/Src/pedals.c | 6 +++--- Drivers/Embedded-Base | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/Inc/fault.h b/Core/Inc/fault.h index 8d006f9e..6b7d8805 100644 --- a/Core/Inc/fault.h +++ b/Core/Inc/fault.h @@ -6,9 +6,9 @@ typedef enum { /* START CRIT FAULTS HERE */ - ONBOARD_PEDAL_OC_FAULT, - ONBOARD_PEDAL_SC_FAULT, - ONBOARD_PEDAL_DIFF_FAULT, + ONBOARD_PEDAL_OPEN_CIRCUIT_FAULT, + ONBOARD_PEDAL_SHORT_CIRCUIT_FAULT, + ONBOARD_PEDAL_DIFFERENCE_FAULT, CAN_DISPATCH_FAULT, CAN_ROUTING_FAULT, BMS_CAN_MONITOR_FAULT, diff --git a/Core/Src/pedals.c b/Core/Src/pedals.c index 92956e2a..cf7c75a4 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -171,7 +171,7 @@ bool get_launch_control() void pedal_open_circuit_fault_cb(void *arg) { fault_data_t fault_data = { - .fault_id = ONBOARD_PEDAL_OC_FAULT, + .fault_id = ONBOARD_PEDAL_OPEN_CIRCUIT_FAULT, }; fault_data.diag = (char *)arg; queue_fault(&fault_data); @@ -185,7 +185,7 @@ void pedal_open_circuit_fault_cb(void *arg) void pedal_short_circuit_fault_cb(void *arg) { fault_data_t fault_data = { - .fault_id = ONBOARD_PEDAL_SC_FAULT, + .fault_id = ONBOARD_PEDAL_SHORT_CIRCUIT_FAULT, }; fault_data.diag = (char *)arg; queue_fault(&fault_data); @@ -199,7 +199,7 @@ void pedal_short_circuit_fault_cb(void *arg) void pedal_difference_fault_cb(void *arg) { fault_data_t fault_data = { - .fault_id = ONBOARD_PEDAL_DIFF_FAULT, + .fault_id = ONBOARD_PEDAL_DIFFERENCE_FAULT, }; fault_data.diag = (char *)arg; queue_fault(&fault_data); diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index f6e18795..2bab6e4a 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit f6e1879508244c94621595c8b35a1197f2e88230 +Subproject commit 2bab6e4a1c660046a91b94c142ab907364a0e0cb From 3aa330636cccbce0b77834b5d175838388329ef5 Mon Sep 17 00:00:00 2001 From: Chris Pyle Date: Fri, 8 Aug 2025 20:09:41 -0400 Subject: [PATCH 3/4] formatting --- Core/Src/pedals.c | 3 ++- Drivers/Embedded-Base | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Src/pedals.c b/Core/Src/pedals.c index cf7c75a4..946acfcf 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -280,7 +280,8 @@ bool calc_brake_faults(float brake1, float brake2) brake1 > BRAKE_SENSOR_IRREGULAR_HIGH + BRAKE_THRESHOLD_BUF || brake2 > BRAKE_SENSOR_IRREGULAR_HIGH + BRAKE_THRESHOLD_BUF; debounce(open_circuit, &oc_fault_timer, BRAKE_FAULT_TIME, - &pedal_open_circuit_fault_cb, "Brake open circuit fault - max brake value"); + &pedal_open_circuit_fault_cb, + "Brake open circuit fault - max brake value"); /* Pedal short circuit to gnd */ bool short_circuit = diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 2bab6e4a..30af2b36 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 2bab6e4a1c660046a91b94c142ab907364a0e0cb +Subproject commit 30af2b364cfcc780c4e6a5cb4f0e5efd8f210c35 From b1eaa261e0bd2639f92b0e4c55fb87d271f5a8d0 Mon Sep 17 00:00:00 2001 From: Caio Date: Sat, 9 Aug 2025 11:54:02 -0400 Subject: [PATCH 4/4] bump embedded base --- Drivers/Embedded-Base | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Drivers/Embedded-Base b/Drivers/Embedded-Base index 30af2b36..1bffad75 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 30af2b364cfcc780c4e6a5cb4f0e5efd8f210c35 +Subproject commit 1bffad75d8a2a7ec58f6512753d40ea6e2865296