/* FUNCTION ************************************/ uint8_t W5500_spi_read (uint32_t addr) /* ***********************************************/ { #define OPMODE_SREAD (0x00 | OM10_FDM1) // BSB = %00000, RW=0(read), OM =%10 uint8_t spi_reg; CS_W5500_LOW; // CS=0, SPI start SPI_Transfer (uint8_t)(addr >> 16); // without CS! SPI_Transfer (uint8_t)(addr >> 8); // without CS! SPI_Transfer ( (uint8_t)addr | (OPMODE_SREAD) ); // without CS! spi_reg = SPI_Transfer (0); /* dummy write */ // without CS! CS_W5500_HIGH; // CS=1, SPI end return spi_reg; } /* --- W5500_spi_read --- */ /* FUNCTION ************************************/ uint8_t W5500_Register_LoopBackTest (void) /* ***********************************************/ { uint16_t ii; uint8_t rd_val, err, tmp; setMR (MR_RST); // Reset ms_tick_wait (10); // Delay err = getMR (); // for delay ms_tick_wait (200); err = 0; rd_val = W5500_spi_read (VERSIONR); if (rd_val != 4) { err = 1; } if (err == 0) { tmp = getRCR(); /* Check R/W capability */ for (ii= 2; ii<500; ii++) // check several times { setRCR ((uint8_t)ii); // write Session ID Register in PPPoE mode rd_val = getRCR(); // read back Session ID Register if (rd_val != (uint8_t)ii) { err = 1; break; } ms_tick_wait (1); }; setRCR (tmp); } return err; } /* --- W5500_Register_LoopBackTest --- */