SPI to Ethernet Master
Dependencies: WIZnetInterface mbed
Fork of SPI_HelloWorld_Mbed by
Revision 5:fc5ffd86b1df, committed 2016-03-10
- Comitter:
- Ricky_Kwon
- Date:
- Thu Mar 10 01:27:35 2016 +0000
- Parent:
- 4:1b4fc2571fd4
- Commit message:
- Ethernet ---> W7500 ---> SPI ---> W7500 ---> Ethernet
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1b4fc2571fd4 -r fc5ffd86b1df main.cpp --- a/main.cpp Wed Mar 09 08:23:40 2016 +0000 +++ b/main.cpp Thu Mar 10 01:27:35 2016 +0000 @@ -9,15 +9,14 @@ const char gateway_addr[] = "xxx.xxx.xxx.xxx"; const char* Target_addr = "192.168.0.2"; -const int Target_port = 10001; +const int Target_port = 11111; SPI master(PA_8, PA_7, PA_6, PA_5); // mosi, miso, sclk int main() { - char txbuf[256]={0,}; - char rxbuf[256]={0,}; - int i, n, closecount, slave_h, length; + char EthTx[256]={0,}; + int i, n; printf("SPI to Ethernet Master\r\n"); @@ -66,14 +65,14 @@ while(1) { - n = socket.receive(txbuf, sizeof(txbuf)); - if(n >= 0) + if((n = socket.receive(EthTx, sizeof(EthTx)))>0) { for(i=0; i<n; i++) { - master.write(txbuf[i]); + master.write(EthTx[i]); } - } + memset(EthTx, 0, strlen(EthTx)); + } } } }