]> git.gag.com Git - debian/gnuradio/blob - usrp2/firmware/lib/db_xcvr2450.c
switch source package format to 3.0 quilt
[debian/gnuradio] / usrp2 / firmware / lib / db_xcvr2450.c
1 /*
2  * Copyright 2009 Free Software Foundation, Inc.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <memory_map.h>
19 #include <db_base.h>
20 #include <stdio.h>
21 #include <spi.h>
22 #include <hal_io.h>
23 #include <clocks.h>
24 #include <mdelay.h>
25
26 void set_atr_regs(int bank, struct db_base *db); //FIXME I need to be in a header
27
28 // RX IO Pins
29 #define LOCKDET (1 << 15)           // This is an INPUT!!!
30 #define EN      (1 << 14)
31 #define RX_EN   (1 << 13)           // 1 = RX on, 0 = RX off
32 #define RX_HP   (1 << 12)
33 #define B1      (1 << 11)
34 #define B2      (1 << 10)
35 #define B3      (1 << 9)
36 #define B4      (1 << 8)
37 #define B5      (1 << 7)
38 #define B6      (1 << 6)
39 #define B7      (1 << 5)
40 #define RX_OE_MASK EN|RX_EN|RX_HP|B1|B2|B3|B4|B5|B6|B7
41 #define RX_SAFE_IO EN
42 #define RX_ATR_MASK EN|RX_EN|RX_HP
43
44 // TX IO Pins
45 #define HB_PA_OFF      (1 << 15)    // 5GHz PA, 1 = off, 0 = on
46 #define LB_PA_OFF      (1 << 14)    // 2.4GHz PA, 1 = off, 0 = on
47 #define ANTSEL_TX1_RX2 (1 << 13)    // 1 = Ant 1 to TX, Ant 2 to RX
48 #define ANTSEL_TX2_RX1 (1 << 12)    // 1 = Ant 2 to TX, Ant 1 to RX
49 #define TX_EN          (1 << 11)    // 1 = TX on, 0 = TX off
50 #define AD9515DIV      (1 << 4)     // 1 = Div  by 3, 0 = Div by 2
51 #define TX_OE_MASK HB_PA_OFF|LB_PA_OFF|ANTSEL_TX1_RX2|ANTSEL_TX2_RX1|TX_EN|AD9515DIV
52 #define TX_SAFE_IO HB_PA_OFF|LB_PA_OFF|ANTSEL_TX1_RX2|AD9515DIV
53 #define TX_ATR_MASK HB_PA_OFF|LB_PA_OFF|ANTSEL_TX1_RX2|ANTSEL_TX2_RX1|TX_EN|AD9515DIV
54
55 #define LB_FREQ_MIN U2_DOUBLE_TO_FXPT_FREQ(2.3e9)
56 #define LB_FREQ_MAX U2_DOUBLE_TO_FXPT_FREQ(2.6e9)
57 #define HB_FREQ_MIN U2_DOUBLE_TO_FXPT_FREQ(4.8e9)
58 #define HB_FREQ_MAX U2_DOUBLE_TO_FXPT_FREQ(6.1e9)
59 #define MASTER_REF_CLK_DIV 1
60 #define N_DIV_MIN_Q16 (131 << 16)
61
62 bool xcvr2450_init(struct db_base *db);
63 bool xcvr2450_set_freq(struct db_base *db, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc);
64 bool xcvr2450_set_gain_rx(struct db_base *db, u2_fxpt_gain_t gain);
65 bool xcvr2450_set_gain_tx(struct db_base *db, u2_fxpt_gain_t gain);
66 bool xcvr2450_set_tx_enable(struct db_base *db, bool on);
67 bool xcvr2450_set_rx_antenna(struct db_base *db, int ant);
68 bool xcvr2450_set_tx_antenna(struct db_base *db, int ant);
69
70 struct db_xcvr2450_common {
71   int d_mimo, d_int_div, d_frac_div, d_highband, d_five_gig;
72   int d_cp_current, d_ref_div, d_rssi_hbw;
73   int d_txlpf_bw, d_rxlpf_bw, d_rxlpf_fine, d_rxvga_ser;
74   int d_rssi_range, d_rssi_mode, d_rssi_mux;
75   int d_rx_hp_pin, d_rx_hpf, d_rx_ant;
76   int d_tx_ant, d_txvga_ser, d_tx_driver_lin;
77   int d_tx_vga_lin, d_tx_upconv_lin, d_tx_bb_gain;
78   int d_pabias_delay, d_pabias;
79   int d_rx_rf_gain, d_rx_bb_gain, d_txgain;
80   int d_ad9515_div;
81   int d_tx_enb;
82 };
83
84 struct db_xcvr2450_dummy {
85   struct db_base base;
86   struct db_xcvr2450_common *common;
87 };
88
89 struct db_xcvr2450_rx {
90   struct db_base base;
91   struct db_xcvr2450_common *common;
92 };
93
94 struct db_xcvr2450_tx {
95   struct db_base base;
96   struct db_xcvr2450_common *common;
97 };
98
99 /*
100  * shared common between rx and tx db
101  */
102 struct db_xcvr2450_common db_xcvr2450_common = {
103   /* set sane defaults */
104   .d_mimo = 1,          // 0 = OFF, 1 = ON
105   .d_int_div = 192,     // 128 = min, 255 = max
106   .d_frac_div = 0,      // 0 = min, 65535 = max
107   .d_highband = 0,      // 0 = freq <= 5.4e9, 1 = freq > 5.4e9
108   .d_five_gig = 0,      // 0 = freq <= 3.e9, 1 = freq > 3e9
109   .d_cp_current = 0,    // 0 = 2mA, 1 = 4mA
110   .d_ref_div = 1,       // 1 to 7
111   .d_rssi_hbw = 0,      // 0 = 2 MHz, 1 = 6 MHz
112   .d_txlpf_bw = 1,      // 1 = 12 MHz, 2 = 18 MHz, 3 = 24 MHz
113   .d_rxlpf_bw = 1,      // 0 = 7.5 MHz, 1 = 9.5 MHz, 2 = 14 MHz, 3 = 18 MHz
114   .d_rxlpf_fine = 2,    // 0 = 90%, 1 = 95%, 2 = 100%, 3 = 105%, 4 = 110%
115   .d_rxvga_ser = 1,     // 0 = RXVGA controlled by B7:1, 1=controlled serially
116   .d_rssi_range = 1,    // 0 = low range (datasheet typo), 1=high range (0.5V - 2.0V)
117   .d_rssi_mode = 1,     // 0 = enable follows RXHP, 1 = enabled
118   .d_rssi_mux = 0,      // 0 = RSSI, 1 = TEMP
119   .d_rx_hp_pin = 0,     // 0 = Fc set by rx_hpf, 1 = 600 KHz
120   .d_rx_hpf = 0,        // 0 = 100Hz, 1 = 30KHz
121   .d_rx_ant = 0,        // 0 = Ant. #1, 1 = Ant. #2
122   .d_tx_ant = 0,        // 0 = Ant. #1, 1 = Ant. #2
123   .d_txvga_ser = 1,     // 0 = TXVGA controlled by B6:1, 1=controlled serially
124   .d_tx_driver_lin = 2, // 0=50% (worst linearity), 1=63%, 2=78%, 3=100% (best lin)
125   .d_tx_vga_lin = 2,    // 0=50% (worst linearity), 1=63%, 2=78%, 3=100% (best lin)
126   .d_tx_upconv_lin = 2, // 0=50% (worst linearity), 1=63%, 2=78%, 3=100% (best lin)
127   .d_tx_bb_gain = 3,    // 0=maxgain-5dB, 1=max-3dB, 2=max-1.5dB, 3=max
128   .d_pabias_delay = 15, // 0 = 0, 15 = 7uS
129   .d_pabias = 0,        // 0 = 0 uA, 63 = 315uA
130   .d_rx_rf_gain = 0,    // 0 = 0dB, 1 = 0dB, 2 = 15dB, 3 = 30dB
131   .d_rx_bb_gain = 16,   // 0 = min, 31 = max (0 - 62 dB)
132   .d_txgain = 63,       // 0 = min, 63 = max
133   .d_tx_enb = 1,        // 0 = disabled, 1 = enabled
134 };
135
136 /*
137  * The class instances
138  */
139 struct db_xcvr2450_rx db_xcvr2450_rx = {
140   .base.dbid = 0x0061,
141   .base.is_tx = false,
142   .base.output_enables = RX_OE_MASK,
143   .base.used_pins = 0xFFFF,
144   .base.freq_min = LB_FREQ_MIN,
145   .base.freq_max = HB_FREQ_MAX,
146   .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0),
147   .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(92),
148   .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(1),
149   .base.is_quadrature = true,
150   .base.i_and_q_swapped = false,
151   .base.spectrum_inverted = false,
152   .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0),
153   .base.init = xcvr2450_init,
154   .base.set_freq = xcvr2450_set_freq,
155   .base.set_gain = xcvr2450_set_gain_rx,
156   .base.atr_mask = RX_ATR_MASK,
157   .base.atr_txval = 0x0,
158   .base.atr_rxval = 0x0,
159   .base.set_antenna = xcvr2450_set_rx_antenna,
160   .common = &db_xcvr2450_common,
161 };
162
163 struct db_xcvr2450_tx db_xcvr2450_tx = {
164   .base.dbid = 0x0060,
165   .base.is_tx = true,
166   .base.output_enables = TX_OE_MASK,
167   .base.used_pins = 0xFFFF,
168   .base.freq_min = LB_FREQ_MIN,
169   .base.freq_max = HB_FREQ_MAX,
170   .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0),
171   .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(30),
172   .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(30.0/63.0),
173   .base.is_quadrature = true,
174   .base.i_and_q_swapped = true,
175   .base.spectrum_inverted = false,
176   .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0),
177   .base.init = xcvr2450_init,
178   .base.set_freq = xcvr2450_set_freq,
179   .base.set_gain = xcvr2450_set_gain_tx,
180   .base.set_tx_enable = xcvr2450_set_tx_enable,
181   .base.atr_mask = TX_ATR_MASK,
182   .base.atr_txval = 0x0,
183   .base.atr_rxval = 0x0,
184   .base.set_antenna = xcvr2450_set_tx_antenna,
185   .common = &db_xcvr2450_common,
186 };
187
188 /**************************************************
189  * Set Registers
190  **************************************************/
191 static void
192 send_reg(int v){
193   // Send 24 bits, it keeps last 18 clocked in
194   spi_transact(SPI_TXONLY,SPI_SS_RX_DB,v,24,SPIF_PUSH_FALL);
195   //printf("xcvr2450: Setting reg %d to %x\n", (v&15), v);
196 }
197
198 static void
199 set_reg_standby(struct db_xcvr2450_dummy *db){
200   int reg_standby = (
201     (db->common->d_mimo<<17) |
202     (1<<16)                 |
203     (1<<6)                  |
204     (1<<5)                  |
205     (1<<4)                  | 2);
206   send_reg(reg_standby);
207 }
208
209 static void
210 set_reg_int_divider(struct db_xcvr2450_dummy *db){
211   int reg_int_divider = ((
212     (db->common->d_frac_div & 0x03)<<16) |
213     (db->common->d_int_div<<4)           | 3);
214   send_reg(reg_int_divider);
215 }
216
217 static void
218 set_reg_frac_divider(struct db_xcvr2450_dummy *db){
219   int reg_frac_divider = ((db->common->d_frac_div & 0xfffc)<<2) | 4;
220   send_reg(reg_frac_divider);
221 }
222
223 static void
224 set_reg_bandselpll(struct db_xcvr2450_dummy *db){
225   int reg_bandselpll = ((db->common->d_mimo<<17) |
226     (1<<16) |
227     (1<<15) |
228     (0<<11) | //this bit gets toggled
229     (db->common->d_highband<<10)  |
230     (db->common->d_cp_current<<9) |
231     (db->common->d_ref_div<<5)    |
232     (db->common->d_five_gig<<4)   | 5);
233   send_reg(reg_bandselpll);
234   reg_bandselpll = ((db->common->d_mimo<<17) |
235     (1<<16) |
236     (1<<15) |
237     (1<<11) |
238     (db->common->d_highband<<10)  |
239     (db->common->d_cp_current<<9) |
240     (db->common->d_ref_div<<5)    |
241     (db->common->d_five_gig<<4)   | 5);
242   send_reg(reg_bandselpll);
243 }
244
245 static void
246 set_reg_cal(struct db_xcvr2450_dummy *db){
247   // FIXME do calibration
248   int reg_cal = (
249     (1<<14) | 6);
250   send_reg(reg_cal);
251 }
252
253 static void
254 set_reg_lpf(struct db_xcvr2450_dummy *db){
255   int reg_lpf = (
256     (db->common->d_rssi_hbw<<15)  |
257     (db->common->d_txlpf_bw<<9)  |
258     (db->common->d_rxlpf_bw<<7)   |
259     (db->common->d_rxlpf_fine<<4) | 7);
260   send_reg(reg_lpf);
261 }
262
263 static void
264 set_reg_rxrssi_ctrl(struct db_xcvr2450_dummy *db){
265   int reg_rxrssi_ctrl = (
266        (db->common->d_rxvga_ser<<16)  |
267        (db->common->d_rssi_range<<15) |
268        (db->common->d_rssi_mode<<14)  |
269        (db->common->d_rssi_mux<<12)   |
270        (1<<9)                        |
271        (db->common->d_rx_hpf<<6)      |
272        (1<<4)                        | 8);
273   send_reg(reg_rxrssi_ctrl);
274 }
275
276 static void
277 set_reg_txlin_gain(struct db_xcvr2450_dummy *db){
278   int reg_txlin_gain = (
279       (db->common->d_txvga_ser<<14)     |
280       (db->common->d_tx_driver_lin<<12) |
281       (db->common->d_tx_vga_lin<<10)    |
282       (db->common->d_tx_upconv_lin<<6)  |
283       (db->common->d_tx_bb_gain<<4)     | 9);
284   send_reg(reg_txlin_gain);
285 }
286
287 static void
288 set_reg_pabias(struct db_xcvr2450_dummy *db){
289   int reg_pabias = (
290       (db->common->d_pabias_delay<<10) |
291       (db->common->d_pabias<<4)        | 10);
292   send_reg(reg_pabias);
293 }
294
295 static void
296 set_reg_rxgain(struct db_xcvr2450_dummy *db){
297   int reg_rxgain = (
298     (db->common->d_rx_rf_gain<<9) |
299     (db->common->d_rx_bb_gain<<4) | 11);
300   send_reg(reg_rxgain);
301 }
302
303 static void
304 set_reg_txgain(struct db_xcvr2450_dummy *db){
305   int reg_txgain = (
306     (db->common->d_txgain<<4) | 12);
307   send_reg(reg_txgain);
308 }
309
310 /**************************************************
311  * GPIO
312  **************************************************/
313 static void
314 set_gpio(struct db_xcvr2450_dummy *db){
315   //set tx/rx gpio pins for auto tr
316   int tx_enb_sel = (db->common->d_tx_enb)? TX_EN:0;
317   int ad9515_sel = (db->common->d_ad9515_div == 3)? AD9515DIV:0;
318   int rx_hp = (db->common->d_rx_hp_pin)? RX_HP:0;
319   int tx_antsel = (db->common->d_tx_ant)? ANTSEL_TX2_RX1:ANTSEL_TX1_RX2;
320   int rx_antsel = (db->common->d_rx_ant)? ANTSEL_TX2_RX1:ANTSEL_TX1_RX2;
321   int tx_pa_sel = (db->common->d_five_gig)? LB_PA_OFF:HB_PA_OFF;
322
323   /* FIXME better way to set rx and tx val for RX and TX banks */
324   /* set rx bank */
325   db->base.atr_rxval = EN|rx_hp|RX_EN;
326   db->base.atr_txval = EN|rx_hp;
327   set_atr_regs(GPIO_RX_BANK, (struct db_base *)db);
328   /* set tx bank */
329   db->base.atr_rxval = HB_PA_OFF|LB_PA_OFF|rx_antsel|ad9515_sel;
330   db->base.atr_txval = tx_pa_sel|tx_antsel|tx_enb_sel|ad9515_sel;
331   set_atr_regs(GPIO_TX_BANK, (struct db_base *)db);
332 }
333
334 /**************************************************
335  * Init for TX and RX
336  **************************************************/
337 bool
338 xcvr2450_init(struct db_base *dbb){
339   struct db_xcvr2450_dummy *db = (struct db_xcvr2450_dummy *) dbb;
340   /* Initialize chipset */
341   clocks_enable_tx_dboard(true, MASTER_REF_CLK_DIV);
342   set_gpio(db);
343   set_reg_standby(db);
344   set_reg_bandselpll(db);
345   set_reg_cal(db);
346   set_reg_lpf(db);
347   set_reg_rxrssi_ctrl(db);
348   set_reg_txlin_gain(db);
349   set_reg_pabias(db);
350   set_reg_rxgain(db);
351   set_reg_txgain(db);
352   //u2_fxpt_freq_t dc;
353   //db->base.set_freq(dbb, U2_DOUBLE_TO_FXPT_FREQ(2.434e9), &dc);
354   return true;
355 }
356
357 /**************************************************
358  * Lock detect
359  **************************************************/
360 static bool
361 lock_detect(){
362   //true when the VCO/PLL lock detect bit is set.
363   if(hal_gpio_read(GPIO_RX_BANK) & LOCKDET) {
364     return true;
365   }
366   else {      // Give it a second chance
367     mdelay(1);
368     if(hal_gpio_read(GPIO_RX_BANK) & LOCKDET)
369       return true;
370     else
371       return false;
372   }
373 }
374
375 /**************************************************
376  * Set the freq
377  **************************************************/
378 bool
379 xcvr2450_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc){
380   unsigned int scaler, div_factor, actual_div_q16;
381   struct db_xcvr2450_dummy *db = (struct db_xcvr2450_dummy *) dbb;
382   /* determine if the freq range is in low or high band */
383   if (freq >= LB_FREQ_MIN && freq <= LB_FREQ_MAX) {
384     db->common->d_five_gig = 0;
385     scaler = 3;
386     //printf("2.4-GHZ\n");
387   } else if (freq >= HB_FREQ_MIN && freq <= HB_FREQ_MAX) {
388     db->common->d_five_gig = 1;
389     scaler = 5;
390     //printf("5-GHZ\n");
391   } else {
392     printf("Out of range\n");
393     return false;
394   }
395   /* set the highband bit */
396   if(freq > U2_DOUBLE_TO_FXPT_FREQ(5.408e9)) {
397     db->common->d_highband = 1;
398     //printf("5-HB\n");
399   }
400   else {
401     db->common->d_highband = 0;
402     //printf("5-LB\n");
403   }
404   unsigned int loop_iter = 0;
405   do { /* set the dividers so that the n divider is above the practical minimum */
406     switch(loop_iter){
407       case 0:
408         db->common->d_ad9515_div = 3;
409         db->common->d_ref_div = 1;
410         break;
411       case 1:
412         db->common->d_ad9515_div = 2;
413         db->common->d_ref_div = 2;
414         break;
415       default:
416         db->common->d_ad9515_div = 3;
417         db->common->d_ref_div = loop_iter;
418     }
419     loop_iter++;
420     div_factor = db->common->d_ref_div*db->common->d_ad9515_div*4*MASTER_REF_CLK_DIV;
421     actual_div_q16 = ((freq*div_factor)/(scaler*MASTER_CLK_RATE)) >> (U2_FPF_RP-16);
422   } while (actual_div_q16 < N_DIV_MIN_Q16);
423   /* calculate the divisors */
424   db->common->d_int_div = actual_div_q16 >> 16;
425   db->common->d_frac_div = actual_div_q16 & 0xffff; //isolate lower 16 bits
426   /* calculate the dc freq */
427   *dc = ((((u2_fxpt_freq_t)MASTER_CLK_RATE)*actual_div_q16*scaler) / div_factor) << (U2_FPF_RP-16);
428   /*printf("scaler %d, div(int) %u, div_factor %d, ad9515_div %u, ref_div %u\n",
429     scaler, db->common->d_int_div, div_factor, db->common->d_ad9515_div, db->common->d_ref_div);
430   printf("actual div %u, Target Freq %uKHz, Actual Freq %uKHz\n",
431     actual_div_q16, u2_fxpt_freq_round_to_int(freq/1000), u2_fxpt_freq_round_to_int(*dc/1000));
432   */
433   set_gpio(db);
434   set_reg_int_divider(db);
435   set_reg_frac_divider(db);
436   set_reg_bandselpll(db);
437
438   bool ok = lock_detect();
439   if(!ok){
440     printf("Fail lock detect %uKHz\n", u2_fxpt_freq_round_to_int(freq/1000));
441   }
442   return ok;
443 }
444
445 /**************************************************
446  * Set RX Gain
447  **************************************************/
448 bool
449 xcvr2450_set_gain_rx(struct db_base *dbb, u2_fxpt_gain_t gain){
450   struct db_xcvr2450_dummy *db = (struct db_xcvr2450_dummy *) dbb;
451   //ensure gain is within range
452   if(!(gain >= db->base.gain_min && gain <= db->base.gain_max)) {
453     return false;
454   }
455   // Split the gain between RF and baseband
456   // This is experimental, not prescribed
457   if(gain < U2_DOUBLE_TO_FXPT_GAIN(30.0)) {
458     db->common->d_rx_rf_gain = 0; // 0 dB RF gain
459     db->common->d_rx_bb_gain = u2_fxpt_gain_round_to_int(gain/2);
460   }
461   else if(gain >= U2_DOUBLE_TO_FXPT_GAIN(30.0) && gain < U2_DOUBLE_TO_FXPT_GAIN(61.0)) {
462     db->common->d_rx_rf_gain = 2; // 15 dB RF gain
463     db->common->d_rx_bb_gain = u2_fxpt_gain_round_to_int((gain-U2_DOUBLE_TO_FXPT_GAIN(15.0))/2);
464   }
465   else if(gain >= U2_DOUBLE_TO_FXPT_GAIN(61.0)) {
466     db->common->d_rx_rf_gain = 3; // 30.5 dB RF gain
467     db->common->d_rx_bb_gain = u2_fxpt_gain_round_to_int((gain-U2_DOUBLE_TO_FXPT_GAIN(30.5))/2);
468   }
469   //printf("RX RF Gain %u, RX BB Gain %u\n", db->common->d_rx_rf_gain, db->common->d_rx_bb_gain);
470   set_reg_rxgain(db);
471   return true;
472 }
473
474 /**************************************************
475  * Set TX Gain
476  **************************************************/
477 bool
478 xcvr2450_set_gain_tx(struct db_base *dbb, u2_fxpt_gain_t gain){
479   struct db_xcvr2450_dummy *db = (struct db_xcvr2450_dummy *) dbb;
480   //ensure gain in within range
481   if(!(gain >= db->base.gain_min && gain <= db->base.gain_max)) {
482     return false;
483   }
484   //scale for register and set
485   db->common->d_txgain = (gain*63)/db->base.gain_max;
486   //printf("TX Gain %u, TX Reg %u\n", u2_fxpt_gain_round_to_int(gain), db->common->d_txgain);
487   set_reg_txgain(db);
488   return true;
489 }
490
491 /**************************************************
492  * Set TX Enable
493  **************************************************/
494 bool
495 xcvr2450_set_tx_enable(struct db_base *dbb, bool on){
496   struct db_xcvr2450_dummy *db = (struct db_xcvr2450_dummy *) dbb;
497   db->common->d_tx_enb = on;
498   set_gpio(db);
499   return true;
500 }
501
502 /**************************************************
503  * Set Antennas
504  **************************************************/
505 bool xcvr2450_set_rx_antenna(struct db_base *dbb, int ant){
506     printf("xcvr set rx ant %d\n", ant);
507     if (ant > 1) return false;
508     struct db_xcvr2450_dummy *db = (struct db_xcvr2450_dummy *) dbb;
509     db->common->d_rx_ant = ant;
510     set_gpio(db);
511     return true;
512 }
513
514 bool xcvr2450_set_tx_antenna(struct db_base *dbb, int ant){
515     printf("xcvr set tx ant %d\n", ant);
516     if (ant > 1) return false;
517     struct db_xcvr2450_dummy *db = (struct db_xcvr2450_dummy *) dbb;
518     db->common->d_tx_ant = ant;
519     set_gpio(db);
520     return true;
521 }