![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
while loop removed ( master cant send)
Fork of slave_working_obama by
Diff: main.cpp
- Revision:
- 6:8aea752c6eda
- Parent:
- 5:ce0bb4174ca4
- Child:
- 7:debeb7070a54
--- a/main.cpp Wed Dec 10 16:38:29 2014 +0000 +++ b/main.cpp Fri Dec 12 08:51:42 2014 +0000 @@ -17,11 +17,12 @@ Mail<i2c_data,16> i2c_data_receive; Mail<i2c_data,16> i2c_data_send; - + + int alpha; void FUNC_I2C_WRITE2CDMS(char *data, int length=1) { - - int slave_status = 1; + int slave_status = 1; + while(slave_status) { slave.address(0x20); @@ -60,15 +61,21 @@ while(1) { Thread::signal_wait(0x1); + printf("\nbdh\n"); + //i2c_status=alpha; + printf(" i2c status is %d " , i2c_status); if(i2c_status == 0) { FUNC_I2C_WRITE2CDMS(&data_receive); - //printf("\n Data received from CDMS is %c\n",data_receive); + printf("\n i2c=0\n\r"); + i2c_data * i2c_data_r = i2c_data_receive.alloc(); i2c_data_r->data = data_receive; i2c_data_r->length = 1; i2c_data_receive.put(i2c_data_r); + printf("\n Data received from CDMS is %c\n",data_receive); + } else if(i2c_status ==1 ) { @@ -82,9 +89,14 @@ printf("\nData sent to CDMS is %c\n",data_send); i2c_data_send.free(i2c_data_s); i2c_status = 0; + //delete i2c_data_r; } - } + + + + } + } } @@ -92,15 +104,18 @@ { // char * data = new char; //*data = 'a'; + //printf("\blah\n"); ptr_t_i2c->signal_set(0x1); //delete data; + } -void main() -{ - printf("\nStarted slave... waiting for master\n"); +int main() +{ + + ptr_t_i2c = new Thread(T_I2C_BAE); char data='a'; interrupt.rise(&FUNC_INT); @@ -125,12 +140,22 @@ //put in comments for receiving data data_ready=0; data = pc.getc(); + printf(" %c ", data); + i2c_status=1; + printf(" %d ", i2c_status ); i2c_data * i2c_data_s = i2c_data_send.alloc(); i2c_data_s->data = data; i2c_data_s->length = 1; i2c_data_send.put(i2c_data_s); + // wait(0.5); + alpha=i2c_status; data_ready=1; - i2c_status=1; + } -} \ No newline at end of file + +} + + + +