![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
i2c stand alone working
Fork of slave_working_obama by
Revision 14:67cebba9c452, committed 2015-04-09
- Comitter:
- sakthipriya
- Date:
- Thu Apr 09 21:40:47 2015 +0000
- Parent:
- 13:fe24dd810078
- Commit message:
- i2c stand alone working
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r fe24dd810078 -r 67cebba9c452 main.cpp --- a/main.cpp Mon Jan 26 11:12:57 2015 +0000 +++ b/main.cpp Thu Apr 09 21:40:47 2015 +0000 @@ -13,7 +13,10 @@ int reset=0; int temp; Timer t; +Timer t1; Timer t2; +Timer t3; + typedef struct { @@ -30,7 +33,7 @@ unsigned char* c1_reg = (unsigned char*)0x40067002; unsigned char* c2_reg = (unsigned char*)0x40067005; unsigned char* freq_reg = (unsigned char*)0x40067001; -int receive_status =0; +//int slave.receive() =0; void FUNC_I2C_WRITE2CDMS(char *data, int length=1) { int slave_status = 1; @@ -44,20 +47,25 @@ //printf("\nin int loop\n"); //t.stop(); //t2.start(); - receive_status = slave.receive(); + //t2.stop(); - //printf("\n%d\n",receive_status); - t.stop(); - //printf("\n status %d \n",receive_status); - if( receive_status==1) + //printf("\n%d\n",slave.receive()); + + //printf("\n status %d \n",slave.receive()); + if(slave.receive() == 0) + t2.stop(); + t.stop(); + + if( slave.receive()==1) { // printf("\nslave receive b4: \n"); //t.stop(); //t2.start(); - + t2.stop(); + t3.start(); slave_status=slave.write(data,length); - - t2.stop(); + t3.stop(); + // printf("\nData sent to CDMS is %c\n\r",*data); // printf("\n\r write"); //printf("\nslave receive after: %d \n",slave.receive()); @@ -65,11 +73,14 @@ } - else if( receive_status==3 || receive_status==2) + else if( slave.receive()==3 || slave.receive()==2) { //t.stop(); //printf("\nh\n"); + t2.stop(); + t3.start(); slave_status=slave.read(data,length); + t3.stop(); } //printf("\n \r done while loop %d \n",slave.receive()); @@ -77,10 +88,12 @@ // printf("\n\r %d %d %d %d %d \n",*data_reg,*status_reg,*c1_reg,*c2_reg,*freq_reg); } - printf("\n%f\r",t.read()); + printf("\n%d\r",t.read_us()); t.reset(); printf("\n%d\r",t2.read_us()); t2.reset(); + printf("\n%d\r",t3.read_us()); + t3.reset(); //printf("\n%f\r",t.read()); } @@ -129,6 +142,7 @@ { //reset = 0; t.start(); + t2.start(); ptr_t_i2c->signal_set(0x1); }