commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10312 - in gnuradio/branches/releases/3.2/usrp2/firmw


From: jcorgan
Subject: [Commit-gnuradio] r10312 - in gnuradio/branches/releases/3.2/usrp2/firmware: . apps config lib
Date: Tue, 27 Jan 2009 08:50:30 -0700 (MST)

Author: jcorgan
Date: 2009-01-27 08:50:29 -0700 (Tue, 27 Jan 2009)
New Revision: 10312

Added:
   gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.c
   gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.h
Modified:
   gnuradio/branches/releases/3.2/usrp2/firmware/Makefile.common
   gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_common_v2.c
   gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_passthru_v2.c
   gnuradio/branches/releases/3.2/usrp2/firmware/apps/eth_serdes.c
   gnuradio/branches/releases/3.2/usrp2/firmware/apps/serdes_txrx.c
   gnuradio/branches/releases/3.2/usrp2/firmware/config/grc_usrp2_firmware.m4
   gnuradio/branches/releases/3.2/usrp2/firmware/configure.gnu
   gnuradio/branches/releases/3.2/usrp2/firmware/lib/Makefile.am
   gnuradio/branches/releases/3.2/usrp2/firmware/lib/dbsm.c
   gnuradio/branches/releases/3.2/usrp2/firmware/lib/memory_map.h
   gnuradio/branches/releases/3.2/usrp2/firmware/lib/stdint.h
Log:
Merged r10291, r10292:10294, r10296 from trunk to release-3.2 branch

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/Makefile.common
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/Makefile.common       
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/Makefile.common       
2009-01-27 15:50:29 UTC (rev 10312)
@@ -23,7 +23,7 @@
 
 AM_CPPFLAGS = $(HAL_IO) $(STD_INCLUDES)
 
-STD_CFLAGS = -Wall -Werror-implicit-function-declaration -mxl-soft-div 
-msoft-float
+STD_CFLAGS = --std=gnu99 -Wall -Werror-implicit-function-declaration 
-mxl-soft-div -msoft-float
 
 AM_CFLAGS = $(STD_CFLAGS) -mxl-soft-mul -mxl-barrel-shift
 #AM_CFLAGS = $(STD_CFLAGS) -mxl-soft-mul -mxl-barrel-shift -mxl-gp-opt -G 16384
@@ -33,9 +33,10 @@
 #AM_LDFLAGS = -Wl,-T,$(LINKER_SCRIPT) -Wl,-defsym -Wl,_STACK_SIZE=1024
 #AM_LDFLAGS = -Wl,-T,$(LINKER_SCRIPT) -Wl,-Map -Wl,address@hidden
 #AM_LDFLAGS = -Wl,-T,$(LINKER_SCRIPT)
-#AM_LDFLAGS = -Wl,-Map -Wl,address@hidden -Wl,-defsym -Wl,_STACK_SIZE=2048
-AM_LDFLAGS = -Wl,-defsym -Wl,_STACK_SIZE=2048
+AM_LDFLAGS = -Wl,-Map -Wl,address@hidden -Wl,-defsym -Wl,_STACK_SIZE=3072
+#AM_LDFLAGS = -Wl,-defsym -Wl,_STACK_SIZE=2048
 
+
 %.bin : %
        mb-objcopy -O binary $< $@
 

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_common_v2.c
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_common_v2.c  
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_common_v2.c  
2009-01-27 15:50:29 UTC (rev 10312)
@@ -422,6 +422,8 @@
     const op_generic_t *gp = (const op_generic_t *) payload;
     subpktlen = 0;
 
+    // printf("\nopcode = %d\n", gp->opcode);
+
     switch(gp->opcode){
     case OP_EOP:               // end of subpackets
       goto end_of_subpackets;
@@ -568,7 +570,7 @@
 link_changed_callback(int speed)
 {
   link_is_up = speed != 0;
-  hal_set_leds(link_is_up ? 0x20 : 0x0, 0x20);
+  hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45);
   printf("\neth link changed: speed = %d\n", speed);
 }
 

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_passthru_v2.c
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_passthru_v2.c        
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/apps/app_passthru_v2.c        
2009-01-27 15:50:29 UTC (rev 10312)
@@ -153,6 +153,12 @@
       subpktlen = op_id_cmd(gp, reply_payload, reply_payload_space);
       handled_it = true;
       break;
+
+    default:
+      if (0){
+       printf("\npassing on %d\n", gp->opcode);
+      }
+      break;
     }
 
     int t = (gp->len + 3) & ~3;                // bump to a multiple of 4
@@ -239,6 +245,6 @@
 link_changed_callback(int speed)
 {
   link_is_up = speed != 0;
-  hal_set_leds(link_is_up ? 0x10 : 0x0, 0x10);
+  hal_set_leds(link_is_up ? LED_RJ45 : 0x0, LED_RJ45);
   printf("\neth link changed: speed = %d\n", speed);
 }

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/apps/eth_serdes.c
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/apps/eth_serdes.c     
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/apps/eth_serdes.c     
2009-01-27 15:50:29 UTC (rev 10312)
@@ -168,6 +168,9 @@
 {
   u2_init();
 
+  output_regs->led_src = 0x3;          // h/w controls bottom two bits
+  clocks_enable_test_clk(true, 1);
+
   putstr("\neth <-> serdes\n");
 
   ethernet_register_link_changed_callback(link_changed_callback);

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/apps/serdes_txrx.c
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/apps/serdes_txrx.c    
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/apps/serdes_txrx.c    
2009-01-27 15:50:29 UTC (rev 10312)
@@ -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
@@ -246,8 +246,15 @@
 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);
 }
@@ -257,22 +264,27 @@
 {
   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");
@@ -288,6 +300,8 @@
            eth_pkt_inspector);
 
 
+  //output_regs->flush_icache = 1;
+ 
   // initialize double buffering state machine for DSP RX -> Ethernet
 
   if (FW_SETS_SEQNO){
@@ -301,6 +315,8 @@
              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;
 
@@ -308,9 +324,13 @@
   // 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){

Modified: 
gnuradio/branches/releases/3.2/usrp2/firmware/config/grc_usrp2_firmware.m4
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/config/grc_usrp2_firmware.m4  
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/config/grc_usrp2_firmware.m4  
2009-01-27 15:50:29 UTC (rev 10312)
@@ -25,6 +25,7 @@
 
     AC_REQUIRE([AC_PROG_CC])
     AC_REQUIRE([AC_PROG_CPP])
+    AC_REQUIRE([AM_PROG_AS])
     AC_REQUIRE([AC_PROG_RANLIB])
 
 

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/configure.gnu
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/configure.gnu 2009-01-27 
15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/configure.gnu 2009-01-27 
15:50:29 UTC (rev 10312)
@@ -3,7 +3,7 @@
 # wrapper to setup cross-compilation of firmware
 #
 
-for v in CC CPP CXX AR NM RANLIB STRIP F77 CFLAGS CXXFLAGS CPPFLAGS LDFLAGS 
+for v in CC CPP CXX AS AR NM RANLIB STRIP F77 CFLAGS CXXFLAGS CPPFLAGS LDFLAGS 
 do
   unset $v
 done
@@ -13,9 +13,10 @@
 do
   case "$t" in
       (CC=*)       ;;
-      (CPP=*)       ;;
+      (CPP=*)      ;;
       (CXX=*)      ;;
       (AR=*)       ;;
+      (AS=*)       ;;
       (NM=*)       ;;
       (RANLIB=*)   ;;
       (STRIP=*)    ;;

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/lib/Makefile.am
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/lib/Makefile.am       
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/lib/Makefile.am       
2009-01-27 15:50:29 UTC (rev 10312)
@@ -25,6 +25,7 @@
        abort.c \
        ad9510.c \
        ad9777.c \
+       bsm12.c \
        buffer_pool.c \
        clocks.c \
        db_basic.c \
@@ -62,6 +63,7 @@
        ad9777.h \
        ad9777_regs.h \
        bool.h \
+       bsm12.h \
        buffer_pool.h \
        clocks.h \
        db.h \
@@ -90,6 +92,6 @@
        u2_init.h \
        usrp2_bytesex.h \
         wb16550.h
-        
+
 EXTRA_DIST = \
         microblaze.ld

Copied: gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.c (from rev 
10294, gnuradio/trunk/usrp2/firmware/lib/bsm12.c)
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.c                   
        (rev 0)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.c   2009-01-27 
15:50:29 UTC (rev 10312)
@@ -0,0 +1,319 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * buffer state machine: 1 input to two outputs
+ *
+ * Typically used to read packets from the ethernet and then after inspecting,
+ * handle the packet in firmware or pass it on to 1 of the 2 buffer 
destinations.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "bsm12.h"
+#include "memory_map.h"
+#include "buffer_pool.h"
+#include "bool.h"
+#include "nonstdio.h"
+#include <stdlib.h>
+
+typedef enum {
+  BS_EMPTY,
+  BS_FILLING,
+  BS_FULL,
+  BS_EMPTYING,
+} buffer_state_t;
+
+static buffer_state_t buffer_state[NBUFFERS];
+static uint32_t last_send_ctrl[NBUFFERS];
+static int8_t  buffer_target[NBUFFERS];            // -1, 0 or 1.
+static uint8_t buffer_dst[NBUFFERS];       // 0 or 1. Valid only when 
BF_EMPTYING
+
+#define ST_IDLE (-1)
+
+void
+bsm12_init(bsm12_t *sm, int buf0,
+          const buf_cmd_args_t *recv,
+          const buf_cmd_args_t *send0,
+          const buf_cmd_args_t *send1,
+          bsm12_inspector_t inspect)
+{
+  if (buf0 & 0x3)      // precondition: buf0 % 4 == 0
+    abort();
+
+  sm->buf0 = buf0;
+  sm->running = false;
+  sm->recv_args = *recv;
+  sm->send_args[0] = *send0;
+  sm->send_args[1] = *send1;
+
+  sm->rx_state = ST_IDLE;
+  sm->tx_state[0] = ST_IDLE;
+  sm->tx_state[1] = ST_IDLE;
+
+  sm->inspect = inspect;
+
+  sm->bps_error = BPS_ERROR(buf0 + 0) | BPS_ERROR(buf0 + 1) | BPS_ERROR(buf0 + 
2);
+  sm->bps_done  = BPS_DONE(buf0 + 0)  | BPS_DONE(buf0 + 1)  | BPS_DONE(buf0 + 
2);
+  sm->bps_error_or_done = sm->bps_error | sm->bps_done;
+
+  // How much to adjust the last_line register.
+  // It's 1 for everything but the ethernet.
+  sm->last_line_adj = recv->port == PORT_ETH ? 3 : 1;
+
+  buffer_state[sm->buf0 + 0] = BS_EMPTY;
+  buffer_state[sm->buf0 + 1] = BS_EMPTY;
+  buffer_state[sm->buf0 + 2] = BS_EMPTY;
+
+  buffer_target[sm->buf0 + 0] = -1;
+  buffer_target[sm->buf0 + 1] = -1;
+  buffer_target[sm->buf0 + 2] = -1;
+
+  for (int i = 0; i < NBUFFERS; i++)
+    sm->next_buf[i] = buf0;
+
+  sm->next_buf[buf0 + 0] = buf0 + 1;
+  sm->next_buf[buf0 + 1] = buf0 + 2;
+  sm->next_buf[buf0 + 2] = buf0 + 0;
+
+  for (int i = 0; i < 3; i++){
+    sm->precomputed_receive_to_buf_ctrl_word[i] =
+      (BPC_READ
+       | BPC_BUFFER(sm->buf0 + i)
+       | BPC_PORT(sm->recv_args.port)
+       | BPC_STEP(1)
+       | BPC_FIRST_LINE(sm->recv_args.first_line)
+       | BPC_LAST_LINE(sm->recv_args.last_line));
+    
+    for (int j = 0; j < 2; j++){
+      sm->precomputed_send_from_buf_ctrl_word[i][j] =
+       (BPC_WRITE
+        | BPC_BUFFER(sm->buf0 + i)
+        | BPC_PORT(sm->send_args[j].port)
+        | BPC_STEP(1)
+        | BPC_FIRST_LINE(sm->send_args[j].first_line)
+        | BPC_LAST_LINE(0));           // last line filled in at runtime
+    }
+  }
+}
+
+static inline void
+bsm12_receive_to_buf(bsm12_t *sm, int bufno)
+{
+  buffer_pool_ctrl->ctrl = sm->precomputed_receive_to_buf_ctrl_word[bufno & 
0x3];
+}
+
+static inline void
+bsm12_send_from_buf(bsm12_t *sm, int bufno, int dst_idx)
+{
+  dst_idx &= 0x1;
+
+  uint32_t t = 
+    (sm->precomputed_send_from_buf_ctrl_word[bufno & 0x3][dst_idx]
+     | BPC_LAST_LINE(buffer_pool_status->last_line[bufno] - 
sm->last_line_adj));
+
+  buffer_pool_ctrl->ctrl = t;
+  last_send_ctrl[bufno] = t;
+  buffer_dst[bufno] = dst_idx;
+}
+
+static inline void
+bsm12_resend_from_buf(bsm12_t *sm, int bufno)
+{
+  buffer_pool_ctrl->ctrl = last_send_ctrl[bufno];
+}
+
+void
+bsm12_start(bsm12_t *sm)
+{
+  sm->running = true;
+
+  buffer_state[sm->buf0 + 0] = BS_EMPTY;
+  buffer_state[sm->buf0 + 1] = BS_EMPTY;
+  buffer_state[sm->buf0 + 2] = BS_EMPTY;
+
+  buffer_target[sm->buf0 + 0] = -1;
+  buffer_target[sm->buf0 + 1] = -1;
+  buffer_target[sm->buf0 + 2] = -1;
+
+  bp_clear_buf(sm->buf0 + 0);
+  bp_clear_buf(sm->buf0 + 1);
+  bp_clear_buf(sm->buf0 + 2);
+
+  sm->rx_state = 0;
+  sm->tx_state[0] = ST_IDLE;
+  sm->tx_state[1] = ST_IDLE;
+  bsm12_receive_to_buf(sm, sm->buf0);
+  buffer_state[sm->buf0] = BS_FILLING;
+}
+
+void
+bsm12_stop(bsm12_t *sm)
+{
+  sm->running = false;
+  bp_clear_buf(sm->buf0 + 0);
+  bp_clear_buf(sm->buf0 + 1);
+  bp_clear_buf(sm->buf0 + 2);
+  buffer_state[sm->buf0 + 0] = BS_EMPTY;
+  buffer_state[sm->buf0 + 1] = BS_EMPTY;
+  buffer_state[sm->buf0 + 2] = BS_EMPTY;
+}
+
+static void bsm12_process_helper(bsm12_t *sm, int buf_this);
+static void bsm12_error_helper(bsm12_t *sm, int buf_this);
+
+void
+bsm12_process_status(bsm12_t *sm, uint32_t status)
+{
+  // anything for us?
+  if ((status & sm->bps_error_or_done) == 0 || !sm->running)
+    return;
+
+  if (status & sm->bps_error){
+    // Most likely an ethernet Rx error.  We just restart the transfer.
+    if (status & (BPS_ERROR(sm->buf0 + 0)))
+      bsm12_error_helper(sm, sm->buf0 + 0);
+
+    if (status & (BPS_ERROR(sm->buf0 + 1)))
+      bsm12_error_helper(sm, sm->buf0 + 1);
+
+    if (status & (BPS_ERROR(sm->buf0 + 2)))
+      bsm12_error_helper(sm, sm->buf0 + 2);
+  }
+
+  if (status & BPS_DONE(sm->buf0 + 0))
+    bsm12_process_helper(sm, sm->buf0 + 0);
+
+  if (status & BPS_DONE(sm->buf0 + 1))
+    bsm12_process_helper(sm, sm->buf0 + 1);
+
+  if (status & BPS_DONE(sm->buf0 + 2))
+    bsm12_process_helper(sm, sm->buf0 + 2);
+}
+
+static void 
+bsm12_process_helper(bsm12_t *sm, int buf_this)
+{
+  bp_clear_buf(buf_this);
+
+  if (buffer_state[buf_this] == BS_FILLING){
+
+    buffer_state[buf_this] = BS_FULL;
+    buffer_target[buf_this] = -1;
+
+    //
+    // where does this packet go?
+    //
+    int dst = sm->inspect(sm, buf_this);
+    if (dst == -1){
+      //
+      // f/w handled the packet; refill the buffer
+      //
+      bsm12_receive_to_buf(sm, buf_this);
+      buffer_state[buf_this] = BS_FILLING;
+      buffer_target[buf_this] = -1;
+      sm->rx_state = buf_this & 0x3;
+    }
+    else {     // goes to dst 0 or 1
+      //
+      // If the next buffer is empty, start a receive on it
+      //
+      int t = sm->next_buf[buf_this];
+      if (buffer_state[t] == BS_EMPTY){
+       bsm12_receive_to_buf(sm, t);
+       buffer_state[t] = BS_FILLING;
+       buffer_target[t] = -1;
+       sm->rx_state = t & 0x3;
+      }
+      else
+       sm->rx_state = ST_IDLE;
+
+      //
+      // If the destination is idle, start the xfer, othewise remember it
+      //
+      if (sm->tx_state[dst] == ST_IDLE){
+       bsm12_send_from_buf(sm, buf_this, dst);
+       sm->tx_state[dst] = buf_this & 0x3;
+       buffer_state[buf_this] = BS_EMPTYING;
+       buffer_target[buf_this] = -1;
+      }
+      else {
+       buffer_target[buf_this] = dst;
+      }
+    }
+  }
+
+  else {    // BS_EMPTYING
+
+    buffer_state[buf_this] = BS_EMPTY;
+    buffer_target[buf_this] = -1;
+
+    if (sm->rx_state == ST_IDLE){      // fire off another receive
+      sm->rx_state = buf_this & 0x3;
+      bsm12_receive_to_buf(sm, buf_this);
+      buffer_state[buf_this] = BS_FILLING;
+      buffer_target[buf_this] = -1;
+    }
+
+    int dst = buffer_dst[buf_this];    // the dst we were emptying into
+    // is the next buffer full and for us?
+    int t = sm->next_buf[buf_this];
+    if (buffer_target[t] == dst){              // yes,
+      bsm12_send_from_buf(sm, t, dst);         // send it
+      buffer_state[t] = BS_EMPTYING;
+      buffer_target[t] = -1;
+      sm->tx_state[dst] = t & 0x3;
+    }
+    // how about the one after that?
+    else if (buffer_target[t=sm->next_buf[t]] == dst){ // yes,
+      bsm12_send_from_buf(sm, t, dst);                 // send it
+      buffer_state[t] = BS_EMPTYING;
+      buffer_target[t] = -1;
+      sm->tx_state[dst] = t & 0x3;
+    }
+    else {
+      sm->tx_state[dst] = ST_IDLE;
+    }
+  }
+}
+
+static void
+bsm12_error_helper(bsm12_t *sm, int buf_this)
+{
+  bp_clear_buf(buf_this);                // clears ERROR flag
+
+  if (buffer_state[buf_this] == BS_FILLING){
+    bsm12_receive_to_buf(sm, buf_this);          // restart the xfer
+  }
+  else { // buffer was emptying
+    bsm12_resend_from_buf(sm, buf_this);  // restart the xfer
+  }
+}
+
+
+void
+bsm12_handle_tx_underrun(bsm12_t *sm)
+{
+}
+
+void
+bsm12_handle_rx_overrun(bsm12_t *sm)
+{
+}

Copied: gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.h (from rev 
10294, gnuradio/trunk/usrp2/firmware/lib/bsm12.h)
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.h                   
        (rev 0)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/lib/bsm12.h   2009-01-27 
15:50:29 UTC (rev 10312)
@@ -0,0 +1,83 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef INCLUDED_BSM12_H
+#define INCLUDED_BSM12_H
+
+#include "dbsm.h"
+#include "memory_map.h"
+
+/*!
+ * buffer state machine: 1 input to two outputs
+ *
+ * Typically used to read packets from the ethernet and then after inspecting,
+ * handle the packet in firmware or pass it on to 1 of the 2 buffer 
destinations.
+ */
+
+struct _bsm12;
+typedef struct _bsm12 bsm12_t;
+
+/*!
+ * Pointer to function that does packet inspection.
+ *
+ * \param sm           the state machine
+ * \param buf_this     the index of the buffer to inspect and/or pass on
+ *
+ * Returns -1, 0 or 1.  If it returns -1, it means that the s/w
+ * handled that packet, and that it should NOT be passed on to one of
+ * the buffer endpoints.  0 indicates the first endpoint, 1 the second 
endpoint.
+ */
+typedef int (*bsm12_inspector_t)(bsm12_t *sm, int buf_this);
+
+
+/*!
+ * buffer state machine: 1 input to two outputs
+ */
+struct _bsm12
+{
+  uint8_t        buf0;  // This machine uses buf0, buf0+1 and buf0+2.  buf0 % 
4 == 0.
+  uint8_t        running;
+  int8_t         rx_state;     // -1, 0, 1, 2  which buffer we're receiving 
into
+  int8_t         tx_state[2];  // -1, 0, 1, 2  which buffer we're sending from
+  buf_cmd_args_t  recv_args;
+  buf_cmd_args_t  send_args[2];
+  bsm12_inspector_t inspect;
+  int            last_line_adj;
+  uint32_t       bps_error;
+  uint32_t       bps_done;
+  uint32_t       bps_error_or_done;
+  uint8_t        next_buf[NBUFFERS];
+  uint32_t       precomputed_receive_to_buf_ctrl_word[3];
+  uint32_t       precomputed_send_from_buf_ctrl_word[4][2];  // really only 3, 
not 4 
+                                                              //   (easier 
addr comp)
+};
+
+void bsm12_init(bsm12_t *sm, int buf0,
+               const buf_cmd_args_t *recv,
+               const buf_cmd_args_t *send0,
+               const buf_cmd_args_t *send1,
+               bsm12_inspector_t inspect);
+
+void bsm12_start(bsm12_t *sm);
+void bsm12_stop(bsm12_t *sm);
+void bsm12_process_status(bsm12_t *sm, uint32_t status);
+void bsm12_handle_tx_underrun(bsm12_t *sm);
+void bsm12_handle_rx_overrun(bsm12_t *sm);
+
+
+#endif /* INCLUDED_BSM12_H */

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/lib/dbsm.c
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/lib/dbsm.c    2009-01-27 
15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/lib/dbsm.c    2009-01-27 
15:50:29 UTC (rev 10312)
@@ -34,7 +34,7 @@
   BS_EMPTYING,
 } buffer_state_t;
 
-buffer_state_t buffer_state[NBUFFERS];
+static buffer_state_t buffer_state[NBUFFERS];
 
 bool
 dbsm_nop_inspector(dbsm_t *sm, int buf_this)

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/lib/memory_map.h
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/lib/memory_map.h      
2009-01-27 15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/lib/memory_map.h      
2009-01-27 15:50:29 UTC (rev 10312)
@@ -366,6 +366,16 @@
 #define        ADC_CTRL_ON     0x0F
 #define        ADC_CTRL_OFF    0x00
 
+// crazy order that matches the labels on the case
+
+#define        LED_A           (1 << 4)
+#define        LED_B           (1 << 1)
+#define        LED_C           (1 << 3)
+#define        LED_D           (1 << 0)
+#define        LED_E           (1 << 2)
+//      LED_F          // controlled by CPLD
+#define        LED_RJ45        (1 << 5)
+
 #define output_regs ((output_regs_t *) MISC_OUTPUT_BASE)
 
 // --- dsp tx regs ---

Modified: gnuradio/branches/releases/3.2/usrp2/firmware/lib/stdint.h
===================================================================
--- gnuradio/branches/releases/3.2/usrp2/firmware/lib/stdint.h  2009-01-27 
15:43:04 UTC (rev 10311)
+++ gnuradio/branches/releases/3.2/usrp2/firmware/lib/stdint.h  2009-01-27 
15:50:29 UTC (rev 10312)
@@ -1,6 +1,6 @@
 /* -*- c -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,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
@@ -19,7 +19,7 @@
 #ifndef INCLUDED_STDINT_H
 #define INCLUDED_STDINT_H
 
-typedef char           int8_t;
+typedef signed char    int8_t;
 typedef unsigned char  uint8_t;
 typedef short          int16_t;
 typedef unsigned short uint16_t;





reply via email to

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