Merge branch 'grc' from http://gnuradio.org/git/jblum.git into master
[debian/gnuradio] / usrp2 / host / lib / control.h
index 678f12e4b5ae4fed01ab0d09dd54855e30f97a8f..8769e4522f2e7dcfe38cba6170eef5065c0b1c36 100644 (file)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2009 Free Software Foundation, Inc.
  *
  * 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
 #ifndef INCLUDED_CONTROL_H
 #define INCLUDED_CONTROL_H
 
-#include <omnithread.h>
+#include <gnuradio/omnithread.h>
 #include <usrp2_eth_packet.h>
 
 namespace usrp2 {
+
+  struct op_generic_cmd {
+    u2_eth_packet_t h;
+    op_generic_t    op;
+    op_generic_t    eop;
+  };
+
   /*!
    * OP_CONFIG_RX_V2 command packet
    */
@@ -53,6 +60,13 @@ namespace usrp2 {
     op_generic_t      eop;
   };
 
+  struct op_config_mimo_cmd
+  {
+    u2_eth_packet_t   h;
+    op_config_mimo_t  op;
+    op_generic_t      eop;
+  };
+
   struct op_burn_mac_addr_cmd 
   {
     u2_eth_packet_t    h;
@@ -60,6 +74,43 @@ namespace usrp2 {
     op_generic_t       eop;
   };
 
+  struct op_dboard_info_cmd {
+    u2_eth_packet_t h;
+    op_generic_t    op;
+    op_generic_t    eop;
+  };
+
+  struct op_peek_cmd {
+    u2_eth_packet_t h;
+    op_peek_t       op;
+    op_generic_t    eop;
+  };
+
+  struct op_poke_cmd {
+    u2_eth_packet_t h;
+    op_poke_t       op;
+    // words to write go here
+    // eop must be dynamically written here
+  };
+
+  struct op_freq_cmd {
+    u2_eth_packet_t h;
+    op_freq_t       op;
+    op_generic_t    eop;
+  };
+
+  struct op_gpio_cmd {
+    u2_eth_packet_t h;
+    op_gpio_t       op;
+    op_generic_t    eop;
+  };
+
+  struct op_gpio_set_sels_cmd {
+    u2_eth_packet_t h;
+    op_gpio_set_sels_t op;
+    op_generic_t    eop;
+  };
+
   /*!
    * Control mechanism to allow API calls to block waiting for reply packets
    */    
@@ -67,10 +118,13 @@ namespace usrp2 {
   {
   private:
     unsigned int    d_rid;
-    omni_mutex      d_mutex;
-    omni_condition  d_cond;
     void           *d_buffer;
     size_t         d_len;
+    
+    // d_mutex is used with d_cond and also protects d_complete
+    omni_mutex      d_mutex;
+    omni_condition  d_cond;
+    bool           d_complete;
 
   public:  
     /*!
@@ -89,12 +143,12 @@ namespace usrp2 {
      * Returns: 1 = ok, reply packet in buffer
      *          0 = timeout
      */
-    int wait(double secs);
+    int wait_for_completion(double secs);
 
     /*!
      * Allows creating thread to resume after copying reply into buffer
      */
-    void signal();
+    void notify_completion();
 
     /*!
      * Retrieve pending reply ID