Skip to content

Commit 50cc730

Browse files
committed
Renaming SPI.send() to SPI.transfer() to better reflect its bi-directional nature.
1 parent f82d28e commit 50cc730

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

examples/BarometricPressureWebServer/BarometricPressureWebServer.pde

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ void writeRegister(byte registerName, byte registerValue) {
183183
// take the chip select low to select the device:
184184
digitalWrite(chipSelectPin, LOW);
185185

186-
SPI.send(registerName); //Send register location
187-
SPI.send(registerValue); //Send value to record into register
186+
SPI.transfer(registerName); //Send register location
187+
SPI.transfer(registerValue); //Send value to record into register
188188

189189
// take the chip select high to de-select:
190190
digitalWrite(chipSelectPin, HIGH);
@@ -205,16 +205,16 @@ unsigned int readRegister(byte registerName, int numBytes) {
205205
// take the chip select low to select the device:
206206
digitalWrite(chipSelectPin, LOW);
207207
// send the device the register you want to read:
208-
int command = SPI.send(registerName);
208+
int command = SPI.transfer(registerName);
209209
// send a value of 0 to read the first byte returned:
210-
inByte = SPI.send(0x00);
210+
inByte = SPI.transfer(0x00);
211211

212212
result = inByte;
213213
// if there's more than one byte returned,
214214
// shift the first byte then get the second byte:
215215
if (numBytes > 1){
216216
result = inByte << 8;
217-
inByte = SPI.send(0x00);
217+
inByte = SPI.transfer(0x00);
218218
result = result |inByte;
219219
}
220220
// take the chip select high to de-select:

utility/w5100.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ void W5100Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *ds
118118
uint8_t W5100Class::write(uint16_t _addr, uint8_t _data)
119119
{
120120
setSS();
121-
SPI.send(0xF0);
122-
SPI.send(_addr >> 8);
123-
SPI.send(_addr & 0xFF);
124-
SPI.send(_data);
121+
SPI.transfer(0xF0);
122+
SPI.transfer(_addr >> 8);
123+
SPI.transfer(_addr & 0xFF);
124+
SPI.transfer(_data);
125125
resetSS();
126126
return 1;
127127
}
@@ -131,11 +131,11 @@ uint16_t W5100Class::write(uint16_t _addr, uint8_t *_buf, uint16_t _len)
131131
for (int i=0; i<_len; i++)
132132
{
133133
setSS();
134-
SPI.send(0xF0);
135-
SPI.send(_addr >> 8);
136-
SPI.send(_addr & 0xFF);
134+
SPI.transfer(0xF0);
135+
SPI.transfer(_addr >> 8);
136+
SPI.transfer(_addr & 0xFF);
137137
_addr++;
138-
SPI.send(_buf[i]);
138+
SPI.transfer(_buf[i]);
139139
resetSS();
140140
}
141141
return _len;
@@ -144,10 +144,10 @@ uint16_t W5100Class::write(uint16_t _addr, uint8_t *_buf, uint16_t _len)
144144
uint8_t W5100Class::read(uint16_t _addr)
145145
{
146146
setSS();
147-
SPI.send(0x0F);
148-
SPI.send(_addr >> 8);
149-
SPI.send(_addr & 0xFF);
150-
uint8_t _data = SPI.send(0);
147+
SPI.transfer(0x0F);
148+
SPI.transfer(_addr >> 8);
149+
SPI.transfer(_addr & 0xFF);
150+
uint8_t _data = SPI.transfer(0);
151151
resetSS();
152152
return _data;
153153
}
@@ -157,11 +157,11 @@ uint16_t W5100Class::read(uint16_t _addr, uint8_t *_buf, uint16_t _len)
157157
for (int i=0; i<_len; i++)
158158
{
159159
setSS();
160-
SPI.send(0x0F);
161-
SPI.send(_addr >> 8);
162-
SPI.send(_addr & 0xFF);
160+
SPI.transfer(0x0F);
161+
SPI.transfer(_addr >> 8);
162+
SPI.transfer(_addr & 0xFF);
163163
_addr++;
164-
_buf[i] = SPI.send(0);
164+
_buf[i] = SPI.transfer(0);
165165
resetSS();
166166
}
167167
return _len;

0 commit comments

Comments
 (0)