diff --git a/stm-firmware/safety/safety-controller.c b/stm-firmware/safety/safety-controller.c index 3a953c9..02f533f 100644 --- a/stm-firmware/safety/safety-controller.c +++ b/stm-firmware/safety/safety-controller.c @@ -42,6 +42,7 @@ #include #include #include +#include /** * @brief Macro that checks if a given @ref error_flag is persistent @@ -563,6 +564,7 @@ static void safety_controller_process_active_timing_mons() /** * @brief safety_controller_process_monitor_checks * Process the analog and timing monitors and set the relevant flags in case of a monitor outside its limits. + * Furthermore, the PT1000 resistance is checked for overtemperature * * The checking of the analog monitors will only be armed after a startup delay of 1000 ms to allow the values to stabilize. */ @@ -572,6 +574,7 @@ static void safety_controller_process_monitor_checks(void) struct analog_monitor_info amon_info; uint32_t idx; uint32_t analog_mon_count; + float pt1000_val = 1000000.0f; if (!startup_completed && systick_get_global_tick() >= 1000) startup_completed = true; @@ -589,6 +592,11 @@ static void safety_controller_process_monitor_checks(void) } } + adc_pt1000_get_current_resistance(&pt1000_val); + if (pt1000_val > safety_controller_overtemp_config.overtemp_equiv_resistance) { + safety_controller_report_error(ERR_FLAG_OVERTEMP); + } + safety_controller_process_active_timing_mons(); } diff --git a/stm-firmware/settings/settings-eeprom.c b/stm-firmware/settings/settings-eeprom.c index 99171bb..35e13ff 100644 --- a/stm-firmware/settings/settings-eeprom.c +++ b/stm-firmware/settings/settings-eeprom.c @@ -24,7 +24,7 @@ #include #define EEPROM_HEADER_MAGIC 0xA5 -#define EEPROM_HEADER_COMP_VER 0xFF +#define EEPROM_HEADER_COMP_VER 0x01 static const uint8_t expected_header[2] = {EEPROM_HEADER_MAGIC, EEPROM_HEADER_COMP_VER}; @@ -36,6 +36,12 @@ struct eeprom_calibration_settings { uint32_t crc; }; +#define EEPROM_OVER_TEMP_CONFIG_BASE_ADDR (EEPROM_CALIBRATION_BASE_ADDR + sizeof(struct eeprom_calibration_settings)) +struct eeprom_over_temp_config { + float over_temperature; + float over_temperature_redundant; +}; + static bool check_eeprom_header(void) { uint8_t header[2] = {0};