I2C master

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jimmy4399
Date:
Wed Jul 24 03:27:30 2019 +0000
Commit message:
I2C Master

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jul 24 03:27:30 2019 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+I2C i2c(I2C_SDA , I2C_SCL ); 
+
+const int addr8bit = 0xA0; // 8bit I2C address, 0x90
+
+char cmd[2];
+
+int main() 
+{
+    while(1)
+    {
+        cmd[0] = 'a';
+        cmd[1] = 'b';
+        i2c.write(addr8bit, cmd, 2);
+ 
+        wait(0.5);
+ 
+        #if 0
+        cmd[0] = 0x00;
+        i2c.write(addr8bit, cmd, 1);
+        i2c.read( addr8bit, cmd, 2);
+        #endif
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Jul 24 03:27:30 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file