Skip to content

Commit 648bcc7

Browse files
committed
ethernet: add ksz8041 in basic ethernet example
1 parent 62237cf commit 648bcc7

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

components/esp_eth/include/esp_eth_phy.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,29 +240,30 @@ esp_eth_phy_t *esp_eth_phy_new_lan8720(const eth_phy_config_t *config);
240240
*/
241241
esp_eth_phy_t *esp_eth_phy_new_dp83848(const eth_phy_config_t *config);
242242

243-
#if CONFIG_ETH_SPI_ETHERNET_DM9051
244243
/**
245-
* @brief Create a PHY instance of DM9051
244+
* @brief Create a PHY instance of KSZ8041
246245
*
247246
* @param[in] config: configuration of PHY
248247
*
249248
* @return
250249
* - instance: create PHY instance successfully
251250
* - NULL: create PHY instance failed because some error occurred
252251
*/
253-
esp_eth_phy_t *esp_eth_phy_new_dm9051(const eth_phy_config_t *config);
252+
esp_eth_phy_t *esp_eth_phy_new_ksz8041(const eth_phy_config_t *config);
254253

254+
#if CONFIG_ETH_SPI_ETHERNET_DM9051
255255
/**
256-
* @brief Create a PHY instance of KSZ8041
256+
* @brief Create a PHY instance of DM9051
257257
*
258258
* @param[in] config: configuration of PHY
259259
*
260260
* @return
261261
* - instance: create PHY instance successfully
262262
* - NULL: create PHY instance failed because some error occurred
263263
*/
264-
esp_eth_phy_t *esp_eth_phy_new_ksz8041(const eth_phy_config_t *config);
264+
esp_eth_phy_t *esp_eth_phy_new_dm9051(const eth_phy_config_t *config);
265265
#endif
266+
266267
#ifdef __cplusplus
267268
}
268269
#endif

components/esp_eth/src/esp_eth_phy_ksz8041.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "freertos/FreeRTOS.h"
2121
#include "freertos/task.h"
2222
#include "driver/gpio.h"
23+
#include "esp_rom_gpio.h"
2324

2425
static const char *TAG = "ksz8041";
2526
#define PHY_CHECK(a, str, goto_tag, ...) \
@@ -166,7 +167,7 @@ static esp_err_t ksz8041_reset_hw(esp_eth_phy_t *phy)
166167
{
167168
phy_ksz8041_t *ksz8041 = __containerof(phy, phy_ksz8041_t, parent);
168169
if (ksz8041->reset_gpio_num >= 0) {
169-
gpio_pad_select_gpio(ksz8041->reset_gpio_num);
170+
esp_rom_gpio_pad_select_gpio(ksz8041->reset_gpio_num);
170171
gpio_set_direction(ksz8041->reset_gpio_num, GPIO_MODE_OUTPUT);
171172
gpio_set_level(ksz8041->reset_gpio_num, 0);
172173
gpio_set_level(ksz8041->reset_gpio_num, 1);

examples/ethernet/basic/main/Kconfig.projbuild

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ menu "Example Configuration"
5252
help
5353
DP83848 is a single port 10/100Mb/s Ethernet Physical Layer Transceiver.
5454
Goto http://www.ti.com/product/DP83848J for more information about it.
55+
56+
config EXAMPLE_ETH_PHY_KSZ8041
57+
bool "KSZ8041"
58+
help
59+
The KSZ8041 is a single supply 10Base-T/100Base-TX Physical Layer Transceiver.
60+
Goto https://www.microchip.com/wwwproducts/en/KSZ8041 for more information about it.
5561
endchoice
5662

5763
config EXAMPLE_ETH_MDC_GPIO

examples/ethernet/basic/main/ethernet_example_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ void app_main(void)
9393
esp_eth_phy_t *phy = esp_eth_phy_new_lan8720(&phy_config);
9494
#elif CONFIG_EXAMPLE_ETH_PHY_DP83848
9595
esp_eth_phy_t *phy = esp_eth_phy_new_dp83848(&phy_config);
96+
#elif CONFIG_EXAMPLE_ETH_PHY_KSZ8041
97+
esp_eth_phy_t *phy = esp_eth_phy_new_ksz8041(&phy_config);
9698
#endif
9799
#elif CONFIG_EXAMPLE_USE_DM9051
98100
gpio_install_isr_service(0);

0 commit comments

Comments
 (0)