commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r6762 - gnuradio/branches/developers/matt/u2f/firmware
Date: Wed, 31 Oct 2007 16:27:48 -0600 (MDT)

Author: eb
Date: 2007-10-31 16:27:47 -0600 (Wed, 31 Oct 2007)
New Revision: 6762

Modified:
   gnuradio/branches/developers/matt/u2f/firmware/Makefile
   gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c
   gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h
   gnuradio/branches/developers/matt/u2f/firmware/test_phy_comm.c
Log:
work-in-progress

Modified: gnuradio/branches/developers/matt/u2f/firmware/Makefile
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/Makefile     2007-10-31 
21:10:45 UTC (rev 6761)
+++ gnuradio/branches/developers/matt/u2f/firmware/Makefile     2007-10-31 
22:27:47 UTC (rev 6762)
@@ -78,3 +78,4 @@
 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
+test_phy_comm.o: test_phy_comm.c memory_map.h eth_mac_regs.h eth_mac.h 
eth_driver.h
\ No newline at end of file

Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c 2007-10-31 
21:10:45 UTC (rev 6761)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c 2007-10-31 
22:27:47 UTC (rev 6762)
@@ -28,7 +28,15 @@
 #include "hal_io.h"
 
 static eth_driver_t ed_state;
+static ed_link_changed_callback_t ed_callback = 0;
 
+void 
+eth_driver_register_link_changed_callback(ed_link_changed_callback_t 
new_callback)
+{
+  ed_callback = new_callback;
+}
+
+
 static void
 ed_set_mac_speed(int speed)
 {
@@ -54,7 +62,8 @@
 
   ed_set_mac_speed(speed);
 
-  // FIXME invoke "link up" callback
+  if (ed_callback)             // fire link changed callback
+    (*ed_callback)(speed);
 }
 
 static void
@@ -62,9 +71,11 @@
 {
   hal_puts("ed_link_down\n");
 
-  // FIXME invoke "link down" callback
+  if (ed_callback)             // fire link changed callback
+    (*ed_callback)(0);
 }
 
+
 static void
 ed_link_speed_change(int speed)
 {

Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h 2007-10-31 
21:10:45 UTC (rev 6761)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h 2007-10-31 
22:27:47 UTC (rev 6762)
@@ -22,8 +22,20 @@
 #ifndef INCLUDED_ETH_DRIVER_H
 #define INCLUDED_ETH_DRIVER_H
 
+typedef void (*ed_link_changed_callback_t)(int speed);
+
+
 void eth_driver_init(void);
 
+/*!
+ * \brief Specify the function to call on link state changes.
+ * 
+ * When the link comes up, speed is the link speed in Mbit/s.
+ * When the link goes down, speed is 0.
+ */
+void eth_driver_register_link_changed_callback(ed_link_changed_callback_t cb);
+
+
 typedef enum { LS_UNKNOWN, LS_DOWN, LS_UP } eth_link_state_t;
 
 #define S_UNKNOWN (-1)                 // unknown link speed

Modified: gnuradio/branches/developers/matt/u2f/firmware/test_phy_comm.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/test_phy_comm.c      
2007-10-31 21:10:45 UTC (rev 6761)
+++ gnuradio/branches/developers/matt/u2f/firmware/test_phy_comm.c      
2007-10-31 22:27:47 UTC (rev 6762)
@@ -31,15 +31,59 @@
 
 #define DELTA_T  50000000              // 0.5s (10ns per tick)
 
-static int led_val = 0;
+// debugging output on tx pins
+#define LS_MASK  0xE0000
+#define LS_1000  0x80000
+#define LS_100   0x40000
+#define LS_10    0x20000
 
-void 
+
+static int led_link_up_flag = 0;
+
+/*
+ * Called when eth phy state changes (w/ interrupts disabled)
+ */
+void
+link_changed_callback(int speed)
+{
+  int v = 0;
+  switch(speed){
+  case 10:
+    v = LS_10;
+    led_link_up_flag = 0x2;
+    break;
+    
+  case 100:
+    v = LS_100;
+    led_link_up_flag = 0x2;
+    break;
+    
+  case 1000:
+    v = LS_100;
+    led_link_up_flag = 0x2;
+    break;
+
+  default:
+    v = 0;
+    led_link_up_flag = 0;
+    break;
+  }
+
+  hal_gpio_set_tx(v, LS_MASK); /* set debug bits on d'board */
+
+  hal_puts("\neth link changed: speed = ");
+  hal_puthex_nl(speed);
+}
+
+void
 timer_handler(unsigned irq)
 {
+  static int led_counter = 0;
+
   int t = timer_regs->time;
   timer_regs->time = t + DELTA_T;
 
-  output_regs->leds = led_val++;
+  output_regs->leds = (led_counter++ & 0x1) | led_link_up_flag;
 }
 
 int
@@ -55,7 +99,10 @@
   int t = timer_regs->time;
   timer_regs->time = t + DELTA_T;
 
+  hal_gpio_set_tx_mode(15,13, GPIOM_OUTPUT);
 
+  eth_driver_register_link_changed_callback(link_changed_callback);
+
   eth_mac_init();
   eth_driver_init();
 





reply via email to

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