USRP Hardware Driver and USRP Manual  Version: 3.11.0.HEAD-0-gdca39145
UHD and USRP Manual
serial.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2013 Ettus Research LLC
3 //
4 // SPDX-License-Identifier: GPL-3.0
5 //
6 
7 #ifndef INCLUDED_UHD_TYPES_SERIAL_HPP
8 #define INCLUDED_UHD_TYPES_SERIAL_HPP
9 
10 #include <uhd/config.hpp>
11 #include <boost/shared_ptr.hpp>
12 #include <stdint.h>
13 #include <vector>
14 
15 namespace uhd{
16 
20  typedef std::vector<uint8_t> byte_vector_t;
21 
35  public:
36  typedef boost::shared_ptr<i2c_iface> sptr;
37 
38  virtual ~i2c_iface(void);
39 
41  i2c_iface::sptr eeprom16(void);
42 
48  virtual void write_i2c(
49  uint16_t addr,
50  const byte_vector_t &buf
51  ) = 0;
52 
59  virtual byte_vector_t read_i2c(
60  uint16_t addr,
61  size_t num_bytes
62  ) = 0;
63 
70  virtual void write_eeprom(
71  uint16_t addr,
72  uint16_t offset,
73  const byte_vector_t &buf
74  );
75 
83  virtual byte_vector_t read_eeprom(
84  uint16_t addr,
85  uint16_t offset,
86  size_t num_bytes
87  );
88  };
89 
99  enum edge_t{
100  EDGE_RISE = 'r',
101  EDGE_FALL = 'f'
102  };
103 
106 
109 
112 
114  size_t divider;
115 
120  spi_config_t(edge_t edge = EDGE_RISE);
121  };
122 
128  public:
129  typedef boost::shared_ptr<spi_iface> sptr;
130 
131  virtual ~spi_iface(void);
132 
142  virtual uint32_t transact_spi(
143  int which_slave,
144  const spi_config_t &config,
145  uint32_t data,
146  size_t num_bits,
147  bool readback
148  ) = 0;
149 
158  virtual uint32_t read_spi(
159  int which_slave,
160  const spi_config_t &config,
161  uint32_t data,
162  size_t num_bits
163  );
164 
172  virtual void write_spi(
173  int which_slave,
174  const spi_config_t &config,
175  uint32_t data,
176  size_t num_bits
177  );
178  };
179 
184  public:
185  typedef boost::shared_ptr<uart_iface> sptr;
186 
187  virtual ~uart_iface(void);
188 
193  virtual void write_uart(const std::string &buf) = 0;
194 
200  virtual std::string read_uart(double timeout) = 0;
201  };
202 
203 } //namespace uhd
204 
205 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */
size_t divider
Optionally set the SPI clock divider for this transaction.
Definition: serial.hpp:114
Definition: serial.hpp:127
Definition: serial.hpp:34
bool use_custom_divider
Set the clock speed for this transaction.
Definition: serial.hpp:111
edge_t mosi_edge
on what edge is the mosi data valid?
Definition: serial.hpp:105
Definition: build_info.hpp:14
Definition: serial.hpp:94
boost::shared_ptr< spi_iface > sptr
Definition: serial.hpp:129
#define UHD_API
Definition: config.h:62
edge_t miso_edge
on what edge is the miso data valid?
Definition: serial.hpp:108
Definition: serial.hpp:183
boost::shared_ptr< uart_iface > sptr
Definition: serial.hpp:185
edge_t
Definition: serial.hpp:99
boost::shared_ptr< i2c_iface > sptr
Definition: serial.hpp:36
std::vector< uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition: byte_vector.hpp:22