summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/examples/rx_timed_samples.cpp6
-rw-r--r--host/examples/tx_timed_samples.cpp9
-rw-r--r--host/include/linux/usrp_e.h88
-rw-r--r--host/lib/transport/convert_types_impl.hpp5
4 files changed, 98 insertions, 10 deletions
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index 5fbf8b6c5..4856f6779 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -85,12 +85,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//loop until total number of samples reached
size_t num_acc_samps = 0; //number of accumulated samples
- uhd::rx_metadata_t md;
- std::vector<std::complex<short> > buff(dev->get_max_recv_samps_per_packet());
while(num_acc_samps < total_num_samps){
+ uhd::rx_metadata_t md;
+ std::vector<std::complex<float> > buff(dev->get_max_recv_samps_per_packet());
size_t num_rx_samps = dev->recv(
&buff.front(), buff.size(), md,
- uhd::io_type_t::COMPLEX_INT16,
+ uhd::io_type_t::COMPLEX_FLOAT32,
uhd::device::RECV_MODE_ONE_PACKET
);
diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp
index f7d7ea2ca..5b72bd72f 100644
--- a/host/examples/tx_timed_samples.cpp
+++ b/host/examples/tx_timed_samples.cpp
@@ -35,7 +35,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
size_t samps_per_packet;
double tx_rate, freq;
float ampl;
- float tx_gain;
//setup the program options
po::options_description desc("Allowed options");
@@ -48,7 +47,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("txrate", po::value<double>(&tx_rate)->default_value(100e6/16), "rate of outgoing samples")
("freq", po::value<double>(&freq)->default_value(0), "rf center frequency in Hz")
("ampl", po::value<float>(&ampl)->default_value(float(0.3)), "amplitude of each sample")
- ("gain", po::value<float>(&tx_gain)->default_value(float(0)), "TX Gain setting")
("dilv", "specify to disable inner-loop verbose")
;
po::variables_map vm;
@@ -77,16 +75,15 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << boost::format("Setting device timestamp to 0...") << std::endl;
sdev->set_tx_freq(freq);
sdev->set_time_now(uhd::time_spec_t(0.0));
- sdev->set_tx_gain(tx_gain);
//allocate data to send
- std::vector<std::complex<short> > buff(samps_per_packet, std::complex<short>(ampl, ampl));
- uhd::tx_metadata_t md;
+ std::vector<std::complex<float> > buff(samps_per_packet, std::complex<float>(ampl, ampl));
//send the data in multiple packets
size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet;
for (size_t i = 0; i < num_packets; i++){
//setup the metadata flags and time spec
+ uhd::tx_metadata_t md;
md.start_of_burst = true; //always SOB (good for continuous streaming)
md.end_of_burst = (i == num_packets-1); //only last packet has EOB
md.has_time_spec = (i == 0); //only first packet has time
@@ -97,7 +94,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//send the entire packet (driver fragments internally)
size_t num_tx_samps = dev->send(
&buff.front(), samps_to_send, md,
- uhd::io_type_t::COMPLEX_INT16,
+ uhd::io_type_t::COMPLEX_FLOAT32,
uhd::device::SEND_MODE_FULL_BUFF
);
if(verbose) std::cout << std::endl << boost::format("Sent %d samples") % num_tx_samps << std::endl;
diff --git a/host/include/linux/usrp_e.h b/host/include/linux/usrp_e.h
new file mode 100644
index 000000000..b098ad114
--- /dev/null
+++ b/host/include/linux/usrp_e.h
@@ -0,0 +1,88 @@
+
+/*
+ * Copyright (C) 2010 Ettus Research, LLC
+ *
+ * Written by Philip Balister <philip@opensdr.com>
+ *
+ * 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 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __USRP_E_H
+#define __USRP_E_H
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+struct usrp_e_ctl16 {
+ __u32 offset;
+ __u32 count;
+ __u16 buf[20];
+};
+
+struct usrp_e_ctl32 {
+ __u32 offset;
+ __u32 count;
+ __u32 buf[10];
+};
+
+/* SPI interface */
+
+#define UE_SPI_TXONLY 0
+#define UE_SPI_TXRX 1
+
+/* Defines for spi ctrl register */
+#define UE_SPI_CTRL_TXNEG (1 << 10)
+#define UE_SPI_CTRL_RXNEG (1 << 9)
+
+#define UE_SPI_PUSH_RISE 0
+#define UE_SPI_PUSH_FALL UE_SPI_CTRL_TXNEG
+#define UE_SPI_LATCH_RISE 0
+#define UE_SPI_LATCH_FALL UE_SPI_CTRL_RXNEG
+
+struct usrp_e_spi {
+ __u8 readback;
+ __u32 slave;
+ __u32 data;
+ __u32 length;
+ __u32 flags;
+};
+
+struct usrp_e_i2c {
+ __u8 addr;
+ __u32 len;
+ __u8 data[];
+};
+
+#define USRP_E_IOC_MAGIC 'u'
+#define USRP_E_WRITE_CTL16 _IOW(USRP_E_IOC_MAGIC, 0x20, struct usrp_e_ctl16)
+#define USRP_E_READ_CTL16 _IOWR(USRP_E_IOC_MAGIC, 0x21, struct usrp_e_ctl16)
+#define USRP_E_WRITE_CTL32 _IOW(USRP_E_IOC_MAGIC, 0x22, struct usrp_e_ctl32)
+#define USRP_E_READ_CTL32 _IOWR(USRP_E_IOC_MAGIC, 0x23, struct usrp_e_ctl32)
+#define USRP_E_SPI _IOWR(USRP_E_IOC_MAGIC, 0x24, struct usrp_e_spi)
+#define USRP_E_I2C_READ _IOWR(USRP_E_IOC_MAGIC, 0x25, struct usrp_e_i2c)
+#define USRP_E_I2C_WRITE _IOW(USRP_E_IOC_MAGIC, 0x26, struct usrp_e_i2c)
+
+/* Data transfer frame definition */
+
+struct usrp_transfer_frame {
+ __u32 status;
+ __u32 len;
+ __u8 buf[];
+};
+
+/* Flag defines */
+#define RB_USER (1 << 0)
+#define RB_KERNEL (1 << 1)
+#define RB_OVERRUN (1 << 2)
+#define RB_DMA_ACTIVE (1 << 3)
+
+struct ring_buffer_entry {
+ unsigned int flags;
+ unsigned long dma_addr;
+ struct usrp_transfer_frame *frame_addr;
+};
+
+#endif
diff --git a/host/lib/transport/convert_types_impl.hpp b/host/lib/transport/convert_types_impl.hpp
index 6cfc8fed6..04e6fc81a 100644
--- a/host/lib/transport/convert_types_impl.hpp
+++ b/host/lib/transport/convert_types_impl.hpp
@@ -150,13 +150,16 @@ static UHD_INLINE void fc32_to_item32_nswap(
size_t i;
float32x4_t Q0 = vdupq_n_f32(shorts_per_float);
- for (i=0; i < (nsamps & ~0x03); i+=4) {
+ for (i=0; i < (nsamps & ~0x03); i+=2) {
float32x4_t Q1 = vld1q_f32(reinterpret_cast<const float *>(&input[i]));
float32x4_t Q2 = vmulq_f32(Q1, Q0);
int32x4_t Q3 = vcvtq_s32_f32(Q2);
int16x4_t D8 = vmovn_s32(Q3);
vst1_s16((reinterpret_cast<int16_t *>(&output[i])), D8);
}
+
+ for (; i < nsamps; i++)
+ output[i] = fc32_to_item32(input[i]);
}
#else