sakthi priya amirtharaj
/
CDMS_icecream
i2c while removed working
Fork of CDMS_tc2 by
Diff: main.cpp
- Revision:
- 1:24c54d213671
- Parent:
- 0:252ce694a71e
- Child:
- 2:c75bb488d17c
diff -r 252ce694a71e -r 24c54d213671 main.cpp --- a/main.cpp Wed Dec 17 12:49:58 2014 +0000 +++ b/main.cpp Sat Dec 20 06:05:33 2014 +0000 @@ -25,7 +25,7 @@ //while(1){ //interrupt = 0; // if(pc.getc()=='z'){ - wait(0.5); + //wait(0.5); interrupt = 1; printf("\nMaster executed\n"); @@ -55,7 +55,7 @@ }*/ - while(ack0) + while(ack0 && data_ready ==1 ) { //printf("2 master clk freq setup and addressing slave\n\r"); @@ -72,6 +72,7 @@ //printf("done\n\r"); //delete data; interrupt=0; + printf("\n blahblah\n\r"); } void T_I2C_MASTER_FSLAVE(void const *args) @@ -80,12 +81,15 @@ while(1) { Thread::signal_wait(0x1); + + FUNC_I2C_MASTER_FSLAVE(data_receive,25); /*i2c_data * i2c_data_r = i2c_data_receive.alloc(); strcpy(i2c_data_r->data , data_receive); i2c_data_r->length = 25; i2c_data_receive.put(i2c_data_r);*/ printf("\n Data received from slave is %s\n\r",data_receive); + } } @@ -121,7 +125,7 @@ i2c_data *i2c_data_s = (i2c_data*)evt.value.p; writedata = i2c_data_s -> data; master.frequency(100000); //set clock frequency - while(write2slave) + while(write2slave && interrupt ==1 ) { printf("master clk freq setup and addressing slave\n\r"); master.start(); //initiating the data transfer @@ -141,6 +145,7 @@ int main() { + interrupt=0; ptr_t_i2c = new Thread(T_I2C_MASTER_FSLAVE); data_ready.rise(&FUNC_INT); printf("\nstarted master\n");