Fix WBX tuning to allow DDC use in reaching 50MHz
[debian/gnuradio] / usrp2 / firmware / apps / serdes_txrx.c
index 8f28a84f16599c06d6ff38c12611c97189423b70..aa4a3f33cc3fed38bd89ec4e5933e9014de3b76d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007,2008 Free Software Foundation, Inc.
+ * Copyright 2007,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
@@ -124,11 +124,12 @@ static unsigned int streaming_items_per_frame = 0;
 static int          streaming_frame_count = 0;
 #define FRAMES_PER_CMD 1000
 
+bool is_streaming(void){ return streaming_p; }
 
 // ----------------------------------------------------------------
 
 
-static void
+void
 restart_streaming(void)
 {
   // setup RX DSP regs
@@ -151,7 +152,7 @@ restart_streaming(void)
   dsp_rx_regs->rx_command =
     MK_RX_CMD(FRAMES_PER_CMD * streaming_items_per_frame,
              streaming_items_per_frame,
-             1, 1);                            
+             1, 1);
 
   dsp_rx_regs->rx_time = 0;            // enqueue second command
 }
@@ -167,6 +168,7 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
   u2_eth_packet_t      pkt;
   memset(&pkt, 0, sizeof(pkt));
   pkt.ehdr.dst = *host;
+  pkt.ehdr.src = *ethernet_mac_addr();
   pkt.ehdr.ethertype = U2_ETHERTYPE;
   u2p_set_word0(&pkt.fixed, 0, 0);
   // DSP RX will fill in timestamp
@@ -182,6 +184,10 @@ start_rx_streaming_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p)
   restart_streaming();
 }
 
+void start_rx_streaming_at_cmd(const u2_mac_addr_t *host, op_start_rx_streaming_t *p, uint32_t time)
+{}
+void restart_streaming_at(uint32_t time)
+{}
 
 void
 stop_rx_cmd(void)
@@ -220,7 +226,7 @@ setup_tx()
  * that we didn't handle the packet.  A bit of a kludge
  * but it should work.
  */
-bool 
+bool
 fw_sets_seqno_inspector(dbsm_t *sm, int buf_this)      // returns false
 {
   uint32_t *p = buffer_ram(buf_this);
@@ -245,8 +251,15 @@ fw_sets_seqno_inspector(dbsm_t *sm, int buf_this)  // returns false
 inline static void
 buffer_irq_handler(unsigned irq)
 {
+  // hal_toggle_leds(LED_A);
+
   uint32_t  status = buffer_pool_status->status;
 
+  if (0 && (status & ~BPS_IDLE_ALL)){
+    putstr("status = ");
+    puthex32_nl(status);
+  }
+
   dbsm_process_status(&dsp_tx_sm, status);
   dbsm_process_status(&dsp_rx_sm, status);
 }
@@ -256,22 +269,27 @@ main(void)
 {
   u2_init();
 
+  output_regs->led_src = 0x3;          // h/w controls bottom two bits
+  clocks_enable_test_clk(true, 1);
+
   putstr("\nSERDES TxRx\n");
 
   cpu_tx_buf_dest_port = PORT_SERDES;
 
-  ethernet_register_link_changed_callback(link_changed_callback);
-  ethernet_init();
+  // ethernet_register_link_changed_callback(link_changed_callback);
+  // ethernet_init();
 
   clocks_mimo_config(MC_WE_LOCK_TO_MIMO);
 
+  // puts("post clocks_mimo_config");
+
 #if 0
   // make bit 15 of Tx gpio's be a s/w output
   hal_gpio_set_sel(GPIO_TX_BANK, 15, 's');
   hal_gpio_set_ddr(GPIO_TX_BANK, 0x8000, 0x8000);
 #endif
 
-#if 1
+#if 0
   output_regs->debug_mux_ctrl = 1;
   hal_gpio_set_sels(GPIO_TX_BANK, "0000000000000000");
   hal_gpio_set_sels(GPIO_RX_BANK, "0000000000000000");
@@ -287,6 +305,8 @@ main(void)
            eth_pkt_inspector);
 
 
+  //output_regs->flush_icache = 1;
+
   // initialize double buffering state machine for DSP RX -> Ethernet
 
   if (FW_SETS_SEQNO){
@@ -300,6 +320,8 @@ main(void)
              dbsm_nop_inspector);
   }
 
+  // puts("post dbsm_init's");
+
   // tell app_common that this dbsm could be sending to the ethernet
   ac_could_be_sending_to_eth = &dsp_rx_sm;
 
@@ -307,9 +329,13 @@ main(void)
   // program tx registers
   setup_tx();
 
+  // puts("post setup_tx");
+
   // kick off the state machine
   dbsm_start(&dsp_tx_sm);
 
+  // puts("post dbsm_start");
+
   //int which = 0;
 
   while(1){