SoDaRadio-5.0.3-master:8901fb5
B200Control.cxx
Go to the documentation of this file.
1 /*
2  Copyright (c) 2015, Matthew H. Reilly (kb1vc)
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11  Redistributions in binary form must reproduce the above copyright
12  notice, this list of conditions and the following disclaimer in
13  the documentation and/or other materials provided with the
14  distribution.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 #include "B200Control.hxx"
30 #include <boost/format.hpp>
31 #include <boost/foreach.hpp>
32 #include <boost/assign.hpp>
33 #include <math.h>
34 #include <stdexcept>
35 
36 
37 #include <stdio.h>
38 #include <unistd.h>
39 #include <fcntl.h>
40 #include <errno.h>
41 #include <termios.h>
42 #include <time.h>
43 
44 #include <strings.h>
45 
46 
47 namespace SoDa
48 {
49  B200Control::B200Control(uhd::usrp::multi_usrp::sptr _usrp, int _mboard) : TRControl() {
50  usrp = _usrp;
51  mboard = _mboard;
52 
53  std::vector<std::string> port = usrp->get_gpio_banks(0);
54 
55  // we set J400 pin 1 HIGH on transmit, LOW on RX.
56  // this is becaus the "default" drive on the pins
57  // if the wrong fpga binary is loaded, the transmitter
58  // TR switch will be left in the TX position.
59  // This may result in "no signal heard" but at least
60  // it is less likely to result in "blown up radio"
61  // Best configuratio, is to look at both pin 1 and pin 3
62  // TX is when 1 is HIGH and 3 is LOW
63  // RX is when 1 is LOW and 3 is HIGH
64  // do something safe when they are both HIGH or both LOW.
65  usrp->set_gpio_attr("FP0", "DDR", 0x300, 0x300);
66  usrp->set_gpio_attr("FP0", "CTRL", 0x0, 0x300);
67 
68  setTXOff();
69  }
70 
72  {
73  usrp->set_gpio_attr("FP0", "OUT", 0x100, 0x300);
74  return true;
75  }
76 
78  {
79  usrp->set_gpio_attr("FP0", "OUT", 0x200, 0x300);
80  return true;
81  return true;
82  }
83 
85  {
86  return true;
87  }
88 
89  bool B200Control::setBand(unsigned int band, bool state)
90  { (void) band; (void) state; return false; }
91  bool B200Control::getBand(unsigned int band)
92  { (void) band; return false; }
93 }
bool setTXOn()
activate external controls to enable transmit mode.
Definition: B200Control.cxx:71
bool setBand(unsigned int band, bool state)
turn on/off signal path for selected band note that multiple bands can be enabled at one time(!) ...
Definition: B200Control.cxx:89
B200Control(uhd::usrp::multi_usrp::sptr usrp, int mboard=0)
constructor
Definition: B200Control.cxx:49
Generic Control class to activate T/R switching, band switching, and other control functions...
Definition: TRControl.hxx:51
bool getTX()
report state of transmit-enable.
Definition: B200Control.cxx:84
bool getBand(unsigned int band)
query state of signal path for selected band
Definition: B200Control.cxx:91
uhd::usrp::multi_usrp::sptr usrp
bool setTXOff()
activate external controls to disable transmit mode.
Definition: B200Control.cxx:77