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 slave_1 by
Diff: main.cpp
- Revision:
- 1:afb4a0df7ff1
- Parent:
- 0:ee332448b24c
- Child:
- 2:ba6aa46cd931
--- a/main.cpp Sat Dec 06 13:03:55 2014 +0000
+++ b/main.cpp Sun Dec 07 07:38:30 2014 +0000
@@ -11,17 +11,15 @@
void read_command()
{
- bool read_loop = true;
- printf("\nEntered slave \n");
- char *command = new char;
- while(read_loop){
- slave.address(0x20);
- int slave_status =1;
- slave_status=slave.read(command,1);
- if(!slave_status){
- printf("read %c from master\n\r",*command);
- read_loop = false;}
- }
+ printf("\nEntered slave \n\r");
+ char *command = new char;
+ slave.address(0x20);
+ int slave_status =1;
+ slave.stop();
+ while(slave.receive()!=3);
+ while(slave_status)
+ slave_status=slave.read(command,1);
+ printf("\nread %c from master\n\r",*command);
execute_command(command); //assumed command is very important
printf("\n done \n \r");
delete command;
@@ -46,13 +44,12 @@
-int main(){
-
- printf("waiting for commands from master");
+int main()
+{
+ printf("\nwaiting for command from master\n\r");
m2s_interrupt.rise(&read_command);
while(1)
{
;
}
- //write2slave();
- }
\ No newline at end of file
+}
\ No newline at end of file
