phy.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include "esp_eth.h"
  18. /**
  19. * @brief Common PHY-management functions.
  20. *
  21. * @note These are not enough to drive any particular Ethernet PHY.
  22. * They provide a common configuration structure and management functions.
  23. *
  24. */
  25. /**
  26. * @brief Configure fixed pins for RMII data interface.
  27. *
  28. * @note This configures GPIOs 0, 19, 22, 25, 26, 27 for use with RMII data interface.
  29. * These pins cannot be changed, and must be wired to ethernet functions.
  30. * This is not sufficient to fully configure the Ethernet PHY.
  31. * MDIO configuration interface pins (such as SMI MDC, MDO, MDI) must also be configured correctly in the GPIO matrix.
  32. *
  33. */
  34. void phy_rmii_configure_data_interface_pins(void);
  35. /**
  36. * @brief Configure variable pins for SMI ethernet functions.
  37. *
  38. * @param mdc_gpio MDC GPIO Pin number
  39. * @param mdio_gpio MDIO GPIO Pin number
  40. *
  41. * @note Calling this function along with mii_configure_default_pins() will fully configure the GPIOs for the ethernet PHY.
  42. */
  43. void phy_rmii_smi_configure_pins(uint8_t mdc_gpio, uint8_t mdio_gpio);
  44. /**
  45. * @brief Enable flow control in standard PHY MII register.
  46. *
  47. */
  48. void phy_mii_enable_flow_ctrl(void);
  49. /**
  50. * @brief Check Ethernet link status via MII interface
  51. *
  52. * @return true Link is on
  53. * @return false Link is off
  54. */
  55. bool phy_mii_check_link_status(void);
  56. /**
  57. * @brief Check pause frame ability of partner via MII interface
  58. *
  59. * @return true Partner is able to process pause frame
  60. * @return false Partner can not process pause frame
  61. */
  62. bool phy_mii_get_partner_pause_enable(void);
  63. #ifdef __cplusplus
  64. }
  65. #endif