diff --git a/ksz8863/examples/simple_switch/main/simple_switch_main.c b/ksz8863/examples/simple_switch/main/simple_switch_main.c index 20ae863..f6afbeb 100644 --- a/ksz8863/examples/simple_switch/main/simple_switch_main.c +++ b/ksz8863/examples/simple_switch/main/simple_switch_main.c @@ -325,7 +325,7 @@ void app_main(void) ESP_ERROR_CHECK(esp_eth_start(p1_eth_handle)); ESP_ERROR_CHECK(esp_eth_start(p2_eth_handle)); - // Sync semaphore is needed since local variables are used during initialization in other tasks + // Sync semaphore is needed since main task local variables are used during initialization in other tasks init_done = xSemaphoreCreateBinary(); assert(init_done); diff --git a/ksz8863/examples/switch_mode/main/switch_main.c b/ksz8863/examples/switch_mode/main/switch_main.c index dd80e7c..5860e62 100644 --- a/ksz8863/examples/switch_mode/main/switch_main.c +++ b/ksz8863/examples/switch_mode/main/switch_main.c @@ -378,7 +378,7 @@ void app_main(void) ESP_ERROR_CHECK(esp_eth_start(p1_eth_handle)); ESP_ERROR_CHECK(esp_eth_start(p2_eth_handle)); - // Sync semaphore is needed since local variables are used during initialization in other tasks + // Sync semaphore is needed since main task local variables are used during initialization in other tasks init_done = xSemaphoreCreateBinary(); assert(init_done); diff --git a/ksz8863/examples/two_ports_mode/main/two_ports_main.c b/ksz8863/examples/two_ports_mode/main/two_ports_main.c index 06525ed..61ea8c0 100644 --- a/ksz8863/examples/two_ports_mode/main/two_ports_main.c +++ b/ksz8863/examples/two_ports_mode/main/two_ports_main.c @@ -393,7 +393,7 @@ void app_main(void) ESP_ERROR_CHECK(esp_eth_start(p1_eth_handle)); ESP_ERROR_CHECK(esp_eth_start(p2_eth_handle)); - // Sync semaphore is needed since local variables are used during initialization in other tasks + // Sync semaphore is needed since main task local variables are used during initialization in other tasks init_done = xSemaphoreCreateBinary(); assert(init_done); diff --git a/ksz8863/idf_component.yml b/ksz8863/idf_component.yml index 234165e..09a450e 100644 --- a/ksz8863/idf_component.yml +++ b/ksz8863/idf_component.yml @@ -1,7 +1,7 @@ -version: "0.2.3" +version: "0.2.4" targets: - esp32 description: KSZ8863 Ethernet Driver url: https://github.com/espressif/esp-eth-drivers/tree/master/ksz8863 dependencies: - idf: ">=5.0" \ No newline at end of file + idf: ">=5.3" \ No newline at end of file diff --git a/ksz8863/src/esp_eth_phy_ksz8863.c b/ksz8863/src/esp_eth_phy_ksz8863.c index 213c854..277f087 100644 --- a/ksz8863/src/esp_eth_phy_ksz8863.c +++ b/ksz8863/src/esp_eth_phy_ksz8863.c @@ -124,6 +124,21 @@ static esp_err_t ksz8863_get_link(esp_eth_phy_t *phy) return ret; } +static esp_err_t ksz8863_set_link(esp_eth_phy_t *phy, eth_link_t link) +{ + esp_err_t ret = ESP_OK; + phy_ksz8863_t *ksz8863 = __containerof(phy, phy_ksz8863_t, parent); + esp_eth_mediator_t *eth = ksz8863->eth; + + if (ksz8863->link_status != link) { + ksz8863->link_status = link; + // link status changed, inmiedately report to upper layers + ESP_GOTO_ON_ERROR(eth->on_state_changed(eth, ETH_STATE_LINK, (void *)ksz8863->link_status), err, TAG, "change link failed"); + } +err: + return ret; +} + static esp_err_t ksz8863_reset_sw(esp_eth_phy_t *phy) { // reset needs to be performed externally since multiple instances of PHY driver exist and so they could reset the chip multiple times @@ -139,7 +154,7 @@ static esp_err_t ksz8863_reset_hw(esp_eth_phy_t *phy) /** * @note This function is responsible for restarting a new auto-negotiation, * the result of negotiation won't be reflected to upper layers. - * Instead, the negotiation result is fetched by linker timer, see `ksz8863_get_link()` + * Instead, the negotiation result is fetched by status link timer, see `ksz8863_get_link()` */ static esp_err_t ksz8863_autonego_ctrl(esp_eth_phy_t *phy, eth_phy_autoneg_cmd_t cmd, bool *autonego_en_stat) { @@ -492,6 +507,7 @@ esp_eth_phy_t *esp_eth_phy_new_ksz8863(const eth_phy_config_t *config) ksz8863->parent.set_mediator = ksz8863_set_mediator; ksz8863->parent.autonego_ctrl = ksz8863_autonego_ctrl; ksz8863->parent.get_link = ksz8863_get_link; + ksz8863->parent.set_link = ksz8863_set_link; ksz8863->parent.pwrctl = ksz8863_pwrctl; ksz8863->parent.get_addr = ksz8863_get_addr; ksz8863->parent.set_addr = ksz8863_set_addr;