questo a me andava già da subito
Dependencies: WIZ820ioInterface mbed
Fork of Seeed_Ethernet_Shield by
main.cpp@8:eb977ef6d2ab, 2018-07-11 (annotated)
- Committer:
- Wonderjack996
- Date:
- Wed Jul 11 10:50:18 2018 +0000
- Revision:
- 8:eb977ef6d2ab
- Parent:
- 6:4bb23453ce91
funziona
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 6:4bb23453ce91 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
screamer | 6:4bb23453ce91 | 2 | * |
screamer | 6:4bb23453ce91 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
screamer | 6:4bb23453ce91 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
screamer | 6:4bb23453ce91 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
screamer | 6:4bb23453ce91 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
screamer | 6:4bb23453ce91 | 7 | * Software is furnished to do so, subject to the following conditions: |
screamer | 6:4bb23453ce91 | 8 | * |
screamer | 6:4bb23453ce91 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
screamer | 6:4bb23453ce91 | 10 | * substantial portions of the Software. |
screamer | 6:4bb23453ce91 | 11 | * |
screamer | 6:4bb23453ce91 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
screamer | 6:4bb23453ce91 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
screamer | 6:4bb23453ce91 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
screamer | 6:4bb23453ce91 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
screamer | 6:4bb23453ce91 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
screamer | 6:4bb23453ce91 | 17 | */ |
screamer | 6:4bb23453ce91 | 18 | |
screamer | 0:1e952439b254 | 19 | #include "mbed.h" |
screamer | 0:1e952439b254 | 20 | #include "WIZ820ioInterface.h" |
screamer | 0:1e952439b254 | 21 | |
screamer | 0:1e952439b254 | 22 | Serial pc(USBTX, USBRX); |
screamer | 2:3b6c391a682d | 23 | |
Wonderjack996 | 8:eb977ef6d2ab | 24 | /* |
screamer | 2:3b6c391a682d | 25 | * D11 - MOSI pin |
Wonderjack996 | 8:eb977ef6d2ab | 26 | JNH * D12 - MISO pin |
screamer | 2:3b6c391a682d | 27 | * D13 - SCK pin |
screamer | 2:3b6c391a682d | 28 | * D10 - SEL pin |
screamer | 3:2d0986d5542e | 29 | * NC - Reset pin; use D5 otherwise the shield might get into reset loop |
screamer | 2:3b6c391a682d | 30 | */ |
screamer | 3:2d0986d5542e | 31 | WIZ820ioInterface eth(D11, D12, D13, D10, D5); |
screamer | 0:1e952439b254 | 32 | |
Wonderjack996 | 8:eb977ef6d2ab | 33 | const char * IP_Addr = "10.51.23.95"; |
Wonderjack996 | 8:eb977ef6d2ab | 34 | const char * IP_Subnet = "255.255.255.0"; |
Wonderjack996 | 8:eb977ef6d2ab | 35 | const char * IP_Gateway = "10.51.70.254"; |
Wonderjack996 | 8:eb977ef6d2ab | 36 | unsigned char MAC_Addr[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; |
screamer | 0:1e952439b254 | 37 | int main() |
screamer | 0:1e952439b254 | 38 | { |
screamer | 0:1e952439b254 | 39 | wait(3); |
screamer | 1:bb040724d21b | 40 | |
screamer | 1:bb040724d21b | 41 | // Initialize the interface. |
screamer | 1:bb040724d21b | 42 | // If no param is passed to init() then DHCP will be used on connect() |
Wonderjack996 | 8:eb977ef6d2ab | 43 | int s = eth.init(IP_Addr,IP_Subnet,IP_Gateway); |
screamer | 0:1e952439b254 | 44 | if (s != NULL) { |
screamer | 3:2d0986d5542e | 45 | printf(">>> Could not initialise. Halting!\n"); |
screamer | 0:1e952439b254 | 46 | exit(0); |
screamer | 0:1e952439b254 | 47 | } |
screamer | 0:1e952439b254 | 48 | |
screamer | 3:2d0986d5542e | 49 | printf(">>> Get IP address...\n"); |
screamer | 0:1e952439b254 | 50 | while (1) { |
screamer | 1:bb040724d21b | 51 | s = eth.connect(); // Connect to network |
screamer | 0:1e952439b254 | 52 | |
screamer | 0:1e952439b254 | 53 | if (s == false || s < 0) { |
screamer | 4:14045b8557cb | 54 | printf(">>> Could not connect to network! Retrying ...\n"); |
screamer | 0:1e952439b254 | 55 | wait(3); |
screamer | 0:1e952439b254 | 56 | } else { |
screamer | 0:1e952439b254 | 57 | break; |
screamer | 0:1e952439b254 | 58 | } |
screamer | 0:1e952439b254 | 59 | } |
screamer | 3:2d0986d5542e | 60 | printf(">>> Got IP address: %s\n", eth.getIPAddress()); |
screamer | 0:1e952439b254 | 61 | |
Wonderjack996 | 8:eb977ef6d2ab | 62 | while(true); |
screamer | 4:14045b8557cb | 63 | |
screamer | 0:1e952439b254 | 64 | return 0; |
screamer | 0:1e952439b254 | 65 | } |