12 #include <sys/ioctl.h>
13 #include <sys/socket.h>
30 #include <semaphore.h>
32 #include <linux/ppdev.h>
33 #include <linux/parport.h>
36 #define PRIVATE static
40 typedef unsigned char BYTE;
50 // ======================================================
51 // Constants and PRIVATE Variables
52 // ======================================================
54 typedef enum _bandplan
61 //Constants for BPF relays
63 typedef enum _bandsetting
66 bs0 = 0x01, //2.5MHz LPF
67 bs1 = 0x02, //2-6MHz BPF
68 bs2 = 0x08, //5-12MHz BPF
69 bs3 = 0x04, //10-24MHz BPF
70 bs4 = 0x10, //20-40MHz BPF
71 bs5 = 0x20, //35-60MHz BPF
74 //PIO Control Pin Numbers
86 typedef enum _statuspin
95 //External control port mask
108 //BEGIN RFE CONTROLS =====================================================
110 //Control and data lines for RFE serial decoders
116 //RFE 1:4 Decoder (74HC139) values to drive shift register RCK lines
117 typedef enum _rfe_rck
125 //RFE control constants
126 #define LPF0 1 //On board low pass filter relays
137 #define BPF0 128 //Band pass filter relays
139 #define BPF2 16 //Note: BPF2 and BPF3 are reverse order
140 #define BPF3 32 //on BPF board
144 #define PAF0 1 //Power Amplifier low pass filters
150 #define PAFR 64 //Power amplifier TR relay
152 #define ATUCTL 128 //Automatic Tuning Unit control
154 #define AMP_RLYS 3 //Controls both AMP1 and AMP2 relays
155 #define XVTR_RLY 8 //Switches 2M transverter switching relayinto signal path
156 #define ATTN_RLY 16 //Attenuator relay
157 #define XVTR_TR_RLY 4 //2M transverter TR relay (on for RX) XVRX on schematic
158 #define IMPULSE_RLY 32 //Impulse circuit switching relay
159 #define SPARE_CTRL 64 //Spare control line to PA
162 //Constants latch outputs
170 //DDS Control Constants
171 #define COMP_PD 0x10 //DDS Comparator power down
172 #define DIG_PD 0x01 //DDS Digital Power down
173 #define BYPASS_PLL 0x20 //Bypass DDS PLL
174 #define INT_IOUD 0x01 //Internal IO Update
175 #define OSK_EN 0x20 //Offset Shift Keying enable
176 #define OSK_INT 0x10 //Offset Shift Keying
177 #define BYPASS_SINC 0x40 //Bypass Inverse Sinc Filter
178 #define PLL_RANGE 0x40 //Set PLL Range
182 //PIO register base address
183 // unsigned short baseAdr;
184 double min_freq; // minimum allowable tuning frequency
185 double max_freq; // maximum allowable tuning frequency
186 unsigned radio_number;
190 BOOLEAN rfe_enabled; //True if RFE board is enabled
191 BOOLEAN xvtr_enabled; //Transverter is enabled
193 BOOLEAN xvtr_tr_logic;
198 BandSetting band_relay;
205 //DDS Clock properties
208 double dds_clock_correction;
211 unsigned short dac_mult;
213 //DDS Frequency Control properties
217 BOOLEAN spur_reduction;
218 double dds_step_size;
223 double tune_frac_rel;
228 BandPlan curBandPlan;
230 double TWO_TO_THE_48_DIVIDED_BY_200;
231 long last_tuning_word;
234 BOOLEAN needs_OSC_change;
240 extern BOOLEAN openRig(char *port);
241 extern void closeRig(void);
243 extern BOOLEAN getExtended(void);
244 extern void setExtended(BOOLEAN value);
245 extern BOOLEAN getRFE_Enabled(void);
246 extern void setRFE_Enabled(BOOLEAN value);
247 extern BOOLEAN getXVTR_Enabled(void);
248 extern void setXVTR_Enabled(BOOLEAN value);
249 extern BOOLEAN getXVTR_TR_Logic(void);
250 extern void setXVTR_TR_Logic(BOOLEAN value);
251 extern int getLatchDelay(void);
252 extern void setLatchDelay(int value);
253 extern double getMinFreq(void);
254 extern double getMaxFreq(void);
255 //extern unsigned short getBaseAddr(void);
256 //extern void setBaseAddr(unsigned short value);
257 extern BandSetting getBandRelay(void);
258 extern void setBandRelay(BandSetting value);
259 extern BOOLEAN getTransmitRelay(void);
260 extern void setTransmitRelay(BOOLEAN value);
261 extern BOOLEAN getMuteRelay(void);
262 extern void setMuteRelay(BOOLEAN value);
263 extern BOOLEAN getGainRelay(void);
264 extern void setGainRelay(BOOLEAN value);
265 extern int getExternalOutput(void);
266 extern void setExternalOutput(int value);
267 extern double getDDSClockCorrection(void);
268 extern void setDDSClockCorrection(double value);
269 extern int getPLLMult(void);
270 extern void setPLLMult(int value);
271 extern double getDDSClock(void);
272 extern void setDDSClock(double value);
273 extern BOOLEAN getIFShift(void);
274 extern void setIFShift(BOOLEAN value);
275 extern BOOLEAN getSpurReduction(void);
276 extern void setSpurReduction(BOOLEAN value);
277 extern double getIFFreq(void);
278 extern void setIFFreq(double value);
279 extern double getDDSFreq(void);
280 extern void setDDSFreq(double value);
281 extern int getSampleRate(void);
282 extern void setSampleRate(int value);
283 extern int getFFTLength(void);
284 extern void setFFTLength(int value);
285 extern int getTuneFFT(void);
286 extern double getTuneFracRel(void);
287 extern double getVFOOffset(void);
288 extern void setVFOOffset(double value);
289 extern int getIOUDClock(void);
290 extern void setIOUDClock(int value);
291 extern unsigned short getDACMult(void);
292 extern void setDACMult(unsigned short value);
293 extern BOOLEAN InputPin(StatusPin vStatusPin);
294 extern BYTE StatusPort(void);
295 extern void RigInit(void);
296 extern void PowerOn(void);
297 extern void StandBy(void);
298 extern void SetExt(ExtPin pin);
299 extern void ResExt(ExtPin pin);
300 extern BOOLEAN PinValue(ExtPin pin);
301 extern void SetBPF(double VFOValue);
302 extern BOOLEAN IsHamBand(BandPlan b);
303 extern void TestPort(void);
304 extern void RCKStrobe(BOOLEAN ClearReg, RFE_RCK Reg);
305 extern void SRLoad(RFE_RCK Reg, int Data);
306 extern void ResetRFE(void);
307 extern BOOLEAN getAMP_Relay(void);
308 extern void setAMP_Relay(BOOLEAN value);
309 extern BOOLEAN getATTN_Relay(void);
310 extern void setATTN_Relay(BOOLEAN value);
311 extern BOOLEAN getXVTR_TR_Relay(void);
312 extern void setXVTR_TR_Relay(BOOLEAN value);
313 extern BOOLEAN getXVTR_Relay(void);
314 extern void setXVTR_Relay(BOOLEAN value);
315 extern BOOLEAN getIMPULSE_Relay(void);
316 extern void setIMPULSE_Relay(BOOLEAN);
317 extern void Impulse(void);