[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6022 - gnuradio/branches/developers/gnychis/inband/us
From: |
gnychis |
Subject: |
[Commit-gnuradio] r6022 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband |
Date: |
Wed, 18 Jul 2007 16:06:15 -0600 (MDT) |
Author: gnychis
Date: 2007-07-18 16:06:15 -0600 (Wed, 18 Jul 2007)
New Revision: 6022
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
Log:
Adding functionality to generate SPI read reply subpackets.
USRP server now parses SPI reads and tracks the RID.
TX stub also parses SPI reads and generates a dummy SPI read response and places
it in the CS response queue for the RX stub to read.
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
2007-07-18 21:46:01 UTC (rev 6021)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
2007-07-18 22:06:15 UTC (rev 6022)
@@ -699,6 +699,44 @@
return true;
}
+ bool cs_spi_read_reply(long rid, uint8_t *spi_data, long spi_data_len)
+ {
+ if(!align32())
+ return false;
+
+ int p_len = payload_len();
+
+ int spi_len = spi_data_len + 2;
+
+ if((MAX_PAYLOAD - p_len) < (spi_len + CS_FIXED_LEN))
+ return false;
+
+ uint32_t word = 0;
+
+ // First word contains the opcode, length, and RID
+ word = (
+ ((OP_SPI_READ_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+ | ((spi_len & CS_LEN_MASK) << CS_LEN_SHIFT)
+ | ((rid & CS_RID_MASK) << CS_RID_SHIFT)
+ );
+ uint32_t *payload = (uint32_t *) (d_payload + p_len);
+ *payload = host_to_usrp_u32(word);
+
+ // Jump a word and write the actual data
+ payload += 1;
+ memcpy(payload, spi_data, spi_data_len);
+
+ // Update payload length
+ int h_flags = flags();
+ int h_chan = chan();
+ int h_tag = tag();
+ int h_payload_len = payload_len() + CS_FIXED_LEN + spi_len;
+
+ set_header(h_flags, h_chan, h_tag, h_payload_len);
+
+ return true;
+ }
+
// The following method takes an offset within the packet payload to extract
// a control/status subpacket and construct a pmt response which includes the
// proper signal and arguments specified by usrp-low-level-cs. The USRP
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-07-18 21:46:01 UTC (rev 6021)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.cc
2007-07-18 22:06:15 UTC (rev 6022)
@@ -101,6 +101,7 @@
d_op_ping_fixed_rid = 0;
d_op_read_reg_rid = 0;
d_op_i2c_read_rid = 0;
+ d_op_spi_read_rid = 0;
for(int i=0; i < D_OP_PING_FIXED_MAX_RID; i++)
d_op_ping_fixed_owners.push_back(PMT_NIL);
@@ -110,6 +111,9 @@
for(int i=0; i < D_OP_I2C_READ_MAX_RID; i++)
d_op_i2c_read_owners.push_back(PMT_NIL);
+
+ for(int i=0; i < D_OP_SPI_READ_MAX_RID; i++)
+ d_op_spi_read_owners.push_back(PMT_NIL);
//d_fake_rx=true;
}
@@ -905,7 +909,38 @@
if(verbose)
std::cout << "[USRP_SERVER] Received SPI write\n";
}
+
+ //--------- SPI READ -----------//
+ if(pmt_eq(subp_cmd, s_op_spi_read)) {
+
+ // Generate an RID for the READ
+ long rid = d_op_spi_read_rid % D_OP_SPI_READ_MAX_RID;
+ d_op_spi_read_owners[rid] = port->port_symbol();
+
+ long enables = pmt_to_long(pmt_nth(1, subp_data));
+ long format = pmt_to_long(pmt_nth(2, subp_data));
+ long opt = pmt_to_long(pmt_nth(3, subp_data));
+ long n_bytes = pmt_to_long(pmt_nth(4, subp_data));
+ // Make the USB packet
+ if(!pkt->cs_spi_read(rid, enables, format, opt, n_bytes))
+ {
+ d_cs_usrp->send(s_cmd_usrp_write,
+ pmt_list3(invocation_handle,
+ pmt_from_long(channel),
+ v_packet));
+
+ // Return the rid
+ d_op_spi_read_owners[rid] = PMT_NIL;
+ d_op_spi_read_rid--;
+
+ goto new_packet;
+ }
+
+ if(verbose)
+ std::cout << "[USRP_SERVER] Received SPI read\n";
+ }
+
curr_subpkt++;
}
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-07-18 21:46:01 UTC (rev 6021)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_server.h
2007-07-18 22:06:15 UTC (rev 6022)
@@ -71,6 +71,9 @@
static const long D_OP_I2C_READ_MAX_RID = 64;
std::vector<pmt_t> d_op_i2c_read_owners;
+ long d_op_spi_read_rid;
+ static const long D_OP_SPI_READ_MAX_RID = 64;
+ std::vector<pmt_t> d_op_spi_read_owners;
struct channel_info {
long assigned_capacity; // the capacity currently assignedby the channel
Modified:
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
===================================================================
---
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
2007-07-18 21:46:01 UTC (rev 6021)
+++
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_tx_stub.cc
2007-07-18 22:06:15 UTC (rev 6022)
@@ -293,6 +293,35 @@
<< ")\n";
}
+ //---------------- SPI READ ------------------//
+ if(pmt_eq(op_symbol, s_op_spi_read)) {
+ long rid = pmt_to_long(pmt_nth(1, sub_packet));
+ long enables = pmt_to_long(pmt_nth(2, sub_packet));
+ long format = pmt_to_long(pmt_nth(3, sub_packet));
+ long opt = pmt_to_long(pmt_nth(4, sub_packet));
+ long n_bytes = pmt_to_long(pmt_nth(5, sub_packet));
+
+ // Create data to place as a fake response
+ size_t ignore;
+ pmt_t spi_data = pmt_make_u8vector(n_bytes, 0xff);
+ uint8_t *w_data = (uint8_t *) pmt_u8vector_writeable_elements(spi_data,
ignore);
+
+ // Generate a reply and put it in the queue for the RX stub to read
+ if(!q_pkt->cs_spi_read_reply(rid, w_data, n_bytes))
+ goto new_packet;
+
+ if(verbose)
+ std::cout << "[USRP_TX_STUB] Received spi read command "
+ << "("
+ << "RID: " << rid << ", "
+ << "Enables: " << enables << ", "
+ << "Format: " << format << ", "
+ << "Options: " << opt << ", "
+ << "Bytes: " << n_bytes
+ << ")\n";
+
+ }
+
// Each subpacket has an unaccounted for 2 bytes which is the opcode
// and the length field
curr_payload += len + 2;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6022 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband,
gnychis <=