// // 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)); }