Imported Upstream version 3.0
[debian/gnuradio] / usrp / host / lib / usrp_basic.h
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2003,2004 Free Software Foundation, Inc.
4  * 
5  * This file is part of GNU Radio
6  * 
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  * 
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING.  If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 /*
24  * ----------------------------------------------------------------------
25  * Mid level interface to the Universal Software Radio Peripheral (Rev 1)
26  *
27  * These classes implement the basic functionality for talking to the
28  * USRP.  They try to be as independent of the signal processing code
29  * in FPGA as possible.  They implement access to the low level
30  * peripherals on the board, provide a common way for reading and
31  * writing registers in the FPGA, and provide the high speed interface
32  * to streaming data across the USB.
33  *
34  * It is expected that subclasses will be derived that provide
35  * access to the functionality to a particular FPGA configuration.
36  * ----------------------------------------------------------------------
37  */
38
39 #ifndef INCLUDED_USRP_BASIC_H
40 #define INCLUDED_USRP_BASIC_H
41
42 #include <usrp_slots.h>
43 #include <string>
44
45 struct usb_dev_handle;
46 class  fusb_devhandle;
47 class  fusb_ephandle;
48
49 /*!
50  * \brief base class for usrp operations
51  */
52 class usrp_basic
53 {
54 private:
55   // NOT IMPLEMENTED
56   usrp_basic (const usrp_basic &rhs);                   // no copy constructor
57   usrp_basic &operator= (const usrp_basic &rhs);        // no assignment operator
58
59   
60 protected:
61   struct usb_dev_handle *d_udh;
62   int                    d_usb_data_rate;       // bytes/sec
63   int                    d_bytes_per_poll;      // how often to poll for overruns
64   bool                   d_verbose;
65
66   static const int       MAX_REGS = 128;
67   unsigned int           d_fpga_shadows[MAX_REGS];
68
69   usrp_basic (int which_board,
70               struct usb_dev_handle *open_interface (struct usb_device *dev),
71               const std::string fpga_filename = "",
72               const std::string firmware_filename = "");
73
74   /*!
75    * \brief advise usrp_basic of usb data rate (bytes/sec)
76    *
77    * N.B., this doesn't tweak any hardware.  Derived classes
78    * should call this to inform us of the data rate whenever it's
79    * first set or if it changes.
80    *
81    * \param usb_data_rate       bytes/sec
82    */
83   void set_usb_data_rate (int usb_data_rate);
84   
85   /*!
86    * \brief Write auxiliary digital to analog converter.
87    *
88    * \param slot        Which Tx or Rx slot to write.
89    *                    N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.
90    *                    SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.
91    * \param which_dac   [0,3] RX slots must use only 0 and 1.  TX slots must use only 2 and 3.
92    * \param value       [0,4095]
93    * \returns true iff successful
94    */
95   bool write_aux_dac (int slot, int which_dac, int value);
96
97   /*!
98    * \brief Read auxiliary analog to digital converter.
99    *
100    * \param slot        2-bit slot number. E.g., SLOT_TX_A
101    * \param which_adc   [0,1]
102    * \param value       return 12-bit value [0,4095]
103    * \returns true iff successful
104    */
105   bool read_aux_adc (int slot, int which_adc, int *value);
106
107   /*!
108    * \brief Read auxiliary analog to digital converter.
109    *
110    * \param slot        2-bit slot number. E.g., SLOT_TX_A
111    * \param which_adc   [0,1]
112    * \returns value in the range [0,4095] if successful, else READ_FAILED.
113    */
114   int read_aux_adc (int slot, int which_adc);
115
116 public:
117   virtual ~usrp_basic ();
118
119   /*!
120    * \brief return frequency of master oscillator on USRP
121    */
122   long  fpga_master_clock_freq () const { return 64000000; }
123
124   /*!
125    * \returns usb data rate in bytes/sec
126    */
127   int usb_data_rate () const { return d_usb_data_rate; }
128
129   void set_verbose (bool on) { d_verbose = on; }
130
131   //! magic value used on alternate register read interfaces
132   static const int READ_FAILED = -99999;
133
134   /*!
135    * \brief Write EEPROM on motherboard or any daughterboard.
136    * \param i2c_addr            I2C bus address of EEPROM
137    * \param eeprom_offset       byte offset in EEPROM to begin writing
138    * \param buf                 the data to write
139    * \returns true iff sucessful
140    */
141   bool write_eeprom (int i2c_addr, int eeprom_offset, const std::string buf);
142
143   /*!
144    * \brief Read EEPROM on motherboard or any daughterboard.
145    * \param i2c_addr            I2C bus address of EEPROM
146    * \param eeprom_offset       byte offset in EEPROM to begin reading
147    * \param len                 number of bytes to read
148    * \returns the data read if successful, else a zero length string.
149    */
150   std::string read_eeprom (int i2c_addr, int eeprom_offset, int len);
151
152   /*!
153    * \brief Write to I2C peripheral
154    * \param i2c_addr            I2C bus address (7-bits)
155    * \param buf                 the data to write
156    * \returns true iff successful
157    * Writes are limited to a maximum of of 64 bytes.
158    */
159   bool write_i2c (int i2c_addr, const std::string buf);
160
161   /*!
162    * \brief Read from I2C peripheral
163    * \param i2c_addr            I2C bus address (7-bits)
164    * \param len                 number of bytes to read
165    * \returns the data read if successful, else a zero length string.
166    * Reads are limited to a maximum of 64 bytes.
167    */
168   std::string read_i2c (int i2c_addr, int len);
169
170   /*!
171    * \brief Set ADC offset correction
172    * \param which       which ADC[0,3]: 0 = RX_A I, 1 = RX_A Q...
173    * \param offset      16-bit value to subtract from raw ADC input.
174    */
175   bool set_adc_offset (int which, int offset);
176
177   /*!
178    * \brief Set DAC offset correction
179    * \param which       which DAC[0,3]: 0 = TX_A I, 1 = TX_A Q...
180    * \param offset      10-bit offset value (ambiguous format:  See AD9862 datasheet).
181    * \param offset_pin  1-bit value.  If 0 offset applied to -ve differential pin;
182    *                                  If 1 offset applied to +ve differential pin.
183    */
184   bool set_dac_offset (int which, int offset, int offset_pin);
185
186   /*!
187    * \brief Control ADC input buffer
188    * \param which       which ADC[0,3]
189    * \param bypass      if non-zero, bypass input buffer and connect input
190    *                    directly to switched cap SHA input of RxPGA.
191    */
192   bool set_adc_buffer_bypass (int which, bool bypass);
193
194
195   /*!
196    * \brief return the usrp's serial number.
197    *
198    * \returns non-zero length string iff successful.
199    */
200   std::string serial_number();
201
202   // ----------------------------------------------------------------
203   // Low level implementation routines.
204   // You probably shouldn't be using these...
205   //
206
207   bool _set_led (int which, bool on);
208
209   /*!
210    * \brief Write FPGA register.
211    * \param regno       7-bit register number
212    * \param value       32-bit value
213    * \returns true iff successful
214    */
215   bool _write_fpga_reg (int regno, int value);  //< 7-bit regno, 32-bit value
216
217   /*!
218    * \brief Read FPGA register.
219    * \param regno       7-bit register number
220    * \param value       32-bit value
221    * \returns true iff successful
222    */
223   bool _read_fpga_reg (int regno, int *value);  //< 7-bit regno, 32-bit value
224
225   /*!
226    * \brief Read FPGA register.
227    * \param regno       7-bit register number
228    * \returns register value if successful, else READ_FAILED
229    */
230   int  _read_fpga_reg (int regno);
231
232
233   /*!
234    * \brief Write FPGA register with mask.
235    * \param regno       7-bit register number
236    * \param value       16-bit value
237    * \param mask        16-bit value
238    * \returns true if successful
239    * Only use this for registers who actually implement a mask in the verilog firmware, like FR_RX_MASTER_SLAVE
240    */
241   bool _write_fpga_reg_masked (int regno, int value, int mask);
242
243   /*!
244    * \brief Write AD9862 register.
245    * \param which_codec 0 or 1
246    * \param regno       6-bit register number
247    * \param value       8-bit value
248    * \returns true iff successful
249    */
250   bool _write_9862 (int which_codec, int regno, unsigned char value);
251
252   /*!
253    * \brief Read AD9862 register.
254    * \param which_codec 0 or 1
255    * \param regno       6-bit register number
256    * \param value       8-bit value
257    * \returns true iff successful
258    */
259   bool _read_9862 (int which_codec, int regno, unsigned char *value) const;
260
261   /*!
262    * \brief Read AD9862 register.
263    * \param which_codec 0 or 1
264    * \param regno       6-bit register number
265    * \returns register value if successful, else READ_FAILED
266    */
267   int  _read_9862 (int which_codec, int regno) const;
268
269   /*!
270    * \brief Write data to SPI bus peripheral.
271    *
272    * \param optional_header     0,1 or 2 bytes to write before buf.
273    * \param enables             bitmask of peripherals to write. See usrp_spi_defs.h
274    * \param format              transaction format.  See usrp_spi_defs.h SPI_FMT_*
275    * \param buf                 the data to write
276    * \returns true iff successful
277    * Writes are limited to a maximum of 64 bytes.
278    *
279    * If \p format specifies that optional_header bytes are present, they are
280    * written to the peripheral immediately prior to writing \p buf.
281    */
282   bool _write_spi (int optional_header, int enables, int format, std::string buf);
283
284   /*
285    * \brief Read data from SPI bus peripheral.
286    *
287    * \param optional_header     0,1 or 2 bytes to write before buf.
288    * \param enables             bitmask of peripheral to read. See usrp_spi_defs.h
289    * \param format              transaction format.  See usrp_spi_defs.h SPI_FMT_*
290    * \param len                 number of bytes to read.  Must be in [0,64].
291    * \returns the data read if sucessful, else a zero length string.
292    *
293    * Reads are limited to a maximum of 64 bytes.
294    *
295    * If \p format specifies that optional_header bytes are present, they
296    * are written to the peripheral first.  Then \p len bytes are read from
297    * the peripheral and returned.
298    */
299   std::string _read_spi (int optional_header, int enables, int format, int len);
300
301   /*!
302    * \brief Start data transfers.
303    * Called in base class to derived class order.
304    */
305   bool start ();
306
307   /*!
308    * \brief Stop data transfers.
309    * Called in base class to derived class order.
310    */
311   bool stop ();
312 };
313
314 \f/*!
315  * \brief class for accessing the receive side of the USRP
316  */
317 class usrp_basic_rx : public usrp_basic 
318 {
319 private:
320   fusb_devhandle        *d_devhandle;
321   fusb_ephandle         *d_ephandle;
322   int                    d_bytes_seen;          // how many bytes we've seen
323   bool                   d_first_read;
324   bool                   d_rx_enable;
325
326 protected:
327   int                    d_dbid[2];             // Rx daughterboard ID's
328
329   /*!
330    * \param which_board      Which USRP board on usb (not particularly useful; use 0)
331    * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 512. 
332    *                         Use zero for a reasonable default.
333    * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero for a reasonable default. 
334    */
335   usrp_basic_rx (int which_board,
336                  int fusb_block_size=0,
337                  int fusb_nblocks=0,
338                  const std::string fpga_filename = "",
339                  const std::string firmware_filename = ""
340                  );  // throws if trouble
341
342   bool set_rx_enable (bool on);
343   bool rx_enable () const { return d_rx_enable; }
344
345   bool disable_rx ();           // conditional disable, return prev state
346   void restore_rx (bool on);    // conditional set
347
348   void probe_rx_slots (bool verbose);
349   int  dboard_to_slot (int dboard) { return (dboard << 1) | 1; }
350
351 public:
352   ~usrp_basic_rx ();
353
354   /*!
355    * \brief invokes constructor, returns instance or 0 if trouble
356    *
357    * \param which_board      Which USRP board on usb (not particularly useful; use 0)
358    * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 512. 
359    *                         Use zero for a reasonable default.
360    * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero for a reasonable default. 
361    */
362   static usrp_basic_rx *make (int which_board,
363                               int fusb_block_size=0,
364                               int fusb_nblocks=0,
365                               const std::string fpga_filename = "",
366                               const std::string firmware_filename = ""
367                               );
368
369   // MANIPULATORS
370
371   /*!
372    * \brief tell the fpga the rate rx samples are coming from the A/D's
373    *
374    * div = fpga_master_clock_freq () / sample_rate
375    *
376    * sample_rate is determined by a myriad of registers
377    * in the 9862.  That's why you have to tell us, so
378    * we can tell the fpga.
379    */
380   bool set_fpga_rx_sample_rate_divisor (unsigned int div);
381
382   /*!
383    * \brief read data from the D/A's via the FPGA.
384    * \p len must be a multiple of 512 bytes.
385    *
386    * \returns the number of bytes read, or -1 on error.
387    *
388    * If overrun is non-NULL it will be set true iff an RX overrun is detected.
389    */
390   int read (void *buf, int len, bool *overrun);
391
392   // ACCESSORS
393
394   //! sampling rate of A/D converter
395   virtual long converter_rate() const { return fpga_master_clock_freq(); } // 64M
396   long adc_rate() const { return converter_rate(); }
397   long adc_freq() const { return converter_rate(); }   //!< deprecated method name
398
399   /*!
400    * \brief Return daughterboard ID for given Rx daughterboard slot [0,1].
401    *
402    * \param which_dboard        [0,1] which Rx daughterboard
403    *
404    * \return daughterboard id >= 0 if successful
405    * \return -1 if no daugherboard
406    * \return -2 if invalid EEPROM on daughterboard
407    */
408   int daughterboard_id (int which_dboard) const { return d_dbid[which_dboard & 0x1]; }
409
410   // ----------------------------------------------------------------
411   // routines for controlling the Programmable Gain Amplifier
412   /*!
413    * \brief Set Programmable Gain Amplifier (PGA)
414    *
415    * \param which       which A/D [0,3]
416    * \param gain_in_db  gain value (linear in dB)
417    *
418    * gain is rounded to closest setting supported by hardware.
419    *
420    * \returns true iff sucessful.
421    *
422    * \sa pga_min(), pga_max(), pga_db_per_step()
423    */
424   bool set_pga (int which, double gain_in_db);
425
426   /*!
427    * \brief Return programmable gain amplifier gain setting in dB.
428    *
429    * \param which       which A/D [0,3]
430    */
431   double pga (int which) const;
432
433   /*!
434    * \brief Return minimum legal PGA gain in dB.
435    */
436   double pga_min () const { return 0.0; }
437
438   /*!
439    * \brief Return maximum legal PGA gain in dB.
440    */
441   double pga_max () const { return 20.0; }
442
443   /*!
444    * \brief Return hardware step size of PGA (linear in dB).
445    */
446   double pga_db_per_step () const { return 20.0 / 20; }
447
448   /*!
449    * \brief Write direction register (output enables) for pins that go to daughterboard.
450    *
451    * \param which_dboard        [0,1] which d'board
452    * \param value               value to write into register
453    * \param mask                which bits of value to write into reg
454    *
455    * Each d'board has 16-bits of general purpose i/o.
456    * Setting the bit makes it an output from the FPGA to the d'board.
457    *
458    * This register is initialized based on a value stored in the
459    * d'board EEPROM.  In general, you shouldn't be using this routine
460    * without a very good reason.  Using this method incorrectly will
461    * kill your USRP motherboard and/or daughterboard.
462    */
463   bool _write_oe (int which_dboard, int value, int mask);
464
465   /*!
466    * \brief Write daughterboard i/o pin value
467    *
468    * \param which_dboard        [0,1] which d'board
469    * \param value               value to write into register
470    * \param mask                which bits of value to write into reg
471    */
472   bool write_io (int which_dboard, int value, int mask);
473
474   /*!
475    * \brief Read daughterboard i/o pin value
476    *
477    * \param which_dboard        [0,1] which d'board
478    * \param value               output
479    */
480   bool read_io (int which_dboard, int *value);
481
482   /*!
483    * \brief Read daughterboard i/o pin value
484    *
485    * \param which_dboard        [0,1] which d'board
486    * \returns register value if successful, else READ_FAILED
487    */
488   int read_io (int which_dboard);
489
490   /*!
491    * \brief Write auxiliary digital to analog converter.
492    *
493    * \param which_dboard        [0,1] which d'board
494    *                            N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.
495    *                            SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.
496    * \param which_dac           [2,3] TX slots must use only 2 and 3.
497    * \param value               [0,4095]
498    * \returns true iff successful
499    */
500   bool write_aux_dac (int which_board, int which_dac, int value);
501
502   /*!
503    * \brief Read auxiliary analog to digital converter.
504    *
505    * \param which_dboard        [0,1] which d'board
506    * \param which_adc           [0,1]
507    * \param value               return 12-bit value [0,4095]
508    * \returns true iff successful
509    */
510   bool read_aux_adc (int which_dboard, int which_adc, int *value);
511
512   /*!
513    * \brief Read auxiliary analog to digital converter.
514    *
515    * \param which_dboard        [0,1] which d'board
516    * \param which_adc           [0,1]
517    * \returns value in the range [0,4095] if successful, else READ_FAILED.
518    */
519   int read_aux_adc (int which_dboard, int which_adc);
520
521   /*!
522    * \brief returns current fusb block size
523    */
524   int block_size() const;
525
526   /*!
527    * \brief Enable/disable automatic DC offset removal control loop in FPGA
528    *
529    * \param bits  which control loops to enable
530    * \param mask  which \p bits to pay attention to
531    *
532    * If the corresponding bit is set, enable the automatic DC
533    * offset correction control loop.
534    *
535    * <pre>
536    * The 4 low bits are significant:
537    *
538    *   ADC0 = (1 << 0)
539    *   ADC1 = (1 << 1)
540    *   ADC2 = (1 << 2)
541    *   ADC3 = (1 << 3)
542    * </pre>
543    *
544    * By default the control loop is enabled on all ADC's.
545    */
546   bool set_dc_offset_cl_enable(int bits, int mask);
547
548   // called in base class to derived class order
549   bool start ();
550   bool stop ();
551 };
552
553 \f/*!
554  * \brief class for accessing the transmit side of the USRP
555  */
556 class usrp_basic_tx : public usrp_basic 
557 {
558 private:
559   fusb_devhandle        *d_devhandle;
560   fusb_ephandle         *d_ephandle;
561   int                    d_bytes_seen;          // how many bytes we've seen
562   bool                   d_first_write;
563   bool                   d_tx_enable;
564
565  protected:
566   int                    d_dbid[2];             // Tx daughterboard ID's
567
568   /*!
569    * \param which_board      Which USRP board on usb (not particularly useful; use 0)
570    * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 512.
571    *                         Use zero for a reasonable default.
572    * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero for a reasonable default.
573    */
574   usrp_basic_tx (int which_board,
575                  int fusb_block_size=0,
576                  int fusb_nblocks=0,
577                  const std::string fpga_filename = "",
578                  const std::string firmware_filename = ""
579                  );             // throws if trouble
580
581   bool set_tx_enable (bool on);
582   bool tx_enable () const { return d_tx_enable; }
583
584   bool disable_tx ();           // conditional disable, return prev state
585   void restore_tx (bool on);    // conditional set
586
587   void probe_tx_slots (bool verbose);
588   int  dboard_to_slot (int dboard) { return (dboard << 1) | 0; }
589
590 public:
591
592   ~usrp_basic_tx ();
593
594   /*!
595    * \brief invokes constructor, returns instance or 0 if trouble
596    *
597    * \param which_board      Which USRP board on usb (not particularly useful; use 0)
598    * \param fusb_block_size  fast usb xfer block size.  Must be a multiple of 512. 
599    *                         Use zero for a reasonable default.
600    * \param fusb_nblocks     number of fast usb URBs to allocate.  Use zero for a reasonable default. 
601    */
602   static usrp_basic_tx *make (int which_board, int fusb_block_size=0, int fusb_nblocks=0,
603                               const std::string fpga_filename = "",
604                               const std::string firmware_filename = ""
605                               );
606
607   // MANIPULATORS
608
609   /*!
610    * \brief tell the fpga the rate tx samples are going to the D/A's
611    *
612    * div = fpga_master_clock_freq () * 2
613    *
614    * sample_rate is determined by a myriad of registers
615    * in the 9862.  That's why you have to tell us, so
616    * we can tell the fpga.
617    */
618   bool set_fpga_tx_sample_rate_divisor (unsigned int div);
619
620   /*!
621    * \brief Write data to the A/D's via the FPGA.
622    *
623    * \p len must be a multiple of 512 bytes.
624    * \returns number of bytes written or -1 on error.
625    *
626    * if \p underrun is non-NULL, it will be set to true iff
627    * a transmit underrun condition is detected.
628    */
629   int write (const void *buf, int len, bool *underrun);
630
631   /*
632    * Block until all outstanding writes have completed.
633    * This is typically used to assist with benchmarking
634    */
635   void wait_for_completion ();
636
637   // ACCESSORS
638
639   //! sampling rate of D/A converter
640   virtual long converter_rate() const { return fpga_master_clock_freq () * 2; } // 128M
641   long dac_rate() const { return converter_rate(); }
642   long dac_freq() const { return converter_rate(); }    //!< deprecated method name
643
644   /*!
645    * \brief Return daughterboard ID for given Tx daughterboard slot [0,1].
646    *
647    * \return daughterboard id >= 0 if successful
648    * \return -1 if no daugherboard
649    * \return -2 if invalid EEPROM on daughterboard
650    */
651   int daughterboard_id (int which_dboard) const { return d_dbid[which_dboard & 0x1]; }
652
653   // ----------------------------------------------------------------
654   // routines for controlling the Programmable Gain Amplifier
655   /*!
656    * \brief Set Programmable Gain Amplifier (PGA)
657    *
658    * \param which       which D/A [0,3]
659    * \param gain_in_db  gain value (linear in dB)
660    *
661    * gain is rounded to closest setting supported by hardware.
662    * Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.
663    * Setting DAC 0 affects DAC 1 and vice versa.  Same with DAC 2 and DAC 3.
664    *
665    * \returns true iff sucessful.
666    *
667    * \sa pga_min(), pga_max(), pga_db_per_step()
668    */
669   bool set_pga (int which, double gain_in_db);
670
671   /*!
672    * \brief Return programmable gain amplifier gain in dB.
673    *
674    * \param which       which D/A [0,3]
675    */
676   double pga (int which) const;
677
678   /*!
679    * \brief Return minimum legal PGA gain in dB.
680    */
681   double pga_min () const { return -20.0; }
682
683   /*!
684    * \brief Return maximum legal PGA gain in dB.
685    */
686   double pga_max () const { return 0.0; }
687
688   /*!
689    * \brief Return hardware step size of PGA (linear in dB).
690    */
691   double pga_db_per_step () const { return 20.0/255; }
692
693   /*!
694    * \brief Write direction register (output enables) for pins that go to daughterboard.
695    *
696    * \param which_dboard        [0,1] which d'board
697    * \param value               value to write into register
698    * \param mask                which bits of value to write into reg
699    *
700    * Each d'board has 16-bits of general purpose i/o.
701    * Setting the bit makes it an output from the FPGA to the d'board.
702    *
703    * This register is initialized based on a value stored in the
704    * d'board EEPROM.  In general, you shouldn't be using this routine
705    * without a very good reason.  Using this method incorrectly will
706    * kill your USRP motherboard and/or daughterboard.
707    */
708   bool _write_oe (int which_dboard, int value, int mask);
709
710   /*!
711    * \brief Write daughterboard i/o pin value
712    *
713    * \param which_dboard        [0,1] which d'board
714    * \param value               value to write into register
715    * \param mask                which bits of value to write into reg
716    */
717   bool write_io (int which_dboard, int value, int mask);
718
719   /*!
720    * \brief Read daughterboard i/o pin value
721    *
722    * \param which_dboard        [0,1] which d'board
723    * \param value               return value
724    */
725   bool read_io (int which_dboard, int *value);
726
727   /*!
728    * \brief Read daughterboard i/o pin value
729    *
730    * \param which_dboard        [0,1] which d'board
731    * \returns register value if successful, else READ_FAILED
732    */
733   int read_io (int which_dboard);
734
735   /*!
736    * \brief Write auxiliary digital to analog converter.
737    *
738    * \param which_dboard        [0,1] which d'board
739    *                            N.B., SLOT_TX_A and SLOT_RX_A share the same AUX DAC's.
740    *                            SLOT_TX_B and SLOT_RX_B share the same AUX DAC's.
741    * \param which_dac           [2,3] TX slots must use only 2 and 3.
742    * \param value               [0,4095]
743    * \returns true iff successful
744    */
745   bool write_aux_dac (int which_board, int which_dac, int value);
746
747   /*!
748    * \brief Read auxiliary analog to digital converter.
749    *
750    * \param which_dboard        [0,1] which d'board
751    * \param which_adc           [0,1]
752    * \param value               return 12-bit value [0,4095]
753    * \returns true iff successful
754    */
755   bool read_aux_adc (int which_dboard, int which_adc, int *value);
756
757   /*!
758    * \brief Read auxiliary analog to digital converter.
759    *
760    * \param which_dboard        [0,1] which d'board
761    * \param which_adc           [0,1]
762    * \returns value in the range [0,4095] if successful, else READ_FAILED.
763    */
764   int read_aux_adc (int which_dboard, int which_adc);
765
766   /*!
767    * \brief returns current fusb block size
768    */
769   int block_size() const;
770
771   // called in base class to derived class order
772   bool start ();
773   bool stop ();
774 };
775
776 #endif