I2C Master Test

Dependencies:   mbed

Revision:
0:4f748e5902b7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 04 09:02:48 2018 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+
+#define I2C_ARDUINO_ADDR   (0x08 << 1)  // 8bit address
+
+I2C I2cArduino(PB_9, PB_8);  // SDA, SCL
+
+int main()
+{
+    I2cArduino.frequency(400000);
+    
+    uint8_t x = 0;
+    while(1) {
+        if (I2cArduino.write(I2C_ARDUINO_ADDR, "x is ", 5, true) != 0) {
+            printf("I2C failure");
+        }
+        if (I2cArduino.write(I2C_ARDUINO_ADDR, (char *)&x, 1) != 0) {
+            printf("I2C failure");
+        }
+        x++;
+        wait_ms(500);
+    }
+}