Add CRC monitoring over ADC registers
This commit is contained in:
		@@ -58,6 +58,8 @@ enum safety_flag {
 | 
			
		||||
	ERR_FLAG_OVERTEMP = (1<<18),
 | 
			
		||||
	ERR_FLAG_FLASH_CRC_CODE = (1<<19),
 | 
			
		||||
	ERR_FLAG_FLASH_CRC_DATA = (1<<20),
 | 
			
		||||
	ERR_FLAG_CFG_CRC_MEAS_ADC = (1<<21),
 | 
			
		||||
	ERR_FLAG_CFG_CRC_SAFETY_ADC = (1<<22),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -73,6 +75,12 @@ enum timing_monitor {
 | 
			
		||||
	ERR_TIMING_MAIN_LOOP = (1<<3),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum crc_monitor {
 | 
			
		||||
	ERR_CRC_MON_MEAS_ADC = 0,
 | 
			
		||||
	ERR_CRC_MON_SAFETY_ADC,
 | 
			
		||||
	N_ERR_CRC_MON
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Enum Type representing analog value monitors.
 | 
			
		||||
 *
 | 
			
		||||
@@ -146,6 +154,16 @@ enum analog_value_monitor {
 | 
			
		||||
 */
 | 
			
		||||
#define SAFETY_CONTROLLER_ADC_DELAY_MS 250
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Password for resetting ERR_CRC_MON_MEAS_ADC
 | 
			
		||||
 */
 | 
			
		||||
#define SAFETY_CRC_MON_MEAS_ADC_PW 0xD96254A2
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Password for resetting ERR_CRC_MON_SAFETY_ADC
 | 
			
		||||
 */
 | 
			
		||||
#define SAFETY_CRC_MON_SAFETY_ADC_PW 0xA8DF2368
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Default persistence of safety flags. These values are loaded into the safety tables on startup
 | 
			
		||||
 */
 | 
			
		||||
@@ -169,7 +187,9 @@ enum analog_value_monitor {
 | 
			
		||||
					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)
 | 
			
		||||
					ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_FLASH_CRC_DATA, true), \
 | 
			
		||||
					ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_CFG_CRC_MEAS_ADC, true), \
 | 
			
		||||
					ERR_FLAG_PERSIST_ENTRY(ERR_FLAG_CFG_CRC_SAFETY_ADC, true), \
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Default config weights of safety flags. These values are loaded into the safety tables on startup
 | 
			
		||||
 */
 | 
			
		||||
@@ -194,5 +214,7 @@ enum analog_value_monitor {
 | 
			
		||||
			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), \
 | 
			
		||||
			ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_CFG_CRC_MEAS_ADC, SAFETY_FLAG_CONFIG_WEIGHT_NONE), \
 | 
			
		||||
			ERR_FLAG_WEIGHT_ENTRY(ERR_FLAG_CFG_CRC_SAFETY_ADC, SAFETY_FLAG_CONFIG_WEIGHT_NONE), \
 | 
			
		||||
 | 
			
		||||
#endif /* __SAFETY_CONFIG_H__ */
 | 
			
		||||
 
 | 
			
		||||
@@ -274,6 +274,14 @@ float safety_controller_get_overtemp_limit(void);
 | 
			
		||||
 */
 | 
			
		||||
int safety_controller_trigger_flash_crc_check(void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Recalculate the CRC of a given CRC Monitor. This has to be done once the supervised registers update
 | 
			
		||||
 * @param mon Monitor to recalculate
 | 
			
		||||
 * @param password Password
 | 
			
		||||
 * @return 0 if successful
 | 
			
		||||
 */
 | 
			
		||||
int safety_controller_set_crc_monitor(enum crc_monitor mon, uint32_t password);
 | 
			
		||||
 | 
			
		||||
#endif /* __SAFETY_CONTROLLER_H__ */
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user