Unverified Commit d20778ed authored by Arnim Läuger's avatar Arnim Läuger Committed by GitHub
Browse files

Support eth boards without power pin, extend docs (#2855)

* fix handling of optional power pin

* add init example for wESP32

* add example for eth.on()
parent 7ad6bc1b
...@@ -26,7 +26,8 @@ typedef enum { ...@@ -26,7 +26,8 @@ typedef enum {
static struct { static struct {
const eth_config_t *eth_config; const eth_config_t *eth_config;
gpio_num_t pin_power, pin_mdc, pin_mdio; int pin_power;
gpio_num_t pin_mdc, pin_mdio;
} module_config; } module_config;
......
...@@ -74,12 +74,20 @@ An error is thrown in case of invalid parameters or if the ethernet driver faile ...@@ -74,12 +74,20 @@ An error is thrown in case of invalid parameters or if the ethernet driver faile
#### Example #### Example
```lua ```lua
-- Initialize ESP32-GATEWAY
eth.init({phy = eth.PHY_LAN8720, eth.init({phy = eth.PHY_LAN8720,
addr = 0, addr = 0,
clock_mode = eth.CLOCK_GPIO17_OUT, clock_mode = eth.CLOCK_GPIO17_OUT,
power = 5, power = 5,
mdc = 23, mdc = 23,
mdio = 18}) mdio = 18})
-- Initialize wESP32
eth.init({phy = eth.PHY_LAN8720,
addr = 0,
clock_mode = eth.CLOCK_GPIO0_IN,
mdc = 16,
mdio = 17})
``` ```
...@@ -111,6 +119,25 @@ Event information provided for each event is as follows: ...@@ -111,6 +119,25 @@ Event information provided for each event is as follows:
- `netmask`: the IP netmask - `netmask`: the IP netmask
- `gw`: the gateway ("0.0.0.0" if no gateway) - `gw`: the gateway ("0.0.0.0" if no gateway)
#### Example
```lua
function ev(event, info)
print("event", event)
if event == "got_ip" then
print("ip:"..info.ip..", nm:"..info.netmask..", gw:"..info.gw)
elseif event == "connected" then
print("speed:", eth.get_speed())
print("mac:", eth.get_mac())
end
end
eth.on("connected", ev)
eth.on("disconnected", ev)
eth.on("start", ev)
eth.on("stop", ev)
eth.on("got_ip", ev)
```
## eth.set_mac() ## eth.set_mac()
Set MAC address. Set MAC address.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment