|
17 | 17 | #include <Arduino.h>
|
18 | 18 | #include <SPI.h>
|
19 | 19 |
|
20 |
| -// Safe for all chips |
21 |
| -#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0) |
22 |
| - |
23 |
| -// Safe for W5200 and W5500, but too fast for W5100 |
24 |
| -// Uncomment this if you know you'll never need W5100 support. |
25 |
| -// Higher SPI clock only results in faster transfer to hosts on a LAN |
26 |
| -// or with very low packet latency. With ordinary internet latency, |
27 |
| -// the TCP window size & packet loss determine your overall speed. |
28 |
| -//#define SPI_ETHERNET_SETTINGS SPISettings(30000000, MSBFIRST, SPI_MODE0) |
| 20 | +#if defined(ETHERNET_SPI_SPEED) |
| 21 | + // Good! Using the configured value. |
| 22 | +#elif defined(ARDUINO_ARCH_ARC32) |
| 23 | + // Arduino 101's SPI can not run faster than 8 MHz. |
| 24 | + #define ETHERNET_SPI_SPEED 8000000 |
| 25 | +#elif defined(__SAMD21G18A__) |
| 26 | + // Arduino Zero can't use W5100-based shields faster than 8 MHz |
| 27 | + // https://github.com/arduino-libraries/Ethernet/issues/37#issuecomment-408036848 |
| 28 | + // W5500 does seem to work at 12 MHz. Delete this if only using W5500 |
| 29 | + #define ETHERNET_SPI_SPEED 8000000 |
| 30 | +#else |
| 31 | + // Default. Safe for all chips. |
| 32 | + #define ETHERNET_SPI_SPEED 14000000 |
| 33 | +#endif |
29 | 34 |
|
| 35 | +#define SPI_ETHERNET_SETTINGS SPISettings(ETHERNET_SPI_SPEED, MSBFIRST, SPI_MODE0) |
30 | 36 |
|
31 | 37 | // Require Ethernet.h, because we need MAX_SOCK_NUM
|
32 | 38 | #ifndef ethernet_h_
|
33 | 39 | #error "Ethernet.h must be included before w5100.h"
|
34 | 40 | #endif
|
35 | 41 |
|
36 |
| - |
37 |
| -// Arduino 101's SPI can not run faster than 8 MHz. |
38 |
| -#if defined(ARDUINO_ARCH_ARC32) |
39 |
| -#undef SPI_ETHERNET_SETTINGS |
40 |
| -#define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE0) |
41 |
| -#endif |
42 |
| - |
43 |
| -// Arduino Zero can't use W5100-based shields faster than 8 MHz |
44 |
| -// https://github.com/arduino-libraries/Ethernet/issues/37#issuecomment-408036848 |
45 |
| -// W5500 does seem to work at 12 MHz. Delete this if only using W5500 |
46 |
| -#if defined(__SAMD21G18A__) |
47 |
| -#undef SPI_ETHERNET_SETTINGS |
48 |
| -#define SPI_ETHERNET_SETTINGS SPISettings(8000000, MSBFIRST, SPI_MODE0) |
49 |
| -#endif |
50 |
| - |
51 |
| - |
52 | 42 | typedef uint8_t SOCKET;
|
53 | 43 |
|
54 | 44 | class SnMR {
|
|
0 commit comments