Make error structures volatile
This commit is contained in:
		@@ -70,7 +70,7 @@ struct analog_mon {
 | 
			
		||||
#define TIM_MON_ENTRY(mon, min, max, flag) {.name=#mon, .monitor = (mon), .associated_flag=(flag), .min_delta = (min), .max_delta = (max), .last = 0ULL, .enabled= false}
 | 
			
		||||
#define ANA_MON_ENTRY(mon, min_value, max_value, flag) {.name=#mon, .monitor = (mon), .associated_flag=(flag), .min = (min_value), .max = (max_value), .value = 0.0f, .valid = false}
 | 
			
		||||
 | 
			
		||||
static struct error_flag flags[] = {
 | 
			
		||||
static volatile struct error_flag flags[] = {
 | 
			
		||||
	ERR_FLAG_ENTRY(ERR_FLAG_MEAS_ADC_OFF, false),
 | 
			
		||||
	ERR_FLAG_ENTRY(ERR_FLAG_MEAS_ADC_WATCHDOG, false),
 | 
			
		||||
	ERR_FLAG_ENTRY(ERR_FLAG_MEAS_ADC_UNSTABLE, false),
 | 
			
		||||
@@ -85,23 +85,23 @@ static struct error_flag flags[] = {
 | 
			
		||||
	ERR_FLAG_ENTRY(ERR_FLAG_WTCHDG_FIRED, true),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct timing_mon timings[] = {
 | 
			
		||||
static volatile struct timing_mon timings[] = {
 | 
			
		||||
	TIM_MON_ENTRY(ERR_TIMING_PID, 1, 800, ERR_FLAG_TIMING_PID),
 | 
			
		||||
	TIM_MON_ENTRY(ERR_TIMING_MEAS_ADC, 1, 50, ERR_FLAG_TIMING_MEAS_ADC),
 | 
			
		||||
	TIM_MON_ENTRY(ERR_TIMING_SAFETY_ADC, 1, 250, ERR_FLAG_SAFETY_ADC),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct analog_mon analog_mons[] = {
 | 
			
		||||
static volatile struct analog_mon analog_mons[] = {
 | 
			
		||||
	ANA_MON_ENTRY(ERR_AMON_VREF, SAFETY_ADC_VREF_MVOLT - SAFETY_ADC_VREF_TOL_MVOLT,
 | 
			
		||||
		      SAFETY_ADC_VREF_MVOLT + SAFETY_ADC_VREF_TOL_MVOLT, ERR_FLAG_AMON_VREF),
 | 
			
		||||
	ANA_MON_ENTRY(ERR_AMON_UC_TEMP, SAFETY_ADC_TEMP_LOW_LIM, SAFETY_ADC_TEMP_HIGH_LIM,
 | 
			
		||||
		      ERR_FLAG_AMON_UC_TEMP),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static struct analog_mon *find_analog_mon(enum analog_value_monitor mon)
 | 
			
		||||
static volatile struct analog_mon *find_analog_mon(enum analog_value_monitor mon)
 | 
			
		||||
{
 | 
			
		||||
	uint32_t i;
 | 
			
		||||
	struct analog_mon *ret = NULL;
 | 
			
		||||
	volatile struct analog_mon *ret = NULL;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < COUNT_OF(analog_mons); i++) {
 | 
			
		||||
		if (analog_mons[i].monitor == mon)
 | 
			
		||||
@@ -111,10 +111,10 @@ static struct analog_mon *find_analog_mon(enum analog_value_monitor mon)
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct timing_mon *find_timing_mon(enum timing_monitor mon)
 | 
			
		||||
static volatile struct timing_mon *find_timing_mon(enum timing_monitor mon)
 | 
			
		||||
{
 | 
			
		||||
	uint32_t i;
 | 
			
		||||
	struct timing_mon *ret = NULL;
 | 
			
		||||
	volatile struct timing_mon *ret = NULL;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < COUNT_OF(timings); i++) {
 | 
			
		||||
		if (timings[i].monitor == mon)
 | 
			
		||||
@@ -124,10 +124,10 @@ static struct timing_mon *find_timing_mon(enum timing_monitor mon)
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static struct error_flag *find_error_flag(enum safety_flag flag)
 | 
			
		||||
static volatile struct error_flag *find_error_flag(enum safety_flag flag)
 | 
			
		||||
{
 | 
			
		||||
	uint32_t i;
 | 
			
		||||
	struct error_flag *ret = NULL;
 | 
			
		||||
	volatile struct error_flag *ret = NULL;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < COUNT_OF(flags); i++) {
 | 
			
		||||
		if (flags[i].flag == flag)
 | 
			
		||||
@@ -140,7 +140,7 @@ static struct error_flag *find_error_flag(enum safety_flag flag)
 | 
			
		||||
static void safety_controller_process_active_timing_mons()
 | 
			
		||||
{
 | 
			
		||||
	uint32_t i;
 | 
			
		||||
	struct timing_mon *current_mon;
 | 
			
		||||
	volatile struct timing_mon *current_mon;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < COUNT_OF(timings); i++) {
 | 
			
		||||
		current_mon = &timings[i];
 | 
			
		||||
@@ -201,7 +201,7 @@ int safety_controller_report_error(enum safety_flag flag)
 | 
			
		||||
 | 
			
		||||
void safety_controller_report_timing(enum timing_monitor monitor)
 | 
			
		||||
{
 | 
			
		||||
	struct timing_mon *tim;
 | 
			
		||||
	volatile struct timing_mon *tim;
 | 
			
		||||
	uint64_t timestamp;
 | 
			
		||||
 | 
			
		||||
	timestamp = systick_get_global_tick();
 | 
			
		||||
@@ -223,7 +223,7 @@ void safety_controller_report_timing(enum timing_monitor monitor)
 | 
			
		||||
 | 
			
		||||
void safety_controller_report_analog_value(enum analog_value_monitor monitor, float value)
 | 
			
		||||
{
 | 
			
		||||
	struct analog_mon *ana;
 | 
			
		||||
	volatile struct analog_mon *ana;
 | 
			
		||||
 | 
			
		||||
	/* Return if not a power of two */
 | 
			
		||||
	if (!is_power_of_two(monitor))
 | 
			
		||||
@@ -314,7 +314,7 @@ int safety_controller_handle()
 | 
			
		||||
 | 
			
		||||
int safety_controller_enable_timing_mon(enum timing_monitor monitor, bool enable)
 | 
			
		||||
{
 | 
			
		||||
	struct timing_mon *tim;
 | 
			
		||||
	volatile struct timing_mon *tim;
 | 
			
		||||
 | 
			
		||||
	if (enable) {
 | 
			
		||||
		safety_controller_report_timing(monitor);
 | 
			
		||||
@@ -330,7 +330,7 @@ int safety_controller_enable_timing_mon(enum timing_monitor monitor, bool enable
 | 
			
		||||
 | 
			
		||||
enum analog_monitor_status safety_controller_get_analog_mon_value(enum analog_value_monitor monitor, float *value)
 | 
			
		||||
{
 | 
			
		||||
	struct analog_mon *mon;
 | 
			
		||||
	volatile struct analog_mon *mon;
 | 
			
		||||
	int ret = ANALOG_MONITOR_ERROR;
 | 
			
		||||
 | 
			
		||||
	if (!is_power_of_two(monitor))
 | 
			
		||||
@@ -361,7 +361,7 @@ go_out:
 | 
			
		||||
 | 
			
		||||
int safety_controller_get_flag(enum safety_flag flag, bool *status, bool try_ack)
 | 
			
		||||
{
 | 
			
		||||
	struct error_flag *found_flag;
 | 
			
		||||
	volatile struct error_flag *found_flag;
 | 
			
		||||
	int ret = -1;
 | 
			
		||||
 | 
			
		||||
	if (!status)
 | 
			
		||||
@@ -392,7 +392,7 @@ int safety_controller_ack_flag(enum safety_flag flag)
 | 
			
		||||
int safety_controller_ack_flag_with_key(enum safety_flag flag, uint32_t key)
 | 
			
		||||
{
 | 
			
		||||
	int ret = -1;
 | 
			
		||||
	struct error_flag *found_flag;
 | 
			
		||||
	volatile struct error_flag *found_flag;
 | 
			
		||||
 | 
			
		||||
	if (!is_power_of_two(flag)) {
 | 
			
		||||
		return -1001;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user