Skip to content

Commit 8e667b1

Browse files
committed
reset when swoc
1 parent 388f942 commit 8e667b1

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

Apps/Src/ReadTritium.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,13 @@ void Task_ReadTritium(void *p_arg) {
170170
}
171171
}
172172

173-
static void restartMotorController(void) {
174-
//CANDATA_t resetmsg = {0};
175-
//resetmsg.ID = MOTOR_RESET;
176-
//CANbus_Send(resetmsg, true, MOTORCAN);
173+
static void resetMotorController(void) {
174+
CANDATA_t resetCmd = {
175+
.ID = MOTOR_RESET,
176+
.idx = 0,
177+
.data = {0.0f}
178+
};
179+
CANbus_Send(resetCmd, true, MOTORCAN);
177180
}
178181

179182
// Getter function for motor RPM
@@ -208,7 +211,7 @@ uint16_t Motor_Error_Get() { return Motor_FaultBitmap; }
208211
* @brief A callback function to be run by the main throwTaskError function for hall sensor errors
209212
* restart the motor if the number of hall errors is still less than the MOTOR_RESTART_THRESHOLD.
210213
*/
211-
static inline void handler_ReadTritium_HallError(void) { restartMotorController(); }
214+
static inline void handler_ReadTritium_HallError(void) { resetMotorController(); }
212215

213216
/**
214217
* @brief Assert a Tritium error by checking Motor_FaultBitmap
@@ -229,19 +232,28 @@ void assertTritiumError(controls_error_e m_err) {
229232
// Start of fallthrough
230233
case C_ERR_RTR_GENERIC:
231234
case C_ERR_RTR_HARDWARE_OC:
232-
case C_ERR_RTR_SOFTWARE_OC:
233235
case C_ERR_RTR_DC_BUS_OV:
234236
case C_ERR_RTR_WDOG_LAST_RESET:
235237
case C_ERR_RTR_CONFIG_READ:
236238
case C_ERR_RTR_UNDERVOLT_LOCKOUT:
237239
case C_ERR_RTR_DESAT_FAULT:
238240
case C_ERR_RTR_MOTOR_OVERSPEED:
241+
case C_ERR_RTR_HALL_SENSOR:
239242
case C_ERR_RTR_INIT_FAIL:
240243
case C_ERR_RTR_MULTIPLE:
241244
case C_ERR_RTR_UNKNOWN_ERROR:
242245
throwTaskError(m_err, !EVAC_NEEDED, NULL, OPT_LOCK_SCHED, OPT_NONRECOV, CAN_NONE_BPS);
243246
break;
244-
// Emd of fallthrough
247+
248+
case C_ERR_RTR_SOFTWARE_OC:
249+
// Try to restart the motor a few times and then fail out
250+
if (++motor_fault_cnt > 1) {
251+
throwTaskError(m_err, !EVAC_NEEDED, NULL, OPT_LOCK_SCHED, OPT_NONRECOV, CAN_NONE_BPS);
252+
} else {
253+
resetMotorController();
254+
}
255+
break;
256+
// End of fallthrough
245257

246258
case C_ERR_RTR_MOTOR_WDOG_TRIP:
247259
// Try to restart the motor a few times and then fail out
@@ -251,7 +263,7 @@ void assertTritiumError(controls_error_e m_err) {
251263
// throwTaskError(m_err, !EVAC_NEEDED, handler_ReadTritium_HallError, OPT_NO_LOCK_SCHED, OPT_NONRECOV, CAN_NONE_BPS);
252264
}
253265
break;
254-
266+
/*
255267
case C_ERR_RTR_HALL_SENSOR:
256268
// If it's purely a hall sensor error, try to restart the motor a few times and then
257269
// fail out
@@ -261,6 +273,7 @@ void assertTritiumError(controls_error_e m_err) {
261273
throwTaskError(m_err, !EVAC_NEEDED, handler_ReadTritium_HallError, OPT_NO_LOCK_SCHED, OPT_NONRECOV, CAN_UNKNOWN_BPS);
262274
}
263275
break;
276+
*/
264277

265278
default:
266279
// Critical failure, we have a non readtritium error in readtritium somehow

0 commit comments

Comments
 (0)