diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2013-06-25 07:13:23 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2013-06-25 07:13:23 -0400 |
commit | c7ab84e3530e26163226d9adb3d9490c72370223 (patch) | |
tree | 13ea0ff0064d6bb2fb4121d855117ec5b18bc4c2 | |
parent | 47f1640b243e28014a71d83f2474d96861af286a (diff) |
forward-port multi-channel min/max fixes from 4.16
-rw-r--r-- | error_utils.c | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/error_utils.c b/error_utils.c index 974da44..1b0b19e 100644 --- a/error_utils.c +++ b/error_utils.c @@ -1433,6 +1433,108 @@ int Error_check(ChannelStruct ChannelStateToTest[max_channels]) /* --- done all per-channel checking ---- */ } + // merge min/max values for shared channel variables on multi-channel instruments + // for example, ampl on CH2 may force lower max freq on all channels + + if (num_of_chan>1) { + if (!globals.Flash.ChanKey_frequency) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_freq[0] < globals.Constraints.err_min_freq[i]) { + globals.Constraints.err_min_freq[0] = globals.Constraints.err_min_freq[i]; + } + if (globals.Constraints.err_max_freq[0] > globals.Constraints.err_max_freq[i]) { + globals.Constraints.err_max_freq[0] = globals.Constraints.err_max_freq[i]; + } + } + + if (!globals.Flash.ChanKey_delay) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_delay[0] < globals.Constraints.err_min_delay[i]) { + globals.Constraints.err_min_delay[0] = globals.Constraints.err_min_delay[i]; + } + if (globals.Constraints.err_max_delay[0] > globals.Constraints.err_max_delay[i]) { + globals.Constraints.err_max_delay[0] = globals.Constraints.err_max_delay[i]; + } + } + + if (!globals.Flash.ChanKey_pw) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_pw[0] < globals.Constraints.err_min_pw[i]) { + globals.Constraints.err_min_pw[0] = globals.Constraints.err_min_pw[i]; + } + if (globals.Constraints.err_max_pw[0] > globals.Constraints.err_max_pw[i]) { + globals.Constraints.err_max_pw[0] = globals.Constraints.err_max_pw[i]; + } + } + + if (!globals.Flash.ChanKey_amplitude) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_ampl[0] < globals.Constraints.err_min_ampl[i]) { + globals.Constraints.err_min_ampl[0] = globals.Constraints.err_min_ampl[i]; + } + if (globals.Constraints.err_max_ampl[0] > globals.Constraints.err_max_ampl[i]) { + globals.Constraints.err_max_ampl[0] = globals.Constraints.err_max_ampl[i]; + } + } + + if (!globals.Flash.ChanKey_offset) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_offset[0] < globals.Constraints.err_min_offset[i]) { + globals.Constraints.err_min_offset[0] = globals.Constraints.err_min_offset[i]; + } + if (globals.Constraints.err_max_offset[0] > globals.Constraints.err_max_offset[i]) { + globals.Constraints.err_max_offset[0] = globals.Constraints.err_max_offset[i]; + } + } + + if (!globals.Flash.ChanKey_load_type) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_load_type[0] < globals.Constraints.err_min_load_type[i]) { + globals.Constraints.err_min_load_type[0] = globals.Constraints.err_min_load_type[i]; + } + if (globals.Constraints.err_max_load_type[0] > globals.Constraints.err_max_load_type[i]) { + globals.Constraints.err_max_load_type[0] = globals.Constraints.err_max_load_type[i]; + } + } + + if (!globals.Flash.ChanKey_Burst_Count) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_max_burst_count[0] > globals.Constraints.err_max_burst_count[i]) { + globals.Constraints.err_max_burst_count[0] = globals.Constraints.err_max_burst_count[i]; + } + } + + if (!globals.Flash.ChanKey_Burst_Time) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_burst_time[0] < globals.Constraints.err_min_burst_time[i]) { + globals.Constraints.err_min_burst_time[0] = globals.Constraints.err_min_burst_time[i]; + } + if (globals.Constraints.err_max_burst_time[0] > globals.Constraints.err_max_burst_time[i]) { + globals.Constraints.err_max_burst_time[0] = globals.Constraints.err_max_burst_time[i]; + } + } + + if (!globals.Flash.ChanKey_rise_time) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_rise_time[0] < globals.Constraints.err_min_rise_time[i]) { + globals.Constraints.err_min_rise_time[0] = globals.Constraints.err_min_rise_time[i]; + } + if (globals.Constraints.err_max_rise_time[0] > globals.Constraints.err_max_rise_time[i]) { + globals.Constraints.err_max_rise_time[0] = globals.Constraints.err_max_rise_time[i]; + } + } + + if (!globals.Flash.ChanKey_slew) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_slew[0] < globals.Constraints.err_min_slew[i]) { + globals.Constraints.err_min_slew[0] = globals.Constraints.err_min_slew[i]; + } + if (globals.Constraints.err_max_slew[0] > globals.Constraints.err_max_slew[i]) { + globals.Constraints.err_max_slew[0] = globals.Constraints.err_max_slew[i]; + } + } + + if (!globals.Flash.ChanKey_current_limit) for (i=1; i<num_of_chan; ++i) { + if (globals.Constraints.err_min_soft_current_limit[0] < globals.Constraints.err_min_soft_current_limit[i]) { + globals.Constraints.err_min_soft_current_limit[0] = globals.Constraints.err_min_soft_current_limit[i]; + } + if (globals.Constraints.err_max_soft_current_limit[0] > globals.Constraints.err_max_soft_current_limit[i]) { + globals.Constraints.err_max_soft_current_limit[0] = globals.Constraints.err_max_soft_current_limit[i]; + } + } + } + + g_static_mutex_unlock (&mutex); return report_error; |