Compare commits
No commits in common. "2f39b5eb69081603cbed42aa7ddb6bc4db6317b2" and "4a441a9c44bc4ce7a0b40e831e3c7d48b74ba317" have entirely different histories.
2f39b5eb69
...
4a441a9c44
@ -37,14 +37,12 @@ enum safety_flag {
|
||||
ERR_FLAG_WTCHDG_FIRED = (1<<11),
|
||||
ERR_FLAG_UNCAL = (1<<12),
|
||||
ERR_FLAG_DEBUG = (1<<13),
|
||||
ERR_FLAG_TIMING_MAIN_LOOP = (1<<14),
|
||||
};
|
||||
|
||||
enum timing_monitor {
|
||||
ERR_TIMING_PID = (1<<0),
|
||||
ERR_TIMING_MEAS_ADC = (1<<1),
|
||||
ERR_TIMING_SAFETY_ADC = (1<<2),
|
||||
ERR_TIMING_MAIN_LOOP = (1<<3),
|
||||
};
|
||||
|
||||
enum analog_value_monitor {
|
||||
|
@ -46,14 +46,6 @@ struct analog_monitor_info {
|
||||
uint64_t timestamp;
|
||||
};
|
||||
|
||||
struct timing_monitor_info {
|
||||
uint64_t last_run;
|
||||
uint64_t min;
|
||||
uint64_t max;
|
||||
bool enabled;
|
||||
uint64_t delta;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize the safety controller
|
||||
*
|
||||
@ -102,12 +94,6 @@ int safety_controller_get_analog_mon_by_index(uint32_t index, struct analog_moni
|
||||
|
||||
int safety_controller_get_analog_mon_name_by_index(uint32_t index, char *buffer, size_t buffsize);
|
||||
|
||||
int safety_controller_get_timing_mon_by_index(uint32_t index, struct timing_monitor_info *info);
|
||||
|
||||
int safety_controller_get_timing_mon_name_by_index(uint32_t index, char *buffer, size_t buffsize);
|
||||
|
||||
uint32_t safety_controller_get_timing_monitor_count();
|
||||
|
||||
#endif /* __SAFETY_CONTROLLER_H__ */
|
||||
|
||||
/** @} */
|
||||
|
@ -206,9 +206,9 @@ int main(void)
|
||||
shell_print_motd(shell_handle);
|
||||
|
||||
while (1) {
|
||||
sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted);
|
||||
|
||||
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
|
||||
sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted);
|
||||
quarter_sec_timestamp = systick_get_global_tick();
|
||||
}
|
||||
|
||||
@ -220,7 +220,6 @@ int main(void)
|
||||
oven_driver_set_power(0);
|
||||
oven_driver_apply_power_level();
|
||||
|
||||
safety_controller_report_timing(ERR_TIMING_MAIN_LOOP);
|
||||
if (menu_wait_request)
|
||||
__WFI();
|
||||
else
|
||||
|
@ -48,7 +48,6 @@ struct timing_mon {
|
||||
uint64_t min_delta;
|
||||
uint64_t max_delta;
|
||||
uint64_t last;
|
||||
uint64_t calculated_delta;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
@ -88,14 +87,12 @@ static volatile struct error_flag flags[] = {
|
||||
ERR_FLAG_ENTRY(ERR_FLAG_WTCHDG_FIRED, true),
|
||||
ERR_FLAG_ENTRY(ERR_FLAG_UNCAL, false),
|
||||
ERR_FLAG_ENTRY(ERR_FLAG_DEBUG, true),
|
||||
ERR_FLAG_ENTRY(ERR_FLAG_TIMING_MAIN_LOOP, false),
|
||||
};
|
||||
|
||||
static volatile struct timing_mon timings[] = {
|
||||
TIM_MON_ENTRY(ERR_TIMING_PID, 2, 1000, ERR_FLAG_TIMING_PID),
|
||||
TIM_MON_ENTRY(ERR_TIMING_MEAS_ADC, 0, 50, ERR_FLAG_TIMING_MEAS_ADC),
|
||||
TIM_MON_ENTRY(ERR_TIMING_SAFETY_ADC, 10, SAFETY_CONTROLLER_ADC_DELAY_MS + 1000, ERR_FLAG_SAFETY_ADC),
|
||||
TIM_MON_ENTRY(ERR_TIMING_MAIN_LOOP, 0, 1000, ERR_FLAG_TIMING_MAIN_LOOP),
|
||||
};
|
||||
|
||||
static volatile struct analog_mon analog_mons[] = {
|
||||
@ -220,7 +217,6 @@ void safety_controller_report_timing(enum timing_monitor monitor)
|
||||
}
|
||||
}
|
||||
|
||||
tim->calculated_delta = timestamp - tim->last;
|
||||
tim->last = timestamp;
|
||||
tim->enabled = true;
|
||||
}
|
||||
@ -467,11 +463,6 @@ uint32_t safety_controller_get_analog_monitor_count()
|
||||
return COUNT_OF(analog_mons);
|
||||
}
|
||||
|
||||
uint32_t safety_controller_get_timing_monitor_count()
|
||||
{
|
||||
return COUNT_OF(timings);
|
||||
}
|
||||
|
||||
int safety_controller_get_analog_mon_name_by_index(uint32_t index, char *buffer, size_t buffsize)
|
||||
{
|
||||
if (index >= COUNT_OF(analog_mons))
|
||||
@ -500,20 +491,6 @@ int safety_controller_get_flag_name_by_index(uint32_t index, char *buffer, size_
|
||||
return 0;
|
||||
}
|
||||
|
||||
int safety_controller_get_timing_mon_name_by_index(uint32_t index, char *buffer, size_t buffsize)
|
||||
{
|
||||
if (index >= COUNT_OF(timings))
|
||||
return -1;
|
||||
|
||||
if (buffsize == 0 || !buffer)
|
||||
return -1000;
|
||||
|
||||
strncpy(buffer, timings[index].name, buffsize);
|
||||
buffer[buffsize - 1] = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int safety_controller_get_flag_by_index(uint32_t index, bool *status, enum safety_flag *flag_enum)
|
||||
{
|
||||
int ret = -1;
|
||||
@ -566,26 +543,4 @@ int safety_controller_get_analog_mon_by_index(uint32_t index, struct analog_moni
|
||||
return 0;
|
||||
}
|
||||
|
||||
int safety_controller_get_timing_mon_by_index(uint32_t index, struct timing_monitor_info *info)
|
||||
{
|
||||
volatile struct timing_mon *mon;
|
||||
|
||||
if (!info)
|
||||
return -1002;
|
||||
|
||||
if (index >= COUNT_OF(timings)) {
|
||||
return -1001;
|
||||
}
|
||||
|
||||
mon = &timings[index];
|
||||
|
||||
info->max = mon->max_delta;
|
||||
info->min = mon->min_delta;
|
||||
info->enabled = mon->enabled;
|
||||
info->last_run = mon->last;
|
||||
info->delta = mon->calculated_delta;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @} */
|
||||
|
@ -355,7 +355,6 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
|
||||
bool flag;
|
||||
int status;
|
||||
struct analog_monitor_info amon_info;
|
||||
struct timing_monitor_info timing_info;
|
||||
|
||||
shellmatta_printf(handle, "Error flags\r\n"
|
||||
"-----------\r\n");
|
||||
@ -406,22 +405,6 @@ static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handl
|
||||
}
|
||||
}
|
||||
|
||||
shellmatta_printf(handle, "\r\nTiming Monitors\r\n"
|
||||
"--------------\r\n");
|
||||
|
||||
|
||||
count = safety_controller_get_timing_monitor_count();
|
||||
for (i = 0; i < count; i++) {
|
||||
(void)safety_controller_get_timing_mon_by_index(i, &timing_info);
|
||||
(void)safety_controller_get_timing_mon_name_by_index(i, name, sizeof(name));
|
||||
|
||||
shellmatta_printf(handle, "\t%2lu) %-20s\t", i+1, name);
|
||||
if (timing_info.enabled)
|
||||
shellmatta_printf(handle, "%lu ms ago\r\n", (unsigned long int)timing_info.delta);
|
||||
else
|
||||
shellmatta_printf(handle, "[disabled]\r\n");
|
||||
}
|
||||
|
||||
return SHELLMATTA_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user