kjkjkjkjk

Dependencies:   mbed

Fork of i2c_master by green rosh

Files at this revision

API Documentation at this revision

Comitter:
viswachaitanya
Date:
Thu Jul 17 11:23:58 2014 +0000
Parent:
1:14b369c0f314
Commit message:
i2c master test

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
master.cpp Show annotated file Show diff for this revision Revisions of this file
master.h Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Jul 15 10:06:29 2014 +0000
+++ b/main.cpp	Thu Jul 17 11:23:58 2014 +0000
@@ -2,9 +2,11 @@
 
 int main()
 {
+    
     while(true)
     {
+        wait(0.5);
         FUNC_I2C_MASTER_MAIN(1,0x20,24);
-        wait(23);
+        wait(5);
     }
 }
\ No newline at end of file
--- a/master.cpp	Tue Jul 15 10:06:29 2014 +0000
+++ b/master.cpp	Thu Jul 17 11:23:58 2014 +0000
@@ -6,6 +6,7 @@
   
 void FUNC_I2C_MASTER_MAIN(int command, int slave_address, int iterations)
 {
+    wait(0.5);
     printf("\nmaster entered\n");
     int acknowledge1;
     int acknowledge2;
@@ -13,14 +14,16 @@
     int addr = slave_address;
     while(loopvariable1)
     {
+        printf("\nmaster entered loop \n");
 //-------------writing the command to slave--------------------------------------------------------------        
         master.frequency(100000);                       //set clock frequency
         master.start();                                 //initiating the data transfer
         acknowledge2=master.write(addr|0x00);           //addressing the slave to write
         if(acknowledge2==1)                             //proceeding further only if slave is addressed
         {
+   //       printf("\nmaster entered 1 \n");
         acknowledge1=master.write(command);         //sending the command to slave 
-        if(acknowledge1==1)                             //proceeding further only if sent data is acknowledged   
+      if(acknowledge1==1)                             //proceeding further only if sent data is acknowledged   
            {
                pc.printf("acknowledge1=%d\n",acknowledge1);
                loopvariable1=0;                         //if acknowledged, breaking loop in next iteration
--- a/master.h	Tue Jul 15 10:06:29 2014 +0000
+++ b/master.h	Thu Jul 17 11:23:58 2014 +0000
@@ -1,7 +1,7 @@
 #include "mbed.h"                          //library                                              //
-#define get_hk_data '1'                      //sample telecommands
-#define telecommand2 '2'
-#define telecommand3 '3'
+#define get_hk_data 1                      //sample telecommands
+#define telecommand2 2
+#define telecommand3 3
 #define telecommand4 '4'
 #define telecommand5 '5'
 #define telecommand6 '6'