USRP Hardware Driver and USRP Manual Version: 3.15.0.0-MacPorts-Release
UHD and USRP Manual
 
Loading...
Searching...
No Matches
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 <string>
15#include <vector>
16
17namespace uhd {
18
22typedef std::vector<uint8_t> byte_vector_t;
23
37{
38public:
39 typedef boost::shared_ptr<i2c_iface> sptr;
40
41 virtual ~i2c_iface(void);
42
45
51 virtual void write_i2c(uint16_t addr, const byte_vector_t& buf) = 0;
52
59 virtual byte_vector_t read_i2c(uint16_t addr, size_t num_bytes) = 0;
60
67 virtual void write_eeprom(uint16_t addr, uint16_t offset, const byte_vector_t& buf);
68
76 virtual byte_vector_t read_eeprom(uint16_t addr, uint16_t offset, size_t num_bytes);
77};
78
84{
89 enum edge_t { EDGE_RISE = 'r', EDGE_FALL = 'f' };
90
93
96
99
101 size_t divider;
102
107 spi_config_t(edge_t edge = EDGE_RISE);
108};
109
116{
117public:
118 typedef boost::shared_ptr<spi_iface> sptr;
119
120 virtual ~spi_iface(void);
121
131 virtual uint32_t transact_spi(int which_slave,
132 const spi_config_t& config,
133 uint32_t data,
134 size_t num_bits,
135 bool readback) = 0;
136
145 virtual uint32_t read_spi(
146 int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits);
147
155 virtual void write_spi(
156 int which_slave, const spi_config_t& config, uint32_t data, size_t num_bits);
157};
158
163{
164public:
165 typedef boost::shared_ptr<uart_iface> sptr;
166
167 virtual ~uart_iface(void);
168
173 virtual void write_uart(const std::string& buf) = 0;
174
180 virtual std::string read_uart(double timeout) = 0;
181};
182
183} // namespace uhd
184
185#endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */
Definition serial.hpp:37
virtual byte_vector_t read_i2c(uint16_t addr, size_t num_bytes)=0
boost::shared_ptr< i2c_iface > sptr
Definition serial.hpp:39
virtual byte_vector_t read_eeprom(uint16_t addr, uint16_t offset, size_t num_bytes)
virtual ~i2c_iface(void)
virtual void write_i2c(uint16_t addr, const byte_vector_t &buf)=0
i2c_iface::sptr eeprom16(void)
Create an i2c_iface than can talk to 16 bit addressable EEPROMS.
virtual void write_eeprom(uint16_t addr, uint16_t offset, const byte_vector_t &buf)
Definition serial.hpp:116
virtual ~spi_iface(void)
boost::shared_ptr< spi_iface > sptr
Definition serial.hpp:118
virtual uint32_t transact_spi(int which_slave, const spi_config_t &config, uint32_t data, size_t num_bits, bool readback)=0
virtual uint32_t read_spi(int which_slave, const spi_config_t &config, uint32_t data, size_t num_bits)
virtual void write_spi(int which_slave, const spi_config_t &config, uint32_t data, size_t num_bits)
Definition serial.hpp:163
virtual void write_uart(const std::string &buf)=0
virtual ~uart_iface(void)
virtual std::string read_uart(double timeout)=0
boost::shared_ptr< uart_iface > sptr
Definition serial.hpp:165
#define UHD_API
Definition config.h:68
Definition build_info.hpp:13
std::vector< uint8_t > byte_vector_t
Byte vector used for I2C data passing and EEPROM parsing.
Definition byte_vector.hpp:20
Definition serial.hpp:84
edge_t miso_edge
on what edge is the miso data valid?
Definition serial.hpp:95
spi_config_t(edge_t edge=EDGE_RISE)
edge_t
Definition serial.hpp:89
bool use_custom_divider
Set the clock speed for this transaction.
Definition serial.hpp:98
edge_t mosi_edge
on what edge is the mosi data valid?
Definition serial.hpp:92
size_t divider
Optionally set the SPI clock divider for this transaction.
Definition serial.hpp:101