All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
serial.hpp
Go to the documentation of this file.
//
// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef INCLUDED_UHD_TYPES_SERIAL_HPP
#define INCLUDED_UHD_TYPES_SERIAL_HPP
#include <uhd/config.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/cstdint.hpp>
#include <vector>
namespace uhd{
typedef std::vector<boost::uint8_t> byte_vector_t;
class UHD_API i2c_iface{
public:
typedef boost::shared_ptr<i2c_iface> sptr;
virtual void write_i2c(
boost::uint8_t addr,
const byte_vector_t &buf
) = 0;
virtual byte_vector_t read_i2c(
boost::uint8_t addr,
size_t num_bytes
) = 0;
virtual void write_eeprom(
boost::uint8_t addr,
boost::uint8_t offset,
const byte_vector_t &buf
);
virtual byte_vector_t read_eeprom(
boost::uint8_t addr,
boost::uint8_t offset,
size_t num_bytes
);
};
struct UHD_API spi_config_t{
enum edge_t{
EDGE_RISE = 'r',
EDGE_FALL = 'f'
};
edge_t mosi_edge;
edge_t miso_edge;
spi_config_t(edge_t edge = EDGE_RISE);
};
class UHD_API spi_iface{
public:
typedef boost::shared_ptr<spi_iface> sptr;
virtual boost::uint32_t transact_spi(
int which_slave,
const spi_config_t &config,
boost::uint32_t data,
size_t num_bits,
bool readback
) = 0;
virtual boost::uint32_t read_spi(
int which_slave,
const spi_config_t &config,
boost::uint32_t data,
size_t num_bits
);
virtual void write_spi(
int which_slave,
const spi_config_t &config,
boost::uint32_t data,
size_t num_bits
);
};
class UHD_API uart_iface{
public:
typedef boost::shared_ptr<uart_iface> sptr;
virtual void write_uart(const std::string &buf) = 0;
virtual std::string read_uart(double timeout) = 0;
};
} //namespace uhd
#endif /* INCLUDED_UHD_TYPES_SERIAL_HPP */