3 * Copyright 2004,2006 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 <usrp1_sink_c.h>
28 #include <gr_io_signature.h>
29 #include <usrp_standard.h>
30 #include <usrp_bytesex.h>
33 usrp1_make_sink_c (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 usrp1_sink_c_sptr (new usrp1_sink_c (which_board,
55 usrp1_sink_c::usrp1_sink_c (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 : usrp1_sink_base ("usrp1_sink_c",
65 gr_make_io_signature (1, 1, sizeof (gr_complex)),
66 which_board, interp_rate, nchan, mux,
67 fusb_block_size, fusb_nblocks,
68 fpga_filename, firmware_filename)
72 usrp1_sink_c::~usrp1_sink_c ()
78 * Take one complex input stream and format it into interleaved short I & Q
82 usrp1_sink_c::copy_to_usrp_buffer (gr_vector_const_void_star &input_items,
84 int input_items_available,
85 int &input_items_consumed, // out
87 int usrp_buffer_length,
88 int &bytes_written) // out
90 gr_complex *in = &((gr_complex *) input_items[0])[input_index];
91 short *dst = (short *) usrp_buffer;
93 static const int usrp_bytes_per_input_item = 2 * sizeof (short); // I & Q
95 int nitems = std::min (input_items_available,
96 usrp_buffer_length / usrp_bytes_per_input_item);
98 for (int i = 0; i < nitems; i++){
99 dst[2*i + 0] = host_to_usrp_short((short) real(in[i])); // FIXME saturate?
100 dst[2*i + 1] = host_to_usrp_short((short) imag(in[i])); // FIXME saturate?
103 input_items_consumed = nitems;
104 bytes_written = nitems * usrp_bytes_per_input_item;