summaryrefslogtreecommitdiff
path: root/device-functions.c
diff options
context:
space:
mode:
authorroot <root@avtech.domain.avtechpulse.com>1970-01-01 10:32:44 +0900
committerroot <root@avtech.domain.avtechpulse.com>1970-01-01 10:32:44 +0900
commit6722fd6f15fc3d9f722c7ece4d13ffb505cf0418 (patch)
treeef0417211d6df1044984860dc15b5d8c798655b2 /device-functions.c
parentde81dfcab3036382d82d67ca151bc870d1341fe2 (diff)
move attenuator code out of CH1-only block, so it works for CH2INSTRUMENT_6_2_09c
Diffstat (limited to 'device-functions.c')
-rw-r--r--device-functions.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/device-functions.c b/device-functions.c
index cda68ba..4f9cc22 100644
--- a/device-functions.c
+++ b/device-functions.c
@@ -322,56 +322,8 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w
set_shiftreg_bits(SR_3, POS_13, ONE_BIT, BIT_LOW); /* set O.POL line low to switch pol relay to -, normally */
}
- // Are attenuators used?
- int atten_ctl = 0;
-
- if (attenuator_count(channel) == 1) {
-
- if (atten_range == 0) {
- atten_ctl = BIT_HIGH;
- } else {
- atten_ctl = BIT_LOW;
- }
-
- // XRLY1 for CH1, XRLY4 for CH2
- set_shiftreg_bits(SR_2, XTR_POS + 1 + (channel*3), ONE_BIT, atten_ctl);
-
- } else if (attenuator_count(channel) > 1) {
-
- // octal relay driver is inverted
- if ((atten_range < 0) || (atten_range >= max_attens)) {
- atten_ctl = 0xff;
- } else {
- if (channel) {
- // shift over 4 positions, out of 8, if CH2
- atten_range += 4;
- }
-
- if (globals.Flash.sequential_attenuators[channel]) {
- // For AVRZ-5W-B-LVA, which uses 3 identical 20 dB attenuators.
- // 0, 1, 2 or 3 in series are used.
- atten_ctl = ~((1 << (atten_range+1)) - 1);
- } else {
- // For more standard configurations, where different attenuators
- // are combined in a binary style - 000, 001, 010, 011, 100, etc
- atten_ctl = ~(atten_range+1);
- }
- }
-
- I2C_Write(PCF8574+Octal_Relay_Driver, atten_ctl);
- }
-
- if ( (globals.Registers.last_relay_driver_settings[3] != atten_ctl)) {
-
- globals.Registers.last_relay_driver_settings[3] = atten_ctl;
-
- if (globals.ChannelState[channel].output_state==output_on) {
- globals.Flags.force_output_fully_off=YES;
- }
- }
} else {
-
if (!globals.Flash.ampl_ranges_for_ch2_only) {
/* for CH2 of dual-channel units, use AMPL RANGE pin 2-3 */
set_shiftreg_bits(SR_3, POS_10, TWO_BITS, 1<<relay_range);
@@ -391,6 +343,54 @@ int Set_Amplitude(int check_possible_only,int pol_override,int override_on,int w
}
}
+ // Are attenuators used?
+ int atten_ctl = 0;
+
+ if (attenuator_count(channel) == 1) {
+
+ if (atten_range == 0) {
+ atten_ctl = BIT_HIGH;
+ } else {
+ atten_ctl = BIT_LOW;
+ }
+
+ // XRLY1 for CH1, XRLY4 for CH2
+ set_shiftreg_bits(SR_2, XTR_POS + 1 + (channel*3), ONE_BIT, atten_ctl);
+
+ } else if (attenuator_count(channel) > 1) {
+
+ // octal relay driver is inverted
+ if ((atten_range < 0) || (atten_range >= max_attens)) {
+ atten_ctl = 0xff;
+ } else {
+ if (channel) {
+ // shift over 4 positions, out of 8, if CH2
+ atten_range += 4;
+ }
+
+ if (globals.Flash.sequential_attenuators[channel]) {
+ // For AVRZ-5W-B-LVA, which uses 3 identical 20 dB attenuators.
+ // 0, 1, 2 or 3 in series are used.
+ atten_ctl = ~((1 << (atten_range+1)) - 1);
+ } else {
+ // For more standard configurations, where different attenuators
+ // are combined in a binary style - 000, 001, 010, 011, 100, etc
+ atten_ctl = ~(atten_range+1);
+ }
+ }
+
+ I2C_Write(PCF8574+Octal_Relay_Driver, atten_ctl);
+ }
+
+ if ( (globals.Registers.last_relay_driver_settings[3] != atten_ctl)) {
+
+ globals.Registers.last_relay_driver_settings[3] = atten_ctl;
+
+ if (globals.ChannelState[channel].output_state==output_on) {
+ globals.Flags.force_output_fully_off=YES;
+ }
+ }
+
globals.Changes.update_amp=YES;
globals.ChannelState[channel].amplitude=new_ampl;