#ifndef _ALEX_H
#define _ALEX_H
-#define ALEX_RX_ANTENNA_NONE 0x00000000
-#define ALEX_RX_ANTENNA_XVTR 0x00000900
-#define ALEX_RX_ANTENNA_EXT1 0x00000A00
-#define ALEX_RX_ANTENNA_EXT2 0x00000C00
-#define ALEX_RX_ANTENNA_BYPASS 0x00000800
+//
+// This defines the "standard" ALEX0 bits. For some gear,
+// we need different definitions, but some bits are highly conserved
+// Note that in the standard case, RX signals from Ant1,2,3 go through
+// the TX low-pass filters!
+// For ANAN-7000/8000, there are furthermore ALEX1 bits for the filter
+// board of the second RX.
+//
+#define ALEX_RX_ANTENNA_NONE 0x00000000 // route Ant1,2,2 to RX1
+#define ALEX_RX_ANTENNA_XVTR 0x00000900 // route XVTR-in to RX1
+#define ALEX_RX_ANTENNA_EXT1 0x00000A00 // route EXT1 to RX1
+#define ALEX_RX_ANTENNA_EXT2 0x00000C00 // jOUTE EXT2 to RX1
+#define ALEX_RX_ANTENNA_BYPASS 0x00000800 // disconnect RX1 from Ant1,2,3
-#define ALEX_TX_ANTENNA_1 0x01000000
-#define ALEX_TX_ANTENNA_2 0x02000000
-#define ALEX_TX_ANTENNA_3 0x04000000
+#define ALEX_TX_ANTENNA_1 0x01000000 // route TX to ANT1
+#define ALEX_TX_ANTENNA_2 0x02000000 // route TX to ANT2
+#define ALEX_TX_ANTENNA_3 0x04000000 // route TX to ANT3
+//
+// Note: DO NOT SET attenuator bits on ANAN-7000/8000
+// since ALEX0(14) is used for a different purpose!
+//
#define ALEX_ATTENUATION_0dB 0x00000000
-#define ALEX_ATTENUATION_10dB 0x00004000
-#define ALEX_ATTENUATION_20dB 0x00002000
-#define ALEX_ATTENUATION_30dB 0x00006000
-
-#define ALEX_30_20_LPF 0x00100000
-#define ALEX_60_40_LPF 0x00200000
-#define ALEX_80_LPF 0x00400000
-#define ALEX_160_LPF 0x00800000
-#define ALEX_6_BYPASS_LPF 0x20000000
-#define ALEX_12_10_LPF 0x40000000
-#define ALEX_17_15_LPF 0x80000000
+#define ALEX_ATTENUATION_10dB 0x00004000 // activate 10 dB attenuator for RX1
+#define ALEX_ATTENUATION_20dB 0x00002000 // activate 20 dB attenuator for RX1
+#define ALEX_ATTENUATION_30dB 0x00006000 // activate both attenuators for RX1
+//
+// Note: Anan 100/200: If RX signal comes from Ant1,2,3 it also goes
+// through the TX LPFs
+//
+#define ALEX_30_20_LPF 0x00100000 // activate 30/20m TX LPF
+#define ALEX_60_40_LPF 0x00200000 // activate 60/20m TX LPF
+#define ALEX_80_LPF 0x00400000 // activate 80m TX LPF
+#define ALEX_160_LPF 0x00800000 // activate 160m TX LPF
+#define ALEX_6_BYPASS_LPF 0x20000000 // activate 6m TX LPF
+#define ALEX_12_10_LPF 0x40000000 // activate 12/10m TX LPF
+#define ALEX_17_15_LPF 0x80000000 // activate 17/15m TX LPF
+
+//
+// ALEX RX high-pass filters (Valid for ANAN-100/200)
+//
#define ALEX_13MHZ_HPF 0x00000002
#define ALEX_20MHZ_HPF 0x00000004
+#define ALEX_6M_PREAMP 0x00000008 // 35 MHz HPF + low-noise amplifier
#define ALEX_9_5MHZ_HPF 0x00000010
#define ALEX_6_5MHZ_HPF 0x00000020
#define ALEX_1_5MHZ_HPF 0x00000040
#define ALEX_BYPASS_HPF 0x00001000
-#define ALEX_6M_PREAMP 0x00000008
+//
+// Bit that controls the RX/TX relay
+//
+#define ALEX_TX_RELAY 0x08000000
+
+//
+// Bit used for PURESIGNAL
+//
+#define ALEX_PS_BIT 0x00040000
+
+//
+// From this point on, we define bits that have a slightly
+// different meaning
+//
+
+
+//
+// ALEX bits for ANAN-7000 and ANAN-8000
+// Note that we here also have Alex1 bits which control the filters
+// for the second ADC. The RX input is also very different and now used
+// bit14 which is used for switching attenuators in the general case
+// On the RX side, we now have band-pass filters and the RX signals
+// from Ant1,2,3 DO NOT PASS the TX low-pass filters.
+// The TX bits are just as for the "generic" case.
+//
+
+// These bits only have a function on ANAN-7000
+#define ALEX_ANAN7000_RX_ANT_NONE 0x00000000
+#define ALEX_ANAN7000_RX_ANT_EXT1 0x00004200 // bits 9, 14
+#define ALEX_ANAN7000_RX_ANT_XVTR 0x00004100 // bits 8, 14
+#define ALEX_ANAN7000_RX_ANT_BYPASS 0x00000800 // bit 11
+
+#define ALEX_ANAN7000_RX_30_20_17_BPF 0x00000002 // bit 1, 11.0 - 20.9 MHz
+#define ALEX_ANAN7000_RX_15_12_BPF 0x00000004 // bit 2, 21.0 - 26.9 MHz
+#define ALEX_ANAN7000_RX_10_6_PRE_BPF 0x00000008 // bit 3, 27.0 - 61.4 MHz with preamp
+#define ALEX_ANAN7000_RX_40_30_BPF 0x00000010 // bit 4, 5.5 - 10.9 MHz
+#define ALEX_ANAN7000_RX_80_60_BPF 0x00000020 // bit 5, 2.1 - 5.4 MHz
+#define ALEX_ANAN7000_RX_160_BPF 0x00000040 // bit 6, 1.5 - 2.0 MHz
+#define ALEX_ANAN7000_RX_BYPASS_BPF 0x00001000 // bit 12
+
+#define ALEX1_ANAN7000_RX_GNDonTX 0x00000100 // bit 8
+//
+// For ANAN7000,8000 there also is byte 1400 in the high-priority packet
+// which directs the output of the DUC directly to the "XVTR OUT" jack
+// (bit0) and which we should set when using "XVRT IN"
+//
+#define ANAN7000_XVTR_OUT 0x00000001 //
#endif
static void new_protocol_high_priority() {
int i;
BAND *band;
- int xvtr;
long long rxFrequency;
long long txFrequency;
long phase;
}
#ifdef LOCALCW
if (cw_keyer_internal == 0) {
- // set the ptt if we're not in breakin mode and mox is on
+ // set the ptt if we are not in breakin mode and mox is on
if(cw_breakin == 0 && getMox()) high_priority_buffer_to_radio[4]|=0x02;
}
#endif
}
}
-// rx
+//
+// Set DDC frequencies
+//
if (diversity_enabled) {
//
}
}
- // tx
+//
+// Set DUC frequency
+//
+
if(active_receiver->id==VFO_A) {
txFrequency=vfo[VFO_A].frequency-vfo[VFO_A].lo;
if(split) {
phase=(long)((4294967296.0*(double)txFrequency)/122880000.0);
if(isTransmitting() && transmitter->puresignal) {
- // set DDC0 and DDC1 frequency to transmit frequency
+ //
+ // Set DDC0 and DDC1 (synchronized) to the transmit frequency
+ //
high_priority_buffer_to_radio[9]=phase>>24;
high_priority_buffer_to_radio[10]=phase>>16;
high_priority_buffer_to_radio[11]=phase>>8;
if(split) {
band=band_get_band(vfo[VFO_B].band);
- xvtr=vfo[VFO_B].band>=BANDS;
} else {
band=band_get_band(vfo[VFO_A].band);
- xvtr=vfo[VFO_A].band>=BANDS;
}
- // TODO: set word 1400 for ANAN-8000
high_priority_buffer_to_radio[1401]=band->OCtx<<1;
if(tune) {
if(OCmemory_tune_time!=0) {
high_priority_buffer_to_radio[1401]=band->OCrx<<1;
}
- long filters=0x00000000;
+//
+// ANAN-7000/8000: route TXout to XvtrOut out when not using PA
+//
+ if ((device==NEW_DEVICE_ORION2) && band->disablePA) {
+ high_priority_buffer_to_radio[1400] |= ANAN7000_XVTR_OUT;
+ }
+
+//
+// ALEX bits
+//
+ long alex0=0x00000000;
+ long alex1=0x00000000;
if(isTransmitting()) {
- filters=0x08000000; // Bit 27
+ alex0 |= ALEX_TX_RELAY;
if(transmitter->puresignal) {
- filters|=0x00040000; // Bit 18
+ alex0 |= ALEX_PS_BIT; // Bit 18
}
}
+//
+// The following code is based upon the assumption that
+// the frequency of VFO_A is used with ADC0, and that the
+// frequency of VFO_B can safely be used to control the
+// filters of ADC1 (if there are any).
+//
rxFrequency=vfo[VFO_A].frequency-vfo[VFO_A].lo;
switch(device) {
case NEW_DEVICE_ORION2:
+//
+// new ANAN-7000/8000 band-pass RX filters
+// This info comes from file bpf2_select.v in the
+// P1 firmware
+//
if(rxFrequency<1500000L) {
- filters|=ALEX_BYPASS_HPF;
+ alex0|=ALEX_ANAN7000_RX_BYPASS_BPF;
} else if(rxFrequency<2100000L) {
- filters|=ALEX_1_5MHZ_HPF;
+ alex0|=ALEX_ANAN7000_RX_160_BPF;
} else if(rxFrequency<5500000L) {
- filters|=ALEX_6_5MHZ_HPF;
+ alex0|=ALEX_ANAN7000_RX_80_60_BPF;
} else if(rxFrequency<11000000L) {
- filters|=ALEX_9_5MHZ_HPF;
- } else if(rxFrequency<22000000L) {
- filters|=ALEX_13MHZ_HPF;
+ alex0|=ALEX_ANAN7000_RX_40_30_BPF;
+ } else if(rxFrequency<20900000L) {
+ alex0|=ALEX_ANAN7000_RX_30_20_17_BPF;
} else if(rxFrequency<35000000L) {
- filters|=ALEX_20MHZ_HPF;
+ alex0|=ALEX_ANAN7000_RX_15_12_BPF;
} else {
- filters|=ALEX_6M_PREAMP;
+ alex0|=ALEX_ANAN7000_RX_10_6_PRE_BPF;
}
break;
default:
+//
+// Old (ANAN-100/200) high-pass filters
+//
if(rxFrequency<1800000L) {
- filters|=ALEX_BYPASS_HPF;
+ alex0|=ALEX_BYPASS_HPF;
} else if(rxFrequency<6500000L) {
- filters|=ALEX_1_5MHZ_HPF;
+ alex0|=ALEX_1_5MHZ_HPF;
} else if(rxFrequency<9500000L) {
- filters|=ALEX_6_5MHZ_HPF;
+ alex0|=ALEX_6_5MHZ_HPF;
} else if(rxFrequency<13000000L) {
- filters|=ALEX_9_5MHZ_HPF;
+ alex0|=ALEX_9_5MHZ_HPF;
} else if(rxFrequency<20000000L) {
- filters|=ALEX_13MHZ_HPF;
+ alex0|=ALEX_13MHZ_HPF;
} else if(rxFrequency<50000000L) {
- filters|=ALEX_20MHZ_HPF;
+ alex0|=ALEX_20MHZ_HPF;
} else {
- filters|=ALEX_6M_PREAMP;
+ alex0|=ALEX_6M_PREAMP;
}
break;
}
+//
+// Pre-Orion2 boards: If using Ant1/2/3, the RX signal goes through the TX low-pass
+// filters. Therefore we must set these according to the ADC0
+// (receive) frequency while RXing.
+//
+ if (!isTransmitting() && device != NEW_DEVICE_ORION2 && receiver[0]->alex_antenna < 3) {
+ txFrequency = rxFrequency;
+ }
switch(device) {
case NEW_DEVICE_ORION2:
if(txFrequency>32000000) {
- filters|=ALEX_6_BYPASS_LPF;
+ alex0|=ALEX_6_BYPASS_LPF;
} else if(txFrequency>22000000) {
- filters|=ALEX_12_10_LPF;
+ alex0|=ALEX_12_10_LPF;
} else if(txFrequency>15000000) {
- filters|=ALEX_17_15_LPF;
+ alex0|=ALEX_17_15_LPF;
} else if(txFrequency>8000000) {
- filters|=ALEX_30_20_LPF;
+ alex0|=ALEX_30_20_LPF;
} else if(txFrequency>4500000) {
- filters|=ALEX_60_40_LPF;
+ alex0|=ALEX_60_40_LPF;
} else if(txFrequency>2400000) {
- filters|=ALEX_80_LPF;
+ alex0|=ALEX_80_LPF;
} else {
- filters|=ALEX_160_LPF;
+ alex0|=ALEX_160_LPF;
}
break;
default:
if(txFrequency>35600000) {
- filters|=ALEX_6_BYPASS_LPF;
+ alex0|=ALEX_6_BYPASS_LPF;
} else if(txFrequency>24000000) {
- filters|=ALEX_12_10_LPF;
+ alex0|=ALEX_12_10_LPF;
} else if(txFrequency>16500000) {
- filters|=ALEX_17_15_LPF;
+ alex0|=ALEX_17_15_LPF;
} else if(txFrequency>8000000) {
- filters|=ALEX_30_20_LPF;
+ alex0|=ALEX_30_20_LPF;
} else if(txFrequency>5000000) {
- filters|=ALEX_60_40_LPF;
+ alex0|=ALEX_60_40_LPF;
} else if(txFrequency>2500000) {
- filters|=ALEX_80_LPF;
+ alex0|=ALEX_80_LPF;
} else {
- filters|=ALEX_160_LPF;
+ alex0|=ALEX_160_LPF;
}
break;
-
}
- switch(receiver[0]->alex_antenna) {
- case 0: // ANT 1
- break;
- case 1: // ANT 2
- break;
- case 2: // ANT 3
- break;
+//
+// Set bits that route Ext1/Ext2/XVRTin to the RX
+//
+// If transmitting with PURESIGNAL, we must use the alex_antenna
+// settings of the PS_RX_FEEDBACK receiver
+//
+// ANAN-7000 routes signals differently (these bits have no function on ANAN-80000)
+// and uses ALEX0(14) to connnect Ext/XvrtIn to the RX.
+//
+ i=receiver[0]->alex_antenna;
+ if (isTransmitting() && transmitter->puresignal) {
+ i=receiver[PS_RX_FEEDBACK]->alex_antenna; // 0, 3, or 4
+ }
+ if (device == NEW_DEVICE_ORION2) i +=100;
+ switch(i) {
case 3: // EXT 1
- filters|=ALEX_RX_ANTENNA_EXT2;
+ alex0|=ALEX_RX_ANTENNA_EXT1;
break;
case 4: // EXT 2
- filters|=ALEX_RX_ANTENNA_EXT1;
+ alex0|=ALEX_RX_ANTENNA_EXT2;
break;
case 5: // XVTR
- if(!xvtr) {
- filters|=ALEX_RX_ANTENNA_XVTR;
- }
- break;
- default:
- // invalid value - set to 0
- band->alexRxAntenna=0;
+ alex0|=ALEX_RX_ANTENNA_XVTR;
break;
+ case 103: // EXT1 on ANAN-7000
+ alex0|=ALEX_ANAN7000_RX_ANT_EXT1;
+ break;
+ case 104: // EXT2 means RxBypass on ANAN-7000
+ alex0|=ALEX_ANAN7000_RX_ANT_BYPASS;
+ break;
+ case 105:
+ alex0|=ALEX_ANAN7000_RX_ANT_XVTR;
+ break;
}
- if(isTransmitting()) {
- if(!xvtr) {
- switch(transmitter->alex_antenna) {
- case 0: // ANT 1
- filters|=ALEX_TX_ANTENNA_1;
- break;
- case 1: // ANT 2
- filters|=ALEX_TX_ANTENNA_2;
- break;
- case 2: // ANT 3
- filters|=ALEX_TX_ANTENNA_3;
- break;
- default:
- // invalid value - set to 0
- filters|=ALEX_TX_ANTENNA_1;
- band->alexRxAntenna=0;
- break;
- }
- }
+//
+// Now we set the bits for Ant1/2/3 (RX and TX may be different)
+// If RX is from none of Ant1/2/3, do not switch (leave these relays
+// in TX state)
+//
+ if(isTransmitting() || (receiver[0]->alex_antenna > 2)) {
+ i=transmitter->alex_antenna;
} else {
- switch(receiver[0]->alex_antenna) {
- case 0: // ANT 1
- filters|=ALEX_TX_ANTENNA_1;
- break;
- case 1: // ANT 2
- filters|=ALEX_TX_ANTENNA_2;
- break;
- case 2: // ANT 3
- filters|=ALEX_TX_ANTENNA_3;
- break;
- case 3: // EXT 1
- case 4: // EXT 2
- case 5: // XVTR
- if(!xvtr) {
- switch(transmitter->alex_antenna) {
- case 0: // ANT 1
- filters|=ALEX_TX_ANTENNA_1;
- break;
- case 1: // ANT 2
- filters|=ALEX_TX_ANTENNA_2;
- break;
- case 2: // ANT 3
- filters|=ALEX_TX_ANTENNA_3;
- break;
- }
- }
- break;
- }
+ i=receiver[0]->alex_antenna;
+ }
+ // i has value 0, 1, or 2.
+ switch(i) {
+ default:
+ // should not happen, ignore silently and connect to ANT1
+ /* FALLTHROUGH */
+ case 0: // ANT 1
+ alex0|=ALEX_TX_ANTENNA_1;
+ break;
+ case 1: // ANT 2
+ alex0|=ALEX_TX_ANTENNA_2;
+ break;
+ case 2: // ANT 3
+ alex0|=ALEX_TX_ANTENNA_3;
+ break;
}
- // TODO: ALEX1 bits 0-15 for ANAN-7000 and ANAN-8000 in 1430 and 1431
- high_priority_buffer_to_radio[1432]=(filters>>24)&0xFF;
- high_priority_buffer_to_radio[1433]=(filters>>16)&0xFF;
- high_priority_buffer_to_radio[1434]=(filters>>8)&0xFF;
- high_priority_buffer_to_radio[1435]=filters&0xFF;
-
-//fprintf(stderr,"filters: txrx0: %02X %02X %02X %02X for rx=%lld tx=%lld\n",high_priority_buffer_to_radio[1432],high_priority_buffer_to_radio[1433],high_priority_buffer_to_radio[1434],high_priority_buffer_to_radio[1435],rxFrequency,txFrequency);
+ high_priority_buffer_to_radio[1432]=(alex0>>24)&0xFF;
+ high_priority_buffer_to_radio[1433]=(alex0>>16)&0xFF;
+ high_priority_buffer_to_radio[1434]=(alex0>>8)&0xFF;
+ high_priority_buffer_to_radio[1435]=alex0&0xFF;
- filters=0x00000000;
- rxFrequency=vfo[VFO_B].frequency-vfo[VFO_B].lo;
+//fprintf(stderr,"ALEX0 bits: %02X %02X %02X %02X for rx=%lld tx=%lld\n",high_priority_buffer_to_radio[1432],high_priority_buffer_to_radio[1433],high_priority_buffer_to_radio[1434],high_priority_buffer_to_radio[1435],rxFrequency,txFrequency);
- switch(device) {
- case NEW_DEVICE_ORION2:
+//
+// Orion2 boards: set RX2 filters according ro VFOB frequency
+//
+ if (device == NEW_DEVICE_ORION2) {
+ rxFrequency=vfo[VFO_B].frequency-vfo[VFO_B].lo;
+//
+// new ANAN-7000/8000 band-pass RX filters
+// This info comes from file bpf2_select.v in the
+// P1 firmware
+//
if(rxFrequency<1500000L) {
- filters|=ALEX_BYPASS_HPF;
+ alex1|=ALEX_ANAN7000_RX_BYPASS_BPF;
} else if(rxFrequency<2100000L) {
- filters|=ALEX_1_5MHZ_HPF;
+ alex1|=ALEX_ANAN7000_RX_160_BPF;
} else if(rxFrequency<5500000L) {
- filters|=ALEX_6_5MHZ_HPF;
+ alex1|=ALEX_ANAN7000_RX_80_60_BPF;
} else if(rxFrequency<11000000L) {
- filters|=ALEX_9_5MHZ_HPF;
- } else if(rxFrequency<22000000L) {
- filters|=ALEX_13MHZ_HPF;
+ alex1|=ALEX_ANAN7000_RX_40_30_BPF;
+ } else if(rxFrequency<20900000L) {
+ alex1|=ALEX_ANAN7000_RX_30_20_17_BPF;
} else if(rxFrequency<35000000L) {
- filters|=ALEX_20MHZ_HPF;
- } else {
- filters|=ALEX_6M_PREAMP;
- }
- break;
- default:
- if(rxFrequency<1800000L) {
- filters|=ALEX_BYPASS_HPF;
- } else if(rxFrequency<6500000L) {
- filters|=ALEX_1_5MHZ_HPF;
- } else if(rxFrequency<9500000L) {
- filters|=ALEX_6_5MHZ_HPF;
- } else if(rxFrequency<13000000L) {
- filters|=ALEX_9_5MHZ_HPF;
- } else if(rxFrequency<20000000L) {
- filters|=ALEX_13MHZ_HPF;
- } else if(rxFrequency<50000000L) {
- filters|=ALEX_20MHZ_HPF;
+ alex1|=ALEX_ANAN7000_RX_15_12_BPF;
} else {
- filters|=ALEX_6M_PREAMP;
+ alex1|=ALEX_ANAN7000_RX_10_6_PRE_BPF;
}
- break;
- }
- //high_priority_buffer_to_radio[1428]=(filters>>24)&0xFF;
- //high_priority_buffer_to_radio[1429]=(filters>>16)&0xFF;
- high_priority_buffer_to_radio[1430]=(filters>>8)&0xFF;
- high_priority_buffer_to_radio[1431]=filters&0xFF;
+//
+// The main purpose of RX2 is DIVERSITY. Therefore,
+// ground RX2 upon TX *always*
+//
+ if (isTransmitting()) {
+ alex1|=ALEX1_ANAN7000_RX_GNDonTX;
+ }
-//fprintf(stderr,"filters: rx1: %02X %02X for rx=%lld\n",high_priority_buffer_to_radio[1430],high_priority_buffer_to_radio[1431],rxFrequency);
+ high_priority_buffer_to_radio[1430]=(alex1>>8)&0xFF;
+ high_priority_buffer_to_radio[1431]=alex1&0xFF;
+//fprintf(stderr,"ALEX1 bits: rx1: %02X %02X for rx=%lld\n",high_priority_buffer_to_radio[1430],high_priority_buffer_to_radio[1431],rxFrequency);
+ }
-//fprintf(stderr,"new_protocol_high_priority: OC=%02X filters=%04X for frequency=%lld\n", high_priority_buffer_to_radio[1401], filters, rxFrequency);
+//
+// Upon transmitting, set the attenuator of ADC0 to the "transmitter attenuation"
+// (used in PURESIGNAL signal strength adjustment) and the attenuator of ADC1
+// to the maximum value (to protect RX2 in DIVERSITY setups).
+//
if(isTransmitting()) {
high_priority_buffer_to_radio[1443]=transmitter->attenuation;
+ high_priority_buffer_to_radio[1442]=31;
} else {
high_priority_buffer_to_radio[1443]=adc_attenuation[0];
high_priority_buffer_to_radio[1442]=adc_attenuation[1];
}
+//
+// Voila mes amis. Envoyons les 1444 octets "high priority" au radio
+//
int rc;
if((rc=sendto(data_socket,high_priority_buffer_to_radio,sizeof(high_priority_buffer_to_radio),0,(struct sockaddr*)&high_priority_addr,high_priority_addr_length))<0) {
fprintf(stderr,"sendto socket failed for high priority: rc=%d errno=%d\n",rc,errno);