commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r6744 - gnuradio/branches/developers/matt/u2f/firmware


From: eb
Subject: [Commit-gnuradio] r6744 - gnuradio/branches/developers/matt/u2f/firmware
Date: Tue, 30 Oct 2007 13:56:53 -0600 (MDT)

Author: eb
Date: 2007-10-30 13:56:52 -0600 (Tue, 30 Oct 2007)
New Revision: 6744

Added:
   gnuradio/branches/developers/matt/u2f/firmware/gen_eth_packets.c
   gnuradio/branches/developers/matt/u2f/firmware/hal_io.c
   gnuradio/branches/developers/matt/u2f/firmware/hal_io.h
Removed:
   gnuradio/branches/developers/matt/u2f/firmware/sim_io.c
   gnuradio/branches/developers/matt/u2f/firmware/sim_io.h
Modified:
   gnuradio/branches/developers/matt/u2f/firmware/Makefile
   gnuradio/branches/developers/matt/u2f/firmware/buffer_pool.c
   gnuradio/branches/developers/matt/u2f/firmware/eth.c
   gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c
   gnuradio/branches/developers/matt/u2f/firmware/eth_test.c
   gnuradio/branches/developers/matt/u2f/firmware/ibs_rx_test.c
   gnuradio/branches/developers/matt/u2f/firmware/ibs_tx_test.c
   gnuradio/branches/developers/matt/u2f/firmware/pic.c
   gnuradio/branches/developers/matt/u2f/firmware/test1_main.c
   gnuradio/branches/developers/matt/u2f/firmware/timer_test.c
   gnuradio/branches/developers/matt/u2f/firmware/u2_init.c
Log:
refactored sim_io into hal_io.  Now does putc via either
the verilog test bench or the tx daughterboard pins.


Modified: gnuradio/branches/developers/matt/u2f/firmware/Makefile
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/Makefile     2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/Makefile     2007-10-30 
19:56:52 UTC (rev 6744)
@@ -2,6 +2,8 @@
 LD = mb-ld
 AR = mb-ar
 
+CPPFLAGS = -DHAL_IO_USES_DBOARD_PINS
+
 # CFLAGS = -Wall -O2 -g -mxl-gp-opt -mxl-soft-div -mxl-soft-mul -msoft-float
 #CFLAGS = -std=gnu99 -Wall -O2 -g  -mxl-soft-div -mxl-soft-mul -msoft-float
 CFLAGS = -Wall -O2 -g  -mxl-soft-div -mxl-soft-mul -msoft-float
@@ -31,7 +33,7 @@
        eth_driver.o    \
        eth_mac.o       \
        pic.o           \
-       sim_io.o        \
+       hal_io.o        \
        spi.o           \
        u2_init.o       
 
@@ -59,13 +61,13 @@
 
 
 # dependencies
-bootstrap.o: memory_map.h eth_mac_regs.h spi.h buffer_pool.h sim_io.h 
bootstrap.c
+bootstrap.o: memory_map.h eth_mac_regs.h spi.h buffer_pool.h hal_io.h 
bootstrap.c
 spi.o: memory_map.h eth_mac_regs.h spi.h spi.c
 buffer_pool.o: memory_map.h buffer_pool.h buffer_pool.c
-sim_io.o: sim_io.h
-test1_main.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h 
sim_io.h test1_main.c
-eth_test.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h sim_io.h 
eth_test.c
-ibs_tx_test.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h 
sim_io.h ibs_tx_test.c
-ibs_rx_test.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h 
sim_io.h ibs_rx_test.c
-eth.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h sim_io.h eth.c
+hal_io.o: hal_io.h
+test1_main.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h 
hal_io.h test1_main.c
+eth_test.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h hal_io.h 
eth_test.c
+ibs_tx_test.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h 
hal_io.h ibs_tx_test.c
+ibs_rx_test.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h 
hal_io.h ibs_rx_test.c
+eth.o: u2_init.h memory_map.h eth_mac_regs.h spi.h buffer_pool.h hal_io.h eth.c
 eth_mac.o: memory_map.h eth_mac_regs.h eth_mac.c

Modified: gnuradio/branches/developers/matt/u2f/firmware/buffer_pool.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/buffer_pool.c        
2007-10-29 18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/buffer_pool.c        
2007-10-30 19:56:52 UTC (rev 6744)
@@ -1,6 +1,6 @@
 #include "memory_map.h"
 #include "buffer_pool.h"
-#include "sim_io.h" 
+#include "hal_io.h" 
 
 void
 bp_init(void)

Modified: gnuradio/branches/developers/matt/u2f/firmware/eth.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth.c        2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth.c        2007-10-30 
19:56:52 UTC (rev 6744)
@@ -16,14 +16,14 @@
   for(i=0;i<BUFFER_SIZE;i++)
     buf[i] = i;
 
-  sim_puts("Filled buffer 0\n");
+  hal_puts("Filled buffer 0\n");
 
   // Write to buffer 1
   int *buffer = (int *)(BUFFER_BASE + BUFFER_1);
   for(i=0;i<BUFFER_SIZE;i++)
     buf[i] =  i + ((i^0xFFFF) << 16);
 
-  sim_puts("Filled buffer 1\n");
+  hal_puts("Filled buffer 1\n");
 
   // Control LEDs
   while(1) {

Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c 2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c 2007-10-30 
19:56:52 UTC (rev 6744)
@@ -25,7 +25,7 @@
 #include "eth_mac.h"
 #include "eth_mac_regs.h"
 #include "pic.h"
-#include "sim_io.h"
+#include "hal_io.h"
 
 static eth_driver_t ed_state;
 
@@ -50,7 +50,7 @@
 static void
 ed_link_up(int speed)
 {
-  sim_puts("ed_link_up: "); sim_puthex_nl(speed);
+  hal_puts("ed_link_up: "); hal_puthex_nl(speed);
 
   ed_set_mac_speed(speed);
 
@@ -60,7 +60,7 @@
 static void
 ed_link_down(void)
 {
-  sim_puts("ed_link_down\n");
+  hal_puts("ed_link_down\n");
 
   // FIXME invoke "link down" callback
 }
@@ -68,7 +68,7 @@
 static void
 ed_link_speed_change(int speed)
 {
-  sim_puts("ed_link_speed_change: "); sim_puthex_nl(speed);
+  hal_puts("ed_link_speed_change: "); hal_puthex_nl(speed);
 
   ed_link_down();
   ed_link_up(speed);
@@ -84,10 +84,10 @@
   eth_link_state_t new_state = LS_UNKNOWN;
   int new_speed = S_UNKNOWN;
 
-  sim_puts("LANSR: "); sim_puthex_nl(lansr);
+  hal_puts("LANSR: "); hal_puthex_nl(lansr);
 
   if (lansr & LANSR_LINK_GOOD){                // link's up
-    sim_puts_nl("  LINK_GOOD");
+    hal_puts_nl("  LINK_GOOD");
 
     new_state = LS_UP;
     switch (lansr & LANSR_SPEED_MASK){
@@ -109,7 +109,7 @@
     }
   }
   else {                               // link's down
-    sim_puts_nl("  NOT LINK_GOOD");
+    hal_puts_nl("  NOT LINK_GOOD");
     
     new_state = LS_DOWN;
     new_speed = S_UNKNOWN;
@@ -124,7 +124,7 @@
   }
   else if (new_state == LS_UP && new_speed != ed_state.link_speed){
     ed_state.link_speed = new_speed;           // remember new speed
-    sim_puts_nl("  New Speed: "); sim_puthex_nl(new_speed);
+    hal_puts_nl("  New Speed: "); hal_puthex_nl(new_speed);
     ed_link_speed_change(new_speed);
   }
 }

Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_test.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_test.c   2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_test.c   2007-10-30 
19:56:52 UTC (rev 6744)
@@ -1,7 +1,7 @@
 #include "u2_init.h"
 #include "memory_map.h"
 #include "spi.h"
-#include "sim_io.h"
+#include "hal_io.h"
 #include "buffer_pool.h"
 
 // Globals
@@ -36,19 +36,19 @@
   volatile unsigned int *buffer1 = buffer_ram(1);
   
 
-  sim_puts("Starting to fill in RAM\n");
+  hal_puts("Starting to fill in RAM\n");
   for(i=0;i<512;i++) 
     buffer0[i] = ((437+i)<<16) + 5395-i;
-  sim_puts("Filled in RAM\n");
+  hal_puts("Filled in RAM\n");
   
   // Set up  receive buffer
   bp_receive_to_buf(1, 2, 1, 0, 511);  // Fill from ethernet
-  sim_puts("Set up RX buffer\n");
+  hal_puts("Set up RX buffer\n");
   
   
   // Set up send buffer
   bp_send_from_buf(0, 2, 1, 0, 20);
-  sim_puts("Set up TX Buffer\n");
+  hal_puts("Set up TX Buffer\n");
 
   while (buffer_pool_status->status != (BPS_DONE_0 | BPS_DONE_1))
     ;
@@ -56,12 +56,12 @@
   bp_clear_buf(0);
   bp_clear_buf(1);
 
-  sim_puts("Both are done\n");
+  hal_puts("Both are done\n");
   
   // Send a bunch, let them pile up in FIFO
   bp_send_from_buf(0, 2, 1, 21, 80);    wait_until_status_nonzero();
   bp_clear_buf(0);
-  sim_puts("First add'l TX done\n");
+  hal_puts("First add'l TX done\n");
   bp_send_from_buf(0, 2, 1, 81, 288);   wait_until_status_nonzero();
   bp_clear_buf(0);
   bp_send_from_buf(0, 2, 1, 289, 292);  wait_until_status_nonzero();
@@ -72,11 +72,11 @@
   bp_clear_buf(0);
   bp_send_from_buf(0, 2, 1, 400, 511);  wait_until_status_nonzero();
   bp_clear_buf(0);
-  sim_puts("All add'l TX done\n");
+  hal_puts("All add'l TX done\n");
   
   bp_receive_to_buf(1, 2, 1, 21, 80);   wait_until_status_nonzero();
   bp_clear_buf(1);
-  sim_puts("First add'l RX done\n");
+  hal_puts("First add'l RX done\n");
   bp_receive_to_buf(1, 2, 1, 81, 288);  wait_until_status_nonzero();
   bp_clear_buf(1);
   bp_receive_to_buf(1, 2, 1, 289, 292); wait_until_status_nonzero();
@@ -87,21 +87,21 @@
   bp_clear_buf(1);
   bp_receive_to_buf(1, 2, 1, 400, 511); wait_until_status_nonzero();
   bp_clear_buf(1);
-  sim_puts("All add'l RX done\n");
+  hal_puts("All add'l RX done\n");
 
   for(i=0;i<512;i++)
     if(buffer0[i] != buffer1[i]) {
-      sim_puts("ERROR at location: ");
-      sim_puthex_nl(i);
-      sim_puts("Value sent: ");
-      sim_puthex_nl(buffer0[i]);
-      sim_puts("Value rcvd: ");
-      sim_puthex_nl(buffer1[i]);
+      hal_puts("ERROR at location: ");
+      hal_puthex_nl(i);
+      hal_puts("Value sent: ");
+      hal_puthex_nl(buffer0[i]);
+      hal_puts("Value rcvd: ");
+      hal_puthex_nl(buffer1[i]);
       //break;
     }
   
-  sim_puts("Done Testing\n");
+  hal_puts("Done Testing\n");
   
-  sim_finish();
+  hal_finish();
   return 1;
 }

Copied: gnuradio/branches/developers/matt/u2f/firmware/gen_eth_packets.c (from 
rev 6559, gnuradio/branches/developers/matt/u2f/firmware/test1_main.c)
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/gen_eth_packets.c            
                (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/gen_eth_packets.c    
2007-10-30 19:56:52 UTC (rev 6744)
@@ -0,0 +1,272 @@
+#include "u2_init.h"
+#include "memory_map.h"
+#include "spi.h"
+#include "hal_io.h"
+#include "buffer_pool.h"
+#include "pic.h"
+#include "timer.h"
+
+
+// ----------------------------------------------------------------
+
+unsigned char src_mac_addr[6] = {
+  0x00, 0x0A, 0x35, 0x98, 0x76, 0x54
+};
+
+unsigned char dst_mac_addr[6] = {
+  0xff, 0xff, 0xff, 0xff, 0xff, 0xff
+};
+
+#define U2_ETHERTYPE 0xBEEF
+
+
+typedef struct {
+  unsigned char dst_addr[6];
+  unsigned char src_addr[6];
+  unsigned short ethertype;
+} ethernet_hdr_t;
+
+
+
+// ----------------------------------------------------------------
+
+void buffer_irq_handler(unsigned irq);
+void timer_irq_handler(unsigned irq);
+
+
+static void
+init_packet(int *p)
+{
+}
+
+
+int
+main(void)
+{
+  u2_init();
+
+  // Control LEDs
+  output_regs->leds = 0x00;
+
+
+  // Set up DSP RX
+  buffer_state[0] = FILLING;
+  serdes_tx_idle = 1;
+  bp_receive_to_buf(0, 1, 1, 10, 509);  // DSP_RX to buffer 0, use 500 lines
+
+  dsp_rx_regs->run_rx = 1;           // Start DSP_RX
+  hal_puts("Done DSP RX setup\n");
+
+  // Set up serdes RX
+  buffer_state[2] = FILLING;
+  dsp_tx_idle = 1;
+  bp_receive_to_buf(2, PORT, 1, 5, 504);
+
+  while (buffer_pool_status->status == 0)  // wait for completion of DSP RX
+    ;
+
+  hal_puts("Done DSP TX setup\n");
+  dsp_tx_regs->run_tx = 1;
+
+  // register interrupt handler
+  pic_register_handler(IRQ_BUFFER, buffer_irq_handler);
+
+  u2_infinite_loop();
+
+  hal_finish();
+  return 1;
+}
+
+void 
+double_buffering(int port) {
+  unsigned int localstatus = buffer_pool_status->status;
+
+  if(localstatus & BPS_DONE_0) {
+    bp_clear_buf(0);
+    if(buffer_state[0] == FILLING) {
+      buffer_state[0] = FULL;
+      if(buffer_state[1] == EMPTY) {
+       bp_receive_to_buf(1, 1, 1, 10, 509);  // DSP_RX to buffer 1, use 500 
lines
+       buffer_state[1] = FILLING;
+      }
+      else
+       dsp_rx_idle = 1;
+      if(serdes_tx_idle) {
+       serdes_tx_idle = 0;
+       bp_send_from_buf(0, port, 1, 10, 509);  // SERDES_TX from buffer 0
+       buffer_state[0] = EMPTYING;
+      }
+    }
+    else {  // buffer was emptying
+      buffer_state[0] = EMPTY;
+      if(dsp_rx_idle) {
+       dsp_rx_idle = 0;
+       bp_receive_to_buf(0, 1, 1, 10, 509);  // DSP_RX to buffer 0, use 500 
lines
+       buffer_state[0] = FILLING;
+      }
+      if(buffer_state[1] == FULL) {
+       bp_send_from_buf(1, port, 1, 10, 509);  // SERDES_TX from buffer 1
+       buffer_state[1] = EMPTYING;
+      }
+      else
+       serdes_tx_idle = 1;
+    }
+    hal_puts("Int Proc'ed 0\n");
+  }
+  if(localstatus & BPS_DONE_1) {
+    bp_clear_buf(1);
+    if(buffer_state[1] == FILLING) {
+      buffer_state[1] = FULL;
+      if(buffer_state[0] == EMPTY) {
+       bp_receive_to_buf(0, 1, 1, 10, 509);  // DSP_RX to buffer 1, use 500 
lines
+       buffer_state[0] = FILLING;
+      }
+      else
+       dsp_rx_idle = 1;
+      if(serdes_tx_idle) {
+       serdes_tx_idle = 0;
+       bp_send_from_buf(1, port, 1, 10, 509);  // SERDES_TX from buffer 1
+       buffer_state[1] = EMPTYING;
+      }
+    }
+    else {  // buffer was emptying
+      buffer_state[1] = EMPTY;
+      if(dsp_rx_idle) {
+       dsp_rx_idle = 0;
+       bp_receive_to_buf(1, 1, 1, 10, 509);  // DSP_RX to buffer 1, use 500 
lines
+       buffer_state[1] = FILLING;
+      }
+      if(buffer_state[0] == FULL) {
+       bp_send_from_buf(0, port, 1, 10, 509);  // SERDES_TX from buffer 0
+       buffer_state[0] = EMPTYING;
+      }
+      else
+       serdes_tx_idle = 1;
+    }
+  hal_puts("Int Proc'ed 1\n");
+  }
+  if(localstatus & BPS_DONE_2) {
+    bp_clear_buf(2);
+    if(buffer_state[2] == FILLING) {
+      buffer_state[2] = FULL;
+      if(buffer_state[3] == EMPTY) {
+       bp_receive_to_buf(3, port, 1, 5, 504);  // SERDES_RX to buffer 3, use 
500 lines
+       buffer_state[3] = FILLING;
+      }
+      else
+       serdes_rx_idle = 1;
+      if(dsp_tx_idle) {
+       dsp_tx_idle = 0;
+       bp_send_from_buf(2, 1, 1, 5, 504);  // DSP_TX from buffer 2
+       buffer_state[2] = EMPTYING;
+      }
+    }
+    else {  // buffer was emptying
+      buffer_state[2] = EMPTY;
+      if(serdes_rx_idle) {
+       serdes_rx_idle = 0;
+       bp_receive_to_buf(2, port, 1, 5, 504);  // SERDES_RX to buffer 2
+       buffer_state[2] = FILLING;
+      }
+      if(buffer_state[3] == FULL) {
+       bp_send_from_buf(3, 1, 1, 5, 504);  // DSP_TX from buffer 3
+       buffer_state[3] = EMPTYING;
+      }
+      else
+       dsp_tx_idle = 1;
+    }
+  hal_puts("Int Proc'ed 2\n");
+  }
+  if(localstatus & BPS_DONE_3) {
+    bp_clear_buf(3);
+    if(buffer_state[3] == FILLING) {
+      buffer_state[3] = FULL;
+      if(buffer_state[2] == EMPTY) {
+       bp_receive_to_buf(2, port, 1, 5, 504);  // SERDES_RX to buffer 2, use 
500 lines
+       buffer_state[2] = FILLING;
+      }
+      else
+       serdes_rx_idle = 1;
+      if(dsp_tx_idle) {
+       dsp_tx_idle = 0;
+       bp_send_from_buf(3, 1, 1, 5, 504);  // DSP_TX from buffer 3
+       buffer_state[3] = EMPTYING;
+      }
+    }
+    else {  // buffer was emptying
+      buffer_state[3] = EMPTY;
+      if(serdes_rx_idle) {
+       serdes_rx_idle = 0;
+       bp_receive_to_buf(3, port, 1, 5, 504);  // SERDES_RX to buffer 3
+       buffer_state[3] = FILLING;
+      }
+      if(buffer_state[2] == FULL) {
+       bp_send_from_buf(2, 1, 1, 5, 504);  // DSP_TX from buffer 2
+       buffer_state[2] = EMPTYING;
+      }
+      else
+       dsp_tx_idle = 1;
+    }
+  hal_puts("Int Proc'ed 3\n");
+  }
+}
+
+// Spare Code
+
+#if 0  
+  // Set up LSDAC
+  int i = 0;
+  while(1) {
+    int command = (3 << 19) | (0 << 16) |  (i & 0xffff);
+    spi_transact(SPI_TXONLY, SPI_SS_TX_DAC, command, 24, 1); // negate TX phase
+    i++;
+  }
+#endif
+
+#if 0  
+  // Write to buffer 0
+  int *buf = (int *)(BUFFER_BASE + BUFFER_0);
+  hal_puthex_nl((int)buf);
+
+  for(i=0;i<BUFFER_SIZE;i++)
+    buf[i] = i;
+
+  hal_puts("Filled buffer 0\n");
+
+  // Write to buffer 1
+  buf = (int *)(BUFFER_BASE + BUFFER_1);
+  hal_puthex_nl((int)buf);
+  for(i=0;i<BUFFER_SIZE;i++)
+    buf[i] =  i + ((i^0xFFFF) << 16);
+
+  hal_puts("Filled buffer 1\n");
+
+#endif
+
+#if 0
+  // rx SERDES into buffer #2  (buf,port,step,fl,ll)
+  bp_receive_to_buf(2, 0, 1, 10, 300);
+  hal_puts("SERDES RX buffer setup\n");
+
+  // send SERDES from buffer #0 (buf,port,step,fl,ll)
+  bp_send_from_buf(0, 0, 1, 20, 200);
+  hal_puts("SERDES TX buffer setup\n");
+
+#endif
+
+#if 0
+  // send to DACs from buffer #1
+  bp_send_from_buf(1 /*buf#*/, 1 /*port*/, 1 /*step*/, 20 /*fl*/, 250 /*ll*/);
+  hal_puts("DAC Buffer setup\n");
+#endif
+
+#if 0
+  //hal_puts("ENTER INT\n");
+  for(i=0;i<8;i++)
+    if(*status & (1<<i)) {
+      //hal_puts("Clearing buf ");
+      hal_puthex_nl(i);
+      bp_clear_buf(i);
+    }
+  //hal_puts("EXIT INT\n");
+#endif

Added: gnuradio/branches/developers/matt/u2f/firmware/hal_io.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/hal_io.c                     
        (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/hal_io.c     2007-10-30 
19:56:52 UTC (rev 6744)
@@ -0,0 +1,160 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+// conditionalized on HAL_IO_USES_DBOARD_PINS
+
+#include "hal_io.h"
+#include "memory_map.h"
+
+// ================================================================
+//                             primitives
+// ================================================================
+
+//
+// Does i/o using high 9-bits of tx daughterboard pins.
+//
+//  1 1 1 1 1 1
+//  5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// |      char     |W|             |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+//
+// 
+// Asserts W when writing char
+//
+#if defined(HAL_IO_USES_DBOARD_PINS)
+
+#define W      0x0080
+
+void
+hal_io_init(void)
+{
+  // make high 9 bits of tx daugtherboard outputs
+  gpio_base->ddr_tx = (gpio_base->ddr_tx & ~0xff80) | 0xff80;
+  gpio_base->io_tx =  (gpio_base->io_tx  & ~0xff80);;  // init to zero
+}
+
+// %c
+inline void 
+hal_putc(unsigned char s)
+{
+  int t = gpio_base->io_tx & 0x7ff;    // keep bottom bits
+  t |= (s << 8);
+  gpio_base->io_tx = W | t;
+  gpio_base->io_tx = 0 | t;
+}
+
+void
+hal_finish(void)
+{
+  volatile unsigned long *p = (unsigned long *) 0xC2F0;
+  *p = 0;
+}
+
+#else  // nop all i/o
+
+void
+hal_io_init(void)
+{
+}
+
+// %c
+inline void
+hal_putc(unsigned char s)
+{
+}
+
+void
+hal_finish(void)
+{
+}
+
+#endif
+
+// ================================================================
+//                 (slightly) higher level functions
+// ================================================================
+
+// \n
+inline void 
+hal_newline(void)
+{
+  hal_putc('\n');
+}
+
+// %c\n
+inline void 
+hal_putc_nl(unsigned char s)
+{
+  hal_putc(s);
+  hal_newline();
+}
+
+
+void 
+hal_puts(const char *s)
+{
+  while (*s)
+    hal_putc(*s++);
+}
+
+void 
+hal_puts_nl(const char *s)
+{
+  hal_puts(s);
+  hal_newline();
+}
+
+// %02x
+void 
+hal_puthex8(unsigned long x)
+{
+  static const char hex[16] = {
+    '0', '1', '2', '3', '4', '5', '6', '7',
+    '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
+  };
+  hal_putc(hex[(x >> 4) & 0xf]);
+  hal_putc(hex[x & 0xf]);
+}
+
+// %04x
+void 
+hal_puthex16(unsigned long x)
+{
+  hal_puthex8(x >> 8);
+  hal_puthex8(x);
+}
+
+// %08x
+void 
+hal_puthex32(unsigned long x)
+{
+  hal_puthex16(x >> 16);
+  hal_puthex16(x);
+}
+
+// %08x\n
+void 
+hal_puthex_nl(unsigned long x)
+{
+  hal_puthex(x);
+  hal_newline();
+}


Property changes on: gnuradio/branches/developers/matt/u2f/firmware/hal_io.c
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: gnuradio/branches/developers/matt/u2f/firmware/hal_io.h (from rev 6743, 
gnuradio/branches/developers/matt/u2f/firmware/sim_io.h)
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/hal_io.h                     
        (rev 0)
+++ gnuradio/branches/developers/matt/u2f/firmware/hal_io.h     2007-10-30 
19:56:52 UTC (rev 6744)
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio 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 2, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+void hal_putc(unsigned char s);
+void hal_putc_nl(unsigned char s);     // adds \n
+void hal_puts(const char *);
+void hal_puts_nl(const char *s);       // adds \n
+void hal_puthex8(unsigned long x);
+void hal_puthex16(unsigned long x);
+void hal_puthex32(unsigned long x);
+#define hal_puthex hal_puthex32
+void hal_puthex_nl(unsigned long x);
+void hal_newline();
+void hal_finish();

Modified: gnuradio/branches/developers/matt/u2f/firmware/ibs_rx_test.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/ibs_rx_test.c        
2007-10-29 18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/ibs_rx_test.c        
2007-10-30 19:56:52 UTC (rev 6744)
@@ -1,7 +1,7 @@
 #include "u2_init.h"
 #include "memory_map.h"
 #include "spi.h"
-#include "sim_io.h"
+#include "hal_io.h"
 #include "buffer_pool.h"
 
 #define PORT 2    // ethernet = 2, serdes = 0
@@ -35,7 +35,7 @@
   volatile unsigned int *buffer1 = buffer_ram(1);
   volatile unsigned int *buffer2 = buffer_ram(2);
   
-  sim_puts("Starting RX\n");
+  hal_puts("Starting RX\n");
   bp_clear_buf(0);
   bp_receive_to_buf(0, 1, 1, 0, 99);
 
@@ -58,25 +58,25 @@
     ;
   
   for(i=0;i<100;i++) {
-    sim_puthex(i);
-    sim_puts("   ");
-    sim_puthex_nl(buffer0[i]);
+    hal_puthex(i);
+    hal_puts("   ");
+    hal_puthex_nl(buffer0[i]);
   }
   for(i=0;i<60;i++) {
-    sim_puthex(i);
-    sim_puts("   ");
-    sim_puthex_nl(buffer1[i]);
+    hal_puthex(i);
+    hal_puts("   ");
+    hal_puthex_nl(buffer1[i]);
   }
   for(i=0;i<60;i++) {
-    sim_puthex(i);
-    sim_puts("   ");
-    sim_puthex_nl(buffer2[i]);
+    hal_puthex(i);
+    hal_puts("   ");
+    hal_puthex_nl(buffer2[i]);
   }
   //while(timer_regs -> time < 0x6000)
   //  {}
 
-  sim_puts("Done\n");
-  sim_finish();
+  hal_puts("Done\n");
+  hal_finish();
   
   return 1;
 }

Modified: gnuradio/branches/developers/matt/u2f/firmware/ibs_tx_test.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/ibs_tx_test.c        
2007-10-29 18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/ibs_tx_test.c        
2007-10-30 19:56:52 UTC (rev 6744)
@@ -1,7 +1,7 @@
 #include "u2_init.h"
 #include "memory_map.h"
 #include "spi.h"
-#include "sim_io.h"
+#include "hal_io.h"
 #include "buffer_pool.h"
 
 // Globals
@@ -40,10 +40,10 @@
   volatile unsigned int *buffer1 = buffer_ram(1);
   
 
-  sim_puts("Starting to fill in RAM\n");
+  hal_puts("Starting to fill in RAM\n");
   for(i=0;i<512;i++) 
     buffer0[i] = i;
-  sim_puts("Filled in RAM\n");
+  hal_puts("Filled in RAM\n");
   
   buffer0[0] = 7; // start and end of buffer, send immediately
   buffer0[1] = 0x0000;  // start time
@@ -105,16 +105,16 @@
   while(timer_regs -> time < 0xa000)
     {}
 
-  sim_puts("Done\n");
+  hal_puts("Done\n");
 
   while(1)
     {}
-  sim_finish();
+  hal_finish();
   
   // Send a bunch, let them pile up in FIFO
   bp_send_from_buf(0, 2, 1, 21, 80);    wait_until_status_nonzero();
   bp_clear_buf(0);
-  sim_puts("First add'l TX done\n");
+  hal_puts("First add'l TX done\n");
   bp_send_from_buf(0, 2, 1, 81, 288);   wait_until_status_nonzero();
   bp_clear_buf(0);
   bp_send_from_buf(0, 2, 1, 289, 292);  wait_until_status_nonzero();
@@ -125,11 +125,11 @@
   bp_clear_buf(0);
   bp_send_from_buf(0, 2, 1, 400, 511);  wait_until_status_nonzero();
   bp_clear_buf(0);
-  sim_puts("All add'l TX done\n");
+  hal_puts("All add'l TX done\n");
   
   bp_receive_to_buf(1, 2, 1, 21, 80);   wait_until_status_nonzero();
   bp_clear_buf(1);
-  sim_puts("First add'l RX done\n");
+  hal_puts("First add'l RX done\n");
   bp_receive_to_buf(1, 2, 1, 81, 288);  wait_until_status_nonzero();
   bp_clear_buf(1);
   bp_receive_to_buf(1, 2, 1, 289, 292); wait_until_status_nonzero();
@@ -140,21 +140,21 @@
   bp_clear_buf(1);
   bp_receive_to_buf(1, 2, 1, 400, 511); wait_until_status_nonzero();
   bp_clear_buf(1);
-  sim_puts("All add'l RX done\n");
+  hal_puts("All add'l RX done\n");
 
   for(i=0;i<512;i++)
     if(buffer0[i] != buffer1[i]) {
-      sim_puts("ERROR at location: ");
-      sim_puthex_nl(i);
-      sim_puts("Value sent: ");
-      sim_puthex_nl(buffer0[i]);
-      sim_puts("Value rcvd: ");
-      sim_puthex_nl(buffer1[i]);
+      hal_puts("ERROR at location: ");
+      hal_puthex_nl(i);
+      hal_puts("Value sent: ");
+      hal_puthex_nl(buffer0[i]);
+      hal_puts("Value rcvd: ");
+      hal_puthex_nl(buffer1[i]);
       //break;
     }
   
-  sim_puts("Done Testing\n");
+  hal_puts("Done Testing\n");
   
-  sim_finish();
+  hal_finish();
   return 1;
 }

Modified: gnuradio/branches/developers/matt/u2f/firmware/pic.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/pic.c        2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/pic.c        2007-10-30 
19:56:52 UTC (rev 6744)
@@ -20,7 +20,7 @@
  */
 
 #include "pic.h"
-#include "sim_io.h"
+#include "hal_io.h"
 #include "memory_map.h"
 
 
@@ -80,7 +80,7 @@
 
 void pic_interrupt_handler()
 {
-  // sim_puts("PIC_handler: ");
+  // hal_puts("PIC_handler: ");
 
   // pending and not masked interrupts
   int live = pic_regs->pending & ~pic_regs->mask;
@@ -91,7 +91,7 @@
   int mask;
   for (i=0, mask=1; i < NVECTORS; i++, mask <<= 1){
     if (mask & live){          // handle this one
-      // sim_puthex_nl(i);
+      // hal_puthex_nl(i);
       (*pic_vector[i])(i);
       pic_regs->pending = mask;        // clear pending interrupt
       return;

Deleted: gnuradio/branches/developers/matt/u2f/firmware/sim_io.c

Deleted: gnuradio/branches/developers/matt/u2f/firmware/sim_io.h

Modified: gnuradio/branches/developers/matt/u2f/firmware/test1_main.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/test1_main.c 2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/test1_main.c 2007-10-30 
19:56:52 UTC (rev 6744)
@@ -1,7 +1,7 @@
 #include "u2_init.h"
 #include "memory_map.h"
 #include "spi.h"
-#include "sim_io.h"
+#include "hal_io.h"
 #include "buffer_pool.h"
 #include "pic.h"
 
@@ -65,7 +65,7 @@
   bp_receive_to_buf(0, 1, 1, 10, 509);  // DSP_RX to buffer 0, use 500 lines
 
   //dsp_rx_regs->run_rx = 1;           // Start DSP_RX
-  sim_puts("Done DSP RX setup\n");
+  hal_puts("Done DSP RX setup\n");
 
   // Set up serdes RX
   buffer_state[2] = FILLING;
@@ -75,7 +75,7 @@
   while (buffer_pool_status->status == 0)  // wait for completion of DSP RX
     ;
 
-  sim_puts("Done DSP TX setup\n");
+  hal_puts("Done DSP TX setup\n");
   //dsp_tx_regs->run_tx = 1;
 
   // register interrupt handler
@@ -83,7 +83,7 @@
 
   u2_infinite_loop();
 
-  sim_finish();
+  hal_finish();
   return 1;
 }
 
@@ -121,7 +121,7 @@
       else
        serdes_tx_idle = 1;
     }
-    sim_puts("Int Proc'ed 0\n");
+    hal_puts("Int Proc'ed 0\n");
   }
   if(localstatus & BPS_DONE_1) {
     bp_clear_buf(1);
@@ -153,7 +153,7 @@
       else
        serdes_tx_idle = 1;
     }
-  sim_puts("Int Proc'ed 1\n");
+  hal_puts("Int Proc'ed 1\n");
   }
   if(localstatus & BPS_DONE_2) {
     bp_clear_buf(2);
@@ -185,7 +185,7 @@
       else
        dsp_tx_idle = 1;
     }
-  sim_puts("Int Proc'ed 2\n");
+  hal_puts("Int Proc'ed 2\n");
   }
   if(localstatus & BPS_DONE_3) {
     bp_clear_buf(3);
@@ -217,7 +217,7 @@
       else
        dsp_tx_idle = 1;
     }
-  sim_puts("Int Proc'ed 3\n");
+  hal_puts("Int Proc'ed 3\n");
   }
 }
 
@@ -236,47 +236,47 @@
 #if 0  
   // Write to buffer 0
   int *buf = (int *)(BUFFER_BASE + BUFFER_0);
-  sim_puthex_nl((int)buf);
+  hal_puthex_nl((int)buf);
 
   for(i=0;i<BUFFER_SIZE;i++)
     buf[i] = i;
 
-  sim_puts("Filled buffer 0\n");
+  hal_puts("Filled buffer 0\n");
 
   // Write to buffer 1
   buf = (int *)(BUFFER_BASE + BUFFER_1);
-  sim_puthex_nl((int)buf);
+  hal_puthex_nl((int)buf);
   for(i=0;i<BUFFER_SIZE;i++)
     buf[i] =  i + ((i^0xFFFF) << 16);
 
-  sim_puts("Filled buffer 1\n");
+  hal_puts("Filled buffer 1\n");
 
 #endif
 
 #if 0
   // rx SERDES into buffer #2  (buf,port,step,fl,ll)
   bp_receive_to_buf(2, 0, 1, 10, 300);
-  sim_puts("SERDES RX buffer setup\n");
+  hal_puts("SERDES RX buffer setup\n");
 
   // send SERDES from buffer #0 (buf,port,step,fl,ll)
   bp_send_from_buf(0, 0, 1, 20, 200);
-  sim_puts("SERDES TX buffer setup\n");
+  hal_puts("SERDES TX buffer setup\n");
 
 #endif
 
 #if 0
   // send to DACs from buffer #1
   bp_send_from_buf(1 /*buf#*/, 1 /*port*/, 1 /*step*/, 20 /*fl*/, 250 /*ll*/);
-  sim_puts("DAC Buffer setup\n");
+  hal_puts("DAC Buffer setup\n");
 #endif
 
 #if 0
-  //sim_puts("ENTER INT\n");
+  //hal_puts("ENTER INT\n");
   for(i=0;i<8;i++)
     if(*status & (1<<i)) {
-      //sim_puts("Clearing buf ");
-      sim_puthex_nl(i);
+      //hal_puts("Clearing buf ");
+      hal_puthex_nl(i);
       bp_clear_buf(i);
     }
-  //sim_puts("EXIT INT\n");
+  //hal_puts("EXIT INT\n");
 #endif

Modified: gnuradio/branches/developers/matt/u2f/firmware/timer_test.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/timer_test.c 2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/timer_test.c 2007-10-30 
19:56:52 UTC (rev 6744)
@@ -1,6 +1,6 @@
 #include "u2_init.h"
 #include "memory_map.h"
-#include "sim_io.h"
+#include "hal_io.h"
 #include "buffer_pool.h"
 #include "pic.h"
 
@@ -14,8 +14,8 @@
   int t = timer_regs->time;
   timer_regs->time = t + DELTA_T;
 
-  sim_puts("Tick: ");
-  sim_puthex_nl(t);
+  hal_puts("Tick: ");
+  hal_puthex_nl(t);
 }
 
 int
@@ -25,7 +25,7 @@
 
   // setup timer
 
-  sim_puts("Setting up timer\n");
+  hal_puts("Setting up timer\n");
   pic_register_handler(IRQ_TIMER, timer_handler);
 
   int t = timer_regs->time;
@@ -33,8 +33,8 @@
 
   u2_infinite_loop();
 
-  sim_puts("Done Testing\n");
+  hal_puts("Done Testing\n");
   
-  sim_finish();
+  hal_finish();
   return 1;
 }

Modified: gnuradio/branches/developers/matt/u2f/firmware/u2_init.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/u2_init.c    2007-10-29 
18:31:51 UTC (rev 6743)
+++ gnuradio/branches/developers/matt/u2f/firmware/u2_init.c    2007-10-30 
19:56:52 UTC (rev 6744)
@@ -3,7 +3,7 @@
 #include "memory_map.h"
 #include "spi.h"
 #include "pic.h"
-#include "sim_io.h"
+#include "hal_io.h"
 #include "buffer_pool.h"
 
 /*
@@ -13,8 +13,10 @@
 int 
 u2_init(void)
 {
-  sim_puts("u2_init\n");
+  hal_io_init();
 
+  hal_puts("u2_init\n");
+
   spi_init();
 
   // Set up AD9510
@@ -63,7 +65,7 @@
   //output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_LOOPEN | SERDES_RXEN);
   output_regs->serdes_ctrl = (SERDES_ENABLE | SERDES_RXEN);
 
-  // sim_puts("Setting up interrupt controller\n");
+  // hal_puts("Setting up interrupt controller\n");
   pic_init();
 
   bp_init();





reply via email to

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