aboutsummaryrefslogtreecommitdiff
path: root/libraries/Wire
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/Wire')
-rw-r--r--libraries/Wire/Wire.cpp5
-rw-r--r--libraries/Wire/Wire.h5
-rw-r--r--libraries/Wire/examples/master_reader/master_reader.ino2
-rw-r--r--libraries/Wire/examples/master_writer/master_writer.ino2
-rw-r--r--libraries/Wire/examples/slave_receiver/slave_receiver.ino2
-rw-r--r--libraries/Wire/examples/slave_sender/slave_sender.ino2
-rw-r--r--libraries/Wire/keywords.txt1
-rw-r--r--libraries/Wire/library.properties9
8 files changed, 22 insertions, 6 deletions
diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp
index 4e7a17c..553add7 100644
--- a/libraries/Wire/Wire.cpp
+++ b/libraries/Wire/Wire.cpp
@@ -75,6 +75,11 @@ void TwoWire::begin(int address)
begin((uint8_t)address);
}
+void TwoWire::setClock(uint32_t frequency)
+{
+ TWBR = ((F_CPU / frequency) - 16) / 2;
+}
+
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop)
{
// clamp to buffer length
diff --git a/libraries/Wire/Wire.h b/libraries/Wire/Wire.h
index a93d0f5..732bdc3 100644
--- a/libraries/Wire/Wire.h
+++ b/libraries/Wire/Wire.h
@@ -49,6 +49,7 @@ class TwoWire : public Stream
void begin();
void begin(uint8_t);
void begin(int);
+ void setClock(uint32_t);
void beginTransmission(uint8_t);
void beginTransmission(int);
uint8_t endTransmission(void);
@@ -62,10 +63,10 @@ class TwoWire : public Stream
virtual int available(void);
virtual int read(void);
virtual int peek(void);
- virtual void flush(void);
+ virtual void flush(void);
void onReceive( void (*)(int) );
void onRequest( void (*)(void) );
-
+
inline size_t write(unsigned long n) { return write((uint8_t)n); }
inline size_t write(long n) { return write((uint8_t)n); }
inline size_t write(unsigned int n) { return write((uint8_t)n); }
diff --git a/libraries/Wire/examples/master_reader/master_reader.ino b/libraries/Wire/examples/master_reader/master_reader.ino
index 74f0155..2d2419b 100644
--- a/libraries/Wire/examples/master_reader/master_reader.ino
+++ b/libraries/Wire/examples/master_reader/master_reader.ino
@@ -20,7 +20,7 @@ void setup()
void loop()
{
- Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
+ Wire.requestFrom(8, 6); // request 6 bytes from slave device #8
while (Wire.available()) // slave may send less than requested
{
diff --git a/libraries/Wire/examples/master_writer/master_writer.ino b/libraries/Wire/examples/master_writer/master_writer.ino
index 482e922..9933cc2 100644
--- a/libraries/Wire/examples/master_writer/master_writer.ino
+++ b/libraries/Wire/examples/master_writer/master_writer.ino
@@ -21,7 +21,7 @@ byte x = 0;
void loop()
{
- Wire.beginTransmission(4); // transmit to device #4
+ Wire.beginTransmission(8); // transmit to device #8
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
diff --git a/libraries/Wire/examples/slave_receiver/slave_receiver.ino b/libraries/Wire/examples/slave_receiver/slave_receiver.ino
index 15eff9a..53df274 100644
--- a/libraries/Wire/examples/slave_receiver/slave_receiver.ino
+++ b/libraries/Wire/examples/slave_receiver/slave_receiver.ino
@@ -14,7 +14,7 @@
void setup()
{
- Wire.begin(4); // join i2c bus with address #4
+ Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
diff --git a/libraries/Wire/examples/slave_sender/slave_sender.ino b/libraries/Wire/examples/slave_sender/slave_sender.ino
index 4437ab1..26b9e52 100644
--- a/libraries/Wire/examples/slave_sender/slave_sender.ino
+++ b/libraries/Wire/examples/slave_sender/slave_sender.ino
@@ -14,7 +14,7 @@
void setup()
{
- Wire.begin(2); // join i2c bus with address #2
+ Wire.begin(8); // join i2c bus with address #8
Wire.onRequest(requestEvent); // register event
}
diff --git a/libraries/Wire/keywords.txt b/libraries/Wire/keywords.txt
index 12f129b..ff31475 100644
--- a/libraries/Wire/keywords.txt
+++ b/libraries/Wire/keywords.txt
@@ -11,6 +11,7 @@
#######################################
begin KEYWORD2
+setClock KEYWORD2
beginTransmission KEYWORD2
endTransmission KEYWORD2
requestFrom KEYWORD2
diff --git a/libraries/Wire/library.properties b/libraries/Wire/library.properties
new file mode 100644
index 0000000..0805847
--- /dev/null
+++ b/libraries/Wire/library.properties
@@ -0,0 +1,9 @@
+name=Wire
+version=1.0
+author=Arduino
+maintainer=Arduino <info@arduino.cc>
+sentence=Allows the communication between devices or sensors connected via Two Wire Interface Bus. For all Arduino boards, BUT Arduino DUE.
+paragraph=
+url=http://www.arduino.cc/en/Reference/Wire
+architectures=avr
+