1 /*
2  * hamlib - (C) Frank Singleton 2000-2003 (vk3fcs@ix.netcom.com)
3  *          (C) Stephane Fillod 2000-2009
4  *
5  * ft100.h - (C) Chris Karpinsky 2001 (aa1vl@arrl.net)
6  * This shared library provides an API for communicating
7  * via serial interface to an FT-100 using the "CAT" interface.
8  * The starting point for this code was Frank's ft847 implementation.
9  *
10  *
11  *   This library is free software; you can redistribute it and/or
12  *   modify it under the terms of the GNU Lesser General Public
13  *   License as published by the Free Software Foundation; either
14  *   version 2.1 of the License, or (at your option) any later version.
15  *
16  *   This library is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *   Lesser General Public License for more details.
20  *
21  *   You should have received a copy of the GNU Lesser General Public
22  *   License along with this library; if not, write to the Free Software
23  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24  *
25  */
26 
27 #ifndef _FT100_H
28 #define _FT100_H 1
29 
30 #define FT100_WRITE_DELAY                    0
31 #define FT100_POST_WRITE_DELAY               100     /* max is 200ms */
32 #define FT100_DEFAULT_READ_TIMEOUT           2000
33 
34 enum ft100_native_cmd_e {
35 
36   FT100_NATIVE_CAT_LOCK_ON = 0,
37   FT100_NATIVE_CAT_LOCK_OFF,
38   FT100_NATIVE_CAT_PTT_ON,
39   FT100_NATIVE_CAT_PTT_OFF,
40   FT100_NATIVE_CAT_SET_FREQ,
41   FT100_NATIVE_CAT_SET_MODE_LSB,
42   FT100_NATIVE_CAT_SET_MODE_USB,
43   FT100_NATIVE_CAT_SET_MODE_CW,
44   FT100_NATIVE_CAT_SET_MODE_CWR,
45   FT100_NATIVE_CAT_SET_MODE_AM,
46   FT100_NATIVE_CAT_SET_MODE_FM,
47   FT100_NATIVE_CAT_SET_MODE_DIG,
48   FT100_NATIVE_CAT_SET_MODE_WFM,
49   FT100_NATIVE_CAT_CLAR_ON,
50   FT100_NATIVE_CAT_CLAR_OFF,
51   FT100_NATIVE_CAT_SET_CLAR_FREQ,
52   FT100_NATIVE_CAT_SET_VFOAB,
53   FT100_NATIVE_CAT_SET_VFOA,
54   FT100_NATIVE_CAT_SET_VFOB,
55   FT100_NATIVE_CAT_SPLIT_ON,
56   FT100_NATIVE_CAT_SPLIT_OFF,
57   FT100_NATIVE_CAT_SET_RPT_SHIFT_MINUS,
58   FT100_NATIVE_CAT_SET_RPT_SHIFT_PLUS,
59   FT100_NATIVE_CAT_SET_RPT_SHIFT_SIMPLEX,
60   FT100_NATIVE_CAT_SET_RPT_OFFSET,
61 /* fix me */
62   FT100_NATIVE_CAT_SET_DCS_ON,
63   FT100_NATIVE_CAT_SET_CTCSS_ENC_ON,
64   FT100_NATIVE_CAT_SET_CTCSS_ENC_DEC_ON,
65   FT100_NATIVE_CAT_SET_CTCSS_DCS_OFF,
66 /* em xif */
67   FT100_NATIVE_CAT_SET_CTCSS_FREQ,
68   FT100_NATIVE_CAT_SET_DCS_CODE,
69   FT100_NATIVE_CAT_GET_RX_STATUS,
70   FT100_NATIVE_CAT_GET_TX_STATUS,
71   FT100_NATIVE_CAT_GET_FREQ_MODE_STATUS,
72   FT100_NATIVE_CAT_PWR_WAKE,
73   FT100_NATIVE_CAT_PWR_ON,
74   FT100_NATIVE_CAT_PWR_OFF,
75   FT100_NATIVE_CAT_READ_STATUS,
76   FT100_NATIVE_CAT_READ_METERS,
77   FT100_NATIVE_CAT_READ_FLAGS,
78   FT100_NATIVE_SIZE		/* end marker */
79 };
80 
81 
82 typedef enum ft100_native_cmd_e ft100_native_cmd_t;
83 
84 /*
85  *  we are able to get way more info
86  *  than we can set
87  *
88  */
89 typedef struct
90 {
91    unsigned char band_no;
92    unsigned char freq[4];
93    unsigned char mode;
94    unsigned char ctcss;
95    unsigned char dcs;
96    unsigned char flag1;
97    unsigned char flag2;
98    unsigned char clarifier[2];
99    unsigned char not_used;
100    unsigned char step1;
101    unsigned char step2;
102    unsigned char filter;
103 
104    unsigned char stuffing[16];
105 }
106  FT100_STATUS_INFO;
107 
108 
109 typedef struct
110 {
111    unsigned char mic_switch_1;
112    unsigned char tx_fwd_power;
113    unsigned char tx_rev_power;
114    unsigned char s_meter;
115    unsigned char mic_level;
116    unsigned char squelch_level;
117    unsigned char mic_switch_2;
118    unsigned char final_temp;
119    unsigned char alc_level;
120 }
121  FT100_METER_INFO;
122 
123 typedef struct
124 {
125    unsigned char byte[8];
126 }
127 FT100_FLAG_INFO;
128 
129 
130 static int ft100_init(RIG *rig);
131 static int ft100_open(RIG *rig);
132 static int ft100_cleanup(RIG *rig);
133 static int ft100_close(RIG *rig);
134 
135 static int ft100_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
136 static int ft100_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
137 
138 static int ft100_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
139 static int ft100_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
140 
141 static int ft100_set_vfo(RIG *rig, vfo_t vfo);
142 static int ft100_get_vfo(RIG *rig, vfo_t *vfo);
143 
144 static int ft100_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt);
145 static int ft100_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt);
146 static int ft100_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
147 #if 0
148 static int ft100_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
149 
150 static int ft100_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
151 static int ft100_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status);
152 
153 static int ft100_set_parm(RIG *rig, setting_t parm, value_t val);
154 static int ft100_get_parm(RIG *rig, setting_t parm, value_t *val);
155 #endif
156 
157 static int ft100_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo);
158 static int ft100_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo);
159 
160 static int ft100_set_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t shift);
161 static int ft100_get_rptr_shift(RIG *rig, vfo_t vfo, rptr_shift_t *shift);
162 
163 static int ft100_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code);
164 static int ft100_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code);
165 
166 static int ft100_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone);
167 static int ft100_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone);
168 
169 //static int ft100_get_info(RIG *rig, FT100_STATUS_INFO *ft100_status, FT100_METER_INFO *ft100_meter, FT100_FLAG_INFO *ft100_flags);
170 
171 #endif /* _FT100_H */
172