USRP Hardware Driver and USRP Manual  Version: 003.009.007-0-g50839059
UHD and USRP Manual
serial.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2013 Ettus Research LLC
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 #ifndef INCLUDED_UHD_TYPES_SERIAL_HPP
19 #define INCLUDED_UHD_TYPES_SERIAL_HPP
20 
21 #include <uhd/config.hpp>
22 #include <boost/shared_ptr.hpp>
23 #include <boost/cstdint.hpp>
24 #include <vector>
25 
26 namespace uhd{
27 
31  typedef std::vector<boost::uint8_t> byte_vector_t;
32 
46  public:
47  typedef boost::shared_ptr<i2c_iface> sptr;
48 
49  virtual ~i2c_iface(void);
50 
52  i2c_iface::sptr eeprom16(void);
53 
59  virtual void write_i2c(
60  boost::uint16_t addr,
61  const byte_vector_t &buf
62  ) = 0;
63 
70  virtual byte_vector_t read_i2c(
71  boost::uint16_t addr,
72  size_t num_bytes
73  ) = 0;
74 
81  virtual void write_eeprom(
82  boost::uint16_t addr,
83  boost::uint16_t offset,
84  const byte_vector_t &buf
85  );
86 
94  virtual byte_vector_t read_eeprom(
95  boost::uint16_t addr,
96  boost::uint16_t offset,
97  size_t num_bytes
98  );
99  };
100 
110  enum edge_t{
111  EDGE_RISE = 'r',
112  EDGE_FALL = 'f'
113  };
114 
117 
120 
125  spi_config_t(edge_t edge = EDGE_RISE);
126  };
127 
133  public:
134  typedef boost::shared_ptr<spi_iface> sptr;
135 
136  virtual ~spi_iface(void);
137 
147  virtual boost::uint32_t transact_spi(
148  int which_slave,
149  const spi_config_t &config,
150  boost::uint32_t data,
151  size_t num_bits,
152  bool readback
153  ) = 0;
154 
163  virtual boost::uint32_t read_spi(
164  int which_slave,
165  const spi_config_t &config,
166  boost::uint32_t data,
167  size_t num_bits
168  );
169 
177  virtual void write_spi(
178  int which_slave,
179  const spi_config_t &config,
180  boost::uint32_t data,
181  size_t num_bits
182  );
183  };
184 
189  public:
190  typedef boost::shared_ptr<uart_iface> sptr;
191 
192  virtual ~uart_iface(void);
193 
198  virtual void write_uart(const std::string &buf) = 0;
199 
205  virtual std::string read_uart(double timeout) = 0;
206  };
207 
208 } //namespace uhd
209 
210 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */
Definition: serial.hpp:132
Definition: serial.hpp:45
edge_t mosi_edge
on what edge is the mosi data valid?
Definition: serial.hpp:116
Definition: convert.hpp:28
Definition: serial.hpp:105
boost::shared_ptr< spi_iface > sptr
Definition: serial.hpp:134
std::vector< boost::uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition: byte_vector.hpp:33
#define UHD_API
Definition: config.h:66
edge_t miso_edge
on what edge is the miso data valid?
Definition: serial.hpp:119
Definition: serial.hpp:188
boost::shared_ptr< uart_iface > sptr
Definition: serial.hpp:190
edge_t
Definition: serial.hpp:110
boost::shared_ptr< i2c_iface > sptr
Definition: serial.hpp:47