Skip to content

Update My Version #3684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions libraries/Ethernet/src/utility/w5100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,26 @@ W5100Class W5100;
#define TXBUF_BASE 0x4000
#define RXBUF_BASE 0x6000

uint8_t W5100Class::slaveSelect = 10;

void W5100Class::select(uint8_t _ss) {
slaveSelect = _ss;
}
void W5100Class::initSS(void) {
digitalWrite(slaveSelect, HIGH);
}
void W5100Class::setSS(void) {
digitalWrite(slaveSelect, LOW);
}
void W5100Class::resetSS(void) {
digitalWrite(slaveSelect, HIGH);
}

void W5100Class::init(void)
{
pinMode(slaveSelect,OUTPUT);
digitalWrite(slaveSelect,HIGH);

delay(300);

#if defined(ARDUINO_ARCH_AVR)
Expand Down
26 changes: 7 additions & 19 deletions libraries/Ethernet/src/utility/w5100.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class W5100Class {

public:
void init();
void select(uint8_t _ss);

/**
* @brief This function is being used for copy the data form Receive buffer of the chip to application buffer.
Expand Down Expand Up @@ -330,25 +331,12 @@ class W5100Class {
uint16_t RBASE[SOCKETS]; // Rx buffer base address

private:
#if defined(ARDUINO_ARCH_AVR)
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
inline static void initSS() { DDRB |= _BV(4); };
inline static void setSS() { PORTB &= ~_BV(4); };
inline static void resetSS() { PORTB |= _BV(4); };
#elif defined(__AVR_ATmega32U4__)
inline static void initSS() { DDRB |= _BV(6); };
inline static void setSS() { PORTB &= ~_BV(6); };
inline static void resetSS() { PORTB |= _BV(6); };
#elif defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB162__)
inline static void initSS() { DDRB |= _BV(0); };
inline static void setSS() { PORTB &= ~_BV(0); };
inline static void resetSS() { PORTB |= _BV(0); };
#else
inline static void initSS() { DDRB |= _BV(2); };
inline static void setSS() { PORTB &= ~_BV(2); };
inline static void resetSS() { PORTB |= _BV(2); };
#endif
#endif // ARDUINO_ARCH_AVR

static uint8_t slaveSelect;
static void initSS(void);
static void setSS(void);
static void resetSS(void);

};

extern W5100Class W5100;
Expand Down