UHD  003.001.002
serial.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2011 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/cstdint.hpp>
23 #include <vector>
24 
25 namespace uhd{
26 
30  typedef std::vector<boost::uint8_t> byte_vector_t;
31 
45  public:
51  virtual void write_i2c(
52  boost::uint8_t addr,
53  const byte_vector_t &buf
54  ) = 0;
55 
62  virtual byte_vector_t read_i2c(
63  boost::uint8_t addr,
64  size_t num_bytes
65  ) = 0;
66 
73  virtual void write_eeprom(
74  boost::uint8_t addr,
75  boost::uint8_t offset,
76  const byte_vector_t &buf
77  );
78 
86  virtual byte_vector_t read_eeprom(
87  boost::uint8_t addr,
88  boost::uint8_t offset,
89  size_t num_bytes
90  );
91  };
92 
102  enum edge_t{
103  EDGE_RISE = 'r',
104  EDGE_FALL = 'f'
105  };
106 
109 
112 
117  spi_config_t(edge_t edge = EDGE_RISE);
118  };
119 
125  public:
135  virtual boost::uint32_t transact_spi(
136  int which_slave,
137  const spi_config_t &config,
138  boost::uint32_t data,
139  size_t num_bits,
140  bool readback
141  ) = 0;
142 
151  virtual boost::uint32_t read_spi(
152  int which_slave,
153  const spi_config_t &config,
154  boost::uint32_t data,
155  size_t num_bits
156  );
157 
165  virtual void write_spi(
166  int which_slave,
167  const spi_config_t &config,
168  boost::uint32_t data,
169  size_t num_bits
170  );
171  };
172 
173 } //namespace uhd
174 
175 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */
Definition: serial.hpp:124
Definition: serial.hpp:44
edge_t mosi_edge
on what edge is the mosi data valid?
Definition: serial.hpp:108
#define UHD_API
Definition: config.hpp:76
Definition: convert.hpp:28
Definition: serial.hpp:97
std::vector< boost::uint8_t > byte_vector_t
Definition: serial.hpp:30
edge_t miso_edge
on what edge is the miso data valid?
Definition: serial.hpp:111
edge_t
Definition: serial.hpp:102