ethernet_phy_main.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Code generated from Atmel Start.
  3. *
  4. * This file will be overwritten when reconfiguring your Atmel Start project.
  5. * Please copy examples or other code you want to keep to a separate file or main.c
  6. * to avoid loosing it when reconfiguring.
  7. */
  8. #include <atmel_start.h>
  9. #include <ieee8023_mii_standard_config.h>
  10. #include <ethernet_phy_main.h>
  11. struct ethernet_phy_descriptor MACIF_PHY_desc;
  12. void MACIF_PHY_init(void)
  13. {
  14. mac_async_enable(&MACIF);
  15. ethernet_phy_init(&MACIF_PHY_desc, &MACIF, CONF_MACIF_PHY_IEEE8023_MII_PHY_ADDRESS);
  16. #if CONF_MACIF_PHY_IEEE8023_MII_CONTROL_REG0_SETTING == 1
  17. ethernet_phy_write_reg(&MACIF_PHY_desc, MDIO_REG0_BMCR, CONF_MACIF_PHY_IEEE8023_MII_CONTROL_REG0);
  18. #endif /* CONF_MACIF_PHY_IEEE8023_MII_CONTROL_REG0_SETTING */
  19. }
  20. void MACIF_PHY_example(void)
  21. {
  22. bool link_state;
  23. int32_t rst;
  24. /* Restart an auto-negotiation */
  25. rst = ethernet_phy_restart_autoneg(&MACIF_PHY_desc);
  26. while (rst != ERR_NONE) {
  27. }
  28. /* Wait for PHY link up */
  29. do {
  30. rst = ethernet_phy_get_link_status(&MACIF_PHY_desc, &link_state);
  31. } while (rst == ERR_NONE && link_state == true);
  32. }
  33. void ethernet_phys_init(void)
  34. {
  35. MACIF_PHY_init();
  36. }