USRP Hardware Driver and USRP Manual  Version: 3.15.0.HEAD-0-g6563c537
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 <stdint.h>
13 #include <boost/shared_ptr.hpp>
14 #include <vector>
15 
16 namespace uhd {
17 
21 typedef std::vector<uint8_t> byte_vector_t;
22 
36 {
37 public:
38  typedef boost::shared_ptr<i2c_iface> sptr;
39 
40  virtual ~i2c_iface(void);
41 
43  i2c_iface::sptr eeprom16(void);
44 
50  virtual void write_i2c(uint16_t addr, const byte_vector_t& buf) = 0;
51 
58  virtual byte_vector_t read_i2c(uint16_t addr, size_t num_bytes) = 0;
59 
66  virtual void write_eeprom(uint16_t addr, uint16_t offset, const byte_vector_t& buf);
67 
75  virtual byte_vector_t read_eeprom(uint16_t addr, uint16_t offset, size_t num_bytes);
76 };
77 
83 {
88  enum edge_t { EDGE_RISE = 'r', EDGE_FALL = 'f' };
89 
92 
95 
98 
100  size_t divider;
101 
106  spi_config_t(edge_t edge = EDGE_RISE);
107 };
108 
115 {
116 public:
117  typedef boost::shared_ptr<spi_iface> sptr;
118 
119  virtual ~spi_iface(void);
120 
130  virtual uint32_t transact_spi(int which_slave,
131  const spi_config_t& config,
132  uint32_t data,
133  size_t num_bits,
134  bool readback) = 0;
135 
144  virtual uint32_t read_spi(
145  int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits);
146 
154  virtual void write_spi(
155  int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits);
156 };
157 
162 {
163 public:
164  typedef boost::shared_ptr<uart_iface> sptr;
165 
166  virtual ~uart_iface(void);
167 
172  virtual void write_uart(const std::string& buf) = 0;
173 
179  virtual std::string read_uart(double timeout) = 0;
180 };
181 
182 } // namespace uhd
183 
184 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */
size_t divider
Optionally set the SPI clock divider for this transaction.
Definition: serial.hpp:100
Definition: serial.hpp:114
Definition: serial.hpp:35
bool use_custom_divider
Set the clock speed for this transaction.
Definition: serial.hpp:97
edge_t mosi_edge
on what edge is the mosi data valid?
Definition: serial.hpp:91
Definition: build_info.hpp:13
Definition: serial.hpp:82
boost::shared_ptr< spi_iface > sptr
Definition: serial.hpp:117
#define UHD_API
Definition: config.h:68
edge_t miso_edge
on what edge is the miso data valid?
Definition: serial.hpp:94
Definition: serial.hpp:161
boost::shared_ptr< uart_iface > sptr
Definition: serial.hpp:164
edge_t
Definition: serial.hpp:88
boost::shared_ptr< i2c_iface > sptr
Definition: serial.hpp:38
std::vector< uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition: byte_vector.hpp:20