Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 
 

66 rader
1.9 KiB

  1. /** @defgroup ethernet_phy_file PHY Generic Drivers
  2. *
  3. * @ingroup ETH
  4. *
  5. * @brief <b>Ethernet PHY Generic Drivers</b>
  6. *
  7. * @version 1.0.0
  8. * @author @htmlonly &copy; @endhtmlonly 2013 Frantisek Burian <BuFran@seznam.cz>
  9. *
  10. * @date 1 September 2013
  11. *
  12. *
  13. * LGPL License Terms @ref lgpl_license
  14. */
  15. /*
  16. * This file is part of the libopencm3 project.
  17. *
  18. * Copyright (C) 2013 Frantisek Burian <BuFran@seznam.cz>
  19. *
  20. * This library is free software: you can redistribute it and/or modify
  21. * it under the terms of the GNU Lesser General Public License as published by
  22. * the Free Software Foundation, either version 3 of the License, or
  23. * (at your option) any later version.
  24. *
  25. * This library is distributed in the hope that it will be useful,
  26. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. * GNU Lesser General Public License for more details.
  29. *
  30. * You should have received a copy of the GNU Lesser General Public License
  31. * along with this library. If not, see <http://www.gnu.org/licenses/>.
  32. */
  33. #include <libopencm3/ethernet/mac.h>
  34. #include <libopencm3/ethernet/phy.h>
  35. /**@{*/
  36. /*---------------------------------------------------------------------------*/
  37. /** @brief Is the link up ?
  38. *
  39. * @param[in] phy uint8_t phy ID of the PHY
  40. * @returns bool true, if link is up
  41. */
  42. bool phy_link_isup(uint8_t phy)
  43. {
  44. return eth_smi_read(phy, PHY_REG_BSR) & PHY_REG_BSR_UP;
  45. }
  46. /*---------------------------------------------------------------------------*/
  47. /** @brief Reset the PHY
  48. *
  49. * Reset the PHY chip and wait for done
  50. * @param[in] phy uint8_t phy ID of the PHY
  51. */
  52. void phy_reset(uint8_t phy)
  53. {
  54. eth_smi_write(phy, PHY_REG_BCR, PHY_REG_BCR_RESET);
  55. while (eth_smi_read(phy, PHY_REG_BCR) & PHY_REG_BCR_RESET);
  56. }
  57. /*---------------------------------------------------------------------------*/
  58. /**@}*/