Updated FSF address in all files. Fixes ticket:51
[debian/gnuradio] / ezdop / src / host / ezdop / ezdop.h
1 /*
2  * Copyright 2006 Free Software Foundation, Inc.
3  * 
4  * This file is part of GNU Radio
5  * 
6  * GNU Radio is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  * 
11  * GNU Radio 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
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with GNU Radio; see the file COPYING.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef __EZDOP_H__
23 #define __EZDOP_H__
24
25 // Application level includes
26 #include <dopctrl.h>
27
28 // System level includes
29 #include <ftdi.h>
30 #include <complex>
31
32 using std::complex;
33
34 class ezdop
35 {
36 public:
37     ezdop();
38     ~ezdop();
39
40     // Housekeeping
41     bool init();                 // Attach to first device found, TODO: serial no
42     bool finish();               // Release device
43     bool reset();                // Reset state to post-init()
44
45     // Parameters
46     bool set_rate(int rate);     // Set rotation rate
47     int rate() const             // Get rotation rate
48         { return 2000/d_rate; }
49
50     // Commands
51     bool rotate();               // Start antenna rotation
52     bool stop_rotating();        // Stop antenna rotation
53     bool stream();               // Start audio streaming
54     bool stop_streaming();       // Stop audio streaming
55         
56     // Raw read of sample stream from device, length in bytes (2 per sample)
57     int read_raw(unsigned char *buffer, unsigned int length);
58
59     // Read synced, downconverted I and Q samples, one per rotation
60     int read_iq(complex<float> *buffer, unsigned int samples, float &volume);
61
62     // Status
63     bool is_online() const { return d_online; }
64
65 private:
66     struct ftdi_context  *d_device;     // libftdi device instance data
67     bool d_online;     // Successfully found and connected to device
68     bool d_rotating;   // Doppler is rotating
69     int  d_rate;       // Current rotation rate (samples per antenna)
70     enum { ST_HI, ST_LO } d_state;      // Current byte sync state
71     char d_ant;        // Current antenna being sequenced
72     int  d_seq;        // Current phase sample number
73     int  d_val;        // Current reassembled audio sample value
74     int  d_in_phase;   // Downconverted I accumulator
75     int  d_quadrature; // Downconverted Q accumulator
76     
77     bool send_byte(unsigned char data); // Send a byte to AVR
78
79 };
80
81 #endif