1 /*
2  *  Hamlib PCR backend - main header
3  *  Copyright (c) 2001-2010 by Stephane Fillod
4  *
5  *
6  *   This library is free software; you can redistribute it and/or
7  *   modify it under the terms of the GNU Lesser General Public
8  *   License as published by the Free Software Foundation; either
9  *   version 2.1 of the License, or (at your option) any later version.
10  *
11  *   This library is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *   Lesser General Public License for more details.
15  *
16  *   You should have received a copy of the GNU Lesser General Public
17  *   License along with this library; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  */
21 
22 #ifndef _PCR_H
23 #define _PCR_H 1
24 
25 #include "hamlib/rig.h"
26 #include "token.h"
27 
28 /* ext_level's tokens */
29 #define TOK_EL_ANL  TOKEN_BACKEND(1)
30 #define TOK_EL_DIVERSITY  TOKEN_BACKEND(2)
31 
32 #define BACKEND_VER		"20200323"
33 #define PCR_MAX_CMD_LEN		32
34 
35 struct pcr_priv_data
36 {
37 	struct pcr_rcvr {
38 
39 	    freq_t last_freq;
40 	    int last_mode;
41 
42 	    int last_filter;
43 	    int last_shift;
44 	    int last_att;
45 	    int last_agc;
46 	    tone_t last_ctcss_sql;
47 	    tone_t last_dcs_sql;
48 
49 	    float	volume;
50 	    float	squelch;
51 
52 	    unsigned int raw_level;
53 	    unsigned int squelch_status;
54 
55 	} main_rcvr, sub_rcvr;
56 
57 	vfo_t current_vfo;
58 
59 	int auto_update;
60 
61 	char info[100];
62 	char cmd_buf[PCR_MAX_CMD_LEN];
63 	char reply_buf[PCR_MAX_CMD_LEN];
64 
65 	int protocol;
66 	int firmware;
67 	int country;
68 	int options;
69 
70 	int sync;
71 
72 	powerstat_t power;
73 };
74 
75 struct pcr_priv_caps
76 {
77 	unsigned int reply_size;
78 	unsigned int reply_offset;
79 	unsigned int always_sync;
80 };
81 
82 #define pcr_caps(rig) ((struct pcr_priv_caps *)(rig)->caps->priv)
83 
84 extern tone_t pcr_ctcss_list[];
85 extern tone_t pcr_dcs_list[];
86 
87 int pcr_init(RIG *rig);
88 int pcr_cleanup(RIG *rig);
89 int pcr_open(RIG *rig);
90 int pcr_close(RIG *rig);
91 int pcr_set_vfo(RIG * rig, vfo_t vfo);
92 int pcr_get_vfo(RIG * rig, vfo_t *vfo);
93 int pcr_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
94 int pcr_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
95 int pcr_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
96 int pcr_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width);
97 const char *pcr_get_info(RIG *rig);
98 
99 
100 /* Added - G0WCW */
101 
102 int pcr_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val);
103 int pcr_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val);
104 
105 int pcr_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status);
106 int pcr_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
107 int pcr_set_ext_level(RIG *rig, vfo_t vfo, token_t token, value_t val);
108 
109 int pcr_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone);
110 int pcr_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone);
111 int pcr_get_dcs_sql(RIG *rig, vfo_t vfo, tone_t *tone);
112 int pcr_set_dcs_sql(RIG *rig, vfo_t vfo, tone_t tone);
113 int pcr_set_trn(RIG * rig, int trn);
114 int pcr_decode_event(RIG *rig);
115 int pcr_set_powerstat(RIG * rig, powerstat_t status);
116 int pcr_get_powerstat(RIG * rig, powerstat_t *status);
117 int pcr_get_dcd(RIG * rig, vfo_t vfo, dcd_t *dcd);
118 
119 /* ------------------------------------------------------------------ */
120 
121 // int pcr_get_param(RIG *rig, setting_t parm, value_t *val);
122 // int pcr_set_param(RIG *rig, setting_t parm, value_t *val);
123 
124 extern const struct rig_caps pcr1000_caps;
125 extern const struct rig_caps pcr100_caps;
126 extern const struct rig_caps pcr1500_caps;
127 extern const struct rig_caps pcr2500_caps;
128 
129 #endif /* _PCR_H */
130