USRP Hardware Driver and USRP Manual  Version: 004.000.000.HEAD-0-g8773fb2c
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 
123 
125  size_t divider;
126 
131  spi_config_t(edge_t edge = EDGE_RISE);
132  };
133 
139  public:
140  typedef boost::shared_ptr<spi_iface> sptr;
141 
142  virtual ~spi_iface(void);
143 
153  virtual boost::uint32_t transact_spi(
154  int which_slave,
155  const spi_config_t &config,
156  boost::uint32_t data,
157  size_t num_bits,
158  bool readback
159  ) = 0;
160 
169  virtual boost::uint32_t read_spi(
170  int which_slave,
171  const spi_config_t &config,
172  boost::uint32_t data,
173  size_t num_bits
174  );
175 
183  virtual void write_spi(
184  int which_slave,
185  const spi_config_t &config,
186  boost::uint32_t data,
187  size_t num_bits
188  );
189  };
190 
195  public:
196  typedef boost::shared_ptr<uart_iface> sptr;
197 
198  virtual ~uart_iface(void);
199 
204  virtual void write_uart(const std::string &buf) = 0;
205 
211  virtual std::string read_uart(double timeout) = 0;
212  };
213 
214 } //namespace uhd
215 
216 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */
size_t divider
Optionally set the SPI clock divider for this transaction.
Definition: serial.hpp:125
Definition: serial.hpp:138
Definition: serial.hpp:45
bool use_custom_divider
Set the clock speed for this transaction.
Definition: serial.hpp:122
edge_t mosi_edge
on what edge is the mosi data valid?
Definition: serial.hpp:116
Definition: build_info.hpp:25
Definition: serial.hpp:105
boost::shared_ptr< spi_iface > sptr
Definition: serial.hpp:140
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:73
edge_t miso_edge
on what edge is the miso data valid?
Definition: serial.hpp:119
Definition: serial.hpp:194
boost::shared_ptr< uart_iface > sptr
Definition: serial.hpp:196
edge_t
Definition: serial.hpp:110
boost::shared_ptr< i2c_iface > sptr
Definition: serial.hpp:47