commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r6020 - gnuradio/branches/developers/gnychis/inband/us


From: gnychis
Subject: [Commit-gnuradio] r6020 - gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband
Date: Wed, 18 Jul 2007 15:20:27 -0600 (MDT)

Author: gnychis
Date: 2007-07-18 15:20:27 -0600 (Wed, 18 Jul 2007)
New Revision: 6020

Modified:
   
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
Log:
Ability to create C/S subpacket for SPI read's


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:15:18 UTC (rev 6019)
+++ 
gnuradio/branches/developers/gnychis/inband/usrp/host/lib/inband/usrp_inband_usb_packet.h
   2007-07-18 21:20:27 UTC (rev 6020)
@@ -127,8 +127,9 @@
   static const int CS_SPIENABLES_MASK = 0xff;
   static const int CS_SPIENABLES_SHIFT = 24;
   static const int CS_SPIREAD_LEN = 7;
+  static const int CS_SPINBYTES_MASK = 0xff;
+  static const int CS_SPINBYTES_SHIFT = 24;
 
-
 public:
   
   void set_timestamp(uint32_t timestamp){
@@ -644,6 +645,60 @@
     return true;
   }
 
+  bool cs_spi_read(long rid, long enables, long format, long opt_header_bytes, 
long n_bytes)
+  {
+    if(!align32())
+      return false;
+
+    int p_len = payload_len();
+
+    if((MAX_PAYLOAD - p_len) < (CS_SPIREAD_LEN + CS_FIXED_LEN))
+      return false;
+
+    uint32_t word = 0;
+
+    // First word contains the opcode, length, and RID
+    word = (
+        ((OP_SPI_READ & CS_OPCODE_MASK) << CS_OPCODE_SHIFT)
+      | ((CS_SPIREAD_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);
+
+    payload += 1;
+
+    // Second word contains the enables, format, and optional tx bytes
+    word = 0;
+    word = (
+        ((enables & CS_SPIENABLES_MASK) << CS_SPIENABLES_SHIFT)
+      | ((format & CS_SPIFORMAT_MASK) << CS_SPIFORMAT_SHIFT)
+      | ((opt_header_bytes & CS_SPIOPT_MASK) << CS_SPIOPT_SHIFT)
+      );
+    payload = (uint32_t *) (d_payload + p_len);
+    *payload = host_to_usrp_u32(word);
+
+    payload += 1;
+
+    // The third word contains the number of bytes
+    word = 0;
+    word = (
+        ((n_bytes & CS_SPINBYTES_MASK) << CS_SPINBYTES_SHIFT)
+      );
+    payload = (uint32_t *) (d_payload + p_len);
+    *payload = host_to_usrp_u32(word);
+
+    // Update payload length
+    int h_flags = flags();
+    int h_chan = chan();
+    int h_tag = tag();
+    int h_payload_len = payload_len() + CS_FIXED_LEN + CS_SPIREAD_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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]