![](/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:
- 10:f2a8d9ac49d6
- Parent:
- 9:baf5de5828c9
- Child:
- 11:907c02e9fb00
--- a/main.cpp Fri Dec 19 17:59:00 2014 +0000 +++ b/main.cpp Tue Jan 20 16:12:18 2015 +0000 @@ -21,25 +21,43 @@ Mail<i2c_data,16> i2c_data_receive; Mail<i2c_data,16> i2c_data_send; - + +int receive_status =0; void FUNC_I2C_WRITE2CDMS(char *data, int length=1) { int slave_status = 1; - + // printf("\nData is %c\n\r",*data); + + slave.address(0x20); + unsigned char* add_reg = (unsigned char*)0x40067000; + unsigned char* data_reg = (unsigned char*)0x40067004; + unsigned char* status_reg = (unsigned char*)0x40067003; + unsigned char* c1_reg = (unsigned char*)0x40067002; + unsigned char* c2_reg = (unsigned char*)0x40067005; + unsigned char* freq_reg = (unsigned char*)0x40067001; while(slave_status && interrupt ==1) - { - slave.address(0x20); - if(slave.receive()==1) + { + //wait(2); + receive_status = slave.receive(); + + if( receive_status==1) { + // printf("\nslave receive b4: \n"); slave_status=slave.write(data,length); - + // printf("\nData sent to CDMS is %c\n\r",*data); + // printf("\n\r write"); + //printf("\nslave receive after: %d \n",slave.receive()); } - else if(slave.receive()==3 || slave.receive()==2) + else if( receive_status==3 || receive_status==2) { slave_status=slave.read(data,length); + // printf("\n\r read"); } + //printf("\n \r done while loop %d \n",slave.receive()); + //printf("\n\r ahoy drhghhhhhhhhhhh\n"); + printf("\n\r %d %d %d %d %d \n",*data_reg,*status_reg,*c1_reg,*c2_reg,*freq_reg); } printf("\ndone\n\r"); @@ -74,6 +92,7 @@ { i2c_data *i2c_data_s = (i2c_data*)evt.value.p; data_send = i2c_data_s -> data; + //printf("\n1.Data is %c\n\r",data_send); FUNC_I2C_WRITE2CDMS(&data_send); printf("\nData sent to CDMS is %c\n\r",data_send); i2c_data_send.free(i2c_data_s);