diff options
Diffstat (limited to 'device-functions.c')
-rw-r--r-- | device-functions.c | 179 |
1 files changed, 100 insertions, 79 deletions
diff --git a/device-functions.c b/device-functions.c index e516419..421bda9 100644 --- a/device-functions.c +++ b/device-functions.c @@ -3500,104 +3500,125 @@ int Set_rise_time(int check_possible_only,int word_override,int range_override,i } } - /* find appropriate range/fine settings from piece-wise linear data in flash memory */ - if (word_override) { - word_out=word_override; - relay_range=range_override; - } else { - int status; - if ((status=Set_VI_Control(pwl_rise_time_values,channel,new_rise_time,&point_found, - &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) { - return status; - } - } - if (check_possible_only) { - if (point_found) { + if (globals.Flash.rise_time_min_max_only[channel]) { + if (check_possible_only) { return OK; - } else { - return CalibrationMinMaxError; } - } - - set_dac(globals.Flash.rise_time_dac[channel],word_out); - if (!globals.Flash.pcb_203a_rise_time[channel]) { - /* original AVRQ PCB */ - switch (relay_range) { - case 0: - range_control = (char) 0x01; - break; - case 1: - range_control = (char) 0x08; - break; - case 2: - range_control = (char) 0x10; - break; - case 3: - range_control = (char) 0x20; - break; - case 4: - range_control = (char) 0x40; - break; - case 5: - range_control = (char) 0x80; - break; - case 6: - case 7: - return HardwareError; - break; + if (word_override) { + return rise_time_confined_values; } - } else { - /* PCB 203A */ - switch (relay_range) { - case 0: - range_control = (char) 0x0f; - break; - case 1: - range_control = (char) 0x02; - break; - case 2: - range_control = (char) 0x04; - break; - case 3: - range_control = (char) 0x08; - break; - case 4: - range_control = (char) 0x10; - break; - case 5: - case 6: - case 7: - return HardwareError; - break; + + if (fabs(new_rise_time - globals.Flash.min_rise_time[channel]) < smallest_allowed_number) { + /* todo */ + (void)0; + } else { + /* todo */ + (void)0; } - } + } else { + /* find appropriate range/fine settings from piece-wise linear data in flash memory */ + if (word_override) { + word_out=word_override; + relay_range=range_override; + } else { + int status; + if ((status=Set_VI_Control(pwl_rise_time_values,channel,new_rise_time,&point_found, + &relay_range,&dummy,&UseNegData,&entry,&word_out,&actual_pol))) { + return status; + } + } - if (globals.Registers.last_rise_time_relay_setting != range_control) { - /* update range hardware */ - if (globals.ChannelState[channel].trigger_source!=source_hold) { - bus_setpin(O_GATE, 1); + if (check_possible_only) { + if (point_found) { + return OK; + } else { + return CalibrationMinMaxError; + } } + set_dac(globals.Flash.rise_time_dac[channel],word_out); + if (!globals.Flash.pcb_203a_rise_time[channel]) { - I2C_Write(PCF8574A+rise_time_port,range_control); + /* original AVRQ PCB */ + switch (relay_range) { + case 0: + range_control = (char) 0x01; + break; + case 1: + range_control = (char) 0x08; + break; + case 2: + range_control = (char) 0x10; + break; + case 3: + range_control = (char) 0x20; + break; + case 4: + range_control = (char) 0x40; + break; + case 5: + range_control = (char) 0x80; + break; + case 6: + case 7: + return HardwareError; + break; + } } else { - globals.Registers.avrq_reg = (range_control & 0x1f) | - (globals.Registers.avrq_reg & 0xe0); - I2C_Write(PCF8574A+rise_time_port,globals.Registers.avrq_reg); + /* PCB 203A */ + switch (relay_range) { + case 0: + range_control = (char) 0x0f; + break; + case 1: + range_control = (char) 0x02; + break; + case 2: + range_control = (char) 0x04; + break; + case 3: + range_control = (char) 0x08; + break; + case 4: + range_control = (char) 0x10; + break; + case 5: + case 6: + case 7: + return HardwareError; + break; + } } - g_usleep (5e5); - if (globals.ChannelState[channel].trigger_source!=source_hold) { - bus_setpin(O_GATE, 0); + + + if (globals.Registers.last_rise_time_relay_setting != range_control) { + /* update range hardware */ + if (globals.ChannelState[channel].trigger_source!=source_hold) { + bus_setpin(O_GATE, 1); + } + + if (!globals.Flash.pcb_203a_rise_time[channel]) { + I2C_Write(PCF8574A+rise_time_port,range_control); + } else { + globals.Registers.avrq_reg = (range_control & 0x1f) | + (globals.Registers.avrq_reg & 0xe0); + I2C_Write(PCF8574A+rise_time_port,globals.Registers.avrq_reg); + } + g_usleep (5e5); + + if (globals.ChannelState[channel].trigger_source!=source_hold) { + bus_setpin(O_GATE, 0); + } } + globals.Registers.last_rise_time_relay_setting = range_control; } globals.ChannelState[channel].rise_time = new_rise_time; - globals.Registers.last_rise_time_relay_setting = range_control; Set_Update_Chans(); |