Chaitanya Viswa
/
_i2c_master
kjkjkjkjk
Fork of i2c_master by
Revision 2:c1387cf55c7d, committed 2014-07-17
- Comitter:
- viswachaitanya
- Date:
- Thu Jul 17 11:23:58 2014 +0000
- Parent:
- 1:14b369c0f314
- Commit message:
- i2c master test
Changed in this revision
diff -r 14b369c0f314 -r c1387cf55c7d main.cpp --- 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
diff -r 14b369c0f314 -r c1387cf55c7d master.cpp --- 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
diff -r 14b369c0f314 -r c1387cf55c7d master.h --- 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'