Improve code and add a Flash CRC check
This commit is contained in:
@@ -56,6 +56,8 @@ enum safety_flag {
|
||||
ERR_FLAG_SAFETY_TAB_CORRUPT = (1<<16),
|
||||
ERR_FLAG_AMON_SUPPLY_VOLT = (1<<17),
|
||||
ERR_FLAG_OVERTEMP = (1<<18),
|
||||
ERR_FLAG_FLASH_CRC_CODE = (1<<19),
|
||||
ERR_FLAG_FLASH_CRC_DATA = (1<<20),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -166,6 +168,8 @@ enum analog_value_monitor {
|
||||
ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_SAFETY_TAB_CORRUPT, true), \
|
||||
ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_AMON_SUPPLY_VOLT, false), \
|
||||
ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_OVERTEMP, false), \
|
||||
ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_FLASH_CRC_CODE, true), \
|
||||
ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_FLASH_CRC_DATA, true)
|
||||
/**
|
||||
* @brief Default config weights of safety flags. These values are loaded into the safety tables on startup
|
||||
*/
|
||||
@@ -188,5 +192,7 @@ enum analog_value_monitor {
|
||||
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_SAFETY_TAB_CORRUPT, SAFETY_FLAG_CONFIG_WEIGHT_PANIC), \
|
||||
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_AMON_SUPPLY_VOLT, SAFETY_FLAG_CONFIG_WEIGHT_PID), \
|
||||
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_OVERTEMP, SAFETY_FLAG_CONFIG_WEIGHT_PID), \
|
||||
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_FLASH_CRC_CODE, SAFETY_FLAG_CONFIG_WEIGHT_NONE), \
|
||||
ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_FLASH_CRC_DATA, SAFETY_FLAG_CONFIG_WEIGHT_NONE), \
|
||||
|
||||
#endif /* __SAFETY_CONFIG_H__ */
|
||||
|
@@ -267,6 +267,13 @@ int safety_controller_set_overtemp_limit(float over_temperature);
|
||||
*/
|
||||
float safety_controller_get_overtemp_limit(void);
|
||||
|
||||
/**
|
||||
* @brief Perform a CRC check of the flash memory and set appropriate flags
|
||||
* @return negative if internal error occured. Otherwise (independent from CRC check result) 0.
|
||||
* @note This function requires the safety controller to be set up before!
|
||||
*/
|
||||
int safety_controller_trigger_flash_crc_check(void);
|
||||
|
||||
#endif /* __SAFETY_CONTROLLER_H__ */
|
||||
|
||||
/** @} */
|
||||
|
@@ -35,9 +35,14 @@
|
||||
#define SAFETY_MEMORY_MAGIC 0x12AA5CB7
|
||||
|
||||
/**
|
||||
* @brief Error memory NOP entry
|
||||
* @brief Error memory NOP entry word written to the memory
|
||||
*/
|
||||
#define SAFETY_MEMORY_NOP_ENTRY 0xC1AA1222
|
||||
#define SAFETY_MEMORY_NOP_ENTRY_WORD 0xC1AA1222UL
|
||||
|
||||
/**
|
||||
* @brief Low Byte (byte 0) of error memory entry
|
||||
*/
|
||||
#define SAFETY_MEMORY_ERROR_ENTRY_MARKER 0x51U
|
||||
|
||||
/**
|
||||
* @brief Offset address for the safety_memory_header.
|
||||
|
@@ -36,6 +36,6 @@ int temp_converter_convert_resistance_to_temp(float resistance, float *temp_out)
|
||||
* @return 0 if ok, -1 if tmeperature is below the lookup table, 1 if value is above the lookup table, -1000 in case of a pointer error,
|
||||
* -100 if an internal error occured. This should never happen, if the lookup table is correct
|
||||
*/
|
||||
int temp_convertet_convert_temp_to_resistance(float temp, float *resistance_out);
|
||||
int temp_converter_convert_temp_to_resistance(float temp, float *resistance_out);
|
||||
|
||||
#endif /* __TEMP_CONVERTER_H__ */
|
||||
|
Reference in New Issue
Block a user