lpc_phy.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * @brief Common PHY functions
  3. *
  4. * @note
  5. * Copyright(C) NXP Semiconductors, 2012
  6. * All rights reserved.
  7. *
  8. * @par
  9. * Software that is described herein is for illustrative purposes only
  10. * which provides customers with programming information regarding the
  11. * LPC products. This software is supplied "AS IS" without any warranties of
  12. * any kind, and NXP Semiconductors and its licensor disclaim any and
  13. * all warranties, express or implied, including all implied warranties of
  14. * merchantability, fitness for a particular purpose and non-infringement of
  15. * intellectual property rights. NXP Semiconductors assumes no responsibility
  16. * or liability for the use of the software, conveys no license or rights under any
  17. * patent, copyright, mask work right, or any other intellectual property rights in
  18. * or to any products. NXP Semiconductors reserves the right to make changes
  19. * in the software without notification. NXP Semiconductors also makes no
  20. * representation or warranty that such application will be suitable for the
  21. * specified use without further testing or modification.
  22. *
  23. * @par
  24. * Permission to use, copy, modify, and distribute this software and its
  25. * documentation is hereby granted, under NXP Semiconductors' and its
  26. * licensor's relevant copyrights in the software, without fee, provided that it
  27. * is used in conjunction with NXP Semiconductors microcontrollers. This
  28. * copyright, permission, and disclaimer notice must appear in all copies of
  29. * this code.
  30. */
  31. #ifndef __LPC_PHY_H_
  32. #define __LPC_PHY_H_
  33. #include "board.h"
  34. #include "chip.h"
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /** @defgroup BOARD_PHY BOARD: Board specific PHY drivers
  39. * @ingroup BOARD_Common
  40. * The simple PHY function API provides simple non-blocking PHY status
  41. * monitoring and initialization support for various Ethernet PHYs.
  42. * To initialize the PHY, call lpc_phy_init() once. lpc_phy_init() requires
  43. * several standard functions from the MAC driver for interfacing to the
  44. * PHY via a MII link (Chip_ENET_Start_MII_Write(), Chip_ENET_Is_MII_Busy(),
  45. * Chip_ENET_Start_MII_Read(), and Chip_ENET_Read_MII_Data()).
  46. *
  47. * Once initialized, just preiodically call the lpcPHYStsPoll() function
  48. * from the background loop or a thread and monitor the returned status
  49. * to determine if the PHY state has changed and the current PHY state.
  50. * @{
  51. */
  52. #define PHY_LINK_ERROR (1 << 0) /*!< PHY status bit for link error */
  53. #define PHY_LINK_BUSY (1 << 1) /*!< PHY status bit for MII link busy */
  54. #define PHY_LINK_CHANGED (1 << 2) /*!< PHY status bit for changed state (not persistent) */
  55. #define PHY_LINK_CONNECTED (1 << 3) /*!< PHY status bit for connected state */
  56. #define PHY_LINK_SPEED100 (1 << 4) /*!< PHY status bit for 100Mbps mode */
  57. #define PHY_LINK_FULLDUPLX (1 << 5) /*!< PHY status bit for full duplex mode */
  58. /**
  59. * @brief Phy status update state machine
  60. * @return An Or'ed value of PHY_LINK_* statuses
  61. * This function can be called at any rate and will poll the the PHY status. Multiple
  62. * calls may be needed to determine PHY status.
  63. */
  64. uint32_t lpcPHYStsPoll(void);
  65. /**
  66. * @brief Initialize the PHY
  67. * @param rmii : Initializes PHY for RMII mode if true, MII if false
  68. * @param pDelayMsFunc : Delay function (in mS) used for this driver
  69. * @return PHY_LINK_ERROR or 0 on success
  70. * This function initializes the PHY. It will block until complete. It will not
  71. * wait for the PHY to detect a connected cable and remain busy. Use lpcPHYStsPoll to
  72. * detect cable insertion.
  73. */
  74. uint32_t lpc_phy_init(bool rmii, p_msDelay_func_t pDelayMsFunc);
  75. /**
  76. * @}
  77. */
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif /* __LPC_PHY_H_ */