[info] lwip demos on Eth Phy ( ESP32 RMII ) runs

User avatar
rudi ;-)
Posts: 1729
Joined: Fri Nov 13, 2015 3:25 pm

[info] lwip demos on Eth Phy ( ESP32 RMII ) runs

Postby rudi ;-) » Mon Feb 27, 2017 12:16 am

hi

since we have the RMII on ESP32 working and we drive a Eth Phy Nic,
the pull request is done,
we can now do "same" doings like we do with services on wifi.

we can example run on the Eth Phy a web server, echo server, udp server .. and more
we can play with all lwip examples very easy.
found a repo as example here
there are more lwip examples on internet, try to search for "lwip examples"

i push a picture from my desk , sry for craz output, but we are in work alkoholic now
http_tcp_echo_svr.png
http_tcp_echo_svr.png (117.72 KiB) Viewed 5980 times

what you must do that the thing is working:

example http server:
and example TCP echo

copy the c and h file to your LAN8720 / TLK110 main folder
include the header in your main.c file
in the app_main call the init example

Code: Select all

..
#include "tcpecho.h"
#include "httpserver-netconn.h"
..
..
void app_main()
{
    esp_err_t ret = ESP_OK;
    tcpip_adapter_init();
    esp_event_loop_init(NULL, NULL);

#if (CONFIG_PHY_TLK110)
    eth_config_t config;
//    config.phy_addr = PHY31;
    config.phy_addr = PHY1; // tlk eval board
    config.mac_mode = ETH_MODE_RMII;
    config.phy_init = phy_tlk110_init;
    config.gpio_config = eth_gpio_config_rmii;
    config.tcpip_input = tcpip_adapter_eth_input;
    config.phy_check_init = phy_tlk110_check_phy_init;
    config.phy_check_link = phy_tlk110_check_phy_link_status;
    config.phy_get_speed_mode = phy_tlk110_get_speed_mode;
    config.phy_get_duplex_mode = phy_tlk110_get_duplex_mode;
    //Only FULLDUPLEX mode support flow ctrl now!
    config.flow_ctrl_enable = true;
    config.phy_get_partner_pause_enable = phy_tlk110_get_partner_pause_enable;
    config.phy_power_enable = phy_tlk110_power_enable;
#endif
#if (CONFIG_PHY_LAN8720)
    eth_config_t config;
    //Only FULLDUPLEX mode support flow ctrl now!
    config.flow_ctrl_enable = true;
    config.phy_addr = PHY0; // mc lan8720 eval board
    config.mac_mode = ETH_MODE_RMII;
    config.gpio_config = eth_gpio_config_rmii;
    config.tcpip_input = tcpip_adapter_eth_input;
    config.phy_init = phy_lan8720_init;
    config.phy_check_init = phy_lan8720_check_phy_init;
    config.phy_check_link = phy_lan8720_check_phy_link_status;
    config.phy_get_speed_mode = phy_lan8720_get_speed_mode;
    config.phy_get_duplex_mode = phy_lan8720_get_duplex_mode;
    config.phy_get_partner_pause_enable = phy_lan8720_get_partner_pause_enable;
    config.phy_power_enable = phy_lan8720_power_enable;
#endif

    ret = esp_eth_init(&config);
	
    if(ret == ESP_OK) {
        nvs_flash_init();
        esp_eth_enable();
        // xTaskCreate(eth_task, "eth_task", 2048, NULL, (tskIDLE_PRIORITY + 2), NULL);
        // initialise_wifi(); // be sure what you do ;-)
	vTaskDelay(3000 / portTICK_PERIOD_MS);
        
        // init tcp echo server, port will be 7
	tcpecho_init();
	// init http server, port will be 80
	http_server_netconn_init();
	
	// you can use a http client that do request... 
	// xTaskCreate(&http_get_task, "http_get_task", 2048, NULL, 5, NULL);
    }

}


you have now a http server and a tcp echo server on eth phy rmii from esp32
how cool is that ?

best wishes
rudi ;-)

hope the info is welcome and helps
now we go on to build a gateway.. :)
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: No registered users and 92 guests