sakthi priya amirtharaj / Mbed 2 deprecated slave_1

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
sakthipriya
Date:
Sun Dec 07 07:38:30 2014 +0000
Parent:
0:ee332448b24c
Commit message:
commands with switch case

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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