From 3899ffc75d72393478d94b8464ca97166e307e39 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Sat, 7 Aug 2010 20:08:53 +0000 Subject: [PATCH] Renaming SPI.send() to SPI.transfer() to better reflect its bi-directional nature. --- .../BarometricPressureWebServer.pde | 10 +++--- libraries/Ethernet/utility/w5100.cpp | 32 +++++++++---------- libraries/SPI/SPI.h | 4 +-- .../BarometricPressureSensor.pde | 10 +++--- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.pde b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.pde index 39b865737..fd3f791d9 100644 --- a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.pde +++ b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.pde @@ -183,8 +183,8 @@ void writeRegister(byte registerName, byte registerValue) { // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); - SPI.send(registerName); //Send register location - SPI.send(registerValue); //Send value to record into register + SPI.transfer(registerName); //Send register location + SPI.transfer(registerValue); //Send value to record into register // take the chip select high to de-select: digitalWrite(chipSelectPin, HIGH); @@ -205,16 +205,16 @@ unsigned int readRegister(byte registerName, int numBytes) { // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); // send the device the register you want to read: - int command = SPI.send(registerName); + int command = SPI.transfer(registerName); // send a value of 0 to read the first byte returned: - inByte = SPI.send(0x00); + inByte = SPI.transfer(0x00); result = inByte; // if there's more than one byte returned, // shift the first byte then get the second byte: if (numBytes > 1){ result = inByte << 8; - inByte = SPI.send(0x00); + inByte = SPI.transfer(0x00); result = result |inByte; } // take the chip select high to de-select: diff --git a/libraries/Ethernet/utility/w5100.cpp b/libraries/Ethernet/utility/w5100.cpp index 06442268c..a134427d8 100644 --- a/libraries/Ethernet/utility/w5100.cpp +++ b/libraries/Ethernet/utility/w5100.cpp @@ -118,10 +118,10 @@ void W5100Class::read_data(SOCKET s, volatile uint8_t *src, volatile uint8_t *ds uint8_t W5100Class::write(uint16_t _addr, uint8_t _data) { setSS(); - SPI.send(0xF0); - SPI.send(_addr >> 8); - SPI.send(_addr & 0xFF); - SPI.send(_data); + SPI.transfer(0xF0); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + SPI.transfer(_data); resetSS(); return 1; } @@ -131,11 +131,11 @@ uint16_t W5100Class::write(uint16_t _addr, uint8_t *_buf, uint16_t _len) for (int i=0; i<_len; i++) { setSS(); - SPI.send(0xF0); - SPI.send(_addr >> 8); - SPI.send(_addr & 0xFF); + SPI.transfer(0xF0); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); _addr++; - SPI.send(_buf[i]); + SPI.transfer(_buf[i]); resetSS(); } return _len; @@ -144,10 +144,10 @@ uint16_t W5100Class::write(uint16_t _addr, uint8_t *_buf, uint16_t _len) uint8_t W5100Class::read(uint16_t _addr) { setSS(); - SPI.send(0x0F); - SPI.send(_addr >> 8); - SPI.send(_addr & 0xFF); - uint8_t _data = SPI.send(0); + SPI.transfer(0x0F); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); + uint8_t _data = SPI.transfer(0); resetSS(); return _data; } @@ -157,11 +157,11 @@ uint16_t W5100Class::read(uint16_t _addr, uint8_t *_buf, uint16_t _len) for (int i=0; i<_len; i++) { setSS(); - SPI.send(0x0F); - SPI.send(_addr >> 8); - SPI.send(_addr & 0xFF); + SPI.transfer(0x0F); + SPI.transfer(_addr >> 8); + SPI.transfer(_addr & 0xFF); _addr++; - _buf[i] = SPI.send(0); + _buf[i] = SPI.transfer(0); resetSS(); } return _len; diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h index a7e142e7b..48a53db7a 100644 --- a/libraries/SPI/SPI.h +++ b/libraries/SPI/SPI.h @@ -38,7 +38,7 @@ class SPIClass { public: SPIClass(); - inline static byte send(byte _data); + inline static byte transfer(byte _data); // SPI Configuration methods @@ -59,7 +59,7 @@ public: extern SPIClass SPI; -byte SPIClass::send(byte _data) { +byte SPIClass::transfer(byte _data) { SPDR = _data; while (!(SPSR & _BV(SPIF))) ; diff --git a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.pde b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.pde index 16ef0bec7..1fd7c6bbf 100644 --- a/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.pde +++ b/libraries/SPI/examples/BarometricPressureSensor/BarometricPressureSensor.pde @@ -92,8 +92,8 @@ void writeRegister(byte registerName, byte registerValue) { // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); - SPI.send(registerName); //Send register location - SPI.send(registerValue); //Send value to record into register + SPI.transfer(registerName); //Send register location + SPI.transfer(registerValue); //Send value to record into register // take the chip select high to de-select: digitalWrite(chipSelectPin, HIGH); //Select SPI device @@ -114,9 +114,9 @@ unsigned int readRegister(byte registerName, int numBytes) { // take the chip select low to select the device: digitalWrite(chipSelectPin, LOW); // send the device the register you want to read: - int command = SPI.send(registerName); + int command = SPI.transfer(registerName); // send a value of 0 to read the forst byte returned: - inByte = SPI.send(0x00); + inByte = SPI.transfer(0x00); // if there's more than one byte returned, // shift the first byte then get the second byte: @@ -126,7 +126,7 @@ unsigned int readRegister(byte registerName, int numBytes) { break; case 2: result = inByte << 8; - inByte = SPI.send(0x00); + inByte = SPI.transfer(0x00); result = result |inByte; break; }