blob: 485d0371473621b99b7c57f4ae92edb7fe226ffc [file] [log] [blame]
dburgessb3a0ca42011-10-12 07:44:40 +00001/*
2* Copyright 2008 Free Software Foundation, Inc.
3*
4* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion.
5*
6* This use of this software may be subject to additional restrictions.
7* See the LEGAL file in the main directory for details.
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.
12
13*/
14
15#ifndef __RADIO_DEVICE_H__
16#define __RADIO_DEVICE_H__
17
ttsouf60dafa2012-10-22 00:07:14 +000018#include <string>
dburgessb3a0ca42011-10-12 07:44:40 +000019
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif
23
Thomas Tsoucb69f082013-04-08 14:18:26 -040024#define GSMRATE 1625e3/6
25
dburgessb3a0ca42011-10-12 07:44:40 +000026/** a 64-bit virtual timestamp for radio data */
27typedef unsigned long long TIMESTAMP;
28
29/** A class to handle a USRP rev 4, with a two RFX900 daughterboards */
30class RadioDevice {
31
32 public:
kurtis.heimerle380af32011-11-26 03:18:55 +000033 /* Available transport bus types */
Thomas Tsou02d88d12013-04-05 15:36:30 -040034 enum TxWindowType { TX_WINDOW_USRP1, TX_WINDOW_FIXED };
kurtis.heimerle380af32011-11-26 03:18:55 +000035
Thomas Tsoucb69f082013-04-08 14:18:26 -040036 /* Radio interface types */
37 enum RadioInterfaceType { NORMAL, RESAMP };
38
39 static RadioDevice *make(int sps, bool skipRx = false);
kurtis.heimerl965e7572011-11-26 03:16:54 +000040
kurtis.heimerldb2aae52011-11-26 03:17:13 +000041 /** Initialize the USRP */
Thomas Tsoucb69f082013-04-08 14:18:26 -040042 virtual int open(const std::string &args)=0;
dburgessb3a0ca42011-10-12 07:44:40 +000043
44 /** Start the USRP */
45 virtual bool start()=0;
46
47 /** Stop the USRP */
48 virtual bool stop()=0;
49
Thomas Tsou02d88d12013-04-05 15:36:30 -040050 /** Get the Tx window type */
51 virtual enum TxWindowType getWindowType()=0;
kurtis.heimerle380af32011-11-26 03:18:55 +000052
kurtis.heimerldb2aae52011-11-26 03:17:13 +000053 /** Enable thread priority */
54 virtual void setPriority()=0;
55
dburgessb3a0ca42011-10-12 07:44:40 +000056 /**
57 Read samples from the radio.
58 @param buf preallocated buf to contain read result
59 @param len number of samples desired
60 @param overrun Set if read buffer has been overrun, e.g. data not being read fast enough
61 @param timestamp The timestamp of the first samples to be read
62 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
63 @param RSSI The received signal strength of the read result
64 @return The number of samples actually read
65 */
66 virtual int readSamples(short *buf, int len, bool *overrun,
kurtis.heimerl965e7572011-11-26 03:16:54 +000067 TIMESTAMP timestamp = 0xffffffff,
68 bool *underrun = 0,
69 unsigned *RSSI = 0)=0;
dburgessb3a0ca42011-10-12 07:44:40 +000070 /**
71 Write samples to the radio.
72 @param buf Contains the data to be written.
73 @param len number of samples to write.
74 @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough
75 @param timestamp The timestamp of the first sample of the data buffer.
76 @param isControl Set if data is a control packet, e.g. a ping command
77 @return The number of samples actually written
78 */
79 virtual int writeSamples(short *buf, int len, bool *underrun,
80 TIMESTAMP timestamp,
81 bool isControl=false)=0;
82
83 /** Update the alignment between the read and write timestamps */
84 virtual bool updateAlignment(TIMESTAMP timestamp)=0;
85
86 /** Set the transmitter frequency */
87 virtual bool setTxFreq(double wFreq)=0;
88
89 /** Set the receiver frequency */
90 virtual bool setRxFreq(double wFreq)=0;
91
92 /** Returns the starting write Timestamp*/
93 virtual TIMESTAMP initialWriteTimestamp(void)=0;
94
95 /** Returns the starting read Timestamp*/
96 virtual TIMESTAMP initialReadTimestamp(void)=0;
97
98 /** returns the full-scale transmit amplitude **/
99 virtual double fullScaleInputValue()=0;
100
101 /** returns the full-scale receive amplitude **/
102 virtual double fullScaleOutputValue()=0;
103
104 /** sets the receive chan gain, returns the gain setting **/
105 virtual double setRxGain(double dB)=0;
106
107 /** gets the current receive gain **/
108 virtual double getRxGain(void)=0;
109
110 /** return maximum Rx Gain **/
111 virtual double maxRxGain(void) = 0;
112
113 /** return minimum Rx Gain **/
114 virtual double minRxGain(void) = 0;
115
116 /** sets the transmit chan gain, returns the gain setting **/
117 virtual double setTxGain(double dB)=0;
118
119 /** return maximum Tx Gain **/
120 virtual double maxTxGain(void) = 0;
121
122 /** return minimum Tx Gain **/
123 virtual double minTxGain(void) = 0;
124
125 /** Return internal status values */
126 virtual double getTxFreq()=0;
127 virtual double getRxFreq()=0;
128 virtual double getSampleRate()=0;
129 virtual double numberRead()=0;
130 virtual double numberWritten()=0;
131
132};
133
134#endif