Skip to content

Commit

Permalink
feat(ksz8863): added phy set_link fnc
Browse files Browse the repository at this point in the history
  • Loading branch information
kostaond committed Mar 19, 2024
1 parent 51966b5 commit a631cfe
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ksz8863/examples/simple_switch/main/simple_switch_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion ksz8863/examples/switch_mode/main/switch_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion ksz8863/examples/two_ports_mode/main/two_ports_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions ksz8863/idf_component.yml
Original file line number Diff line number Diff line change
@@ -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"
idf: ">=5.3"
18 changes: 17 additions & 1 deletion ksz8863/src/esp_eth_phy_ksz8863.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a631cfe

Please sign in to comment.