From c7274790a0b8a812d731320c2b7711efa2e1daa7 Mon Sep 17 00:00:00 2001 From: Ashish Chaudhari Date: Fri, 1 Aug 2014 13:14:56 -0700 Subject: b200: Moved AD9361 driver to host - Switched to FPGA SPI engine - Moved firmware AD9361 driver to UHD - Bumped FW compat to 5, FPGA compat to 4 - Known Issue: AD9361 SPI rate is too slow --- host/lib/usrp/common/ad9361_platform_uhd.cpp | 86 ++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 host/lib/usrp/common/ad9361_platform_uhd.cpp (limited to 'host/lib/usrp/common/ad9361_platform_uhd.cpp') diff --git a/host/lib/usrp/common/ad9361_platform_uhd.cpp b/host/lib/usrp/common/ad9361_platform_uhd.cpp new file mode 100644 index 000000000..10ea67345 --- /dev/null +++ b/host/lib/usrp/common/ad9361_platform_uhd.cpp @@ -0,0 +1,86 @@ +// +// Copyright 2014 Ettus Research LLC +// + +#include +#include +#include +#include +#include +#include +#include "ad9361_ctrl.hpp" +#include +#include +#include + +//If the platform for the AD9361 driver is UHD (host) then the handle is simply +//a pointer to a device class instance +ad9361_device_t* get_ad9361_device(uint64_t handle) +{ + return reinterpret_cast(reinterpret_cast(handle)); +} + +uint8_t read_ad9361_reg(ad9361_device_t* device, uint32_t reg) +{ + if (device && device->io_iface) { + //If the platform for the AD9361 driver is UHD (host) then the io_iface is + //a pointer to a ad9361_io implementation + ad9361_io* io_iface = reinterpret_cast(device->io_iface); + return io_iface->peek8(reg); + } else { + return 0; + } +} + +void write_ad9361_reg(ad9361_device_t* device, uint32_t reg, uint8_t val) +{ + if (device && device->io_iface) { + //If the platform for the AD9361 driver is UHD (host) then the io_iface is + //a pointer to a ad9361_io implementation + ad9361_io* io_iface = reinterpret_cast(device->io_iface); + io_iface->poke8(reg, val); + } +} + +typedef union +{ + double d; + uint32_t x[2]; +} ad9361_double_union_t; + +void ad9361_double_pack(const double input, uint32_t output[2]) +{ + ad9361_double_union_t p = {}; + p.d = input; + output[0] = p.x[0]; + output[1] = p.x[1]; +} + +double ad9361_double_unpack(const uint32_t input[2]) +{ + ad9361_double_union_t p = {}; + p.x[0] = input[0]; + p.x[1] = input[1]; + return p.d; +} + +double ad9361_sqrt(double val) +{ + return std::sqrt(val); +} + +void ad9361_msleep(const uint32_t millis) +{ + boost::this_thread::sleep(boost::posix_time::milliseconds(millis)); +} + +int ad9361_floor_to_int(double val) +{ + return static_cast(std::floor(val)); +} + +int ad9361_ceil_to_int(double val) +{ + return static_cast(std::ceil(val)); +} + -- cgit v1.2.3