]> Chaos Git - corbenik/bdfe.git/commitdiff
Added for Arduino Wire compatibility
authorAndrey Chilikin <achilikin@gmail.com>
Mon, 5 Oct 2015 18:58:06 +0000 (19:58 +0100)
committerAndrey Chilikin <achilikin@gmail.com>
Mon, 5 Oct 2015 18:58:06 +0000 (19:58 +0100)
wi2c.cpp [new file with mode: 0644]
wi2c.h [new file with mode: 0644]

diff --git a/wi2c.cpp b/wi2c.cpp
new file mode 100644 (file)
index 0000000..1db24f1
--- /dev/null
+++ b/wi2c.cpp
@@ -0,0 +1,18 @@
+#include <Wire.h>
+
+#include "wi2c.h"
+
+int i2c_start(uint8_t address)
+{
+       Wire.beginTransmission(address);
+}
+
+int i2c_write(uint8_t data)
+{
+       Wire.write(data);
+}
+
+int i2c_stop(void)
+{
+       Wire.endTransmission();
+}
diff --git a/wi2c.h b/wi2c.h
new file mode 100644 (file)
index 0000000..aff17bd
--- /dev/null
+++ b/wi2c.h
@@ -0,0 +1,16 @@
+#ifndef WIRE_TO_I2C_HEADER
+#define WIRE_TO_I2C_HEADER
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int i2c_start(uint8_t address);
+int i2c_write(uint8_t data);
+int i2c_stop(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif