3 * Copyright 2004,2006,2009,2010 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
27 #include <usrp_sink_s.h>
28 #include <gr_io_signature.h>
29 #include <usrp/usrp_standard.h>
30 #include <usrp/usrp_bytesex.h>
33 usrp_make_sink_s (int which_board,
34 unsigned int interp_rate,
39 const std::string fpga_filename,
40 const std::string firmware_filename
41 ) throw (std::runtime_error)
43 return gnuradio::get_initial_sptr(new usrp_sink_s (which_board,
55 usrp_sink_s::usrp_sink_s (int which_board,
56 unsigned int interp_rate,
61 const std::string fpga_filename,
62 const std::string firmware_filename
63 ) throw (std::runtime_error)
64 : usrp_sink_base ("usrp_sink_s",
65 gr_make_io_signature (1, 1, sizeof (short)),
66 which_board, interp_rate, nchan, mux,
67 fusb_block_size, fusb_nblocks,
68 fpga_filename, firmware_filename)
70 set_output_multiple (512 / sizeof(short)); // don't change
73 usrp_sink_s::~usrp_sink_s ()
79 * Take one short input stream and format it into interleaved short I & Q
83 usrp_sink_s::copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
85 int input_items_available,
86 int &input_items_consumed, // out
88 int usrp_buffer_length,
89 int &bytes_written) // out
91 short *in = &((short *) input_items[0])[input_index];
92 short *dst = (short *) usrp_buffer;
94 static const int usrp_bytes_per_input_item = sizeof (short);
96 int nitems = std::min (input_items_available,
97 usrp_buffer_length / usrp_bytes_per_input_item);
99 for (int i = 0; i < nitems; i++){ // FIXME unroll
100 dst[i] = host_to_usrp_short(in[i]);
103 input_items_consumed = nitems;
104 bytes_written = nitems * usrp_bytes_per_input_item;