AxedaGo-mbed Demo - WIZwiki_W7500 or Platform+ W5500 (WIZnet) + Sensor (Photosell), This code tested on FRDM-KL25Z, LPCXpresso8324-MAX, NUCLEO_F103RB and WIZwiki_W7500
Dependencies: AxedaGo-mbedNXP WIZnetInterface mbed
Fork of AxedaGo-mbed_WIZnetInterface by
Diff: main.cpp
- Revision:
- 7:979a654458c7
- Parent:
- 6:1f7647c5691a
- Child:
- 8:4652dbf6461d
--- a/main.cpp Thu Jun 26 16:58:53 2014 +0000 +++ b/main.cpp Thu Jun 18 04:05:40 2015 +0000 @@ -1,24 +1,36 @@ #include "mbed.h" #include "EthernetInterface.h" -EthernetInterface eth; - -AnalogIn pot1(p19); -AnalogIn pot2(p20); -TCPSocketConnection sock; - +AnalogIn pot1(A0); +AnalogIn pot2(A1); + DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); - + +#ifdef TARGET_WIZwiki_W7500 +EthernetInterface eth; +#else + +#if defined(TARGET_NUCLEO_F103RB) +SPI spi(PA_7, PA_6, PA_5); // mosi, miso, sclk +EthernetInterface eth(&spi, PB_6, PA_9); // spi, cs, reset +#else //tested on FRDM-KL25Z, LPCXpresso8324-MAX +SPI spi(D11, D12, D13); // mosi, miso, sclk +EthernetInterface eth(&spi, D10, D9); // spi, cs, reset +#endif + +#endif //#if defined TARGET_WIZwiki_W7500 + +TCPSocketConnection sock; + int main() { - + uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x1D, 0x62, 0x11}; char *MODEL = "mbed"; - char *SERIAL_NUM = "SerialNumber"; - float DEADBAND = 0.015; - + char *SERIAL_NUM = "nlr__embeddist_gmail_com___343881"; + float DEADBAND = 0.015; char* ip; int http_cmd_sz=800; @@ -26,15 +38,14 @@ int buffer_sz=300; char buffer[buffer_sz]; int returnCode = 0; - + led1 = 1; led2 = 1; led3 = 1; led4 = 1; - + printf("initializing Ethernet\r\n"); - returnCode = eth.init(); //Use DHCP - + eth.init(mac_addr); //Use DHCP if ( returnCode == 0 ) { printf(" - Ethernet ready\r\n"); @@ -48,6 +59,7 @@ printf("Ethernet.connecting \r\n"); returnCode = eth.connect(); + eth.ethernet_link(); printf(" - connecting returned %d \r\n", returnCode); led2 = returnCode != -1 ? 0: 1; printf("Trying to get IP address..\r\n"); @@ -61,9 +73,8 @@ float oldPotVal2 = -2.0; while(1) { - oil_level = pot1.read(); - oil_level2=pot2.read(); + oil_level2= pot2.read(); if ( abs(oil_level - oldPotVal) < DEADBAND && abs(oil_level2 - oldPotVal2) < DEADBAND) {