I2C Master Test

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ryood
Date:
Sun Nov 04 09:02:48 2018 +0000
Commit message:
first commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 4f748e5902b7 main.cpp
--- /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);
+    }
+}
diff -r 000000000000 -r 4f748e5902b7 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Nov 04 09:02:48 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file