add psu brownout check to do_checks

This commit is contained in:
Oskar Weigl
2018-02-23 13:05:49 -08:00
parent 4088f3fa07
commit 4801c4a8b5
+5 -4
View File
@@ -1324,16 +1324,13 @@ bool check_DRV_fault(Motor_t* motor) {
//Returns true if everything is OK (no fault)
bool check_PSU_brownout(Motor_t* motor) {
if(vbus_voltage < motor->dc_bus_brownout_trip_level) {
motor->error = ERROR_DC_BUS_BROWNOUT;
if(vbus_voltage < motor->dc_bus_brownout_trip_level)
return false;
}
return true;
}
// Returns true if everything is ok. Sets motor->error and returns false otherwise.
bool do_checks(Motor_t* motor) {
// Checks
if (!check_DRV_fault(motor)) {
motor->error = ERROR_DRV_FAULT;
// Update DRV Fault Code
@@ -1344,6 +1341,10 @@ bool do_checks(Motor_t* motor) {
DRV8301_readData(&motor->gate_driver, local_regs);
return false;
}
if (!check_PSU_brownout(motor)) {
motor->error = ERROR_DC_BUS_BROWNOUT;
return false;
}
return true;
}