SPI to Ethernet Slave

Dependencies:   WIZnetInterface mbed

Fork of SPI_HelloWorld_Mbed by mbed official

Files at this revision

API Documentation at this revision

Comitter:
Ricky_Kwon
Date:
Thu Mar 10 05:55:20 2016 +0000
Parent:
8:46bd5776b6ae
Commit message:
123123

Changed in this revision

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