![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
questo a me funziona. Prima non andava quindi ho solo eliminato e rimesso la libreria e ora va
Dependencies: WIZnet_Library mbed
main.cpp@0:f1f0b48a37df, 2018-07-11 (annotated)
- Committer:
- Wonderjack996
- Date:
- Wed Jul 11 10:48:57 2018 +0000
- Revision:
- 0:f1f0b48a37df
funzioante
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Wonderjack996 | 0:f1f0b48a37df | 1 | #include "mbed.h" |
Wonderjack996 | 0:f1f0b48a37df | 2 | #include "WIZnetInterface.h" |
Wonderjack996 | 0:f1f0b48a37df | 3 | |
Wonderjack996 | 0:f1f0b48a37df | 4 | #define MY_DEFAULT_IP_ADDR "10.51.23.95" //IP per comunicare con Siren: 10.51.23.95 - ".95" settabile con Dipswitch |
Wonderjack996 | 0:f1f0b48a37df | 5 | #define MY_DEFAULT_MASK "255.255.255.0" |
Wonderjack996 | 0:f1f0b48a37df | 6 | #define MY_DEFAULT_GATEWAY "10.51.23.254" //Default Gateway della STM32 |
Wonderjack996 | 0:f1f0b48a37df | 7 | |
Wonderjack996 | 0:f1f0b48a37df | 8 | //new server windows 2012 ctosw00014.cto.st.com |
Wonderjack996 | 0:f1f0b48a37df | 9 | #define SIREN_SERVER_NAME "10.51.37.30" |
Wonderjack996 | 0:f1f0b48a37df | 10 | #define SIREN_SERVER_PORT 8897 |
Wonderjack996 | 0:f1f0b48a37df | 11 | |
Wonderjack996 | 0:f1f0b48a37df | 12 | const char * IP_Addr = "10.51.23.95"; |
Wonderjack996 | 0:f1f0b48a37df | 13 | const char * IP_Subnet = "255.255.255.0"; |
Wonderjack996 | 0:f1f0b48a37df | 14 | const char * IP_Gateway = "10.51.23.254"; |
Wonderjack996 | 0:f1f0b48a37df | 15 | |
Wonderjack996 | 0:f1f0b48a37df | 16 | unsigned char MAC_Addr[6] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; |
Wonderjack996 | 0:f1f0b48a37df | 17 | SPI spi(PA_7,PA_6,PA_5); //MOSI, MISO, SCK |
Wonderjack996 | 0:f1f0b48a37df | 18 | WIZnetInterface ethernet(&spi,PB_6,PA_10); |
Wonderjack996 | 0:f1f0b48a37df | 19 | DigitalOut cs(D10); |
Wonderjack996 | 0:f1f0b48a37df | 20 | DigitalOut reset(D2); |
Wonderjack996 | 0:f1f0b48a37df | 21 | |
Wonderjack996 | 0:f1f0b48a37df | 22 | int main() { |
Wonderjack996 | 0:f1f0b48a37df | 23 | reset = 0; |
Wonderjack996 | 0:f1f0b48a37df | 24 | printf("Start4\r\n"); |
Wonderjack996 | 0:f1f0b48a37df | 25 | TCPSocketConnection(); |
Wonderjack996 | 0:f1f0b48a37df | 26 | int ret = ethernet.init(MAC_Addr,"10.51.23.95",IP_Subnet,IP_Gateway); |
Wonderjack996 | 0:f1f0b48a37df | 27 | |
Wonderjack996 | 0:f1f0b48a37df | 28 | if(!ret){ |
Wonderjack996 | 0:f1f0b48a37df | 29 | printf("Initialized, MAC: %s\r\n", ethernet.getMACAddress()); |
Wonderjack996 | 0:f1f0b48a37df | 30 | ret = ethernet.connect(); |
Wonderjack996 | 0:f1f0b48a37df | 31 | if(!ret){ |
Wonderjack996 | 0:f1f0b48a37df | 32 | printf("IP: %s, MASK: %s, GW: %s\r\n", |
Wonderjack996 | 0:f1f0b48a37df | 33 | ethernet.getIPAddress(), ethernet.getNetworkMask(), ethernet.getGateway()); |
Wonderjack996 | 0:f1f0b48a37df | 34 | }else{ |
Wonderjack996 | 0:f1f0b48a37df | 35 | printf("Error ethernet.connect() - ret = %d\r\n", ret); |
Wonderjack996 | 0:f1f0b48a37df | 36 | } |
Wonderjack996 | 0:f1f0b48a37df | 37 | }else{ |
Wonderjack996 | 0:f1f0b48a37df | 38 | printf("Error ethernet.init() - ret = %d\r\n", ret); |
Wonderjack996 | 0:f1f0b48a37df | 39 | } |
Wonderjack996 | 0:f1f0b48a37df | 40 | while(true); |
Wonderjack996 | 0:f1f0b48a37df | 41 | } |