ETHERNET

Application Example

ethernet example: examples/17_ethernet.

API Reference

Macros

Type Definitions

typedef void (*eth_phy_fun)(void)
typedef esp_err_t (*eth_tcpip_input_fun)(void *buffer, uint16_t len, void *eb)
typedef void (*eth_gpio_config_func)(void)

Enumerations

enum eth_mode_t

Values:

ETH_MODE_RMII = 0
ETH_MDOE_MII
enum eth_phy_base_t

Values:

PHY0 = 0
PHY1
PHY2
PHY3
PHY4
PHY5
PHY6
PHY7
PHY8
PHY9
PHY10
PHY11
PHY12
PHY13
PHY14
PHY15
PHY16
PHY17
PHY18
PHY19
PHY20
PHY21
PHY22
PHY23
PHY24
PHY25
PHY26
PHY27
PHY28
PHY29
PHY30
PHY31

Structures

struct eth_config_t

ethernet configuration

Public Members

eth_phy_base_t phy_addr

phy base addr (0~31)

eth_mode_t mac_mode

mac mode only support RMII now

eth_tcpip_input_fun tcpip_input

tcpip input func

eth_phy_fun phy_init

phy init func

eth_gpio_config_func gpio_config

gpio config func

Functions

esp_err_t esp_eth_init(eth_config_t *config)

Init ethernet mac.

Note
config can not be NULL,and phy chip must be suitable to phy init func.
Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • config: mac init data.

esp_err_t esp_eth_tx(uint8_t *buf, uint16_t size)

Send packet from tcp/ip to mac.

Note
buf can not be NULL,size must be less than 1580
Return
  • ESP_OK
  • ESP_FAIL
Parameters
  • buf: start address of packet data.
  • size: size (byte) of packet data.

esp_err_t esp_eth_enable(void)

Enable ethernet interface.

Note
Shout be called after esp_eth_init
Return
  • ESP_OK
  • ESP_FAIL

esp_err_t esp_eth_disable(void)

Disable ethernet interface.

Note
Shout be called after esp_eth_init
Return
  • ESP_OK
  • ESP_FAIL

void esp_eth_get_mac(uint8_t mac[6])

Get mac addr.

Note
mac addr must be a valid unicast address
Parameters
  • mac: start address of mac address.

void esp_eth_smi_write(uint32_t reg_num, uint16_t value)

Read phy reg with smi interface.

Note
phy base addr must be right.
Parameters
  • reg_num: phy reg num.
  • value: value which write to phy reg.

uint16_t esp_eth_smi_read(uint32_t reg_num)

Write phy reg with smi interface.

Note
phy base addr must be right.
Return
value what read from phy reg
Parameters
  • reg_num: phy reg num.