From 6d441bbe709092d070c21b92aeeabfb82cb5982f Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Thu, 8 Dec 2005 20:47:35 +0000 Subject: [PATCH] =?utf8?q?Bugfixes:=201)=20Se=20arregla=20problema=20con?= =?utf8?q?=20paquetes=20con=20tama=C3=B1o=20impar.=202)=20Se=20vuelve=20pa?= =?utf8?q?ra=20atr=C3=A1s=20el=20cambio=20del=20OVW=20(estaba=20basado=20e?= =?utf8?q?n=20el=20driver=20de=20Linux=20=20=20=20que=20hace=20un=20manejo?= =?utf8?q?=20MUCHO=20m=C3=A1s=20elegante=20del=20OVW=20porque=20puede=20da?= =?utf8?q?rse=20el=20lujo=20de=20=20=20=20usar=20mucha=20memoria=20=3D)=20?= =?utf8?q?3)=20Se=20obtiene=20la=20MAC=20de=20la=20placa=20de=20forma=20un?= =?utf8?q?=20poco=20m=C3=A1s=20elegante.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/dp8390.c | 31 +++++++++++-------------------- src/dp8390.h | 1 + src/main.c | 8 +++----- 3 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/dp8390.c b/src/dp8390.c index 642c36f..30b3fb5 100644 --- a/src/dp8390.c +++ b/src/dp8390.c @@ -121,7 +121,7 @@ static void reset() SELECT_REG_PAGE(0); // Clear rx buffer overflow & packet received interrupt flags. - write_reg(ISR, OVW); + write_reg(ISR, PRX | OVW); // Re-itialise transmit configuration reg for normal operation. write_reg(TCR, MODE0); @@ -139,6 +139,8 @@ static void reset() */ bool netdev_init() { + byte i; + // Set IOR & IOW as they're active low. IOR = 1; IOW = 1; @@ -191,18 +193,11 @@ bool netdev_init() write_reg(RSAR0, 0u); // En la dirección 0x0000 write_reg(RSAR1, 0u); write_reg(CR, READ); // Comienza lectura - eth_addr_local[0] = read_reg(RDMA); - read_reg(RDMA); // Ignoramos porque viene como un word - eth_addr_local[1] = read_reg(RDMA); - read_reg(RDMA); // Ignoramos porque viene como un word - eth_addr_local[2] = read_reg(RDMA); - read_reg(RDMA); // Ignoramos porque viene como un word - eth_addr_local[3] = read_reg(RDMA); - read_reg(RDMA); // Ignoramos porque viene como un word - eth_addr_local[4] = read_reg(RDMA); - read_reg(RDMA); // Ignoramos porque viene como un word - eth_addr_local[5] = read_reg(RDMA); - read_reg(RDMA); // Ignoramos porque viene como un word + for (i = 0; i < ETH_ADDR_SIZE; ++i) + { + eth_addr_local[i] = read_reg(RDMA); + read_reg(RDMA); // Ignoramos porque viene como un word + } // Abort/ complete DMA operation. ABORT_DMA(STOP); @@ -226,12 +221,8 @@ bool netdev_init() write_reg(CURR, RX_PAGE_START + 1); // Set physical address - write_reg(PAR0, eth_addr_local[0]); - write_reg(PAR1, eth_addr_local[1]); - write_reg(PAR2, eth_addr_local[2]); - write_reg(PAR3, eth_addr_local[3]); - write_reg(PAR4, eth_addr_local[4]); - write_reg(PAR5, eth_addr_local[5]); + for (i = 0; i < ETH_ADDR_SIZE; ++i) + write_reg(PAR_BASE + i, eth_addr_local[i]); // Restart RTL8019AS. write_reg(CR, START); @@ -427,7 +418,7 @@ byte netdev_recv_start() // Initiate DMA transfer of packet data. write_reg(CR, READ); - + return buf_hdr.len; } return 0; diff --git a/src/dp8390.h b/src/dp8390.h index 2f0f9b8..a11854c 100644 --- a/src/dp8390.h +++ b/src/dp8390.h @@ -137,6 +137,7 @@ sbit NICE = CTRL_PORT^2; // A7, usado para activar placa de red // Each enable bit correspons with an interrupt flag in ISR // Page 1 read/write registers. +#define PAR_BASE REG_BASE + 0x01 // Physical address register base address #define PAR0 REG_BASE + 0x01 // Physical address register 0 #define PAR1 REG_BASE + 0x02 // Physical address register 1 #define PAR2 REG_BASE + 0x03 // Physical address register 2 diff --git a/src/main.c b/src/main.c index c679ac8..419ad41 100644 --- a/src/main.c +++ b/src/main.c @@ -74,12 +74,10 @@ void main(void) // Nuestro protocolo, por ahora un simple echo! for (i = 8; i < udp_dgram_len; ++i) // 8 por la cabecera UDP { - leds0 = ~netdev_recv_byte(); - leds1 = ~i; - sleep(8); + printb(netdev_recv_byte(), 0x00); } - i = (udp_dgram_len % 2) ? udp_dgram_len : (udp_dgram_len + 1); - for (i += 34; i < len; ++i) // 8 por la cabecera UDP + //i = (udp_dgram_len % 2) ? (udp_dgram_len - 1) : udp_dgram_len; + for (i += 34; i < len; ++i) // 8 por las cabeceras eth+IP netdev_recv_byte(); drop: netdev_recv_end(); -- 2.43.0