added unseal() and seal() around write_flash() for enabling/disabling cell undervoltage, we found out today this wasn't being written because that address is in protected flash

This commit is contained in:
Jake Dahl 2018-10-17 17:09:41 -06:00 committed by Daniel Agar
parent 5dbb34c841
commit 27c6432757

View File

@ -319,10 +319,14 @@ void BATT_SMBUS::set_undervoltage_protection(float average_current)
uint8_t protections_a_tmp = BATT_SMBUS_ENABLED_PROTECTIONS_A_CUV_DISABLED;
uint16_t address = BATT_SMBUS_ENABLED_PROTECTIONS_A_ADDRESS;
unseal();
if (write_flash(address, &protections_a_tmp, 1) == PX4_OK) {
_cell_undervoltage_protection_status = 0;
PX4_WARN("Disabled CUV");
}
seal();
}
} else {
@ -332,11 +336,15 @@ void BATT_SMBUS::set_undervoltage_protection(float average_current)
uint8_t protections_a_tmp = BATT_SMBUS_ENABLED_PROTECTIONS_A_DEFAULT;
uint16_t address = BATT_SMBUS_ENABLED_PROTECTIONS_A_ADDRESS;
unseal();
if (write_flash(address, &protections_a_tmp, 1) == PX4_OK) {
_cell_undervoltage_protection_status = 1;
PX4_WARN("Enabled CUV");
}
seal();
}
}
}