@@ -157,7 +157,29 @@ uint8_t W5100Class::init(void)
157157 writeSnTX_SIZE (i, 0 );
158158 }
159159#endif
160- // Try W5100 last. This simple chip uses fixed 4 byte frames
160+ // Try W5100S. Brandnew based W5100.
161+ } else if (isW5100S ()) {
162+ CH_BASE_MSB = 0x04 ;
163+ #ifdef ETHERNET_LARGE_BUFFERS
164+ #if MAX_SOCK_NUM <= 1
165+ SSIZE = 8192 ;
166+ writeTMSR (0x03 );
167+ writeRMSR (0x03 );
168+ #elif MAX_SOCK_NUM <= 2
169+ SSIZE = 4096 ;
170+ writeTMSR (0x0A );
171+ writeRMSR (0x0A );
172+ #else
173+ SSIZE = 2048 ;
174+ writeTMSR (0x55 );
175+ writeRMSR (0x55 );
176+ #endif
177+ SMASK = SSIZE - 1 ;
178+ #else
179+ writeTMSR (0x55 );
180+ writeRMSR (0x55 );
181+ #endif
182+ // Try W5100 last. This simple chip uses fixed 4 byte frames
161183 // for every 8 bit access. Terribly inefficient, but so simple
162184 // it recovers from "hearing" unsuccessful W5100 or W5200
163185 // communication. W5100 is also the only chip without a VERSIONR
@@ -210,7 +232,7 @@ uint8_t W5100Class::softReset(void)
210232 uint8_t mr = readMR ();
211233 // Serial.print("mr=");
212234 // Serial.println(mr, HEX);
213- if (mr == 0 ) return 1 ;
235+ if (mr == 0 || (mr == 3 && chip == 50 ) ) return 1 ;
214236 delay (1 );
215237 } while (++count < 20 );
216238 return 0 ;
@@ -231,6 +253,23 @@ uint8_t W5100Class::isW5100(void)
231253 return 1 ;
232254}
233255
256+ uint8_t W5100Class::isW5100S (void )
257+ {
258+ chip = 50 ;
259+ // Serial.println("w5100.cpp: detect W5100S chip");
260+ if (!softReset ()) return 0 ;
261+ writeMR (0x13 );
262+ if (readMR () != 0x13 ) return 0 ;
263+ writeMR (0x03 );
264+ if (readMR () != 0x03 ) return 0 ;
265+ int ver = readVERSIONR_W5100S ();
266+ // Serial.print("version=");
267+ // Serial.println(ver);
268+ if (ver != 81 ) return 0 ;
269+ // Serial.println("chip is W5100S");
270+ return 1 ;
271+ }
272+
234273uint8_t W5100Class::isW5200 (void )
235274{
236275 chip = 52 ;
@@ -275,6 +314,12 @@ W5100Linkstatus W5100Class::getLinkStatus()
275314
276315 if (!init ()) return UNKNOWN;
277316 switch (chip) {
317+ case 50 :
318+ SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
319+ phystatus = readPHYCFGR_W5100S ();
320+ SPI.endTransaction ();
321+ if (phystatus & 0x01 ) return LINK_ON;
322+ return LINK_OFF;
278323 case 52 :
279324 SPI.beginTransaction (SPI_ETHERNET_SETTINGS);
280325 phystatus = readPSTATUS_W5200 ();
@@ -286,7 +331,7 @@ W5100Linkstatus W5100Class::getLinkStatus()
286331 phystatus = readPHYCFGR_W5500 ();
287332 SPI.endTransaction ();
288333 if (phystatus & 0x01 ) return LINK_ON;
289- return LINK_OFF;
334+ return LINK_OFF;
290335 default :
291336 return UNKNOWN;
292337 }
@@ -296,7 +341,7 @@ uint16_t W5100Class::write(uint16_t addr, const uint8_t *buf, uint16_t len)
296341{
297342 uint8_t cmd[8 ];
298343
299- if (chip == 51 ) {
344+ if (chip == 51 || chip == 50 ) {
300345 for (uint16_t i=0 ; i<len; i++) {
301346 setSS ();
302347 SPI.transfer (0xF0 );
@@ -387,7 +432,7 @@ uint16_t W5100Class::read(uint16_t addr, uint8_t *buf, uint16_t len)
387432{
388433 uint8_t cmd[4 ];
389434
390- if (chip == 51 ) {
435+ if (chip == 51 || chip == 50 ) {
391436 for (uint16_t i=0 ; i < len; i++) {
392437 setSS ();
393438 #if 1
0 commit comments