diff options
author | root <root@galadriel.domain.avtechpulse.com> | 2012-08-29 10:32:26 -0400 |
---|---|---|
committer | root <root@galadriel.domain.avtechpulse.com> | 2012-08-29 10:32:26 -0400 |
commit | b127640ef5f09b10a648701c52f950f3fe569ce6 (patch) | |
tree | ad0736cba88791fac6e238cbb34c15545456cf0a | |
parent | babd34026cf7597ba90563d8b9a9ebb715cab72e (diff) |
add *sav/*rcl
-rw-r--r-- | device-functions.c | 191 | ||||
-rw-r--r-- | device-functions.h | 3 | ||||
-rw-r--r-- | dummy_functions.c | 8 | ||||
-rw-r--r-- | dummy_functions.h | 3 |
4 files changed, 194 insertions, 11 deletions
diff --git a/device-functions.c b/device-functions.c index db36caf..a7d2adc 100644 --- a/device-functions.c +++ b/device-functions.c @@ -4342,3 +4342,194 @@ int I2C_Self_Cal(int channel, int meas_mode, float *meas, float target_time) return OK; } + +void Set_Rcl(int setting_num) +{ + int temp; + int i; + + globals.Flags.do_check_settings=NO; /* don't check for conflicting settings */ + globals.Flags.extended_ampl_min_max=NO; + + // go backwards, so channel 0 overrides everything + for (i=globals.Flash.channels-1; i>=0; --i) { + + globals.ChannelState[i].route_primary=globals.Flash.rcl_route_primary[i][setting_num]; + globals.ChannelState[i].route_secondary=globals.Flash.rcl_route_secondary[i][setting_num]; + + globals.ChannelState[i].frequency=globals.Flash.rcl_frequency[i][setting_num]; + globals.ChannelState[i].delay=globals.Flash.rcl_delay[i][setting_num]; + globals.ChannelState[i].pw=globals.Flash.rcl_pw[i][setting_num]; + globals.ChannelState[i].amplitude=globals.Flash.rcl_amplitude[i][setting_num]; + globals.ChannelState[i].offset=globals.Flash.rcl_offset[i][setting_num]; + globals.ChannelState[i].burst_count=globals.Flash.rcl_burst_count[i][setting_num]; + globals.ChannelState[i].burst_time=globals.Flash.rcl_burst_time[i][setting_num]; + globals.ChannelState[i].rise_time=globals.Flash.rcl_rise_time[i][setting_num]; + globals.ChannelState[i].slew=globals.Flash.rcl_slew[i][setting_num]; + + globals.ChannelState[i].vcc1=globals.Flash.rcl_vcc1[i][setting_num]; + globals.ChannelState[i].vcc2=globals.Flash.rcl_vcc2[i][setting_num]; + globals.ChannelState[i].vlogic=globals.Flash.rcl_vlogic[i][setting_num]; + + globals.ChannelState[i].soft_current_limit=globals.Flash.rcl_soft_current_limit[i][setting_num]; + globals.ChannelState[i].load_type=globals.Flash.rcl_load[i][setting_num]; + + temp=globals.Flash.rcl_misc[i][setting_num]; + + if (temp&1) { + globals.ChannelState[i].zout=globals.Flash.zout_max[i]; + } else { + globals.ChannelState[i].zout=globals.Flash.zout_min[i]; + } + globals.ChannelState[i].hold_setting = (temp >> 1) & 1; + globals.ChannelState[i].double_pulse = (temp >> 2) & 1; + globals.ChannelState[i].ab_mode = (temp >> 3) & 1; + /* one bit removed */ + globals.ChannelState[i].polarity = (temp >> 5) & 1; + globals.ChannelState[i].output_state = (temp >> 6) & 1; + globals.ChannelState[i].gate_type = (temp >> 7) & 1; + globals.ChannelState[i].trigger_source = (temp >> 8) & 7; + globals.ChannelState[i].amp_mode = (temp >> 11) & 1; + globals.ChannelState[i].gate_level = (temp >> 12) & 1; + globals.ChannelState[i].logic_level = (temp >> 14) & 1; + globals.ChannelState[i].os_mode = (temp >> 15) & 1; + + temp=globals.Flash.rcl_misc2[i][setting_num]; + /* the high bit of amp_mode was added later; hence the odd reconstruction */ + globals.ChannelState[i].amp_mode |= (temp << 1) & 2; + globals.ChannelState[i].func_mode = (temp >> 2) & 0x1f; /* 5 bits! */ + + Set_Route(i,ROUTE_PRIMARY,globals.ChannelState[i].route_primary); + Set_Route(i,ROUTE_SECONDARY,globals.ChannelState[i].route_secondary); + + Set_frequency(0,0,0,i,globals.ChannelState[i].frequency); + Set_Delay(0,0,0,i,globals.ChannelState[i].delay); + + Set_Pw(0,0,0,i,globals.ChannelState[i].pw,0); + + Set_Double(i,globals.ChannelState[i].double_pulse); + Set_Pwmode(i,globals.ChannelState[i].ab_mode); + + Set_Func(i,globals.ChannelState[i].func_mode); + Set_Pol(i,globals.ChannelState[i].polarity); + Set_Gate_Sync(i,globals.ChannelState[i].gate_type); + Set_Gate_Level(i,globals.ChannelState[i].gate_level); + Set_EA(i,globals.ChannelState[i].amp_mode); + Set_EO(i,globals.ChannelState[i].os_mode); + + if (globals.Flash.switchable_zout[i]) { + Set_zout(i,globals.ChannelState[i].zout,1); + } + + Set_Load(i,globals.ChannelState[i].load_type); + Set_Logic_Level(i,globals.ChannelState[i].logic_level); + Set_rise_time(0,0,0,i,globals.ChannelState[i].rise_time); + Set_slew(0,0,0,i,globals.ChannelState[i].slew); + Set_current_limit(0,i,globals.ChannelState[i].soft_current_limit); + + if (globals.Flash.max_burst_count[i]>1) { + Set_Burst_Count(i,globals.ChannelState[i].burst_count,globals.ChannelState[i].burst_time); + } + + Set_Trig_Source(i,globals.ChannelState[i].trigger_source); + + Set_Amplitude(0,0,0,0,0,0,i,globals.ChannelState[i].amplitude,0); + + if (globals.Flash.voltage_offset_enabled[i] || globals.Flash.current_offset_enabled[i]) { + Set_Offset(0,0,0,0,i,globals.ChannelState[i].offset); + } + + Set_avrq_ampl(0,0,0,2,globals.ChannelState[i].vcc1); + Set_avrq_ampl(0,0,0,3,globals.ChannelState[i].vcc2); + Set_avrq_ampl(0,0,0,4,globals.ChannelState[i].vlogic); + + Set_Output_State(i,globals.ChannelState[i].output_state); + + } + + Menu_Clear_Buttons(); + + globals.Flags.do_check_settings=YES; /* check for conflicting settings */ + globals.Changes.update_whole_main_menu=YES; + + Error_check(globals.ChannelState); /* establishes min/max values for queries, but reports no errors */ + + return; +} + + +void Set_Sav(int setting_num) +{ + int temp; + int i; + + for (i=0; i<globals.Flash.channels; i++) { + + /* float and large integers */ + globals.Flash.rcl_route_primary[i][setting_num]=globals.ChannelState[i].route_primary; + globals.Flash.rcl_route_secondary[i][setting_num]=globals.ChannelState[i].route_secondary; + + globals.Flash.rcl_frequency[i][setting_num]=globals.ChannelState[i].frequency; + globals.Flash.rcl_delay[i][setting_num]=globals.ChannelState[i].delay; + globals.Flash.rcl_pw[i][setting_num]=globals.ChannelState[i].pw; + globals.Flash.rcl_amplitude[i][setting_num]=globals.ChannelState[i].amplitude; + globals.Flash.rcl_offset[i][setting_num]=globals.ChannelState[i].offset; + globals.Flash.rcl_burst_count[i][setting_num]=globals.ChannelState[i].burst_count; + globals.Flash.rcl_burst_time[i][setting_num]=globals.ChannelState[i].burst_time; + globals.Flash.rcl_rise_time[i][setting_num]=globals.ChannelState[i].rise_time; + globals.Flash.rcl_slew[i][setting_num]=globals.ChannelState[i].slew; + globals.Flash.rcl_soft_current_limit[i][setting_num]=globals.ChannelState[i].soft_current_limit; + globals.Flash.rcl_load[i][setting_num]=globals.ChannelState[i].load_type; + globals.Flash.rcl_vcc1[i][setting_num]=globals.ChannelState[i].vcc1; + globals.Flash.rcl_vcc2[i][setting_num]=globals.ChannelState[i].vcc2; + globals.Flash.rcl_vlogic[i][setting_num]=globals.ChannelState[i].vlogic; + + /* integers setting_nums + globals.ChannelState[i].zout 50 (1) or min (0) + globals.ChannelState[i].hold_setting hold_width 0, hold_duty 1 + globals.ChannelState[i].double_pulse double_on 1, double_off 0 + globals.ChannelState[i].ab_mode pw_normal 1, pw_in_out 0 + globals.ChannelState[i].func_mode pulse_mode_on 0, dc_mode_on 1 + globals.ChannelState[i].polarity pol_norm 0, pol_complement 1 + globals.ChannelState[i].output_state output_off 0,output_on 1 + globals.ChannelState[i].gate_type gate_sync 0, gate_async 1 + globals.ChannelState[i].trigger_source source_internal 0, source_external 1, source_manual 2, source_hold 3, source_immediate 4 + globals.ChannelState[i].amp_mode normal 0, ea 1, ext amplify 2 + globals.ChannelState[i].gate_level gate_low 0, gate_high 1 + */ + + /* compress the assorted integer parameters into a single bitmapped integer */ + if (globals.ChannelState[i].zout==globals.Flash.zout_max[i]) { + temp=1; + } else { + temp=0; + } + temp |= globals.ChannelState[i].hold_setting << 1; + temp |= globals.ChannelState[i].double_pulse << 2; + temp |= globals.ChannelState[i].ab_mode << 3; + /* removed one bit */ + temp |= globals.ChannelState[i].polarity << 5; + temp |= globals.ChannelState[i].output_state << 6; + temp |= globals.ChannelState[i].gate_type << 7; + temp |= globals.ChannelState[i].trigger_source << 8; + temp |= (globals.ChannelState[i].amp_mode & 1) << 11; + temp |= globals.ChannelState[i].gate_level << 12; + temp |= globals.ChannelState[i].logic_level << 14; + temp |= globals.ChannelState[i].os_mode << 15; + + globals.Flash.rcl_misc[i][setting_num]=temp; + + /* need another integer to hold everything now */ + temp = 0; + temp |= ( (globals.ChannelState[i].amp_mode>1) & 1) << 0; + temp |= globals.ChannelState[i].func_mode << 2; /* 5 bits! */ + + globals.Flash.rcl_misc2[i][setting_num]=temp; + + } + + /* save everything */ + writeUserBlock(&globals.Flash, 0, sizeof(globals.Flash)); + + return; +} diff --git a/device-functions.h b/device-functions.h index d31cfa9..cdc040c 100644 --- a/device-functions.h +++ b/device-functions.h @@ -66,4 +66,7 @@ int self_cal(); int do_full_self_cal(CalStruct *caldata); int I2C_Self_Cal(int channel, int meas_mode, float *meas, float target_time); +void Set_Rcl(int setting_num); +void Set_Sav(int setting_num); + #endif diff --git a/dummy_functions.c b/dummy_functions.c index 46de4f7..3cb6039 100644 --- a/dummy_functions.c +++ b/dummy_functions.c @@ -41,11 +41,3 @@ void GPIB_change_address(int new_address) {} void Main_update_shift_registers() { } -int Set_Sav(int setting_num) // FIXME - implement -{ - return 0; -} -int Set_Rcl(int setting_num) // FIXME - implement -{ - return 0; -} diff --git a/dummy_functions.h b/dummy_functions.h index aefe276..a7dd896 100644 --- a/dummy_functions.h +++ b/dummy_functions.h @@ -25,8 +25,5 @@ void GPIB_change_address(int new_address); void Main_update_shift_registers(); -int Set_Sav(int setting_num); -int Set_Rcl(int setting_num); - #endif |