sakthi priya amirtharaj / Mbed 2 deprecated master_i2c1

Dependencies:   mbed

Fork of freemaster_write2master_working by green rosh

Files at this revision

API Documentation at this revision

Comitter:
sakthipriya
Date:
Thu Dec 11 11:00:09 2014 +0000
Parent:
2:2dd5bd9a64fb
Commit message:
i2c not working when master restarts

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Dec 10 16:39:17 2014 +0000
+++ b/main.cpp	Thu Dec 11 11:00:09 2014 +0000
@@ -5,14 +5,18 @@
 Serial pc (USBTX,USBRX);
 DigitalOut interrupt(D9);
 InterruptIn data_ready(D10);
+
+
 void FUNC_I2C_MASTER()
 {
     //printf("press backspace for master to start \n\r");
     //while(1){
       //  interrupt = 0;
       //  if(pc.getc()=='z'){
+            
+            wait(0.5);
             interrupt = 1;
-            printf("\nEntered master function\n");
+            printf("\nEntered master function\n\r");
             int ack0 =true; 
             char *data =  new char;
             *data = 'b';
@@ -24,7 +28,7 @@
                 //printf("2 master clk freq setup and addressing slave\n\r");
                 
                 master.start();                                 //initiating the data transfer
-                ack0 =  master.read(addr,data,1);
+                ack0 =  master.read(addr|1,data,1);
             }
             if(!ack0)
             {
@@ -36,13 +40,94 @@
             //printf("done\n\r");
             delete data;
             interrupt=0;
+            
 }
 void main()
 {
     data_ready.rise(&FUNC_I2C_MASTER);
-    printf("\nstarted master\n");
+    printf("\nstarted master\n\r");
     while(1)
     {
         ;
     }
-}           
\ No newline at end of file
+}           
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+