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