diff --git a/Core/Inc/fault.h b/Core/Inc/fault.h index 87a9671d..6b7d8805 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_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 0f55d505..8b272143 100644 --- a/Core/Src/pedals.c +++ b/Core/Src/pedals.c @@ -193,14 +193,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_OPEN_CIRCUIT_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_SHORT_CIRCUIT_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_DIFFERENCE_FAULT, }; fault_data.diag = (char *)arg; queue_fault(&fault_data); @@ -231,14 +259,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 */ @@ -250,7 +278,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) { @@ -281,14 +309,15 @@ 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 6d4952f5..1bffad75 160000 --- a/Drivers/Embedded-Base +++ b/Drivers/Embedded-Base @@ -1 +1 @@ -Subproject commit 6d4952f5b8a215261a264ce34a46958447de3c31 +Subproject commit 1bffad75d8a2a7ec58f6512753d40ea6e2865296