Skip to content

Commit 9a9652d

Browse files
committed
Revert "Wire library to the 1.5 format"
This reverts commit a318576.
1 parent 258c7af commit 9a9652d

File tree

22 files changed

+293
-14
lines changed

22 files changed

+293
-14
lines changed

libraries/Wire/arch/avr/Wire.cpp renamed to hardware/arduino/avr/libraries/Wire/Wire.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ extern "C" {
2323
#include <stdlib.h>
2424
#include <string.h>
2525
#include <inttypes.h>
26-
#include "utility/twi.h"
26+
#include "twi.h"
2727
}
2828

29-
#include "Wire_Class.h"
29+
#include "Wire.h"
3030

3131
// Initialize Class Variables //////////////////////////////////////////////////
3232

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#######################################
2+
# Syntax Coloring Map For Wire
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
#######################################
10+
# Methods and Functions (KEYWORD2)
11+
#######################################
12+
13+
begin KEYWORD2
14+
beginTransmission KEYWORD2
15+
endTransmission KEYWORD2
16+
requestFrom KEYWORD2
17+
send KEYWORD2
18+
receive KEYWORD2
19+
onReceive KEYWORD2
20+
onRequest KEYWORD2
21+
22+
#######################################
23+
# Instances (KEYWORD2)
24+
#######################################
25+
26+
Wire KEYWORD2
27+
28+
#######################################
29+
# Constants (LITERAL1)
30+
#######################################
31+

libraries/Wire/arch/sam/Wire.cpp renamed to hardware/arduino/sam/libraries/Wire/Wire.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern "C" {
2222
#include <string.h>
2323
}
2424

25-
#include "Wire_Class.h"
25+
#include "Wire.h"
2626

2727
static inline bool TWI_FailedAcknowledge(Twi *pTwi) {
2828
return pTwi->TWI_SR & TWI_SR_NACK;
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// I2C SRF10 or SRF08 Devantech Ultrasonic Ranger Finder
2+
// by Nicholas Zambetti <http://www.zambetti.com>
3+
// and James Tichenor <http://www.jamestichenor.net>
4+
5+
// Demonstrates use of the Wire library reading data from the
6+
// Devantech Utrasonic Rangers SFR08 and SFR10
7+
8+
// Created 29 April 2006
9+
10+
// This example code is in the public domain.
11+
12+
13+
#include <Wire.h>
14+
15+
void setup()
16+
{
17+
Wire.begin(); // join i2c bus (address optional for master)
18+
Serial.begin(9600); // start serial communication at 9600bps
19+
}
20+
21+
int reading = 0;
22+
23+
void loop()
24+
{
25+
// step 1: instruct sensor to read echoes
26+
Wire.beginTransmission(112); // transmit to device #112 (0x70)
27+
// the address specified in the datasheet is 224 (0xE0)
28+
// but i2c adressing uses the high 7 bits so it's 112
29+
Wire.write(byte(0x00)); // sets register pointer to the command register (0x00)
30+
Wire.write(byte(0x50)); // command sensor to measure in "inches" (0x50)
31+
// use 0x51 for centimeters
32+
// use 0x52 for ping microseconds
33+
Wire.endTransmission(); // stop transmitting
34+
35+
// step 2: wait for readings to happen
36+
delay(70); // datasheet suggests at least 65 milliseconds
37+
38+
// step 3: instruct sensor to return a particular echo reading
39+
Wire.beginTransmission(112); // transmit to device #112
40+
Wire.write(byte(0x02)); // sets register pointer to echo #1 register (0x02)
41+
Wire.endTransmission(); // stop transmitting
42+
43+
// step 4: request reading from sensor
44+
Wire.requestFrom(112, 2); // request 2 bytes from slave device #112
45+
46+
// step 5: receive reading from sensor
47+
if(2 <= Wire.available()) // if two bytes were received
48+
{
49+
reading = Wire.read(); // receive high byte (overwrites previous reading)
50+
reading = reading << 8; // shift high byte to be high 8 bits
51+
reading |= Wire.read(); // receive low byte as lower 8 bits
52+
Serial.println(reading); // print the reading
53+
}
54+
55+
delay(250); // wait a bit since people have to read the output :)
56+
}
57+
58+
59+
/*
60+
61+
// The following code changes the address of a Devantech Ultrasonic Range Finder (SRF10 or SRF08)
62+
// usage: changeAddress(0x70, 0xE6);
63+
64+
void changeAddress(byte oldAddress, byte newAddress)
65+
{
66+
Wire.beginTransmission(oldAddress);
67+
Wire.write(byte(0x00));
68+
Wire.write(byte(0xA0));
69+
Wire.endTransmission();
70+
71+
Wire.beginTransmission(oldAddress);
72+
Wire.write(byte(0x00));
73+
Wire.write(byte(0xAA));
74+
Wire.endTransmission();
75+
76+
Wire.beginTransmission(oldAddress);
77+
Wire.write(byte(0x00));
78+
Wire.write(byte(0xA5));
79+
Wire.endTransmission();
80+
81+
Wire.beginTransmission(oldAddress);
82+
Wire.write(byte(0x00));
83+
Wire.write(newAddress);
84+
Wire.endTransmission();
85+
}
86+
87+
*/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// I2C Digital Potentiometer
2+
// by Nicholas Zambetti <http://www.zambetti.com>
3+
// and Shawn Bonkowski <http://people.interaction-ivrea.it/s.bonkowski/>
4+
5+
// Demonstrates use of the Wire library
6+
// Controls AD5171 digital potentiometer via I2C/TWI
7+
8+
// Created 31 March 2006
9+
10+
// This example code is in the public domain.
11+
12+
// This example code is in the public domain.
13+
14+
15+
#include <Wire.h>
16+
17+
void setup()
18+
{
19+
Wire.begin(); // join i2c bus (address optional for master)
20+
}
21+
22+
byte val = 0;
23+
24+
void loop()
25+
{
26+
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
27+
// device address is specified in datasheet
28+
Wire.write(byte(0x00)); // sends instruction byte
29+
Wire.write(val); // sends potentiometer value byte
30+
Wire.endTransmission(); // stop transmitting
31+
32+
val++; // increment value
33+
if(val == 64) // if reached 64th position (max)
34+
{
35+
val = 0; // start over from lowest value
36+
}
37+
delay(500);
38+
}
39+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Wire Master Reader
2+
// by Nicholas Zambetti <http://www.zambetti.com>
3+
4+
// Demonstrates use of the Wire library
5+
// Reads data from an I2C/TWI slave device
6+
// Refer to the "Wire Slave Sender" example for use with this
7+
8+
// Created 29 March 2006
9+
10+
// This example code is in the public domain.
11+
12+
13+
#include <Wire.h>
14+
15+
void setup()
16+
{
17+
Wire.begin(); // join i2c bus (address optional for master)
18+
Serial.begin(9600); // start serial for output
19+
}
20+
21+
void loop()
22+
{
23+
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
24+
25+
while(Wire.available()) // slave may send less than requested
26+
{
27+
char c = Wire.read(); // receive a byte as character
28+
Serial.print(c); // print the character
29+
}
30+
31+
delay(500);
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Wire Master Writer
2+
// by Nicholas Zambetti <http://www.zambetti.com>
3+
4+
// Demonstrates use of the Wire library
5+
// Writes data to an I2C/TWI slave device
6+
// Refer to the "Wire Slave Receiver" example for use with this
7+
8+
// Created 29 March 2006
9+
10+
// This example code is in the public domain.
11+
12+
13+
#include <Wire.h>
14+
15+
void setup()
16+
{
17+
Wire.begin(); // join i2c bus (address optional for master)
18+
}
19+
20+
byte x = 0;
21+
22+
void loop()
23+
{
24+
Wire.beginTransmission(4); // transmit to device #4
25+
Wire.write("x is "); // sends five bytes
26+
Wire.write(x); // sends one byte
27+
Wire.endTransmission(); // stop transmitting
28+
29+
x++;
30+
delay(500);
31+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Wire Slave Receiver
2+
// by Nicholas Zambetti <http://www.zambetti.com>
3+
4+
// Demonstrates use of the Wire library
5+
// Receives data as an I2C/TWI slave device
6+
// Refer to the "Wire Master Writer" example for use with this
7+
8+
// Created 29 March 2006
9+
10+
// This example code is in the public domain.
11+
12+
13+
#include <Wire.h>
14+
15+
void setup()
16+
{
17+
Wire.begin(4); // join i2c bus with address #4
18+
Wire.onReceive(receiveEvent); // register event
19+
Serial.begin(9600); // start serial for output
20+
}
21+
22+
void loop()
23+
{
24+
delay(100);
25+
}
26+
27+
// function that executes whenever data is received from master
28+
// this function is registered as an event, see setup()
29+
void receiveEvent(int howMany)
30+
{
31+
while(1 < Wire.available()) // loop through all but the last
32+
{
33+
char c = Wire.read(); // receive byte as a character
34+
Serial.print(c); // print the character
35+
}
36+
int x = Wire.read(); // receive byte as an integer
37+
Serial.println(x); // print the integer
38+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Wire Slave Sender
2+
// by Nicholas Zambetti <http://www.zambetti.com>
3+
4+
// Demonstrates use of the Wire library
5+
// Sends data as an I2C/TWI slave device
6+
// Refer to the "Wire Master Reader" example for use with this
7+
8+
// Created 29 March 2006
9+
10+
// This example code is in the public domain.
11+
12+
13+
#include <Wire.h>
14+
15+
void setup()
16+
{
17+
Wire.begin(2); // join i2c bus with address #2
18+
Wire.onRequest(requestEvent); // register event
19+
}
20+
21+
void loop()
22+
{
23+
delay(100);
24+
}
25+
26+
// function that executes whenever data is requested by master
27+
// this function is registered as an event, see setup()
28+
void requestEvent()
29+
{
30+
Wire.write("hello "); // respond with message of 6 bytes
31+
// as expected by master
32+
}

libraries/Wire/library.properties

Lines changed: 0 additions & 10 deletions
This file was deleted.

libraries/Wire/src/Wire.h

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)