UHD 003.004.003-0-unknown

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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/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
45 class UHD_API i2c_iface{
46 public:
47 typedef boost::shared_ptr<i2c_iface> sptr;
48
54 virtual void write_i2c(
55 boost::uint8_t addr,
56 const byte_vector_t &buf
57 ) = 0;
58
65 virtual byte_vector_t read_i2c(
66 boost::uint8_t addr,
67 size_t num_bytes
68 ) = 0;
69
76 virtual void write_eeprom(
77 boost::uint8_t addr,
78 boost::uint8_t offset,
79 const byte_vector_t &buf
80 );
81
89 virtual byte_vector_t read_eeprom(
90 boost::uint8_t addr,
91 boost::uint8_t offset,
92 size_t num_bytes
93 );
94 };
95
100 struct UHD_API spi_config_t{
105 enum edge_t{
106 EDGE_RISE = 'r',
107 EDGE_FALL = 'f'
108 };
109
111 edge_t mosi_edge;
112
114 edge_t miso_edge;
115
120 spi_config_t(edge_t edge = EDGE_RISE);
121 };
122
127 class UHD_API spi_iface{
128 public:
129 typedef boost::shared_ptr<spi_iface> sptr;
130
140 virtual boost::uint32_t transact_spi(
141 int which_slave,
142 const spi_config_t &config,
143 boost::uint32_t data,
144 size_t num_bits,
145 bool readback
146 ) = 0;
147
156 virtual boost::uint32_t read_spi(
157 int which_slave,
158 const spi_config_t &config,
159 boost::uint32_t data,
160 size_t num_bits
161 );
162
170 virtual void write_spi(
171 int which_slave,
172 const spi_config_t &config,
173 boost::uint32_t data,
174 size_t num_bits
175 );
176 };
177
181 class UHD_API uart_iface{
182 public:
183 typedef boost::shared_ptr<uart_iface> sptr;
184
189 virtual void write_uart(const std::string &buf) = 0;
190
197 virtual std::string read_uart(double timeout) = 0;
198 };
199
200 } //namespace uhd
201
202 #endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */