update handling of analog monitors. Manually adding analog monotprs to the checking function is not necessary anymore
This commit is contained in:
		@@ -48,6 +48,7 @@ struct analog_monitor_info {
 | 
				
			|||||||
	float min;	/**< @brief Minumum value allowed */
 | 
						float min;	/**< @brief Minumum value allowed */
 | 
				
			||||||
	float max;	/**< @brief Maximum value allowed */
 | 
						float max;	/**< @brief Maximum value allowed */
 | 
				
			||||||
	enum analog_monitor_status status; /**< @brief Current monitor status */
 | 
						enum analog_monitor_status status; /**< @brief Current monitor status */
 | 
				
			||||||
 | 
						enum safety_flag associated_flag; /**< @brief Associated safety flag, that will be set, if monitor out of range */
 | 
				
			||||||
	uint64_t timestamp; /**< @brief ms timestamp when @ref analog_monitor_info::value was taken. */
 | 
						uint64_t timestamp; /**< @brief ms timestamp when @ref analog_monitor_info::value was taken. */
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -358,24 +358,24 @@ static void safety_controller_process_active_timing_mons()
 | 
				
			|||||||
static void safety_controller_process_monitor_checks(void)
 | 
					static void safety_controller_process_monitor_checks(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	static bool startup_completed = false;
 | 
						static bool startup_completed = false;
 | 
				
			||||||
	enum analog_monitor_status amon_state;
 | 
						struct analog_monitor_info amon_info;
 | 
				
			||||||
	float amon_value;
 | 
						uint32_t idx;
 | 
				
			||||||
 | 
						uint32_t analog_mon_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!startup_completed && systick_get_global_tick() >= 1000)
 | 
						if (!startup_completed && systick_get_global_tick() >= 1000)
 | 
				
			||||||
		startup_completed = true;
 | 
							startup_completed = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (startup_completed) {
 | 
						if (startup_completed) {
 | 
				
			||||||
 | 
							analog_mon_count = safety_controller_get_analog_monitor_count();
 | 
				
			||||||
 | 
							for (idx = 0; idx < analog_mon_count; idx++) {
 | 
				
			||||||
 | 
								if (safety_controller_get_analog_mon_by_index(idx, &amon_info)) {
 | 
				
			||||||
 | 
									panic_mode();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (amon_info.status != ANALOG_MONITOR_OK) {
 | 
				
			||||||
		amon_state = safety_controller_get_analog_mon_value(ERR_AMON_VREF, &amon_value);
 | 
									safety_controller_report_error(amon_info.associated_flag);
 | 
				
			||||||
		if (amon_state != ANALOG_MONITOR_OK)
 | 
								}
 | 
				
			||||||
			safety_controller_report_error(ERR_FLAG_AMON_VREF);
 | 
							}
 | 
				
			||||||
		amon_state = safety_controller_get_analog_mon_value(ERR_AMON_UC_TEMP, &amon_value);
 | 
					 | 
				
			||||||
		if (amon_state != ANALOG_MONITOR_OK)
 | 
					 | 
				
			||||||
			safety_controller_report_error(ERR_FLAG_AMON_UC_TEMP);
 | 
					 | 
				
			||||||
		amon_state = safety_controller_get_analog_mon_value(ERR_AMON_SUPPLY_VOLT, &amon_value);
 | 
					 | 
				
			||||||
		if (amon_state != ANALOG_MONITOR_OK)
 | 
					 | 
				
			||||||
			safety_controller_report_error(ERR_FLAG_AMON_SUPPLY_VOLT);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	safety_controller_process_active_timing_mons();
 | 
						safety_controller_process_active_timing_mons();
 | 
				
			||||||
@@ -1005,6 +1005,7 @@ int safety_controller_get_analog_mon_by_index(uint32_t index, struct analog_moni
 | 
				
			|||||||
	info->min = mon->min;
 | 
						info->min = mon->min;
 | 
				
			||||||
	info->value = mon->value;
 | 
						info->value = mon->value;
 | 
				
			||||||
	info->timestamp = mon->timestamp;
 | 
						info->timestamp = mon->timestamp;
 | 
				
			||||||
 | 
						info->associated_flag = mon->associated_flag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!mon->valid) {
 | 
						if (!mon->valid) {
 | 
				
			||||||
		info->status = ANALOG_MONITOR_INACTIVE;
 | 
							info->status = ANALOG_MONITOR_INACTIVE;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user