mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-20 10:24:18 +03:00
@ -5,6 +5,8 @@ With the Arduino Ethernet Shield, this library allows an Arduino board to connec
|
||||
For more information about this library please visit us at
|
||||
http://www.arduino.cc/en/Reference/Ethernet
|
||||
|
||||
modified to run on the ESP8266
|
||||
|
||||
== License ==
|
||||
|
||||
Copyright (c) 2010 Arduino LLC. All right reserved.
|
||||
|
@ -8,9 +8,15 @@ uint8_t EthernetClass::_state[MAX_SOCK_NUM] = {
|
||||
uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = {
|
||||
0, 0, 0, 0 };
|
||||
|
||||
#ifdef ESP8266
|
||||
static DhcpClass s_dhcp;
|
||||
#endif
|
||||
|
||||
int EthernetClass::begin(uint8_t *mac_address)
|
||||
{
|
||||
#ifndef ESP8266
|
||||
static DhcpClass s_dhcp;
|
||||
#endif
|
||||
_dhcp = &s_dhcp;
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ void W5100Class::init(void)
|
||||
{
|
||||
delay(300);
|
||||
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(ESP8266)
|
||||
SPI.begin();
|
||||
initSS();
|
||||
#else
|
||||
@ -136,7 +136,7 @@ void W5100Class::read_data(SOCKET s, volatile uint16_t src, volatile uint8_t *ds
|
||||
|
||||
uint8_t W5100Class::write(uint16_t _addr, uint8_t _data)
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(ESP8266)
|
||||
setSS();
|
||||
SPI.transfer(0xF0);
|
||||
SPI.transfer(_addr >> 8);
|
||||
@ -156,7 +156,7 @@ uint16_t W5100Class::write(uint16_t _addr, const uint8_t *_buf, uint16_t _len)
|
||||
{
|
||||
for (uint16_t i=0; i<_len; i++)
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(ESP8266)
|
||||
setSS();
|
||||
SPI.transfer(0xF0);
|
||||
SPI.transfer(_addr >> 8);
|
||||
@ -177,7 +177,7 @@ uint16_t W5100Class::write(uint16_t _addr, const uint8_t *_buf, uint16_t _len)
|
||||
|
||||
uint8_t W5100Class::read(uint16_t _addr)
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(ESP8266)
|
||||
setSS();
|
||||
SPI.transfer(0x0F);
|
||||
SPI.transfer(_addr >> 8);
|
||||
@ -197,7 +197,7 @@ uint16_t W5100Class::read(uint16_t _addr, uint8_t *_buf, uint16_t _len)
|
||||
{
|
||||
for (uint16_t i=0; i<_len; i++)
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(ESP8266)
|
||||
setSS();
|
||||
SPI.transfer(0x0F);
|
||||
SPI.transfer(_addr >> 8);
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
|
||||
#elif defined(ESP8266)
|
||||
#define SPI_ETHERNET_SETTINGS SPISettings(14000000, MSBFIRST, SPI_MODE0)
|
||||
#else
|
||||
#define SPI_ETHERNET_SETTINGS SPI_CS,SPISettings(4000000, MSBFIRST, SPI_MODE0)
|
||||
#endif
|
||||
@ -348,6 +350,10 @@ private:
|
||||
inline static void setSS() { PORTB &= ~_BV(2); };
|
||||
inline static void resetSS() { PORTB |= _BV(2); };
|
||||
#endif
|
||||
#elif defined(ESP8266)
|
||||
inline static void initSS() { pinMode(SS, OUTPUT); };
|
||||
inline static void setSS() { GPOC = digitalPinToBitMask(SS); };
|
||||
inline static void resetSS() { GPOS = digitalPinToBitMask(SS); };
|
||||
#endif // ARDUINO_ARCH_AVR
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user