mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-15 12:29:26 +01:00
Ethernet library now use SPI_HAS_EXTENDED_CS_PIN_HANDLING to detect when Extended SPI API is available
This commit is contained in:
parent
419597f7e4
commit
2274922d5e
@ -26,7 +26,7 @@ void W5100Class::init(void)
|
|||||||
{
|
{
|
||||||
delay(300);
|
delay(300);
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if !defined(SPI_HAS_EXTENDED_CS_PIN_HANDLING)
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
initSS();
|
initSS();
|
||||||
#else
|
#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)
|
uint8_t W5100Class::write(uint16_t _addr, uint8_t _data)
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if !defined(SPI_HAS_EXTENDED_CS_PIN_HANDLING)
|
||||||
setSS();
|
setSS();
|
||||||
SPI.transfer(0xF0);
|
SPI.transfer(0xF0);
|
||||||
SPI.transfer(_addr >> 8);
|
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++)
|
for (uint16_t i=0; i<_len; i++)
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if !defined(SPI_HAS_EXTENDED_CS_PIN_HANDLING)
|
||||||
setSS();
|
setSS();
|
||||||
SPI.transfer(0xF0);
|
SPI.transfer(0xF0);
|
||||||
SPI.transfer(_addr >> 8);
|
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)
|
uint8_t W5100Class::read(uint16_t _addr)
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if !defined(SPI_HAS_EXTENDED_CS_PIN_HANDLING)
|
||||||
setSS();
|
setSS();
|
||||||
SPI.transfer(0x0F);
|
SPI.transfer(0x0F);
|
||||||
SPI.transfer(_addr >> 8);
|
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++)
|
for (uint16_t i=0; i<_len; i++)
|
||||||
{
|
{
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if !defined(SPI_HAS_EXTENDED_CS_PIN_HANDLING)
|
||||||
setSS();
|
setSS();
|
||||||
SPI.transfer(0x0F);
|
SPI.transfer(0x0F);
|
||||||
SPI.transfer(_addr >> 8);
|
SPI.transfer(_addr >> 8);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#define SPI_CS 10
|
#define SPI_CS 10
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if !defined(SPI_HAS_EXTENDED_CS_PIN_HANDLING)
|
||||||
#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
|
#define SPI_ETHERNET_SETTINGS SPISettings(4000000, MSBFIRST, SPI_MODE0)
|
||||||
#else
|
#else
|
||||||
#define SPI_ETHERNET_SETTINGS SPI_CS,SPISettings(4000000, MSBFIRST, SPI_MODE0)
|
#define SPI_ETHERNET_SETTINGS SPI_CS,SPISettings(4000000, MSBFIRST, SPI_MODE0)
|
||||||
@ -330,25 +330,25 @@ private:
|
|||||||
uint16_t RBASE[SOCKETS]; // Rx buffer base address
|
uint16_t RBASE[SOCKETS]; // Rx buffer base address
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if !defined(SPI_HAS_EXTENDED_CS_PIN_HANDLING)
|
||||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
inline static void initSS() { DDRB |= _BV(4); };
|
inline static void initSS() { DDRB |= _BV(4); };
|
||||||
inline static void setSS() { PORTB &= ~_BV(4); };
|
inline static void setSS() { PORTB &= ~_BV(4); };
|
||||||
inline static void resetSS() { PORTB |= _BV(4); };
|
inline static void resetSS() { PORTB |= _BV(4); };
|
||||||
#elif defined(__AVR_ATmega32U4__)
|
#elif defined(__AVR_ATmega32U4__)
|
||||||
inline static void initSS() { DDRB |= _BV(6); };
|
inline static void initSS() { DDRB |= _BV(6); };
|
||||||
inline static void setSS() { PORTB &= ~_BV(6); };
|
inline static void setSS() { PORTB &= ~_BV(6); };
|
||||||
inline static void resetSS() { PORTB |= _BV(6); };
|
inline static void resetSS() { PORTB |= _BV(6); };
|
||||||
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
|
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
|
||||||
inline static void initSS() { DDRB |= _BV(0); };
|
inline static void initSS() { DDRB |= _BV(0); };
|
||||||
inline static void setSS() { PORTB &= ~_BV(0); };
|
inline static void setSS() { PORTB &= ~_BV(0); };
|
||||||
inline static void resetSS() { PORTB |= _BV(0); };
|
inline static void resetSS() { PORTB |= _BV(0); };
|
||||||
#else
|
#else
|
||||||
inline static void initSS() { DDRB |= _BV(2); };
|
inline static void initSS() { DDRB |= _BV(2); };
|
||||||
inline static void setSS() { PORTB &= ~_BV(2); };
|
inline static void setSS() { PORTB &= ~_BV(2); };
|
||||||
inline static void resetSS() { PORTB |= _BV(2); };
|
inline static void resetSS() { PORTB |= _BV(2); };
|
||||||
#endif
|
#endif
|
||||||
#endif // ARDUINO_ARCH_AVR
|
#endif // !SPI_HAS_EXTENDED_CS_PIN_HANDLING
|
||||||
};
|
};
|
||||||
|
|
||||||
extern W5100Class W5100;
|
extern W5100Class W5100;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user