SPI to Ethernet Slave

Dependencies:   WIZnetInterface mbed

Fork of SPI_HelloWorld_Mbed by mbed official

Revision:
9:32e3edb40824
Parent:
8:46bd5776b6ae
diff -r 46bd5776b6ae -r 32e3edb40824 main.cpp
--- a/main.cpp	Thu Mar 10 05:21:42 2016 +0000
+++ b/main.cpp	Thu Mar 10 05:55:20 2016 +0000
@@ -28,7 +28,8 @@
     int Length=0;
     char Eth_Receive_Check_Flag = 1;
     char EthTx[1]={0};
-    char EthRx[256]={0,};
+    char EthRx[1]={0,};
+    int test;
 
     printf("SPI to Ethernet Slave\r\n");
   
@@ -76,60 +77,12 @@
         
         while(1)
         {
-            if(Eth_Receive_Check_Flag==1)
-            {
-                printf("a");
-                Length = socket.receive(EthRx, sizeof(EthRx));
-                if(Length>0)
-                {
-                    printf("b");
-                    Eth_Receive_Check_Flag = 0;                       
-                }
-            }
             if(slave.receive())
             {
-                SPI_Data = slave.read();
-                switch(SPI_Data)
-                {
-                    case 0x80:
-                        printf("c");
-                        if(!Eth_Receive_Check_Flag)
-                        {
-                            printf("d");
-                            slave.reply(0x80);
-                        }
-                        else
-                        {
-                            printf("e");
-                            slave.reply(0x87);
-                        }
-                        break;
-                    case 0x81:
-                        printf("f");
-                        slave.reply(Length); 
-                        break;
-                    case 0x82:
-                        if(SPI_Send_Cnt!=Length)
-                        {
-                            printf("g");
-                            slave.reply(EthRx[SPI_Send_Cnt]); 
-                            SPI_Send_Cnt++;
-                        }
-                        else
-                        {
-                            printf("h");
-                            SPI_Send_Cnt = 0;
-                            Eth_Receive_Check_Flag = 1;                      
-                        }
-                        break;
-                    default:
-                        printf("i");
-                        EthTx[0] = SPI_Data;
-                        socket.send(EthTx, 1); 
-                        break;
-                            
-                }
+                socket.receive(EthRx, sizeof(EthRx));
+                slave.reply(EthRx[0]);
             }
+            
         }
     }
 }
\ No newline at end of file