Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of all_combined_week6 by
Diff: slave.cpp
- Revision:
- 6:82153349cc9b
- Parent:
- 4:79b97f9cab00
- Child:
- 7:b3f876f605d9
diff -r c7cd684d25a8 -r 82153349cc9b slave.cpp
--- a/slave.cpp Sat Jul 12 07:27:15 2014 +0000
+++ b/slave.cpp Tue Jul 15 10:04:38 2014 +0000
@@ -13,7 +13,7 @@
acknowledge = slave.write(send); //sending the byte to master
if(acknowledge==1)
{
- screen.printf(" acknowledge %d sent %x \n",acknowledge,send);
+ screen.printf(" acknowledge %d sent %u \n",acknowledge,send);
loopvariable4=0;
}
}
@@ -24,7 +24,7 @@
void FUNC_I2C_SLAVE_MAIN(int iterations)
{
- wait(0.5);
+
screen.printf("\nSlave entered\n");
slave.address(slave_address); //assigning slave address
char Switch_Variable;
@@ -47,8 +47,10 @@
//to interpret and write data to master
switch(Switch_Variable)
{
-
- case '1': while(loopvariable3)
+
+
+ case 1: printf("\nEntered switch\n");
+ while(loopvariable3)
{
if(slave.receive()==ReadAddressed) //check if slave is addressed to read
{
@@ -71,6 +73,7 @@
}
loopvariable2++;
}//while(loopvariable2<30)
+ printf("\nExited i2c while loop\n");
slave.stop();
loopvariable3=0;
}//if(read addressed)
@@ -78,12 +81,12 @@
}//while(loopvariable3)
break;
- case '2' : screen.printf(" telecommand 2\n");
+ case 2 : screen.printf(" telecommand 2\n");
break;
}//switch case ends
}
}
- screen.printf("done");
+ screen.printf("\nexited slave function\n");
}
\ No newline at end of file
