static unsigned int etherdev_poll(void)
{
unsigned int len = 0;
- // Retardo mega-bizarro, si no lo pongo a veces leo basura del ISR
- unsigned char j;
- for (j = 0; j < 0xFF; ++j);
// Check if the rx buffer has overflowed.
if (etherdev_reg_read(ISR) & OVW)
{
- leds1 = ~0x01;
- leds2 = ~etherdev_reg_read(ISR);
- sleep(5);
- leds1 = ~0x02;
- leds2 = ~etherdev_reg_read(BNRY);
- sleep(5);
- leds1 = ~0x04;
+ unsigned char current;
+
+ // Select RTL8019AS register page 1.
ETHERDEV_SELECT_REG_PAGE(1);
- leds2 = ~etherdev_reg_read(CURR);
+
+ // Retrieve current receive buffer page
+ current = etherdev_reg_read(CURR);
+
+ // Select RTL8019AS register page 1.
ETHERDEV_SELECT_REG_PAGE(0);
- sleep(5);
- etherdev_reset();
- len = 0;
+
+ if (etherdev_reg_read(BNRY) == current)
+ {
+
+ leds1 = ~0x01;
+ leds2 = ~etherdev_reg_read(ISR);
+ sleep(5);
+ leds1 = ~0x02;
+ leds2 = ~etherdev_reg_read(BNRY);
+ sleep(5);
+ leds1 = ~0x04;
+ leds2 = ~current;
+ sleep(5);
+
+ etherdev_reset();
+ }
}
// Check if there is a packet in the rx buffer.
else if (etherdev_reg_read(ISR) & PRX)