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()
This commit is contained in:
parent
7ad6bc1be7
commit
d20778ed09
|
@ -26,7 +26,8 @@ typedef enum {
|
|||
|
||||
static struct {
|
||||
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;
|
||||
|
||||
|
||||
|
|
|
@ -74,12 +74,20 @@ An error is thrown in case of invalid parameters or if the ethernet driver faile
|
|||
|
||||
#### Example
|
||||
```lua
|
||||
-- Initialize ESP32-GATEWAY
|
||||
eth.init({phy = eth.PHY_LAN8720,
|
||||
addr = 0,
|
||||
clock_mode = eth.CLOCK_GPIO17_OUT,
|
||||
power = 5,
|
||||
mdc = 23,
|
||||
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:
|
|||
- `netmask`: the IP netmask
|
||||
- `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()
|
||||
Set MAC address.
|
||||
|
|
Loading…
Reference in New Issue