green rosh
/
BAE_vr2_1_1
The one with the new HK
Fork of BAE_vr2_1_1 by
Diff: slave.cpp
- Revision:
- 10:ed6d3b8d1d56
- Parent:
- 9:221d218f4690
- Child:
- 11:cf6dac5fdc23
--- a/slave.cpp Mon Dec 15 05:58:04 2014 +0000 +++ b/slave.cpp Tue Dec 16 07:44:54 2014 +0000 @@ -14,12 +14,15 @@ typedef struct { - char data; // To avoid dynamic memory allocation + char data[13]; // To avoid dynamic memory allocation int length; }i2c_data; + + + Mail<i2c_data,16> i2c_data_receive; Mail<i2c_data,16> i2c_data_send; @@ -46,7 +49,7 @@ printf("\ndone\n\r"); } -char data_send,data_receive; +char data_send[13],data_receive[13]; void T_I2C_BAE() { //char data_send,data_receive; @@ -55,16 +58,16 @@ // Thread::signal_wait(0x1); //i2c_status = temp; //wait(0.5); - printf("\n entered thread\n\r"); + printf("\n entered thread %d\n\r",i2c_status); if(i2c_status == 0 && reset !=1) { - FUNC_I2C_WRITE2CDMS(&data_receive); + FUNC_I2C_WRITE2CDMS(data_receive); i2c_data * i2c_data_r = i2c_data_receive.alloc(); - i2c_data_r->data = data_receive; - i2c_data_r->length = 1; + strcpy(i2c_data_r->data,data_receive); + i2c_data_r->length = 13; i2c_data_receive.put(i2c_data_r); - printf("\n Data received from CDMS is %c\n\r",data_receive); + printf("\n Data received from CDMS is %s\n\r",data_receive); i2c_data_receive.free(i2c_data_r); // This has to be done from a differen thread } @@ -74,12 +77,13 @@ if (evt.status == osEventMail) { i2c_data *i2c_data_s = (i2c_data*)evt.value.p; - data_send = i2c_data_s -> data; - FUNC_I2C_WRITE2CDMS(&data_send); - printf("\nData sent to CDMS is %c\n\r",data_send); + strcpy(data_send,i2c_data_s -> data); + FUNC_I2C_WRITE2CDMS(data_send,13); + printf("\nData sent to CDMS is %s\n\r",data_send); i2c_data_send.free(i2c_data_s); i2c_status = 0; //temp = i2c_status; + } } @@ -103,14 +107,16 @@ void ir2master() { - char data='a'; + char data[13]; + strcpy(data,"sakthi "); + strcat(data,"priya"); data_ready=0; - data = pcslave.getc(); + //data = pcslave.getc(); reset =0; i2c_status=1; i2c_data * i2c_data_s = i2c_data_send.alloc(); - i2c_data_s->data = data; - i2c_data_s->length = 1; + strcpy(i2c_data_s->data,data); + i2c_data_s->length = 13; i2c_data_send.put(i2c_data_s); data_ready=1; //temp = i2c_status;