network_driver_DM9051.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "esp_eth.h"
  2. #include "network_ethernet.h"
  3. static esp_eth_mac_t* mac_new(spi_device_handle_t spi_handle, eth_config_t* ethernet_config) {
  4. #ifdef CONFIG_ETH_SPI_ETHERNET_DM9051
  5. eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
  6. eth_dm9051_config_t eth_config = ETH_DM9051_DEFAULT_CONFIG(spi_handle);
  7. // we assume that isr has been installed already
  8. eth_config.int_gpio_num = ethernet_config->intr;
  9. return esp_eth_mac_new_dm9051(&eth_config, &mac_config);
  10. #else
  11. return NULL;
  12. #endif
  13. }
  14. static esp_eth_phy_t* phy_new(eth_config_t* ethernet_config) {
  15. #ifdef CONFIG_ETH_SPI_ETHERNET_DM9051
  16. eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
  17. phy_config.phy_addr = 1;
  18. phy_config.reset_gpio_num = ethernet_config->rst;
  19. return esp_eth_phy_new_dm9051(&phy_config);
  20. #else
  21. return NULL;
  22. #endif
  23. }
  24. static void init_config(eth_config_t* ethernet_config) {
  25. }
  26. static network_ethernet_driver_t DM9051 = {
  27. .mac_new = mac_new,
  28. .phy_new = phy_new,
  29. .init_config = init_config,
  30. .valid = true,
  31. };
  32. network_ethernet_driver_t* DM9051_Detect(char* Driver) {
  33. if (!strcasestr(Driver, "DM9051"))
  34. return NULL;
  35. return &DM9051;
  36. }