fsl_enet.h 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  1. /*
  2. * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2017 NXP
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of the copyright holder nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _FSL_ENET_H_
  31. #define _FSL_ENET_H_
  32. #include "fsl_common.h"
  33. /*!
  34. * @addtogroup enet
  35. * @{
  36. */
  37. /*******************************************************************************
  38. * Definitions
  39. ******************************************************************************/
  40. /*! @name Driver version */
  41. /*@{*/
  42. /*! @brief Defines the driver version. */
  43. #define FSL_ENET_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) /*!< Version 2.1.1. */
  44. /*@}*/
  45. /*! @name Control and status region bit masks of the receive buffer descriptor. */
  46. /*@{*/
  47. #define ENET_BUFFDESCRIPTOR_RX_EMPTY_MASK 0x8000U /*!< Empty bit mask. */
  48. #define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER1_MASK 0x4000U /*!< Software owner one mask. */
  49. #define ENET_BUFFDESCRIPTOR_RX_WRAP_MASK 0x2000U /*!< Next buffer descriptor is the start address. */
  50. #define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER2_Mask 0x1000U /*!< Software owner two mask. */
  51. #define ENET_BUFFDESCRIPTOR_RX_LAST_MASK 0x0800U /*!< Last BD of the frame mask. */
  52. #define ENET_BUFFDESCRIPTOR_RX_MISS_MASK 0x0100U /*!< Received because of the promiscuous mode. */
  53. #define ENET_BUFFDESCRIPTOR_RX_BROADCAST_MASK 0x0080U /*!< Broadcast packet mask. */
  54. #define ENET_BUFFDESCRIPTOR_RX_MULTICAST_MASK 0x0040U /*!< Multicast packet mask. */
  55. #define ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK 0x0020U /*!< Length violation mask. */
  56. #define ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK 0x0010U /*!< Non-octet aligned frame mask. */
  57. #define ENET_BUFFDESCRIPTOR_RX_CRC_MASK 0x0004U /*!< CRC error mask. */
  58. #define ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK 0x0002U /*!< FIFO overrun mask. */
  59. #define ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK 0x0001U /*!< Frame is truncated mask. */
  60. /*@}*/
  61. /*! @name Control and status bit masks of the transmit buffer descriptor. */
  62. /*@{*/
  63. #define ENET_BUFFDESCRIPTOR_TX_READY_MASK 0x8000U /*!< Ready bit mask. */
  64. #define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER1_MASK 0x4000U /*!< Software owner one mask. */
  65. #define ENET_BUFFDESCRIPTOR_TX_WRAP_MASK 0x2000U /*!< Wrap buffer descriptor mask. */
  66. #define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER2_MASK 0x1000U /*!< Software owner two mask. */
  67. #define ENET_BUFFDESCRIPTOR_TX_LAST_MASK 0x0800U /*!< Last BD of the frame mask. */
  68. #define ENET_BUFFDESCRIPTOR_TX_TRANMITCRC_MASK 0x0400U /*!< Transmit CRC mask. */
  69. /*@}*/
  70. /* Extended control regions for enhanced buffer descriptors. */
  71. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  72. /*! @name First extended control region bit masks of the receive buffer descriptor. */
  73. /*@{*/
  74. #define ENET_BUFFDESCRIPTOR_RX_IPV4_MASK 0x0001U /*!< Ipv4 frame mask. */
  75. #define ENET_BUFFDESCRIPTOR_RX_IPV6_MASK 0x0002U /*!< Ipv6 frame mask. */
  76. #define ENET_BUFFDESCRIPTOR_RX_VLAN_MASK 0x0004U /*!< VLAN frame mask. */
  77. #define ENET_BUFFDESCRIPTOR_RX_PROTOCOLCHECKSUM_MASK 0x0010U /*!< Protocol checksum error mask. */
  78. #define ENET_BUFFDESCRIPTOR_RX_IPHEADCHECKSUM_MASK 0x0020U /*!< IP header checksum error mask. */
  79. /*@}*/
  80. /*! @name Second extended control region bit masks of the receive buffer descriptor. */
  81. /*@{*/
  82. #define ENET_BUFFDESCRIPTOR_RX_INTERRUPT_MASK 0x0080U /*!< BD interrupt mask. */
  83. #define ENET_BUFFDESCRIPTOR_RX_UNICAST_MASK 0x0100U /*!< Unicast frame mask. */
  84. #define ENET_BUFFDESCRIPTOR_RX_COLLISION_MASK 0x0200U /*!< BD collision mask. */
  85. #define ENET_BUFFDESCRIPTOR_RX_PHYERR_MASK 0x0400U /*!< PHY error mask. */
  86. #define ENET_BUFFDESCRIPTOR_RX_MACERR_MASK 0x8000U /*!< Mac error mask. */
  87. /*@}*/
  88. /*! @name First extended control region bit masks of the transmit buffer descriptor. */
  89. /*@{*/
  90. #define ENET_BUFFDESCRIPTOR_TX_ERR_MASK 0x8000U /*!< Transmit error mask. */
  91. #define ENET_BUFFDESCRIPTOR_TX_UNDERFLOWERR_MASK 0x2000U /*!< Underflow error mask. */
  92. #define ENET_BUFFDESCRIPTOR_TX_EXCCOLLISIONERR_MASK 0x1000U /*!< Excess collision error mask. */
  93. #define ENET_BUFFDESCRIPTOR_TX_FRAMEERR_MASK 0x0800U /*!< Frame error mask. */
  94. #define ENET_BUFFDESCRIPTOR_TX_LATECOLLISIONERR_MASK 0x0400U /*!< Late collision error mask. */
  95. #define ENET_BUFFDESCRIPTOR_TX_OVERFLOWERR_MASK 0x0200U /*!< Overflow error mask. */
  96. #define ENET_BUFFDESCRIPTOR_TX_TIMESTAMPERR_MASK 0x0100U /*!< Timestamp error mask. */
  97. /*@}*/
  98. /*! @name Second extended control region bit masks of the transmit buffer descriptor. */
  99. /*@{*/
  100. #define ENET_BUFFDESCRIPTOR_TX_INTERRUPT_MASK 0x4000U /*!< Interrupt mask. */
  101. #define ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK 0x2000U /*!< Timestamp flag mask. */
  102. /*@}*/
  103. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  104. /*! @brief Defines the receive error status flag mask. */
  105. #define ENET_BUFFDESCRIPTOR_RX_ERR_MASK \
  106. (ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK | ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK | \
  107. ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK | ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK | ENET_BUFFDESCRIPTOR_RX_CRC_MASK)
  108. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  109. #define ENET_BUFFDESCRIPTOR_RX_EXT_ERR_MASK \
  110. (ENET_BUFFDESCRIPTOR_RX_MACERR_MASK | ENET_BUFFDESCRIPTOR_RX_PHYERR_MASK | ENET_BUFFDESCRIPTOR_RX_COLLISION_MASK)
  111. #endif
  112. #define ENET_TX_INTERRUPT (kENET_TxFrameInterrupt | kENET_TxBufferInterrupt)
  113. #define ENET_RX_INTERRUPT (kENET_RxFrameInterrupt | kENET_RxBufferInterrupt)
  114. #define ENET_TS_INTERRUPT (kENET_TsTimerInterrupt | kENET_TsAvailInterrupt)
  115. #define ENET_ERR_INTERRUPT (kENET_BabrInterrupt | kENET_BabtInterrupt | kENET_EBusERInterrupt | \
  116. kENET_LateCollisionInterrupt | kENET_RetryLimitInterrupt | kENET_UnderrunInterrupt | kENET_PayloadRxInterrupt)
  117. /*! @name Defines the maximum Ethernet frame size. */
  118. /*@{*/
  119. #define ENET_FRAME_MAX_FRAMELEN 1518U /*!< Default maximum Ethernet frame size. */
  120. /*@}*/
  121. #define ENET_FIFO_MIN_RX_FULL 5U /*!< ENET minimum receive FIFO full. */
  122. #define ENET_RX_MIN_BUFFERSIZE 256U /*!< ENET minimum buffer size. */
  123. /*! @brief Defines the PHY address scope for the ENET. */
  124. #define ENET_PHY_MAXADDRESS (ENET_MMFR_PA_MASK >> ENET_MMFR_PA_SHIFT)
  125. /*! @brief Defines the status return codes for transaction. */
  126. enum _enet_status
  127. {
  128. kStatus_ENET_RxFrameError = MAKE_STATUS(kStatusGroup_ENET, 0U), /*!< A frame received but data error happen. */
  129. kStatus_ENET_RxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 1U), /*!< Failed to receive a frame. */
  130. kStatus_ENET_RxFrameEmpty = MAKE_STATUS(kStatusGroup_ENET, 2U), /*!< No frame arrive. */
  131. kStatus_ENET_TxFrameBusy =
  132. MAKE_STATUS(kStatusGroup_ENET, 3U), /*!< Transmit buffer descriptors are under process. */
  133. kStatus_ENET_TxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 4U) /*!< Transmit frame fail. */
  134. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  135. ,
  136. kStatus_ENET_PtpTsRingFull = MAKE_STATUS(kStatusGroup_ENET, 5U), /*!< Timestamp ring full. */
  137. kStatus_ENET_PtpTsRingEmpty = MAKE_STATUS(kStatusGroup_ENET, 6U) /*!< Timestamp ring empty. */
  138. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  139. };
  140. /*! @brief Defines the RMII or MII mode for data interface between the MAC and the PHY. */
  141. typedef enum _enet_mii_mode
  142. {
  143. kENET_MiiMode = 0U, /*!< MII mode for data interface. */
  144. kENET_RmiiMode /*!< RMII mode for data interface. */
  145. } enet_mii_mode_t;
  146. /*! @brief Defines the 10 Mbps or 100 Mbps speed for the MII data interface. */
  147. typedef enum _enet_mii_speed
  148. {
  149. kENET_MiiSpeed10M = 0U, /*!< Speed 10 Mbps. */
  150. kENET_MiiSpeed100M /*!< Speed 100 Mbps. */
  151. } enet_mii_speed_t;
  152. /*! @brief Defines the half or full duplex for the MII data interface. */
  153. typedef enum _enet_mii_duplex
  154. {
  155. kENET_MiiHalfDuplex = 0U, /*!< Half duplex mode. */
  156. kENET_MiiFullDuplex /*!< Full duplex mode. */
  157. } enet_mii_duplex_t;
  158. /*! @brief Defines the write operation for the MII management frame. */
  159. typedef enum _enet_mii_write
  160. {
  161. kENET_MiiWriteNoCompliant = 0U, /*!< Write frame operation, but not MII-compliant. */
  162. kENET_MiiWriteValidFrame /*!< Write frame operation for a valid MII management frame. */
  163. } enet_mii_write_t;
  164. /*! @brief Defines the read operation for the MII management frame. */
  165. typedef enum _enet_mii_read
  166. {
  167. kENET_MiiReadValidFrame = 2U, /*!< Read frame operation for a valid MII management frame. */
  168. kENET_MiiReadNoCompliant = 3U /*!< Read frame operation, but not MII-compliant. */
  169. } enet_mii_read_t;
  170. #if defined (FSL_FEATURE_ENET_HAS_EXTEND_MDIO) && FSL_FEATURE_ENET_HAS_EXTEND_MDIO
  171. /*! @brief Define the MII opcode for extended MDIO_CLAUSES_45 Frame. */
  172. typedef enum _enet_mii_extend_opcode {
  173. kENET_MiiAddrWrite_C45 = 0U, /*!< Address Write operation. */
  174. kENET_MiiWriteFrame_C45 = 1U, /*!< Write frame operation for a valid MII management frame. */
  175. kENET_MiiReadFrame_C45 = 3U /*!< Read frame operation for a valid MII management frame. */
  176. } enet_mii_extend_opcode;
  177. #endif /* FSL_FEATURE_ENET_HAS_EXTEND_MDIO */
  178. /*! @brief Defines a special configuration for ENET MAC controller.
  179. *
  180. * These control flags are provided for special user requirements.
  181. * Normally, these control flags are unused for ENET initialization.
  182. * For special requirements, set the flags to
  183. * macSpecialConfig in the enet_config_t.
  184. * The kENET_ControlStoreAndFwdDisable is used to disable the FIFO store
  185. * and forward. FIFO store and forward means that the FIFO read/send is started
  186. * when a complete frame is stored in TX/RX FIFO. If this flag is set,
  187. * configure rxFifoFullThreshold and txFifoWatermark
  188. * in the enet_config_t.
  189. */
  190. typedef enum _enet_special_control_flag
  191. {
  192. kENET_ControlFlowControlEnable = 0x0001U, /*!< Enable ENET flow control: pause frame. */
  193. kENET_ControlRxPayloadCheckEnable = 0x0002U, /*!< Enable ENET receive payload length check. */
  194. kENET_ControlRxPadRemoveEnable = 0x0004U, /*!< Padding is removed from received frames. */
  195. kENET_ControlRxBroadCastRejectEnable = 0x0008U, /*!< Enable broadcast frame reject. */
  196. kENET_ControlMacAddrInsert = 0x0010U, /*!< Enable MAC address insert. */
  197. kENET_ControlStoreAndFwdDisable = 0x0020U, /*!< Enable FIFO store and forward. */
  198. kENET_ControlSMIPreambleDisable = 0x0040U, /*!< Enable SMI preamble. */
  199. kENET_ControlPromiscuousEnable = 0x0080U, /*!< Enable promiscuous mode. */
  200. kENET_ControlMIILoopEnable = 0x0100U, /*!< Enable ENET MII loop back. */
  201. kENET_ControlVLANTagEnable = 0x0200U /*!< Enable VLAN tag frame. */
  202. } enet_special_control_flag_t;
  203. /*! @brief List of interrupts supported by the peripheral. This
  204. * enumeration uses one-bot encoding to allow a logical OR of multiple
  205. * members. Members usually map to interrupt enable bits in one or more
  206. * peripheral registers.
  207. */
  208. typedef enum _enet_interrupt_enable
  209. {
  210. kENET_BabrInterrupt = ENET_EIR_BABR_MASK, /*!< Babbling receive error interrupt source */
  211. kENET_BabtInterrupt = ENET_EIR_BABT_MASK, /*!< Babbling transmit error interrupt source */
  212. kENET_GraceStopInterrupt = ENET_EIR_GRA_MASK, /*!< Graceful stop complete interrupt source */
  213. kENET_TxFrameInterrupt = ENET_EIR_TXF_MASK, /*!< TX FRAME interrupt source */
  214. kENET_TxBufferInterrupt = ENET_EIR_TXB_MASK, /*!< TX BUFFER interrupt source */
  215. kENET_RxFrameInterrupt = ENET_EIR_RXF_MASK, /*!< RX FRAME interrupt source */
  216. kENET_RxBufferInterrupt = ENET_EIR_RXB_MASK, /*!< RX BUFFER interrupt source */
  217. kENET_MiiInterrupt = ENET_EIR_MII_MASK, /*!< MII interrupt source */
  218. kENET_EBusERInterrupt = ENET_EIR_EBERR_MASK, /*!< Ethernet bus error interrupt source */
  219. kENET_LateCollisionInterrupt = ENET_EIR_LC_MASK, /*!< Late collision interrupt source */
  220. kENET_RetryLimitInterrupt = ENET_EIR_RL_MASK, /*!< Collision Retry Limit interrupt source */
  221. kENET_UnderrunInterrupt = ENET_EIR_UN_MASK, /*!< Transmit FIFO underrun interrupt source */
  222. kENET_PayloadRxInterrupt = ENET_EIR_PLR_MASK, /*!< Payload Receive interrupt source */
  223. kENET_WakeupInterrupt = ENET_EIR_WAKEUP_MASK, /*!< WAKEUP interrupt source */
  224. kENET_TsAvailInterrupt = ENET_EIR_TS_AVAIL_MASK, /*!< TS AVAIL interrupt source for PTP */
  225. kENET_TsTimerInterrupt = ENET_EIR_TS_TIMER_MASK /*!< TS WRAP interrupt source for PTP */
  226. } enet_interrupt_enable_t;
  227. /*! @brief Defines the common interrupt event for callback use. */
  228. typedef enum _enet_event
  229. {
  230. kENET_RxEvent, /*!< Receive event. */
  231. kENET_TxEvent, /*!< Transmit event. */
  232. kENET_ErrEvent, /*!< Error event: BABR/BABT/EBERR/LC/RL/UN/PLR . */
  233. kENET_WakeUpEvent, /*!< Wake up from sleep mode event. */
  234. kENET_TimeStampEvent, /*!< Time stamp event. */
  235. kENET_TimeStampAvailEvent /*!< Time stamp available event.*/
  236. } enet_event_t;
  237. /*! @brief Defines the transmit accelerator configuration. */
  238. typedef enum _enet_tx_accelerator
  239. {
  240. kENET_TxAccelIsShift16Enabled = ENET_TACC_SHIFT16_MASK, /*!< Transmit FIFO shift-16. */
  241. kENET_TxAccelIpCheckEnabled = ENET_TACC_IPCHK_MASK, /*!< Insert IP header checksum. */
  242. kENET_TxAccelProtoCheckEnabled = ENET_TACC_PROCHK_MASK /*!< Insert protocol checksum. */
  243. } enet_tx_accelerator_t;
  244. /*! @brief Defines the receive accelerator configuration. */
  245. typedef enum _enet_rx_accelerator
  246. {
  247. kENET_RxAccelPadRemoveEnabled = ENET_RACC_PADREM_MASK, /*!< Padding removal for short IP frames. */
  248. kENET_RxAccelIpCheckEnabled = ENET_RACC_IPDIS_MASK, /*!< Discard with wrong IP header checksum. */
  249. kENET_RxAccelProtoCheckEnabled = ENET_RACC_PRODIS_MASK, /*!< Discard with wrong protocol checksum. */
  250. kENET_RxAccelMacCheckEnabled = ENET_RACC_LINEDIS_MASK, /*!< Discard with Mac layer errors. */
  251. kENET_RxAccelisShift16Enabled = ENET_RACC_SHIFT16_MASK /*!< Receive FIFO shift-16. */
  252. } enet_rx_accelerator_t;
  253. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  254. /*! @brief Defines the ENET PTP message related constant. */
  255. typedef enum _enet_ptp_event_type
  256. {
  257. kENET_PtpEventMsgType = 3U, /*!< PTP event message type. */
  258. kENET_PtpSrcPortIdLen = 10U, /*!< PTP message sequence id length. */
  259. kENET_PtpEventPort = 319U, /*!< PTP event port number. */
  260. kENET_PtpGnrlPort = 320U /*!< PTP general port number. */
  261. } enet_ptp_event_type_t;
  262. /*! @brief Defines the IEEE 1588 PTP timer channel numbers. */
  263. typedef enum _enet_ptp_timer_channel
  264. {
  265. kENET_PtpTimerChannel1 = 0U, /*!< IEEE 1588 PTP timer Channel 1. */
  266. kENET_PtpTimerChannel2, /*!< IEEE 1588 PTP timer Channel 2. */
  267. kENET_PtpTimerChannel3, /*!< IEEE 1588 PTP timer Channel 3. */
  268. kENET_PtpTimerChannel4 /*!< IEEE 1588 PTP timer Channel 4. */
  269. } enet_ptp_timer_channel_t;
  270. /*! @brief Defines the capture or compare mode for IEEE 1588 PTP timer channels. */
  271. typedef enum _enet_ptp_timer_channel_mode
  272. {
  273. kENET_PtpChannelDisable = 0U, /*!< Disable timer channel. */
  274. kENET_PtpChannelRisingCapture = 1U, /*!< Input capture on rising edge. */
  275. kENET_PtpChannelFallingCapture = 2U, /*!< Input capture on falling edge. */
  276. kENET_PtpChannelBothCapture = 3U, /*!< Input capture on both edges. */
  277. kENET_PtpChannelSoftCompare = 4U, /*!< Output compare software only. */
  278. kENET_PtpChannelToggleCompare = 5U, /*!< Toggle output on compare. */
  279. kENET_PtpChannelClearCompare = 6U, /*!< Clear output on compare. */
  280. kENET_PtpChannelSetCompare = 7U, /*!< Set output on compare. */
  281. kENET_PtpChannelClearCompareSetOverflow = 10U, /*!< Clear output on compare, set output on overflow. */
  282. kENET_PtpChannelSetCompareClearOverflow = 11U, /*!< Set output on compare, clear output on overflow. */
  283. kENET_PtpChannelPulseLowonCompare = 14U, /*!< Pulse output low on compare for one IEEE 1588 clock cycle. */
  284. kENET_PtpChannelPulseHighonCompare = 15U /*!< Pulse output high on compare for one IEEE 1588 clock cycle. */
  285. } enet_ptp_timer_channel_mode_t;
  286. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  287. /*! @brief Defines the receive buffer descriptor structure for the little endian system.*/
  288. typedef struct _enet_rx_bd_struct
  289. {
  290. uint16_t length; /*!< Buffer descriptor data length. */
  291. uint16_t control; /*!< Buffer descriptor control and status. */
  292. uint8_t *buffer; /*!< Data buffer pointer. */
  293. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  294. uint16_t controlExtend0; /*!< Extend buffer descriptor control0. */
  295. uint16_t controlExtend1; /*!< Extend buffer descriptor control1. */
  296. uint16_t payloadCheckSum; /*!< Internal payload checksum. */
  297. uint8_t headerLength; /*!< Header length. */
  298. uint8_t protocolTyte; /*!< Protocol type. */
  299. uint16_t reserved0;
  300. uint16_t controlExtend2; /*!< Extend buffer descriptor control2. */
  301. uint32_t timestamp; /*!< Timestamp. */
  302. uint16_t reserved1;
  303. uint16_t reserved2;
  304. uint16_t reserved3;
  305. uint16_t reserved4;
  306. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  307. } enet_rx_bd_struct_t;
  308. /*! @brief Defines the enhanced transmit buffer descriptor structure for the little endian system. */
  309. typedef struct _enet_tx_bd_struct
  310. {
  311. uint16_t length; /*!< Buffer descriptor data length. */
  312. uint16_t control; /*!< Buffer descriptor control and status. */
  313. uint8_t *buffer; /*!< Data buffer pointer. */
  314. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  315. uint16_t controlExtend0; /*!< Extend buffer descriptor control0. */
  316. uint16_t controlExtend1; /*!< Extend buffer descriptor control1. */
  317. uint16_t reserved0;
  318. uint16_t reserved1;
  319. uint16_t reserved2;
  320. uint16_t controlExtend2; /*!< Extend buffer descriptor control2. */
  321. uint32_t timestamp; /*!< Timestamp. */
  322. uint16_t reserved3;
  323. uint16_t reserved4;
  324. uint16_t reserved5;
  325. uint16_t reserved6;
  326. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  327. } enet_tx_bd_struct_t;
  328. /*! @brief Defines the ENET data error statistic structure. */
  329. typedef struct _enet_data_error_stats
  330. {
  331. uint32_t statsRxLenGreaterErr; /*!< Receive length greater than RCR[MAX_FL]. */
  332. uint32_t statsRxAlignErr; /*!< Receive non-octet alignment/ */
  333. uint32_t statsRxFcsErr; /*!< Receive CRC error. */
  334. uint32_t statsRxOverRunErr; /*!< Receive over run. */
  335. uint32_t statsRxTruncateErr; /*!< Receive truncate. */
  336. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  337. uint32_t statsRxProtocolChecksumErr; /*!< Receive protocol checksum error. */
  338. uint32_t statsRxIpHeadChecksumErr; /*!< Receive IP header checksum error. */
  339. uint32_t statsRxMacErr; /*!< Receive Mac error. */
  340. uint32_t statsRxPhyErr; /*!< Receive PHY error. */
  341. uint32_t statsRxCollisionErr; /*!< Receive collision. */
  342. uint32_t statsTxErr; /*!< The error happen when transmit the frame. */
  343. uint32_t statsTxFrameErr; /*!< The transmit frame is error. */
  344. uint32_t statsTxOverFlowErr; /*!< Transmit overflow. */
  345. uint32_t statsTxLateCollisionErr; /*!< Transmit late collision. */
  346. uint32_t statsTxExcessCollisionErr; /*!< Transmit excess collision.*/
  347. uint32_t statsTxUnderFlowErr; /*!< Transmit under flow error. */
  348. uint32_t statsTxTsErr; /*!< Transmit time stamp error. */
  349. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  350. } enet_data_error_stats_t;
  351. /*! @brief Defines the receive buffer descriptor configuration structure.
  352. *
  353. * Note that for the internal DMA requirements, the buffers have a corresponding alignment requirements.
  354. * 1. The aligned receive and transmit buffer size must be evenly divisible by ENET_BUFF_ALIGNMENT.
  355. * when the data buffers are in cacheable region when cache is enabled, all those size should be
  356. * aligned to the maximum value of "ENET_BUFF_ALIGNMENT" and the cache line size.
  357. * 2. The aligned transmit and receive buffer descriptor start address must be at
  358. * least 64 bit aligned. However, it's recommended to be evenly divisible by ENET_BUFF_ALIGNMENT.
  359. * buffer descriptors should be put in non-cacheable region when cache is enabled.
  360. * 3. The aligned transmit and receive data buffer start address must be evenly divisible by ENET_BUFF_ALIGNMENT.
  361. * Receive buffers should be continuous with the total size equal to "rxBdNumber * rxBuffSizeAlign".
  362. * Transmit buffers should be continuous with the total size equal to "txBdNumber * txBuffSizeAlign".
  363. * when the data buffers are in cacheable region when cache is enabled, all those size should be
  364. * aligned to the maximum value of "ENET_BUFF_ALIGNMENT" and the cache line size.
  365. */
  366. typedef struct _enet_buffer_config
  367. {
  368. uint16_t rxBdNumber; /*!< Receive buffer descriptor number. */
  369. uint16_t txBdNumber; /*!< Transmit buffer descriptor number. */
  370. uint32_t rxBuffSizeAlign; /*!< Aligned receive data buffer size. */
  371. uint32_t txBuffSizeAlign; /*!< Aligned transmit data buffer size. */
  372. volatile enet_rx_bd_struct_t *rxBdStartAddrAlign; /*!< Aligned receive buffer descriptor start address. */
  373. volatile enet_tx_bd_struct_t *txBdStartAddrAlign; /*!< Aligned transmit buffer descriptor start address. */
  374. uint8_t *rxBufferAlign; /*!< Receive data buffer start address. */
  375. uint8_t *txBufferAlign; /*!< Transmit data buffer start address. */
  376. } enet_buffer_config_t;
  377. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  378. /*! @brief Defines the ENET PTP time stamp structure. */
  379. typedef struct _enet_ptp_time
  380. {
  381. uint64_t second; /*!< Second. */
  382. uint32_t nanosecond; /*!< Nanosecond. */
  383. } enet_ptp_time_t;
  384. /*! @brief Defines the structure for the ENET PTP message data and timestamp data.*/
  385. typedef struct _enet_ptp_time_data
  386. {
  387. uint8_t version; /*!< PTP version. */
  388. uint8_t sourcePortId[kENET_PtpSrcPortIdLen]; /*!< PTP source port ID. */
  389. uint16_t sequenceId; /*!< PTP sequence ID. */
  390. uint8_t messageType; /*!< PTP message type. */
  391. enet_ptp_time_t timeStamp; /*!< PTP timestamp. */
  392. } enet_ptp_time_data_t;
  393. /*! @brief Defines the ENET PTP ring buffer structure for the PTP message timestamp store.*/
  394. typedef struct _enet_ptp_time_data_ring
  395. {
  396. uint32_t front; /*!< The first index of the ring. */
  397. uint32_t end; /*!< The end index of the ring. */
  398. uint32_t size; /*!< The size of the ring. */
  399. enet_ptp_time_data_t *ptpTsData; /*!< PTP message data structure. */
  400. } enet_ptp_time_data_ring_t;
  401. /*! @brief Defines the ENET PTP configuration structure. */
  402. typedef struct _enet_ptp_config
  403. {
  404. uint8_t ptpTsRxBuffNum; /*!< Receive 1588 timestamp buffer number*/
  405. uint8_t ptpTsTxBuffNum; /*!< Transmit 1588 timestamp buffer number*/
  406. enet_ptp_time_data_t *rxPtpTsData; /*!< The start address of 1588 receive timestamp buffers */
  407. enet_ptp_time_data_t *txPtpTsData; /*!< The start address of 1588 transmit timestamp buffers */
  408. enet_ptp_timer_channel_t channel; /*!< Used for ERRATA_2579: the PTP 1588 timer channel for time interrupt. */
  409. uint32_t ptp1588ClockSrc_Hz; /*!< The clock source of the PTP 1588 timer. */
  410. } enet_ptp_config_t;
  411. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  412. #if defined (FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE) && FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE
  413. /*! @brief Defines the interrupt coalescing configure structure. */
  414. typedef struct _enet_intcoalesce_config
  415. {
  416. uint8_t txCoalesceFrameCount[FSL_FEATURE_ENET_QUEUE]; /*!< Transmit interrupt coalescing frame count threshold. */
  417. uint16_t txCoalesceTimeCount[FSL_FEATURE_ENET_QUEUE]; /*!< Transmit interrupt coalescing timer count threshold. */
  418. uint8_t rxCoalesceFrameCount[FSL_FEATURE_ENET_QUEUE]; /*!< Receive interrupt coalescing frame count threshold. */
  419. uint16_t rxCoalesceTimeCount[FSL_FEATURE_ENET_QUEUE]; /*!< Receive interrupt coalescing timer count threshold. */
  420. } enet_intcoalesce_config_t;
  421. #endif /* FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE */
  422. /*! @brief Defines the basic configuration structure for the ENET device.
  423. *
  424. * Note:
  425. * 1. macSpecialConfig is used for a special control configuration, a logical OR of
  426. * "enet_special_control_flag_t". For a special configuration for MAC,
  427. * set this parameter to 0.
  428. * 2. txWatermark is used for a cut-through operation. It is in steps of 64 bytes.
  429. * 0/1 - 64 bytes written to TX FIFO before transmission of a frame begins.
  430. * 2 - 128 bytes written to TX FIFO ....
  431. * 3 - 192 bytes written to TX FIFO ....
  432. * The maximum of txWatermark is 0x2F - 4032 bytes written to TX FIFO.
  433. * txWatermark allows minimizing the transmit latency to set the txWatermark to 0 or 1
  434. * or for larger bus access latency 3 or larger due to contention for the system bus.
  435. * 3. rxFifoFullThreshold is similar to the txWatermark for cut-through operation in RX.
  436. * It is in 64-bit words. The minimum is ENET_FIFO_MIN_RX_FULL and the maximum is 0xFF.
  437. * If the end of the frame is stored in FIFO and the frame size if smaller than the
  438. * txWatermark, the frame is still transmitted. The rule is the
  439. * same for rxFifoFullThreshold in the receive direction.
  440. * 4. When "kENET_ControlFlowControlEnable" is set in the macSpecialConfig, ensure
  441. * that the pauseDuration, rxFifoEmptyThreshold, and rxFifoStatEmptyThreshold
  442. * are set for flow control enabled case.
  443. * 5. When "kENET_ControlStoreAndFwdDisabled" is set in the macSpecialConfig, ensure
  444. * that the rxFifoFullThreshold and txFifoWatermark are set for store and forward disable.
  445. * 6. The rxAccelerConfig and txAccelerConfig default setting with 0 - accelerator
  446. * are disabled. The "enet_tx_accelerator_t" and "enet_rx_accelerator_t" are
  447. * recommended to be used to enable the transmit and receive accelerator.
  448. * After the accelerators are enabled, the store and forward feature should be enabled.
  449. * As a result, kENET_ControlStoreAndFwdDisabled should not be set.
  450. */
  451. typedef struct _enet_config
  452. {
  453. uint32_t macSpecialConfig; /*!< Mac special configuration. A logical OR of "enet_special_control_flag_t". */
  454. uint32_t interrupt; /*!< Mac interrupt source. A logical OR of "enet_interrupt_enable_t". */
  455. uint16_t rxMaxFrameLen; /*!< Receive maximum frame length. */
  456. enet_mii_mode_t miiMode; /*!< MII mode. */
  457. enet_mii_speed_t miiSpeed; /*!< MII Speed. */
  458. enet_mii_duplex_t miiDuplex; /*!< MII duplex. */
  459. uint8_t rxAccelerConfig; /*!< Receive accelerator, A logical OR of "enet_rx_accelerator_t". */
  460. uint8_t txAccelerConfig; /*!< Transmit accelerator, A logical OR of "enet_rx_accelerator_t". */
  461. uint16_t pauseDuration; /*!< For flow control enabled case: Pause duration. */
  462. uint8_t rxFifoEmptyThreshold; /*!< For flow control enabled case: when RX FIFO level reaches this value,
  463. it makes MAC generate XOFF pause frame. */
  464. #if defined (FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD) && FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD
  465. uint8_t rxFifoStatEmptyThreshold; /*!< For flow control enabled case: number of frames in the receive FIFO,
  466. independent of size, that can be accept. If the limit is reached, reception
  467. continues and a pause frame is triggered. */
  468. #endif /* FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD */
  469. uint8_t rxFifoFullThreshold; /*!< For store and forward disable case, the data required in RX FIFO to notify
  470. the MAC receive ready status. */
  471. uint8_t txFifoWatermark; /*!< For store and forward disable case, the data required in TX FIFO
  472. before a frame transmit start. */
  473. #if defined (FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE) && FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE
  474. enet_intcoalesce_config_t *intCoalesceCfg; /* If the interrupt coalsecence is not required in the ring n(0,1,2), please set
  475. to NULL. */
  476. #endif /* FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE */
  477. } enet_config_t;
  478. /* Forward declaration of the handle typedef. */
  479. typedef struct _enet_handle enet_handle_t;
  480. /*! @brief ENET callback function. */
  481. typedef void (*enet_callback_t)(ENET_Type *base, enet_handle_t *handle, enet_event_t event, void *userData);
  482. /*! @brief Defines the ENET handler structure. */
  483. struct _enet_handle
  484. {
  485. volatile enet_rx_bd_struct_t *rxBdBase; /*!< Receive buffer descriptor base address pointer. */
  486. volatile enet_rx_bd_struct_t *rxBdCurrent; /*!< The current available receive buffer descriptor pointer. */
  487. volatile enet_tx_bd_struct_t *txBdBase; /*!< Transmit buffer descriptor base address pointer. */
  488. volatile enet_tx_bd_struct_t *txBdCurrent; /*!< The current available transmit buffer descriptor pointer. */
  489. uint32_t rxBuffSizeAlign; /*!< Receive buffer size alignment. */
  490. uint32_t txBuffSizeAlign; /*!< Transmit buffer size alignment. */
  491. enet_callback_t callback; /*!< Callback function. */
  492. void *userData; /*!< Callback function parameter.*/
  493. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  494. volatile enet_tx_bd_struct_t *txBdDirtyStatic; /*!< The dirty transmit buffer descriptor for error static update. */
  495. volatile enet_tx_bd_struct_t *txBdDirtyTime; /*!< The dirty transmit buffer descriptor for time stamp update. */
  496. uint64_t msTimerSecond; /*!< The second for Master PTP timer .*/
  497. enet_ptp_time_data_ring_t rxPtpTsDataRing; /*!< Receive PTP 1588 time stamp data ring buffer. */
  498. enet_ptp_time_data_ring_t txPtpTsDataRing; /*!< Transmit PTP 1588 time stamp data ring buffer. */
  499. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  500. };
  501. /*******************************************************************************
  502. * API
  503. ******************************************************************************/
  504. #if defined(__cplusplus)
  505. extern "C" {
  506. #endif
  507. /*!
  508. * @name Initialization and de-initialization
  509. * @{
  510. */
  511. /*!
  512. * @brief Gets the ENET default configuration structure.
  513. *
  514. * The purpose of this API is to get the default ENET MAC controller
  515. * configuration structure for ENET_Init(). Users may use the initialized
  516. * structure unchanged in ENET_Init() or modify fields of the
  517. * structure before calling ENET_Init().
  518. * This is an example.
  519. @code
  520. enet_config_t config;
  521. ENET_GetDefaultConfig(&config);
  522. @endcode
  523. * @param config The ENET mac controller configuration structure pointer.
  524. */
  525. void ENET_GetDefaultConfig(enet_config_t *config);
  526. /*!
  527. * @brief Initializes the ENET module.
  528. *
  529. * This function ungates the module clock and initializes it with the ENET configuration.
  530. *
  531. * @param base ENET peripheral base address.
  532. * @param handle ENET handler pointer.
  533. * @param config ENET Mac configuration structure pointer.
  534. * The "enet_config_t" type mac configuration return from ENET_GetDefaultConfig
  535. * can be used directly. It is also possible to verify the Mac configuration using other methods.
  536. * @param bufferConfig ENET buffer configuration structure pointer.
  537. * The buffer configuration should be prepared for ENET Initialization.
  538. * @param macAddr ENET mac address of the Ethernet device. This Mac address should be
  539. * provided.
  540. * @param srcClock_Hz The internal module clock source for MII clock.
  541. *
  542. * @note ENET has two buffer descriptors legacy buffer descriptors and
  543. * enhanced IEEE 1588 buffer descriptors. The legacy descriptor is used by default. To
  544. * use the IEEE 1588 feature, use the enhanced IEEE 1588 buffer descriptor
  545. * by defining "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" and calling ENET_Ptp1588Configure()
  546. * to configure the 1588 feature and related buffers after calling ENET_Init().
  547. */
  548. void ENET_Init(ENET_Type *base,
  549. enet_handle_t *handle,
  550. const enet_config_t *config,
  551. const enet_buffer_config_t *bufferConfig,
  552. uint8_t *macAddr,
  553. uint32_t srcClock_Hz);
  554. /*!
  555. * @brief Deinitializes the ENET module.
  556. * This function gates the module clock, clears ENET interrupts, and disables the ENET module.
  557. *
  558. * @param base ENET peripheral base address.
  559. */
  560. void ENET_Deinit(ENET_Type *base);
  561. /*!
  562. * @brief Resets the ENET module.
  563. *
  564. * This function restores the ENET module to the reset state.
  565. * Note that this function sets all registers to the
  566. * reset state. As a result, the ENET module can't work after calling this function.
  567. *
  568. * @param base ENET peripheral base address.
  569. */
  570. static inline void ENET_Reset(ENET_Type *base)
  571. {
  572. base->ECR |= ENET_ECR_RESET_MASK;
  573. }
  574. /* @} */
  575. /*!
  576. * @name MII interface operation
  577. * @{
  578. */
  579. /*!
  580. * @brief Sets the ENET MII speed and duplex.
  581. *
  582. * @param base ENET peripheral base address.
  583. * @param speed The speed of the RMII mode.
  584. * @param duplex The duplex of the RMII mode.
  585. */
  586. void ENET_SetMII(ENET_Type *base, enet_mii_speed_t speed, enet_mii_duplex_t duplex);
  587. /*!
  588. * @brief Sets the ENET SMI (serial management interface) - MII management interface.
  589. *
  590. * @param base ENET peripheral base address.
  591. * @param srcClock_Hz This is the ENET module clock frequency. Normally it's the system clock. See clock distribution.
  592. * @param isPreambleDisabled The preamble disable flag.
  593. * - true Enables the preamble.
  594. * - false Disables the preamble.
  595. */
  596. void ENET_SetSMI(ENET_Type *base, uint32_t srcClock_Hz, bool isPreambleDisabled);
  597. /*!
  598. * @brief Gets the ENET SMI- MII management interface configuration.
  599. *
  600. * This API is used to get the SMI configuration to check whether the MII management
  601. * interface has been set.
  602. *
  603. * @param base ENET peripheral base address.
  604. * @return The SMI setup status true or false.
  605. */
  606. static inline bool ENET_GetSMI(ENET_Type *base)
  607. {
  608. return (0 != (base->MSCR & 0x7E));
  609. }
  610. /*!
  611. * @brief Reads data from the PHY register through an SMI interface.
  612. *
  613. * @param base ENET peripheral base address.
  614. * @return The data read from PHY
  615. */
  616. static inline uint32_t ENET_ReadSMIData(ENET_Type *base)
  617. {
  618. return (uint32_t)((base->MMFR & ENET_MMFR_DATA_MASK) >> ENET_MMFR_DATA_SHIFT);
  619. }
  620. /*!
  621. * @brief Starts an SMI (Serial Management Interface) read command.
  622. *
  623. * @param base ENET peripheral base address.
  624. * @param phyAddr The PHY address.
  625. * @param phyReg The PHY register.
  626. * @param operation The read operation.
  627. */
  628. void ENET_StartSMIRead(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_read_t operation);
  629. /*!
  630. * @brief Starts an SMI write command.
  631. *
  632. * @param base ENET peripheral base address.
  633. * @param phyAddr The PHY address.
  634. * @param phyReg The PHY register.
  635. * @param operation The write operation.
  636. * @param data The data written to PHY.
  637. */
  638. void ENET_StartSMIWrite(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_write_t operation, uint32_t data);
  639. #if defined (FSL_FEATURE_ENET_HAS_EXTEND_MDIO) && FSL_FEATURE_ENET_HAS_EXTEND_MDIO
  640. /*!
  641. * @brief Starts the extended IEEE802.3 Clause 45 MDIO format SMI read command.
  642. *
  643. * @param base ENET peripheral base address.
  644. * @param phyAddr The PHY address.
  645. * @param phyReg The PHY register. For MDIO IEEE802.3 Clause 45,
  646. * the phyReg is a 21-bits combination of the devaddr (5 bits device address)
  647. * and the regAddr (16 bits phy register): phyReg = (devaddr << 16) | regAddr.
  648. */
  649. void ENET_StartExtC45SMIRead(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg);
  650. /*!
  651. * @brief Starts the extended IEEE802.3 Clause 45 MDIO format SMI write command.
  652. *
  653. * @param base ENET peripheral base address.
  654. * @param phyAddr The PHY address.
  655. * @param phyReg The PHY register. For MDIO IEEE802.3 Clause 45,
  656. * the phyReg is a 21-bits combination of the devaddr (5 bits device address)
  657. * and the regAddr (16 bits phy register): phyReg = (devaddr << 16) | regAddr.
  658. * @param data The data written to PHY.
  659. */
  660. void ENET_StartExtC45SMIWrite(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, uint32_t data);
  661. #endif /* FSL_FEATURE_ENET_HAS_EXTEND_MDIO */
  662. /* @} */
  663. /*!
  664. * @name MAC Address Filter
  665. * @{
  666. */
  667. /*!
  668. * @brief Sets the ENET module Mac address.
  669. *
  670. * @param base ENET peripheral base address.
  671. * @param macAddr The six-byte Mac address pointer.
  672. * The pointer is allocated by application and input into the API.
  673. */
  674. void ENET_SetMacAddr(ENET_Type *base, uint8_t *macAddr);
  675. /*!
  676. * @brief Gets the ENET module Mac address.
  677. *
  678. * @param base ENET peripheral base address.
  679. * @param macAddr The six-byte Mac address pointer.
  680. * The pointer is allocated by application and input into the API.
  681. */
  682. void ENET_GetMacAddr(ENET_Type *base, uint8_t *macAddr);
  683. /*!
  684. * @brief Adds the ENET device to a multicast group.
  685. *
  686. * @param base ENET peripheral base address.
  687. * @param address The six-byte multicast group address which is provided by application.
  688. */
  689. void ENET_AddMulticastGroup(ENET_Type *base, uint8_t *address);
  690. /*!
  691. * @brief Moves the ENET device from a multicast group.
  692. *
  693. * @param base ENET peripheral base address.
  694. * @param address The six-byte multicast group address which is provided by application.
  695. */
  696. void ENET_LeaveMulticastGroup(ENET_Type *base, uint8_t *address);
  697. /* @} */
  698. /*!
  699. * @name Other basic operations
  700. * @{
  701. */
  702. /*!
  703. * @brief Activates ENET read or receive.
  704. *
  705. * @param base ENET peripheral base address.
  706. *
  707. * @note This must be called after the MAC configuration and
  708. * state are ready. It must be called after the ENET_Init() and
  709. * ENET_Ptp1588Configure(). This should be called when the ENET receive required.
  710. */
  711. static inline void ENET_ActiveRead(ENET_Type *base)
  712. {
  713. base->RDAR = ENET_RDAR_RDAR_MASK;
  714. }
  715. /*!
  716. * @brief Enables/disables the MAC to enter sleep mode.
  717. * This function is used to set the MAC enter sleep mode.
  718. * When entering sleep mode, the magic frame wakeup interrupt should be enabled
  719. * to wake up MAC from the sleep mode and reset it to normal mode.
  720. *
  721. * @param base ENET peripheral base address.
  722. * @param enable True enable sleep mode, false disable sleep mode.
  723. */
  724. static inline void ENET_EnableSleepMode(ENET_Type *base, bool enable)
  725. {
  726. if (enable)
  727. {
  728. /* When this field is set, MAC enters sleep mode. */
  729. base->ECR |= ENET_ECR_SLEEP_MASK | ENET_ECR_MAGICEN_MASK;
  730. }
  731. else
  732. { /* MAC exits sleep mode. */
  733. base->ECR &= ~(ENET_ECR_SLEEP_MASK | ENET_ECR_MAGICEN_MASK);
  734. }
  735. }
  736. /*!
  737. * @brief Gets ENET transmit and receive accelerator functions from the MAC controller.
  738. *
  739. * @param base ENET peripheral base address.
  740. * @param txAccelOption The transmit accelerator option. The "enet_tx_accelerator_t" is
  741. * recommended as the mask to get the exact the accelerator option.
  742. * @param rxAccelOption The receive accelerator option. The "enet_rx_accelerator_t" is
  743. * recommended as the mask to get the exact the accelerator option.
  744. */
  745. static inline void ENET_GetAccelFunction(ENET_Type *base, uint32_t *txAccelOption, uint32_t *rxAccelOption)
  746. {
  747. assert(txAccelOption);
  748. assert(txAccelOption);
  749. *txAccelOption = base->TACC;
  750. *rxAccelOption = base->RACC;
  751. }
  752. /* @} */
  753. /*!
  754. * @name Interrupts
  755. * @{
  756. */
  757. /*!
  758. * @brief Enables the ENET interrupt.
  759. *
  760. * This function enables the ENET interrupt according to the provided mask. The mask
  761. * is a logical OR of enumeration members. See @ref enet_interrupt_enable_t.
  762. * For example, to enable the TX frame interrupt and RX frame interrupt, do the following.
  763. * @code
  764. * ENET_EnableInterrupts(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt);
  765. * @endcode
  766. *
  767. * @param base ENET peripheral base address.
  768. * @param mask ENET interrupts to enable. This is a logical OR of the
  769. * enumeration :: enet_interrupt_enable_t.
  770. */
  771. static inline void ENET_EnableInterrupts(ENET_Type *base, uint32_t mask)
  772. {
  773. base->EIMR |= mask;
  774. }
  775. /*!
  776. * @brief Disables the ENET interrupt.
  777. *
  778. * This function disables the ENET interrupts according to the provided mask. The mask
  779. * is a logical OR of enumeration members. See @ref enet_interrupt_enable_t.
  780. * For example, to disable the TX frame interrupt and RX frame interrupt, do the following.
  781. * @code
  782. * ENET_DisableInterrupts(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt);
  783. * @endcode
  784. *
  785. * @param base ENET peripheral base address.
  786. * @param mask ENET interrupts to disable. This is a logical OR of the
  787. * enumeration :: enet_interrupt_enable_t.
  788. */
  789. static inline void ENET_DisableInterrupts(ENET_Type *base, uint32_t mask)
  790. {
  791. base->EIMR &= ~mask;
  792. }
  793. /*!
  794. * @brief Gets the ENET interrupt status flag.
  795. *
  796. * @param base ENET peripheral base address.
  797. * @return The event status of the interrupt source. This is the logical OR of members
  798. * of the enumeration :: enet_interrupt_enable_t.
  799. */
  800. static inline uint32_t ENET_GetInterruptStatus(ENET_Type *base)
  801. {
  802. return base->EIR;
  803. }
  804. /*!
  805. * @brief Clears the ENET interrupt events status flag.
  806. *
  807. * This function clears enabled ENET interrupts according to the provided mask. The mask
  808. * is a logical OR of enumeration members. See the @ref enet_interrupt_enable_t.
  809. * For example, to clear the TX frame interrupt and RX frame interrupt, do the following.
  810. * @code
  811. * ENET_ClearInterruptStatus(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt);
  812. * @endcode
  813. *
  814. * @param base ENET peripheral base address.
  815. * @param mask ENET interrupt source to be cleared.
  816. * This is the logical OR of members of the enumeration :: enet_interrupt_enable_t.
  817. */
  818. static inline void ENET_ClearInterruptStatus(ENET_Type *base, uint32_t mask)
  819. {
  820. base->EIR = mask;
  821. }
  822. /* @} */
  823. /*!
  824. * @name Transactional operation
  825. * @{
  826. */
  827. /*!
  828. * @brief Sets the callback function.
  829. * This API is provided for the application callback required case when ENET
  830. * interrupt is enabled. This API should be called after calling ENET_Init.
  831. *
  832. * @param handle ENET handler pointer. Should be provided by application.
  833. * @param callback The ENET callback function.
  834. * @param userData The callback function parameter.
  835. */
  836. void ENET_SetCallback(enet_handle_t *handle, enet_callback_t callback, void *userData);
  837. /*!
  838. * @brief Gets the ENET the error statistics of a received frame.
  839. *
  840. * This API must be called after the ENET_GetRxFrameSize and before the ENET_ReadFrame().
  841. * If the ENET_GetRxFrameSize returns kStatus_ENET_RxFrameError,
  842. * the ENET_GetRxErrBeforeReadFrame can be used to get the exact error statistics.
  843. * This is an example.
  844. * @code
  845. * status = ENET_GetRxFrameSize(&g_handle, &length);
  846. * if (status == kStatus_ENET_RxFrameError)
  847. * {
  848. * // Get the error information of the received frame.
  849. * ENET_GetRxErrBeforeReadFrame(&g_handle, &eErrStatic);
  850. * // update the receive buffer.
  851. * ENET_ReadFrame(EXAMPLE_ENET, &g_handle, NULL, 0);
  852. * }
  853. * @endcode
  854. * @param handle The ENET handler structure pointer. This is the same handler pointer used in the ENET_Init.
  855. * @param eErrorStatic The error statistics structure pointer.
  856. */
  857. void ENET_GetRxErrBeforeReadFrame(enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic);
  858. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  859. /*!
  860. * @brief Gets the ENET transmit frame statistics after the data send.
  861. *
  862. * This interface gets the error statistics of the transmit frame.
  863. * Because the error information is reported by the uDMA after the data delivery, this interface
  864. * should be called after the data transmit API. It is recommended to call this function on
  865. * transmit interrupt handler. After calling the ENET_SendFrame, the
  866. * transmit interrupt notifies the transmit completion.
  867. *
  868. * @param handle The PTP handler pointer. This is the same handler pointer used in the ENET_Init.
  869. * @param eErrorStatic The error statistics structure pointer.
  870. * @return The execute status.
  871. */
  872. status_t ENET_GetTxErrAfterSendFrame(enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic);
  873. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  874. /*!
  875. * @brief Gets the size of the read frame.
  876. * This function gets a received frame size from the ENET buffer descriptors.
  877. * @note The FCS of the frame is automatically removed by Mac and the size is the length without the FCS.
  878. * After calling ENET_GetRxFrameSize, ENET_ReadFrame() should be called to update the
  879. * receive buffers If the result is not "kStatus_ENET_RxFrameEmpty".
  880. *
  881. * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init.
  882. * @param length The length of the valid frame received.
  883. * @retval kStatus_ENET_RxFrameEmpty No frame received. Should not call ENET_ReadFrame to read frame.
  884. * @retval kStatus_ENET_RxFrameError Data error happens. ENET_ReadFrame should be called with NULL data
  885. * and NULL length to update the receive buffers.
  886. * @retval kStatus_Success Receive a frame Successfully then the ENET_ReadFrame
  887. * should be called with the right data buffer and the captured data length input.
  888. */
  889. status_t ENET_GetRxFrameSize(enet_handle_t *handle, uint32_t *length);
  890. /*!
  891. * @brief Reads a frame from the ENET device.
  892. * This function reads a frame (both the data and the length) from the ENET buffer descriptors.
  893. * The ENET_GetRxFrameSize should be used to get the size of the prepared data buffer.
  894. * This is an example.
  895. * @code
  896. * uint32_t length;
  897. * enet_handle_t g_handle;
  898. * //Get the received frame size firstly.
  899. * status = ENET_GetRxFrameSize(&g_handle, &length);
  900. * if (length != 0)
  901. * {
  902. * //Allocate memory here with the size of "length"
  903. * uint8_t *data = memory allocate interface;
  904. * if (!data)
  905. * {
  906. * ENET_ReadFrame(ENET, &g_handle, NULL, 0);
  907. * //Add the console warning log.
  908. * }
  909. * else
  910. * {
  911. * status = ENET_ReadFrame(ENET, &g_handle, data, length);
  912. * //Call stack input API to deliver the data to stack
  913. * }
  914. * }
  915. * else if (status == kStatus_ENET_RxFrameError)
  916. * {
  917. * //Update the received buffer when a error frame is received.
  918. * ENET_ReadFrame(ENET, &g_handle, NULL, 0);
  919. * }
  920. * @endcode
  921. * @param base ENET peripheral base address.
  922. * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init.
  923. * @param data The data buffer provided by user to store the frame which memory size should be at least "length".
  924. * @param length The size of the data buffer which is still the length of the received frame.
  925. * @return The execute status, successful or failure.
  926. */
  927. status_t ENET_ReadFrame(ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length);
  928. /*!
  929. * @brief Transmits an ENET frame.
  930. * @note The CRC is automatically appended to the data. Input the data
  931. * to send without the CRC.
  932. *
  933. * @param base ENET peripheral base address.
  934. * @param handle The ENET handler pointer. This is the same handler pointer used in the ENET_Init.
  935. * @param data The data buffer provided by user to be send.
  936. * @param length The length of the data to be send.
  937. * @retval kStatus_Success Send frame succeed.
  938. * @retval kStatus_ENET_TxFrameBusy Transmit buffer descriptor is busy under transmission.
  939. * The transmit busy happens when the data send rate is over the MAC capacity.
  940. * The waiting mechanism is recommended to be added after each call return with
  941. * kStatus_ENET_TxFrameBusy.
  942. */
  943. status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length);
  944. /*!
  945. * @brief The transmit IRQ handler.
  946. *
  947. * @param base ENET peripheral base address.
  948. * @param handle The ENET handler pointer.
  949. */
  950. void ENET_TransmitIRQHandler(ENET_Type *base, enet_handle_t *handle);
  951. /*!
  952. * @brief The receive IRQ handler.
  953. *
  954. * @param base ENET peripheral base address.
  955. * @param handle The ENET handler pointer.
  956. */
  957. void ENET_ReceiveIRQHandler(ENET_Type *base, enet_handle_t *handle);
  958. /*!
  959. * @brief The error IRQ handler.
  960. *
  961. * @param base ENET peripheral base address.
  962. * @param handle The ENET handler pointer.
  963. */
  964. void ENET_ErrorIRQHandler(ENET_Type *base, enet_handle_t *handle);
  965. /*!
  966. * @brief the common IRQ handler for the tx/rx/error etc irq handler.
  967. *
  968. * This is used for the combined tx/rx/error interrupt for single ring (ring 0).
  969. *
  970. * @param base ENET peripheral base address.
  971. */
  972. void ENET_CommonFrame0IRQHandler(ENET_Type *base);
  973. /* @} */
  974. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  975. /*!
  976. * @name ENET PTP 1588 function operation
  977. * @{
  978. */
  979. /*!
  980. * @brief Configures the ENET PTP IEEE 1588 feature with the basic configuration.
  981. * The function sets the clock for PTP 1588 timer and enables
  982. * time stamp interrupts and transmit interrupts for PTP 1588 features.
  983. * This API should be called when the 1588 feature is enabled
  984. * or the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is defined.
  985. * ENET_Init should be called before calling this API.
  986. *
  987. * @note The PTP 1588 time-stamp second increase though time-stamp interrupt handler
  988. * and the transmit time-stamp store is done through transmit interrupt handler.
  989. * As a result, the TS interrupt and TX interrupt are enabled when you call this API.
  990. *
  991. * @param base ENET peripheral base address.
  992. * @param handle ENET handler pointer.
  993. * @param ptpConfig The ENET PTP1588 configuration.
  994. */
  995. void ENET_Ptp1588Configure(ENET_Type *base, enet_handle_t *handle, enet_ptp_config_t *ptpConfig);
  996. /*!
  997. * @brief Starts the ENET PTP 1588 Timer.
  998. * This function is used to initialize the PTP timer. After the PTP starts,
  999. * the PTP timer starts running.
  1000. *
  1001. * @param base ENET peripheral base address.
  1002. * @param ptpClkSrc The clock source of the PTP timer.
  1003. */
  1004. void ENET_Ptp1588StartTimer(ENET_Type *base, uint32_t ptpClkSrc);
  1005. /*!
  1006. * @brief Stops the ENET PTP 1588 Timer.
  1007. * This function is used to stops the ENET PTP timer.
  1008. *
  1009. * @param base ENET peripheral base address.
  1010. */
  1011. static inline void ENET_Ptp1588StopTimer(ENET_Type *base)
  1012. {
  1013. /* Disable PTP timer and reset the timer. */
  1014. base->ATCR &= ~ENET_ATCR_EN_MASK;
  1015. base->ATCR |= ENET_ATCR_RESTART_MASK;
  1016. }
  1017. /*!
  1018. * @brief Adjusts the ENET PTP 1588 timer.
  1019. *
  1020. * @param base ENET peripheral base address.
  1021. * @param corrIncrease The correction increment value. This value is added every time the correction
  1022. * timer expires. A value less than the PTP timer frequency(1/ptpClkSrc) slows down the timer,
  1023. * a value greater than the 1/ptpClkSrc speeds up the timer.
  1024. * @param corrPeriod The PTP timer correction counter wrap-around value. This defines after how
  1025. * many timer clock the correction counter should be reset and trigger a correction
  1026. * increment on the timer. A value of 0 disables the correction counter and no correction occurs.
  1027. */
  1028. void ENET_Ptp1588AdjustTimer(ENET_Type *base, uint32_t corrIncrease, uint32_t corrPeriod);
  1029. /*!
  1030. * @brief Sets the ENET PTP 1588 timer channel mode.
  1031. *
  1032. * @param base ENET peripheral base address.
  1033. * @param channel The ENET PTP timer channel number.
  1034. * @param mode The PTP timer channel mode, see "enet_ptp_timer_channel_mode_t".
  1035. * @param intEnable Enables or disables the interrupt.
  1036. */
  1037. static inline void ENET_Ptp1588SetChannelMode(ENET_Type *base,
  1038. enet_ptp_timer_channel_t channel,
  1039. enet_ptp_timer_channel_mode_t mode,
  1040. bool intEnable)
  1041. {
  1042. uint32_t tcrReg = 0;
  1043. tcrReg = ENET_TCSR_TMODE(mode) | ENET_TCSR_TIE(intEnable);
  1044. /* Disable channel mode first. */
  1045. base->CHANNEL[channel].TCSR = 0;
  1046. base->CHANNEL[channel].TCSR = tcrReg;
  1047. }
  1048. #if defined(FSL_FEATURE_ENET_HAS_TIMER_PWCONTROL) && FSL_FEATURE_ENET_HAS_TIMER_PWCONTROL
  1049. /*!
  1050. * @brief Sets ENET PTP 1588 timer channel mode pulse width.
  1051. *
  1052. * For the input "mode" in ENET_Ptp1588SetChannelMode, the kENET_PtpChannelPulseLowonCompare
  1053. * kENET_PtpChannelPulseHighonCompare only support the pulse width for one 1588 clock.
  1054. * this function is extended for control the pulse width from 1 to 32 1588 clock cycles.
  1055. * so call this function if you need to set the timer channel mode for
  1056. * kENET_PtpChannelPulseLowonCompare or kENET_PtpChannelPulseHighonCompare
  1057. * with pulse width more than one 1588 clock,
  1058. *
  1059. * @param base ENET peripheral base address.
  1060. * @param channel The ENET PTP timer channel number.
  1061. * @param isOutputLow True --- timer channel is configured for output compare
  1062. * pulse output low.
  1063. * false --- timer channel is configured for output compare
  1064. * pulse output high.
  1065. * @param pulseWidth The pulse width control value, range from 0 ~ 31.
  1066. * 0 --- pulse width is one 1588 clock cycle.
  1067. * 31 --- pulse width is thirty two 1588 clock cycles.
  1068. * @param intEnable Enables or disables the interrupt.
  1069. */
  1070. static inline void ENET_Ptp1588SetChannelOutputPulseWidth(ENET_Type *base,
  1071. enet_ptp_timer_channel_t channel,
  1072. bool isOutputLow,
  1073. uint8_t pulseWidth,
  1074. bool intEnable)
  1075. {
  1076. uint32_t tcrReg;
  1077. tcrReg = ENET_TCSR_TIE(intEnable) | ENET_TCSR_TPWC(pulseWidth);
  1078. if (isOutputLow)
  1079. {
  1080. tcrReg |= ENET_TCSR_TMODE(kENET_PtpChannelPulseLowonCompare);
  1081. }
  1082. else
  1083. {
  1084. tcrReg |= ENET_TCSR_TMODE(kENET_PtpChannelPulseHighonCompare);
  1085. }
  1086. /* Disable channel mode first. */
  1087. base->CHANNEL[channel].TCSR = 0;
  1088. base->CHANNEL[channel].TCSR = tcrReg;
  1089. }
  1090. #endif /* FSL_FEATURE_ENET_HAS_TIMER_PWCONTROL */
  1091. /*!
  1092. * @brief Sets the ENET PTP 1588 timer channel comparison value.
  1093. *
  1094. * @param base ENET peripheral base address.
  1095. * @param channel The PTP timer channel, see "enet_ptp_timer_channel_t".
  1096. * @param cmpValue The compare value for the compare setting.
  1097. */
  1098. static inline void ENET_Ptp1588SetChannelCmpValue(ENET_Type *base, enet_ptp_timer_channel_t channel, uint32_t cmpValue)
  1099. {
  1100. base->CHANNEL[channel].TCCR = cmpValue;
  1101. }
  1102. /*!
  1103. * @brief Gets the ENET PTP 1588 timer channel status.
  1104. *
  1105. * @param base ENET peripheral base address.
  1106. * @param channel The IEEE 1588 timer channel number.
  1107. * @return True or false, Compare or capture operation status
  1108. */
  1109. static inline bool ENET_Ptp1588GetChannelStatus(ENET_Type *base, enet_ptp_timer_channel_t channel)
  1110. {
  1111. return (0 != (base->CHANNEL[channel].TCSR & ENET_TCSR_TF_MASK));
  1112. }
  1113. /*!
  1114. * @brief Clears the ENET PTP 1588 timer channel status.
  1115. *
  1116. * @param base ENET peripheral base address.
  1117. * @param channel The IEEE 1588 timer channel number.
  1118. */
  1119. static inline void ENET_Ptp1588ClearChannelStatus(ENET_Type *base, enet_ptp_timer_channel_t channel)
  1120. {
  1121. base->CHANNEL[channel].TCSR |= ENET_TCSR_TF_MASK;
  1122. base->TGSR = (1U << channel);
  1123. }
  1124. /*!
  1125. * @brief Gets the current ENET time from the PTP 1588 timer.
  1126. *
  1127. * @param base ENET peripheral base address.
  1128. * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init.
  1129. * @param ptpTime The PTP timer structure.
  1130. */
  1131. void ENET_Ptp1588GetTimer(ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime);
  1132. /*!
  1133. * @brief Sets the ENET PTP 1588 timer to the assigned time.
  1134. *
  1135. * @param base ENET peripheral base address.
  1136. * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init.
  1137. * @param ptpTime The timer to be set to the PTP timer.
  1138. */
  1139. void ENET_Ptp1588SetTimer(ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime);
  1140. /*!
  1141. * @brief The IEEE 1588 PTP time stamp interrupt handler.
  1142. *
  1143. * @param base ENET peripheral base address.
  1144. * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init.
  1145. */
  1146. void ENET_Ptp1588TimerIRQHandler(ENET_Type *base, enet_handle_t *handle);
  1147. /*!
  1148. * @brief Gets the time stamp of the received frame.
  1149. *
  1150. * This function is used for PTP stack to get the timestamp captured by the ENET driver.
  1151. *
  1152. * @param handle The ENET handler pointer.This is the same state pointer used in
  1153. * ENET_Init.
  1154. * @param ptpTimeData The special PTP timestamp data for search the receive timestamp.
  1155. * @retval kStatus_Success Get 1588 timestamp success.
  1156. * @retval kStatus_ENET_PtpTsRingEmpty 1588 timestamp ring empty.
  1157. * @retval kStatus_ENET_PtpTsRingFull 1588 timestamp ring full.
  1158. */
  1159. status_t ENET_GetRxFrameTime(enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData);
  1160. /*!
  1161. * @brief Gets the time stamp of the transmit frame.
  1162. *
  1163. * This function is used for PTP stack to get the timestamp captured by the ENET driver.
  1164. *
  1165. * @param handle The ENET handler pointer.This is the same state pointer used in
  1166. * ENET_Init.
  1167. * @param ptpTimeData The special PTP timestamp data for search the receive timestamp.
  1168. * @retval kStatus_Success Get 1588 timestamp success.
  1169. * @retval kStatus_ENET_PtpTsRingEmpty 1588 timestamp ring empty.
  1170. * @retval kStatus_ENET_PtpTsRingFull 1588 timestamp ring full.
  1171. */
  1172. status_t ENET_GetTxFrameTime(enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData);
  1173. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  1174. /* @} */
  1175. #if defined(__cplusplus)
  1176. }
  1177. #endif
  1178. /*! @}*/
  1179. #endif /* _FSL_ENET_H_ */