|
|
@ -94,7 +94,7 @@ STATIC mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar |
|
|
|
return MP_OBJ_FROM_PTR(&lan_obj); |
|
|
|
} |
|
|
|
|
|
|
|
enum { ARG_id, ARG_mdc, ARG_mdio, ARG_power, ARG_phy_addr, ARG_phy_type }; |
|
|
|
enum { ARG_id, ARG_mdc, ARG_mdio, ARG_power, ARG_phy_addr, ARG_phy_type, ARG_clock_mode }; |
|
|
|
static const mp_arg_t allowed_args[] = { |
|
|
|
{ MP_QSTR_id, MP_ARG_OBJ, {.u_obj = mp_const_none} }, |
|
|
|
{ MP_QSTR_mdc, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, |
|
|
@ -102,6 +102,7 @@ STATIC mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar |
|
|
|
{ MP_QSTR_power, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_OBJ }, |
|
|
|
{ MP_QSTR_phy_addr, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, |
|
|
|
{ MP_QSTR_phy_type, MP_ARG_KW_ONLY | MP_ARG_REQUIRED | MP_ARG_INT }, |
|
|
|
{ MP_QSTR_clock_mode, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} }, |
|
|
|
}; |
|
|
|
|
|
|
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; |
|
|
@ -125,6 +126,15 @@ STATIC mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar |
|
|
|
mp_raise_ValueError("invalid phy type"); |
|
|
|
} |
|
|
|
|
|
|
|
if (args[ARG_clock_mode].u_int != -1 && |
|
|
|
args[ARG_clock_mode].u_int != ETH_CLOCK_GPIO0_IN && |
|
|
|
// Disabled due ESP-IDF (see modnetwork.c note)
|
|
|
|
//args[ARG_clock_mode].u_int != ETH_CLOCK_GPIO0_OUT &&
|
|
|
|
args[ARG_clock_mode].u_int != ETH_CLOCK_GPIO16_OUT && |
|
|
|
args[ARG_clock_mode].u_int != ETH_CLOCK_GPIO17_OUT) { |
|
|
|
mp_raise_ValueError("invalid clock mode"); |
|
|
|
} |
|
|
|
|
|
|
|
eth_config_t config; |
|
|
|
|
|
|
|
switch (args[ARG_phy_type].u_int) { |
|
|
@ -146,6 +156,10 @@ STATIC mp_obj_t get_lan(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar |
|
|
|
config.gpio_config = init_lan_rmii; |
|
|
|
config.tcpip_input = tcpip_adapter_eth_input; |
|
|
|
|
|
|
|
if (args[ARG_clock_mode].u_int != -1) { |
|
|
|
config.clock_mode = args[ARG_clock_mode].u_int; |
|
|
|
} |
|
|
|
|
|
|
|
if (esp_eth_init(&config) == ESP_OK) { |
|
|
|
self->active = false; |
|
|
|
self->initialized = true; |
|
|
|