[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r6559 - gnuradio/branches/developers/matt/u2f/firmware
From: |
eb |
Subject: |
[Commit-gnuradio] r6559 - gnuradio/branches/developers/matt/u2f/firmware |
Date: |
Thu, 27 Sep 2007 17:37:55 -0600 (MDT) |
Author: eb
Date: 2007-09-27 17:37:55 -0600 (Thu, 27 Sep 2007)
New Revision: 6559
Modified:
gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c
gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h
gnuradio/branches/developers/matt/u2f/firmware/eth_test.c
Log:
more work-in-progress on ethernet driver
Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c 2007-09-27
20:08:07 UTC (rev 6558)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_driver.c 2007-09-27
23:37:55 UTC (rev 6559)
@@ -30,18 +30,48 @@
static eth_driver_t ed_state;
static void
-ed_link_up(eth_speed_t speed)
+ed_set_mac_speed(int speed)
{
+ switch(speed){
+ case 10:
+ eth_mac->speed = 1;
+ break;
+ case 100:
+ eth_mac->speed = 2;
+ break;
+ case 1000:
+ eth_mac->speed = 4;
+ break;
+ default:
+ break;
+ }
}
static void
+ed_link_up(int speed)
+{
+ sim_puts("ed_link_up: "); sim_puthex_nl(speed);
+
+ ed_set_mac_speed(speed);
+
+ // FIXME invoke "link up" callback
+}
+
+static void
ed_link_down(void)
{
+ sim_puts("ed_link_down\n");
+
+ // FIXME invoke "link down" callback
}
static void
-ed_link_speed_change(eth_speed_t speed)
+ed_link_speed_change(int speed)
{
+ sim_puts("ed_link_speed_change: "); sim_puthex_nl(speed);
+
+ ed_link_down();
+ ed_link_up(speed);
}
/*
@@ -52,7 +82,7 @@
{
int lansr = eth_mac_miim_read(PHY_LINK_AN);
eth_link_state_t new_state = LS_UNKNOWN;
- eth_speed_t new_speed = S_UNKNOWN;
+ int new_speed = S_UNKNOWN;
sim_puts("LANSR: "); sim_puthex_nl(lansr);
@@ -62,15 +92,15 @@
new_state = LS_UP;
switch (lansr & LANSR_SPEED_MASK){
case LANSR_SPEED_10:
- new_speed = S_10;
+ new_speed = 10;
break;
case LANSR_SPEED_100:
- new_speed = S_100;
+ new_speed = 100;
break;
case LANSR_SPEED_1000:
- new_speed = S_1000;
+ new_speed = 1000;
break;
default:
@@ -92,7 +122,7 @@
else if (new_state == LS_DOWN)
ed_link_down();
}
- else if (new_speed != ed_state.link_speed){
+ 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);
ed_link_speed_change(new_speed);
@@ -109,15 +139,25 @@
eth_mac_miim_write(PHY_INT_CLEAR, ~0); // clear all ints
}
-
void
eth_driver_init(void)
{
ed_state.link_state = LS_UNKNOWN;
ed_state.link_speed = S_UNKNOWN;
- // setup PHY to interrupt us on changes
+ // initialize MAC registers
+ eth_mac->tx_hwmark = 0x1e;
+ eth_mac->tx_lwmark = 0x19;
+ eth_mac->pause_frame_send_en = 1;
+ // eth_mac->pause_quanta_set = XXX;
+ eth_mac->tx_pause_en = 1;
+ // eth_mac->rx_hwmark = xxx;
+ // eth_mac->rx_lwmark = xxx;
+ eth_mac->crc_chk_en = 1;
+ eth_mac->rx_max_length = 2048;
+ // setup PHY to interrupt on changes
+
unsigned mask =
(PHY_INT_AN_CMPL // auto-neg completed
| PHY_INT_NO_LINK // no link after auto-neg
@@ -133,6 +173,7 @@
pic_register_handler(IRQ_PHY, eth_phy_irq_handler);
+ // FIXME not sure where we want to make the first check of the link state
ed_check_phy_state();
}
Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h 2007-09-27
20:08:07 UTC (rev 6558)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_driver.h 2007-09-27
23:37:55 UTC (rev 6559)
@@ -25,11 +25,12 @@
void eth_driver_init(void);
typedef enum { LS_UNKNOWN, LS_DOWN, LS_UP } eth_link_state_t;
-typedef enum { S_UNKNOWN, S_10, S_100, S_1000 } eth_speed_t;
+#define S_UNKNOWN (-1) // unknown link speed
+
typedef struct {
eth_link_state_t link_state;
- eth_speed_t link_speed;
+ int link_speed; // in Mb/s
} eth_driver_t;
#endif /* INCLUDED_ETH_DRIVER_H */
Modified: gnuradio/branches/developers/matt/u2f/firmware/eth_test.c
===================================================================
--- gnuradio/branches/developers/matt/u2f/firmware/eth_test.c 2007-09-27
20:08:07 UTC (rev 6558)
+++ gnuradio/branches/developers/matt/u2f/firmware/eth_test.c 2007-09-27
23:37:55 UTC (rev 6559)
@@ -16,30 +16,26 @@
int buffer_state[4];
+static void
+wait_until_status_nonzero(void)
+{
+ while (buffer_pool_status->status == 0)
+ ;
+}
+
int
main(void)
{
int i;
- sim_puts("Start INIT\n");
-
u2_init();
- sim_puts("Start Program\n");
-
// Write data to be sent into the first buffer
- //int *buffer0 = (int *)(BUFFER_BASE + BUFFER_0);
- //int *buffer1 = (int *)(BUFFER_BASE + BUFFER_1);
volatile unsigned int *buffer0 = buffer_ram(0);
volatile unsigned int *buffer1 = buffer_ram(1);
- sim_puts("Buffer0 ="); sim_puthex_nl((int) buffer0);
- sim_puts("Buffer1 ="); sim_puthex_nl((int) buffer1);
- // Buffer status info
- volatile unsigned int *status = (unsigned int *) 0xB020;
-
sim_puts("Starting to fill in RAM\n");
for(i=0;i<512;i++)
buffer0[i] = ((437+i)<<16) + 5395-i;
@@ -54,40 +50,42 @@
bp_send_from_buf(0, 2, 1, 0, 20);
sim_puts("Set up TX Buffer\n");
- while(*status != 3) {}
+ while (buffer_pool_status->status != (BPS_DONE_0 | BPS_DONE_1))
+ ;
+
bp_clear_buf(0);
bp_clear_buf(1);
sim_puts("Both are done\n");
// Send a bunch, let them pile up in FIFO
- bp_send_from_buf(0, 2, 1, 21, 80); while(*status == 0) {}
+ 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");
- bp_send_from_buf(0, 2, 1, 81, 288); while(*status == 0) {}
+ 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); while(*status == 0) {}
+ bp_send_from_buf(0, 2, 1, 289, 292); wait_until_status_nonzero();
bp_clear_buf(0);
- bp_send_from_buf(0, 2, 1, 293, 326); while(*status == 0) {}
+ bp_send_from_buf(0, 2, 1, 293, 326); wait_until_status_nonzero();
bp_clear_buf(0);
- bp_send_from_buf(0, 2, 1, 327, 399); while(*status == 0) {}
+ bp_send_from_buf(0, 2, 1, 327, 399); wait_until_status_nonzero();
bp_clear_buf(0);
- bp_send_from_buf(0, 2, 1, 400, 511); while(*status == 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");
- bp_receive_to_buf(1, 2, 1, 21, 80); while(*status == 0) {}
+ 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");
- bp_receive_to_buf(1, 2, 1, 81, 288); while(*status == 0) {}
+ 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); while(*status == 0) {}
+ bp_receive_to_buf(1, 2, 1, 289, 292); wait_until_status_nonzero();
bp_clear_buf(1);
- bp_receive_to_buf(1, 2, 1, 293, 326); while(*status == 0) {}
+ bp_receive_to_buf(1, 2, 1, 293, 326); wait_until_status_nonzero();
bp_clear_buf(1);
- bp_receive_to_buf(1, 2, 1, 327, 399); while(*status == 0) {}
+ bp_receive_to_buf(1, 2, 1, 327, 399); wait_until_status_nonzero();
bp_clear_buf(1);
- bp_receive_to_buf(1, 2, 1, 400, 511); while(*status == 0) {}
+ 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");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r6559 - gnuradio/branches/developers/matt/u2f/firmware,
eb <=