diff --git a/libraries/Wire/arch/avr/Wire.cpp b/hardware/arduino/avr/libraries/Wire/Wire.cpp similarity index 99% rename from libraries/Wire/arch/avr/Wire.cpp rename to hardware/arduino/avr/libraries/Wire/Wire.cpp index 899901d41..4e7a17c47 100644 --- a/libraries/Wire/arch/avr/Wire.cpp +++ b/hardware/arduino/avr/libraries/Wire/Wire.cpp @@ -23,10 +23,10 @@ extern "C" { #include #include #include - #include "utility/twi.h" + #include "twi.h" } -#include "Wire_Class.h" +#include "Wire.h" // Initialize Class Variables ////////////////////////////////////////////////// diff --git a/libraries/Wire/arch/avr/Wire_Class.h b/hardware/arduino/avr/libraries/Wire/Wire.h similarity index 100% rename from libraries/Wire/arch/avr/Wire_Class.h rename to hardware/arduino/avr/libraries/Wire/Wire.h diff --git a/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino b/hardware/arduino/avr/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino similarity index 100% rename from libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino rename to hardware/arduino/avr/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.ino diff --git a/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino b/hardware/arduino/avr/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino similarity index 100% rename from libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino rename to hardware/arduino/avr/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.ino diff --git a/libraries/Wire/examples/master_reader/master_reader.ino b/hardware/arduino/avr/libraries/Wire/examples/master_reader/master_reader.ino similarity index 100% rename from libraries/Wire/examples/master_reader/master_reader.ino rename to hardware/arduino/avr/libraries/Wire/examples/master_reader/master_reader.ino diff --git a/libraries/Wire/examples/master_writer/master_writer.ino b/hardware/arduino/avr/libraries/Wire/examples/master_writer/master_writer.ino similarity index 100% rename from libraries/Wire/examples/master_writer/master_writer.ino rename to hardware/arduino/avr/libraries/Wire/examples/master_writer/master_writer.ino diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/hardware/arduino/avr/libraries/Wire/examples/slave_receiver/slave_receiver.ino similarity index 100% rename from libraries/Wire/examples/slave_receiver/slave_receiver.ino rename to hardware/arduino/avr/libraries/Wire/examples/slave_receiver/slave_receiver.ino diff --git a/libraries/Wire/examples/slave_sender/slave_sender.ino b/hardware/arduino/avr/libraries/Wire/examples/slave_sender/slave_sender.ino similarity index 100% rename from libraries/Wire/examples/slave_sender/slave_sender.ino rename to hardware/arduino/avr/libraries/Wire/examples/slave_sender/slave_sender.ino diff --git a/hardware/arduino/avr/libraries/Wire/keywords.txt b/hardware/arduino/avr/libraries/Wire/keywords.txt new file mode 100644 index 000000000..12f129b99 --- /dev/null +++ b/hardware/arduino/avr/libraries/Wire/keywords.txt @@ -0,0 +1,31 @@ +####################################### +# Syntax Coloring Map For Wire +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +begin KEYWORD2 +beginTransmission KEYWORD2 +endTransmission KEYWORD2 +requestFrom KEYWORD2 +send KEYWORD2 +receive KEYWORD2 +onReceive KEYWORD2 +onRequest KEYWORD2 + +####################################### +# Instances (KEYWORD2) +####################################### + +Wire KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/libraries/Wire/arch/avr/utility/twi.c b/hardware/arduino/avr/libraries/Wire/utility/twi.c similarity index 100% rename from libraries/Wire/arch/avr/utility/twi.c rename to hardware/arduino/avr/libraries/Wire/utility/twi.c diff --git a/libraries/Wire/arch/avr/utility/twi.h b/hardware/arduino/avr/libraries/Wire/utility/twi.h similarity index 100% rename from libraries/Wire/arch/avr/utility/twi.h rename to hardware/arduino/avr/libraries/Wire/utility/twi.h diff --git a/libraries/Wire/arch/sam/Wire.cpp b/hardware/arduino/sam/libraries/Wire/Wire.cpp similarity index 99% rename from libraries/Wire/arch/sam/Wire.cpp rename to hardware/arduino/sam/libraries/Wire/Wire.cpp index 915cca7cf..90947cbb1 100644 --- a/libraries/Wire/arch/sam/Wire.cpp +++ b/hardware/arduino/sam/libraries/Wire/Wire.cpp @@ -22,7 +22,7 @@ extern "C" { #include } -#include "Wire_Class.h" +#include "Wire.h" static inline bool TWI_FailedAcknowledge(Twi *pTwi) { return pTwi->TWI_SR & TWI_SR_NACK; diff --git a/libraries/Wire/arch/sam/Wire_Class.h b/hardware/arduino/sam/libraries/Wire/Wire.h similarity index 100% rename from libraries/Wire/arch/sam/Wire_Class.h rename to hardware/arduino/sam/libraries/Wire/Wire.h diff --git a/hardware/arduino/sam/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde b/hardware/arduino/sam/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde new file mode 100644 index 000000000..9c41c18f1 --- /dev/null +++ b/hardware/arduino/sam/libraries/Wire/examples/SFRRanger_reader/SFRRanger_reader.pde @@ -0,0 +1,87 @@ +// I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder +// by Nicholas Zambetti +// and James Tichenor + +// Demonstrates use of the Wire library reading data from the +// Devantech Utrasonic Rangers SFR08 and SFR10 + +// Created 29 April 2006 + +// This example code is in the public domain. + + +#include + +void setup() +{ + Wire.begin(); // join i2c bus (address optional for master) + Serial.begin(9600); // start serial communication at 9600bps +} + +int reading = 0; + +void loop() +{ + // step 1: instruct sensor to read echoes + Wire.beginTransmission(112); // transmit to device #112 (0x70) + // the address specified in the datasheet is 224 (0xE0) + // but i2c adressing uses the high 7 bits so it's 112 + Wire.write(byte(0x00)); // sets register pointer to the command register (0x00) + Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50) + // use 0x51 for centimeters + // use 0x52 for ping microseconds + Wire.endTransmission(); // stop transmitting + + // step 2: wait for readings to happen + delay(70); // datasheet suggests at least 65 milliseconds + + // step 3: instruct sensor to return a particular echo reading + Wire.beginTransmission(112); // transmit to device #112 + Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02) + Wire.endTransmission(); // stop transmitting + + // step 4: request reading from sensor + Wire.requestFrom(112, 2); // request 2 bytes from slave device #112 + + // step 5: receive reading from sensor + if(2 <= Wire.available()) // if two bytes were received + { + reading = Wire.read(); // receive high byte (overwrites previous reading) + reading = reading << 8; // shift high byte to be high 8 bits + reading |= Wire.read(); // receive low byte as lower 8 bits + Serial.println(reading); // print the reading + } + + delay(250); // wait a bit since people have to read the output :) +} + + +/* + +// The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08) +// usage: changeAddress(0x70, 0xE6); + +void changeAddress(byte oldAddress, byte newAddress) +{ + Wire.beginTransmission(oldAddress); + Wire.write(byte(0x00)); + Wire.write(byte(0xA0)); + Wire.endTransmission(); + + Wire.beginTransmission(oldAddress); + Wire.write(byte(0x00)); + Wire.write(byte(0xAA)); + Wire.endTransmission(); + + Wire.beginTransmission(oldAddress); + Wire.write(byte(0x00)); + Wire.write(byte(0xA5)); + Wire.endTransmission(); + + Wire.beginTransmission(oldAddress); + Wire.write(byte(0x00)); + Wire.write(newAddress); + Wire.endTransmission(); +} + +*/ diff --git a/hardware/arduino/sam/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde b/hardware/arduino/sam/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde new file mode 100644 index 000000000..38da1c543 --- /dev/null +++ b/hardware/arduino/sam/libraries/Wire/examples/digital_potentiometer/digital_potentiometer.pde @@ -0,0 +1,39 @@ +// I2C Digital Potentiometer +// by Nicholas Zambetti +// and Shawn Bonkowski + +// Demonstrates use of the Wire library +// Controls AD5171 digital potentiometer via I2C/TWI + +// Created 31 March 2006 + +// This example code is in the public domain. + +// This example code is in the public domain. + + +#include + +void setup() +{ + Wire.begin(); // join i2c bus (address optional for master) +} + +byte val = 0; + +void loop() +{ + Wire.beginTransmission(44); // transmit to device #44 (0x2c) + // device address is specified in datasheet + Wire.write(byte(0x00)); // sends instruction byte + Wire.write(val); // sends potentiometer value byte + Wire.endTransmission(); // stop transmitting + + val++; // increment value + if(val == 64) // if reached 64th position (max) + { + val = 0; // start over from lowest value + } + delay(500); +} + diff --git a/hardware/arduino/sam/libraries/Wire/examples/master_reader/master_reader.pde b/hardware/arduino/sam/libraries/Wire/examples/master_reader/master_reader.pde new file mode 100644 index 000000000..4124d7d6b --- /dev/null +++ b/hardware/arduino/sam/libraries/Wire/examples/master_reader/master_reader.pde @@ -0,0 +1,32 @@ +// Wire Master Reader +// by Nicholas Zambetti + +// Demonstrates use of the Wire library +// Reads data from an I2C/TWI slave device +// Refer to the "Wire Slave Sender" example for use with this + +// Created 29 March 2006 + +// This example code is in the public domain. + + +#include + +void setup() +{ + Wire.begin(); // join i2c bus (address optional for master) + Serial.begin(9600); // start serial for output +} + +void loop() +{ + Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 + + while(Wire.available()) // slave may send less than requested + { + char c = Wire.read(); // receive a byte as character + Serial.print(c); // print the character + } + + delay(500); +} diff --git a/hardware/arduino/sam/libraries/Wire/examples/master_writer/master_writer.pde b/hardware/arduino/sam/libraries/Wire/examples/master_writer/master_writer.pde new file mode 100644 index 000000000..ccaa0361b --- /dev/null +++ b/hardware/arduino/sam/libraries/Wire/examples/master_writer/master_writer.pde @@ -0,0 +1,31 @@ +// Wire Master Writer +// by Nicholas Zambetti + +// Demonstrates use of the Wire library +// Writes data to an I2C/TWI slave device +// Refer to the "Wire Slave Receiver" example for use with this + +// Created 29 March 2006 + +// This example code is in the public domain. + + +#include + +void setup() +{ + Wire.begin(); // join i2c bus (address optional for master) +} + +byte x = 0; + +void loop() +{ + Wire.beginTransmission(4); // transmit to device #4 + Wire.write("x is "); // sends five bytes + Wire.write(x); // sends one byte + Wire.endTransmission(); // stop transmitting + + x++; + delay(500); +} diff --git a/hardware/arduino/sam/libraries/Wire/examples/slave_receiver/slave_receiver.pde b/hardware/arduino/sam/libraries/Wire/examples/slave_receiver/slave_receiver.pde new file mode 100644 index 000000000..60dd4bdde --- /dev/null +++ b/hardware/arduino/sam/libraries/Wire/examples/slave_receiver/slave_receiver.pde @@ -0,0 +1,38 @@ +// Wire Slave Receiver +// by Nicholas Zambetti + +// Demonstrates use of the Wire library +// Receives data as an I2C/TWI slave device +// Refer to the "Wire Master Writer" example for use with this + +// Created 29 March 2006 + +// This example code is in the public domain. + + +#include + +void setup() +{ + Wire.begin(4); // join i2c bus with address #4 + Wire.onReceive(receiveEvent); // register event + Serial.begin(9600); // start serial for output +} + +void loop() +{ + delay(100); +} + +// function that executes whenever data is received from master +// this function is registered as an event, see setup() +void receiveEvent(int howMany) +{ + while(1 < Wire.available()) // loop through all but the last + { + char c = Wire.read(); // receive byte as a character + Serial.print(c); // print the character + } + int x = Wire.read(); // receive byte as an integer + Serial.println(x); // print the integer +} diff --git a/hardware/arduino/sam/libraries/Wire/examples/slave_sender/slave_sender.pde b/hardware/arduino/sam/libraries/Wire/examples/slave_sender/slave_sender.pde new file mode 100644 index 000000000..d3b238af9 --- /dev/null +++ b/hardware/arduino/sam/libraries/Wire/examples/slave_sender/slave_sender.pde @@ -0,0 +1,32 @@ +// Wire Slave Sender +// by Nicholas Zambetti + +// Demonstrates use of the Wire library +// Sends data as an I2C/TWI slave device +// Refer to the "Wire Master Reader" example for use with this + +// Created 29 March 2006 + +// This example code is in the public domain. + + +#include + +void setup() +{ + Wire.begin(2); // join i2c bus with address #2 + Wire.onRequest(requestEvent); // register event +} + +void loop() +{ + delay(100); +} + +// function that executes whenever data is requested by master +// this function is registered as an event, see setup() +void requestEvent() +{ + Wire.write("hello "); // respond with message of 6 bytes + // as expected by master +} diff --git a/libraries/Wire/keywords.txt b/hardware/arduino/sam/libraries/Wire/keywords.txt similarity index 100% rename from libraries/Wire/keywords.txt rename to hardware/arduino/sam/libraries/Wire/keywords.txt diff --git a/libraries/Wire/library.properties b/libraries/Wire/library.properties deleted file mode 100644 index cad11e5c8..000000000 --- a/libraries/Wire/library.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=Wire -author=Arduino -email=info@arduino.cc -sentence=This library allows you to communicate with I2C / TWI devices. -paragraph= -url=http://arduino.cc/en/Reference/Wire -architectures=avr,sam -version=1.0 -dependencies= -core-dependencies=arduino (>=1.5.0) diff --git a/libraries/Wire/src/Wire.h b/libraries/Wire/src/Wire.h deleted file mode 100644 index 3a4611879..000000000 --- a/libraries/Wire/src/Wire.h +++ /dev/null @@ -1 +0,0 @@ -#include