fsl_enet.h 75 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628
  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. #if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET
  34. #include "fsl_memory.h"
  35. #endif
  36. /*!
  37. * @addtogroup enet
  38. * @{
  39. */
  40. /*******************************************************************************
  41. * Definitions
  42. ******************************************************************************/
  43. /*! @name Driver version */
  44. /*@{*/
  45. /*! @brief Defines the driver version. */
  46. #define FSL_ENET_DRIVER_VERSION (MAKE_VERSION(2, 2, 1)) /*!< Version 2.2.1. */
  47. /*@}*/
  48. /*! @name ENET DESCRIPTOR QUEUE */
  49. /*@{*/
  50. /*! @brief Defines the queue number. */
  51. #ifndef FSL_FEATURE_ENET_QUEUE
  52. #define FSL_FEATURE_ENET_QUEUE 1 /* Singal queue for previous IP. */
  53. #endif
  54. /*@}*/
  55. /*! @name Control and status region bit masks of the receive buffer descriptor. */
  56. /*@{*/
  57. #define ENET_BUFFDESCRIPTOR_RX_EMPTY_MASK 0x8000U /*!< Empty bit mask. */
  58. #define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER1_MASK 0x4000U /*!< Software owner one mask. */
  59. #define ENET_BUFFDESCRIPTOR_RX_WRAP_MASK 0x2000U /*!< Next buffer descriptor is the start address. */
  60. #define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER2_Mask 0x1000U /*!< Software owner two mask. */
  61. #define ENET_BUFFDESCRIPTOR_RX_LAST_MASK 0x0800U /*!< Last BD of the frame mask. */
  62. #define ENET_BUFFDESCRIPTOR_RX_MISS_MASK 0x0100U /*!< Received because of the promiscuous mode. */
  63. #define ENET_BUFFDESCRIPTOR_RX_BROADCAST_MASK 0x0080U /*!< Broadcast packet mask. */
  64. #define ENET_BUFFDESCRIPTOR_RX_MULTICAST_MASK 0x0040U /*!< Multicast packet mask. */
  65. #define ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK 0x0020U /*!< Length violation mask. */
  66. #define ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK 0x0010U /*!< Non-octet aligned frame mask. */
  67. #define ENET_BUFFDESCRIPTOR_RX_CRC_MASK 0x0004U /*!< CRC error mask. */
  68. #define ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK 0x0002U /*!< FIFO overrun mask. */
  69. #define ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK 0x0001U /*!< Frame is truncated mask. */
  70. /*@}*/
  71. /*! @name Control and status bit masks of the transmit buffer descriptor. */
  72. /*@{*/
  73. #define ENET_BUFFDESCRIPTOR_TX_READY_MASK 0x8000U /*!< Ready bit mask. */
  74. #define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER1_MASK 0x4000U /*!< Software owner one mask. */
  75. #define ENET_BUFFDESCRIPTOR_TX_WRAP_MASK 0x2000U /*!< Wrap buffer descriptor mask. */
  76. #define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER2_MASK 0x1000U /*!< Software owner two mask. */
  77. #define ENET_BUFFDESCRIPTOR_TX_LAST_MASK 0x0800U /*!< Last BD of the frame mask. */
  78. #define ENET_BUFFDESCRIPTOR_TX_TRANMITCRC_MASK 0x0400U /*!< Transmit CRC mask. */
  79. /*@}*/
  80. /* Extended control regions for enhanced buffer descriptors. */
  81. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  82. /*! @name First extended control region bit masks of the receive buffer descriptor. */
  83. /*@{*/
  84. #define ENET_BUFFDESCRIPTOR_RX_IPV4_MASK 0x0001U /*!< Ipv4 frame mask. */
  85. #define ENET_BUFFDESCRIPTOR_RX_IPV6_MASK 0x0002U /*!< Ipv6 frame mask. */
  86. #define ENET_BUFFDESCRIPTOR_RX_VLAN_MASK 0x0004U /*!< VLAN frame mask. */
  87. #define ENET_BUFFDESCRIPTOR_RX_PROTOCOLCHECKSUM_MASK 0x0010U /*!< Protocol checksum error mask. */
  88. #define ENET_BUFFDESCRIPTOR_RX_IPHEADCHECKSUM_MASK 0x0020U /*!< IP header checksum error mask. */
  89. /*@}*/
  90. /*! @name Second extended control region bit masks of the receive buffer descriptor. */
  91. /*@{*/
  92. #define ENET_BUFFDESCRIPTOR_RX_INTERRUPT_MASK 0x0080U /*!< BD interrupt mask. */
  93. #define ENET_BUFFDESCRIPTOR_RX_UNICAST_MASK 0x0100U /*!< Unicast frame mask. */
  94. #define ENET_BUFFDESCRIPTOR_RX_COLLISION_MASK 0x0200U /*!< BD collision mask. */
  95. #define ENET_BUFFDESCRIPTOR_RX_PHYERR_MASK 0x0400U /*!< PHY error mask. */
  96. #define ENET_BUFFDESCRIPTOR_RX_MACERR_MASK 0x8000U /*!< Mac error mask. */
  97. /*@}*/
  98. /*! @name First extended control region bit masks of the transmit buffer descriptor. */
  99. /*@{*/
  100. #define ENET_BUFFDESCRIPTOR_TX_ERR_MASK 0x8000U /*!< Transmit error mask. */
  101. #define ENET_BUFFDESCRIPTOR_TX_UNDERFLOWERR_MASK 0x2000U /*!< Underflow error mask. */
  102. #define ENET_BUFFDESCRIPTOR_TX_EXCCOLLISIONERR_MASK 0x1000U /*!< Excess collision error mask. */
  103. #define ENET_BUFFDESCRIPTOR_TX_FRAMEERR_MASK 0x0800U /*!< Frame error mask. */
  104. #define ENET_BUFFDESCRIPTOR_TX_LATECOLLISIONERR_MASK 0x0400U /*!< Late collision error mask. */
  105. #define ENET_BUFFDESCRIPTOR_TX_OVERFLOWERR_MASK 0x0200U /*!< Overflow error mask. */
  106. #define ENET_BUFFDESCRIPTOR_TX_TIMESTAMPERR_MASK 0x0100U /*!< Timestamp error mask. */
  107. /*@}*/
  108. /*! @name Second extended control region bit masks of the transmit buffer descriptor. */
  109. /*@{*/
  110. #define ENET_BUFFDESCRIPTOR_TX_INTERRUPT_MASK 0x4000U /*!< Interrupt mask. */
  111. #define ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK 0x2000U /*!< Timestamp flag mask. */
  112. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  113. #define ENET_BUFFDESCRIPTOR_TX_USETXLAUNCHTIME_MASK 0x0100U /*!< Use the transmit launch time. */
  114. #define ENET_BUFFDESCRIPTOR_TX_FRAMETYPE_MASK 0x00F0U /*!< Frame type mask. */
  115. #define ENET_BUFFDESCRIPTOR_TX_FRAMETYPE_SHIFT 4U /*!< Frame type shift. */
  116. #define ENET_BD_FTYPE(n) ((n << ENET_BUFFDESCRIPTOR_TX_FRAMETYPE_SHIFT) & ENET_BUFFDESCRIPTOR_TX_FRAMETYPE_MASK)
  117. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  118. /*@}*/
  119. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  120. /*! @brief Defines the receive error status flag mask. */
  121. #define ENET_BUFFDESCRIPTOR_RX_ERR_MASK \
  122. (ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK | ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK | \
  123. ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK | ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK | ENET_BUFFDESCRIPTOR_RX_CRC_MASK)
  124. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  125. #define ENET_BUFFDESCRIPTOR_RX_EXT_ERR_MASK \
  126. (ENET_BUFFDESCRIPTOR_RX_MACERR_MASK | ENET_BUFFDESCRIPTOR_RX_PHYERR_MASK | ENET_BUFFDESCRIPTOR_RX_COLLISION_MASK)
  127. #endif
  128. /*! @name Defines some Ethernet parameters. */
  129. /*@{*/
  130. #define ENET_FRAME_MAX_FRAMELEN 1518U /*!< Default maximum Ethernet frame size. */
  131. #define ENET_FIFO_MIN_RX_FULL 5U /*!< ENET minimum receive FIFO full. */
  132. #define ENET_RX_MIN_BUFFERSIZE 256U /*!< ENET minimum buffer size. */
  133. #define ENET_PHY_MAXADDRESS (ENET_MMFR_PA_MASK >> ENET_MMFR_PA_SHIFT)
  134. #if FSL_FEATURE_ENET_QUEUE > 1
  135. #define ENET_TX_INTERRUPT \
  136. (kENET_TxFrameInterrupt | kENET_TxBufferInterrupt | kENET_TxFrame1Interrupt | kENET_TxBuffer1Interrupt | \
  137. kENET_TxFrame2Interrupt | kENET_TxBuffer2Interrupt)
  138. #define ENET_RX_INTERRUPT \
  139. (kENET_RxFrameInterrupt | kENET_RxBufferInterrupt | kENET_RxFrame1Interrupt | kENET_RxBuffer1Interrupt | \
  140. kENET_RxFrame2Interrupt | kENET_RxBuffer2Interrupt)
  141. #else
  142. #define ENET_TX_INTERRUPT (kENET_TxFrameInterrupt | kENET_TxBufferInterrupt)
  143. #define ENET_RX_INTERRUPT (kENET_RxFrameInterrupt | kENET_RxBufferInterrupt)
  144. #endif /* FSL_FEATURE_ENET_QUEUE > 1 */
  145. #define ENET_TS_INTERRUPT (kENET_TsTimerInterrupt | kENET_TsAvailInterrupt)
  146. #define ENET_ERR_INTERRUPT \
  147. (kENET_BabrInterrupt | kENET_BabtInterrupt | kENET_EBusERInterrupt | kENET_LateCollisionInterrupt | \
  148. kENET_RetryLimitInterrupt | kENET_UnderrunInterrupt | kENET_PayloadRxInterrupt)
  149. #define ENET_ERR_INTERRUPT \
  150. (kENET_BabrInterrupt | kENET_BabtInterrupt | kENET_EBusERInterrupt | kENET_LateCollisionInterrupt | \
  151. kENET_RetryLimitInterrupt | kENET_UnderrunInterrupt | kENET_PayloadRxInterrupt)
  152. /*@}*/
  153. /*! @brief Defines the status return codes for transaction. */
  154. enum _enet_status
  155. {
  156. kStatus_ENET_RxFrameError = MAKE_STATUS(kStatusGroup_ENET, 0U), /*!< A frame received but data error happen. */
  157. kStatus_ENET_RxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 1U), /*!< Failed to receive a frame. */
  158. kStatus_ENET_RxFrameEmpty = MAKE_STATUS(kStatusGroup_ENET, 2U), /*!< No frame arrive. */
  159. kStatus_ENET_TxFrameOverLen = MAKE_STATUS(kStatusGroup_ENET, 3U), /*!< Tx frame over length. */
  160. kStatus_ENET_TxFrameBusy = MAKE_STATUS(kStatusGroup_ENET, 4U), /*!< Tx buffer descriptors are under process. */
  161. kStatus_ENET_TxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 5U) /*!< Transmit frame fail. */
  162. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  163. ,
  164. kStatus_ENET_PtpTsRingFull = MAKE_STATUS(kStatusGroup_ENET, 6U), /*!< Timestamp ring full. */
  165. kStatus_ENET_PtpTsRingEmpty = MAKE_STATUS(kStatusGroup_ENET, 7U) /*!< Timestamp ring empty. */
  166. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  167. };
  168. /*! @brief Defines the MII/RMII/RGMII mode for data interface between the MAC and the PHY. */
  169. typedef enum _enet_mii_mode
  170. {
  171. kENET_MiiMode = 0U, /*!< MII mode for data interface. */
  172. kENET_RmiiMode = 1U, /*!< RMII mode for data interface. */
  173. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  174. kENET_RgmiiMode = 2U /*!< RGMII mode for data interface. */
  175. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  176. } enet_mii_mode_t;
  177. /*! @brief Defines the 10/100/1000 Mbps speed for the MII data interface.
  178. *
  179. * Notice: "kENET_MiiSpeed1000M" only supported when mii mode is "kENET_RgmiiMode".
  180. */
  181. typedef enum _enet_mii_speed
  182. {
  183. kENET_MiiSpeed10M = 0U, /*!< Speed 10 Mbps. */
  184. kENET_MiiSpeed100M = 1U, /*!< Speed 100 Mbps. */
  185. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  186. kENET_MiiSpeed1000M = 2U /*!< Speed 1000M bps. */
  187. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  188. } enet_mii_speed_t;
  189. /*! @brief Defines the half or full duplex for the MII data interface. */
  190. typedef enum _enet_mii_duplex
  191. {
  192. kENET_MiiHalfDuplex = 0U, /*!< Half duplex mode. */
  193. kENET_MiiFullDuplex /*!< Full duplex mode. */
  194. } enet_mii_duplex_t;
  195. /*! @brief Define the MII opcode for normal MDIO_CLAUSES_22 Frame. */
  196. typedef enum _enet_mii_write
  197. {
  198. kENET_MiiWriteNoCompliant = 0U, /*!< Write frame operation, but not MII-compliant. */
  199. kENET_MiiWriteValidFrame /*!< Write frame operation for a valid MII management frame. */
  200. } enet_mii_write_t;
  201. /*! @brief Defines the read operation for the MII management frame. */
  202. typedef enum _enet_mii_read
  203. {
  204. kENET_MiiReadValidFrame = 2U, /*!< Read frame operation for a valid MII management frame. */
  205. kENET_MiiReadNoCompliant = 3U /*!< Read frame operation, but not MII-compliant. */
  206. } enet_mii_read_t;
  207. #if defined(FSL_FEATURE_ENET_HAS_EXTEND_MDIO) && FSL_FEATURE_ENET_HAS_EXTEND_MDIO
  208. /*! @brief Define the MII opcode for extended MDIO_CLAUSES_45 Frame. */
  209. typedef enum _enet_mii_extend_opcode {
  210. kENET_MiiAddrWrite_C45 = 0U, /*!< Address Write operation. */
  211. kENET_MiiWriteFrame_C45 = 1U, /*!< Write frame operation for a valid MII management frame. */
  212. kENET_MiiReadFrame_C45 = 3U /*!< Read frame operation for a valid MII management frame. */
  213. } enet_mii_extend_opcode;
  214. #endif /* FSL_FEATURE_ENET_HAS_EXTEND_MDIO */
  215. /*! @brief Defines a special configuration for ENET MAC controller.
  216. *
  217. * These control flags are provided for special user requirements.
  218. * Normally, these control flags are unused for ENET initialization.
  219. * For special requirements, set the flags to
  220. * macSpecialConfig in the enet_config_t.
  221. * The kENET_ControlStoreAndFwdDisable is used to disable the FIFO store
  222. * and forward. FIFO store and forward means that the FIFO read/send is started
  223. * when a complete frame is stored in TX/RX FIFO. If this flag is set,
  224. * configure rxFifoFullThreshold and txFifoWatermark
  225. * in the enet_config_t.
  226. */
  227. typedef enum _enet_special_control_flag
  228. {
  229. kENET_ControlFlowControlEnable = 0x0001U, /*!< Enable ENET flow control: pause frame. */
  230. kENET_ControlRxPayloadCheckEnable = 0x0002U, /*!< Enable ENET receive payload length check. */
  231. kENET_ControlRxPadRemoveEnable = 0x0004U, /*!< Padding is removed from received frames. */
  232. kENET_ControlRxBroadCastRejectEnable = 0x0008U, /*!< Enable broadcast frame reject. */
  233. kENET_ControlMacAddrInsert = 0x0010U, /*!< Enable MAC address insert. */
  234. kENET_ControlStoreAndFwdDisable = 0x0020U, /*!< Enable FIFO store and forward. */
  235. kENET_ControlSMIPreambleDisable = 0x0040U, /*!< Enable SMI preamble. */
  236. kENET_ControlPromiscuousEnable = 0x0080U, /*!< Enable promiscuous mode. */
  237. kENET_ControlMIILoopEnable = 0x0100U, /*!< Enable ENET MII loop back. */
  238. kENET_ControlVLANTagEnable = 0x0200U, /*!< Enable normal VLAN (single vlan tag). */
  239. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  240. kENET_ControlSVLANEnable = 0x0400U, /*!< Enable S-VLAN. */
  241. kENET_ControlVLANUseSecondTag = 0x0800U /*!< Enable extracting the second vlan tag for further processing. */
  242. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  243. } enet_special_control_flag_t;
  244. /*! @brief List of interrupts supported by the peripheral. This
  245. * enumeration uses one-bot encoding to allow a logical OR of multiple
  246. * members. Members usually map to interrupt enable bits in one or more
  247. * peripheral registers.
  248. */
  249. typedef enum _enet_interrupt_enable
  250. {
  251. kENET_BabrInterrupt = ENET_EIR_BABR_MASK, /*!< Babbling receive error interrupt source */
  252. kENET_BabtInterrupt = ENET_EIR_BABT_MASK, /*!< Babbling transmit error interrupt source */
  253. kENET_GraceStopInterrupt = ENET_EIR_GRA_MASK, /*!< Graceful stop complete interrupt source */
  254. kENET_TxFrameInterrupt = ENET_EIR_TXF_MASK, /*!< TX FRAME interrupt source */
  255. kENET_TxBufferInterrupt = ENET_EIR_TXB_MASK, /*!< TX BUFFER interrupt source */
  256. kENET_RxFrameInterrupt = ENET_EIR_RXF_MASK, /*!< RX FRAME interrupt source */
  257. kENET_RxBufferInterrupt = ENET_EIR_RXB_MASK, /*!< RX BUFFER interrupt source */
  258. kENET_MiiInterrupt = ENET_EIR_MII_MASK, /*!< MII interrupt source */
  259. kENET_EBusERInterrupt = ENET_EIR_EBERR_MASK, /*!< Ethernet bus error interrupt source */
  260. kENET_LateCollisionInterrupt = ENET_EIR_LC_MASK, /*!< Late collision interrupt source */
  261. kENET_RetryLimitInterrupt = ENET_EIR_RL_MASK, /*!< Collision Retry Limit interrupt source */
  262. kENET_UnderrunInterrupt = ENET_EIR_UN_MASK, /*!< Transmit FIFO underrun interrupt source */
  263. kENET_PayloadRxInterrupt = ENET_EIR_PLR_MASK, /*!< Payload Receive error interrupt source */
  264. kENET_WakeupInterrupt = ENET_EIR_WAKEUP_MASK, /*!< WAKEUP interrupt source */
  265. #if FSL_FEATURE_ENET_QUEUE > 1
  266. kENET_RxFlush2Interrupt = ENET_EIR_RXFLUSH_2_MASK, /*!< Rx DMA ring2 flush indication. */
  267. kENET_RxFlush1Interrupt = ENET_EIR_RXFLUSH_1_MASK, /*!< Rx DMA ring1 flush indication. */
  268. kENET_RxFlush0Interrupt = ENET_EIR_RXFLUSH_0_MASK, /*!< RX DMA ring0 flush indication. */
  269. kENET_TxFrame2Interrupt = ENET_EIR_TXF2_MASK, /*!< Tx frame interrupt for Tx ring/class 2. */
  270. kENET_TxBuffer2Interrupt = ENET_EIR_TXB2_MASK, /*!< Tx buffer interrupt for Tx ring/class 2. */
  271. kENET_RxFrame2Interrupt = ENET_EIR_RXF2_MASK, /*!< Rx frame interrupt for Rx ring/class 2. */
  272. kENET_RxBuffer2Interrupt = ENET_EIR_RXB2_MASK, /*!< Rx buffer interrupt for Rx ring/class 2. */
  273. kENET_TxFrame1Interrupt = ENET_EIR_TXF1_MASK, /*!< Tx frame interrupt for Tx ring/class 1. */
  274. kENET_TxBuffer1Interrupt = ENET_EIR_TXB1_MASK, /*!< Tx buffer interrupt for Tx ring/class 1. */
  275. kENET_RxFrame1Interrupt = ENET_EIR_RXF1_MASK, /*!< Rx frame interrupt for Rx ring/class 1. */
  276. kENET_RxBuffer1Interrupt = ENET_EIR_RXB1_MASK, /*!< Rx buffer interrupt for Rx ring/class 1. */
  277. #endif /* FSL_FEATURE_ENET_QUEUE > 1 */
  278. kENET_TsAvailInterrupt = ENET_EIR_TS_AVAIL_MASK, /*!< TS AVAIL interrupt source for PTP */
  279. kENET_TsTimerInterrupt = ENET_EIR_TS_TIMER_MASK /*!< TS WRAP interrupt source for PTP */
  280. } enet_interrupt_enable_t;
  281. /*! @brief Defines the common interrupt event for callback use. */
  282. typedef enum _enet_event
  283. {
  284. kENET_RxEvent, /*!< Receive event. */
  285. kENET_TxEvent, /*!< Transmit event. */
  286. kENET_ErrEvent, /*!< Error event: BABR/BABT/EBERR/LC/RL/UN/PLR . */
  287. kENET_WakeUpEvent, /*!< Wake up from sleep mode event. */
  288. kENET_TimeStampEvent, /*!< Time stamp event. */
  289. kENET_TimeStampAvailEvent /*!< Time stamp available event.*/
  290. } enet_event_t;
  291. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  292. /*! @brief Defines certain idle slope for bandwidth fraction. */
  293. typedef enum _enet_idle_slope
  294. {
  295. kENET_IdleSlope1 = 1U, /*!< The bandwidth fraction is about 0.002. */
  296. kENET_IdleSlope2 = 2U, /*!< The bandwidth fraction is about 0.003. */
  297. kENET_IdleSlope4 = 4U, /*!< The bandwidth fraction is about 0.008. */
  298. kENET_IdleSlope8 = 8U, /*!< The bandwidth fraction is about 0.02. */
  299. kENET_IdleSlope16 = 16U, /*!< The bandwidth fraction is about 0.03. */
  300. kENET_IdleSlope32 = 32U, /*!< The bandwidth fraction is about 0.06. */
  301. kENET_IdleSlope64 = 64U, /*!< The bandwidth fraction is about 0.11. */
  302. kENET_IdleSlope128 = 128U, /*!< The bandwidth fraction is about 0.20. */
  303. kENET_IdleSlope256 = 256U, /*!< The bandwidth fraction is about 0.33. */
  304. kENET_IdleSlope384 = 384U, /*!< The bandwidth fraction is about 0.43. */
  305. kENET_IdleSlope512 = 512U, /*!< The bandwidth fraction is about 0.50. */
  306. kENET_IdleSlope640 = 640U, /*!< The bandwidth fraction is about 0.56. */
  307. kENET_IdleSlope768 = 768U, /*!< The bandwidth fraction is about 0.60. */
  308. kENET_IdleSlope896 = 896U, /*!< The bandwidth fraction is about 0.64. */
  309. kENET_IdleSlope1024 = 1024U, /*!< The bandwidth fraction is about 0.67. */
  310. kENET_IdleSlope1152 = 1152U, /*!< The bandwidth fraction is about 0.69. */
  311. kENET_IdleSlope1280 = 1280U, /*!< The bandwidth fraction is about 0.71. */
  312. kENET_IdleSlope1408 = 1408U, /*!< The bandwidth fraction is about 0.73. */
  313. kENET_IdleSlope1536 = 1536U /*!< The bandwidth fraction is about 0.75. */
  314. } enet_idle_slope_t;
  315. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  316. /*! @brief Defines the transmit accelerator configuration. */
  317. typedef enum _enet_tx_accelerator
  318. {
  319. kENET_TxAccelIsShift16Enabled = ENET_TACC_SHIFT16_MASK, /*!< Transmit FIFO shift-16. */
  320. kENET_TxAccelIpCheckEnabled = ENET_TACC_IPCHK_MASK, /*!< Insert IP header checksum. */
  321. kENET_TxAccelProtoCheckEnabled = ENET_TACC_PROCHK_MASK /*!< Insert protocol checksum. */
  322. } enet_tx_accelerator_t;
  323. /*! @brief Defines the receive accelerator configuration. */
  324. typedef enum _enet_rx_accelerator
  325. {
  326. kENET_RxAccelPadRemoveEnabled = ENET_RACC_PADREM_MASK, /*!< Padding removal for short IP frames. */
  327. kENET_RxAccelIpCheckEnabled = ENET_RACC_IPDIS_MASK, /*!< Discard with wrong IP header checksum. */
  328. kENET_RxAccelProtoCheckEnabled = ENET_RACC_PRODIS_MASK, /*!< Discard with wrong protocol checksum. */
  329. kENET_RxAccelMacCheckEnabled = ENET_RACC_LINEDIS_MASK, /*!< Discard with Mac layer errors. */
  330. kENET_RxAccelisShift16Enabled = ENET_RACC_SHIFT16_MASK /*!< Receive FIFO shift-16. */
  331. } enet_rx_accelerator_t;
  332. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  333. /*! @brief Defines the ENET PTP message related constant. */
  334. typedef enum _enet_ptp_event_type
  335. {
  336. kENET_PtpEventMsgType = 3U, /*!< PTP event message type. */
  337. kENET_PtpSrcPortIdLen = 10U, /*!< PTP message sequence id length. */
  338. kENET_PtpEventPort = 319U, /*!< PTP event port number. */
  339. kENET_PtpGnrlPort = 320U /*!< PTP general port number. */
  340. } enet_ptp_event_type_t;
  341. /*! @brief Defines the IEEE 1588 PTP timer channel numbers. */
  342. typedef enum _enet_ptp_timer_channel
  343. {
  344. kENET_PtpTimerChannel1 = 0U, /*!< IEEE 1588 PTP timer Channel 1. */
  345. kENET_PtpTimerChannel2, /*!< IEEE 1588 PTP timer Channel 2. */
  346. kENET_PtpTimerChannel3, /*!< IEEE 1588 PTP timer Channel 3. */
  347. kENET_PtpTimerChannel4 /*!< IEEE 1588 PTP timer Channel 4. */
  348. } enet_ptp_timer_channel_t;
  349. /*! @brief Defines the capture or compare mode for IEEE 1588 PTP timer channels. */
  350. typedef enum _enet_ptp_timer_channel_mode
  351. {
  352. kENET_PtpChannelDisable = 0U, /*!< Disable timer channel. */
  353. kENET_PtpChannelRisingCapture = 1U, /*!< Input capture on rising edge. */
  354. kENET_PtpChannelFallingCapture = 2U, /*!< Input capture on falling edge. */
  355. kENET_PtpChannelBothCapture = 3U, /*!< Input capture on both edges. */
  356. kENET_PtpChannelSoftCompare = 4U, /*!< Output compare software only. */
  357. kENET_PtpChannelToggleCompare = 5U, /*!< Toggle output on compare. */
  358. kENET_PtpChannelClearCompare = 6U, /*!< Clear output on compare. */
  359. kENET_PtpChannelSetCompare = 7U, /*!< Set output on compare. */
  360. kENET_PtpChannelClearCompareSetOverflow = 10U, /*!< Clear output on compare, set output on overflow. */
  361. kENET_PtpChannelSetCompareClearOverflow = 11U, /*!< Set output on compare, clear output on overflow. */
  362. kENET_PtpChannelPulseLowonCompare = 14U, /*!< Pulse output low on compare for one IEEE 1588 clock cycle. */
  363. kENET_PtpChannelPulseHighonCompare = 15U /*!< Pulse output high on compare for one IEEE 1588 clock cycle. */
  364. } enet_ptp_timer_channel_mode_t;
  365. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  366. /*! @brief Defines the receive buffer descriptor structure for the little endian system.*/
  367. typedef struct _enet_rx_bd_struct
  368. {
  369. uint16_t length; /*!< Buffer descriptor data length. */
  370. uint16_t control; /*!< Buffer descriptor control and status. */
  371. uint8_t *buffer; /*!< Data buffer pointer. */
  372. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  373. uint16_t controlExtend0; /*!< Extend buffer descriptor control0. */
  374. uint16_t controlExtend1; /*!< Extend buffer descriptor control1. */
  375. uint16_t payloadCheckSum; /*!< Internal payload checksum. */
  376. uint8_t headerLength; /*!< Header length. */
  377. uint8_t protocolTyte; /*!< Protocol type. */
  378. uint16_t reserved0;
  379. uint16_t controlExtend2; /*!< Extend buffer descriptor control2. */
  380. uint32_t timestamp; /*!< Timestamp. */
  381. uint16_t reserved1;
  382. uint16_t reserved2;
  383. uint16_t reserved3;
  384. uint16_t reserved4;
  385. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  386. } enet_rx_bd_struct_t;
  387. /*! @brief Defines the enhanced transmit buffer descriptor structure for the little endian system. */
  388. typedef struct _enet_tx_bd_struct
  389. {
  390. uint16_t length; /*!< Buffer descriptor data length. */
  391. uint16_t control; /*!< Buffer descriptor control and status. */
  392. uint8_t *buffer; /*!< Data buffer pointer. */
  393. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  394. uint16_t controlExtend0; /*!< Extend buffer descriptor control0. */
  395. uint16_t controlExtend1; /*!< Extend buffer descriptor control1. */
  396. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  397. int8_t *txLaunchTime; /*!< Transmit launch time. */
  398. #else
  399. uint16_t reserved0;
  400. uint16_t reserved1;
  401. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  402. uint16_t reserved2;
  403. uint16_t controlExtend2; /*!< Extend buffer descriptor control2. */
  404. uint32_t timestamp; /*!< Timestamp. */
  405. uint16_t reserved3;
  406. uint16_t reserved4;
  407. uint16_t reserved5;
  408. uint16_t reserved6;
  409. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  410. } enet_tx_bd_struct_t;
  411. /*! @brief Defines the ENET data error statistic structure. */
  412. typedef struct _enet_data_error_stats
  413. {
  414. uint32_t statsRxLenGreaterErr; /*!< Receive length greater than RCR[MAX_FL]. */
  415. uint32_t statsRxAlignErr; /*!< Receive non-octet alignment/ */
  416. uint32_t statsRxFcsErr; /*!< Receive CRC error. */
  417. uint32_t statsRxOverRunErr; /*!< Receive over run. */
  418. uint32_t statsRxTruncateErr; /*!< Receive truncate. */
  419. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  420. uint32_t statsRxProtocolChecksumErr; /*!< Receive protocol checksum error. */
  421. uint32_t statsRxIpHeadChecksumErr; /*!< Receive IP header checksum error. */
  422. uint32_t statsRxMacErr; /*!< Receive Mac error. */
  423. uint32_t statsRxPhyErr; /*!< Receive PHY error. */
  424. uint32_t statsRxCollisionErr; /*!< Receive collision. */
  425. uint32_t statsTxErr; /*!< The error happen when transmit the frame. */
  426. uint32_t statsTxFrameErr; /*!< The transmit frame is error. */
  427. uint32_t statsTxOverFlowErr; /*!< Transmit overflow. */
  428. uint32_t statsTxLateCollisionErr; /*!< Transmit late collision. */
  429. uint32_t statsTxExcessCollisionErr; /*!< Transmit excess collision.*/
  430. uint32_t statsTxUnderFlowErr; /*!< Transmit under flow error. */
  431. uint32_t statsTxTsErr; /*!< Transmit time stamp error. */
  432. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  433. } enet_data_error_stats_t;
  434. /*! @brief Defines the receive buffer descriptor configuration structure.
  435. *
  436. * Note that for the internal DMA requirements, the buffers have a corresponding alignment requirements.
  437. * 1. The aligned receive and transmit buffer size must be evenly divisible by ENET_BUFF_ALIGNMENT.
  438. * when the data buffers are in cacheable region when cache is enabled, all those size should be
  439. * aligned to the maximum value of "ENET_BUFF_ALIGNMENT" and the cache line size.
  440. * 2. The aligned transmit and receive buffer descriptor start address must be at
  441. * least 64 bit aligned. However, it's recommended to be evenly divisible by ENET_BUFF_ALIGNMENT.
  442. * buffer descriptors should be put in non-cacheable region when cache is enabled.
  443. * 3. The aligned transmit and receive data buffer start address must be evenly divisible by ENET_BUFF_ALIGNMENT.
  444. * Receive buffers should be continuous with the total size equal to "rxBdNumber * rxBuffSizeAlign".
  445. * Transmit buffers should be continuous with the total size equal to "txBdNumber * txBuffSizeAlign".
  446. * when the data buffers are in cacheable region when cache is enabled, all those size should be
  447. * aligned to the maximum value of "ENET_BUFF_ALIGNMENT" and the cache line size.
  448. */
  449. typedef struct _enet_buffer_config
  450. {
  451. uint16_t rxBdNumber; /*!< Receive buffer descriptor number. */
  452. uint16_t txBdNumber; /*!< Transmit buffer descriptor number. */
  453. uint32_t rxBuffSizeAlign; /*!< Aligned receive data buffer size. */
  454. uint32_t txBuffSizeAlign; /*!< Aligned transmit data buffer size. */
  455. volatile enet_rx_bd_struct_t *rxBdStartAddrAlign; /*!< Aligned receive buffer descriptor start address: should be non-cacheable. */
  456. volatile enet_tx_bd_struct_t *txBdStartAddrAlign; /*!< Aligned transmit buffer descriptor start address: should be non-cacheable. */
  457. uint8_t *rxBufferAlign; /*!< Receive data buffer start address. */
  458. uint8_t *txBufferAlign; /*!< Transmit data buffer start address. */
  459. } enet_buffer_config_t;
  460. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  461. /*! @brief Defines the ENET PTP time stamp structure. */
  462. typedef struct _enet_ptp_time
  463. {
  464. uint64_t second; /*!< Second. */
  465. uint32_t nanosecond; /*!< Nanosecond. */
  466. } enet_ptp_time_t;
  467. /*! @brief Defines the structure for the ENET PTP message data and timestamp data.*/
  468. typedef struct _enet_ptp_time_data
  469. {
  470. uint8_t version; /*!< PTP version. */
  471. uint8_t sourcePortId[kENET_PtpSrcPortIdLen]; /*!< PTP source port ID. */
  472. uint16_t sequenceId; /*!< PTP sequence ID. */
  473. uint8_t messageType; /*!< PTP message type. */
  474. enet_ptp_time_t timeStamp; /*!< PTP timestamp. */
  475. } enet_ptp_time_data_t;
  476. /*! @brief Defines the ENET PTP ring buffer structure for the PTP message timestamp store.*/
  477. typedef struct _enet_ptp_time_data_ring
  478. {
  479. uint32_t front; /*!< The first index of the ring. */
  480. uint32_t end; /*!< The end index of the ring. */
  481. uint32_t size; /*!< The size of the ring. */
  482. enet_ptp_time_data_t *ptpTsData; /*!< PTP message data structure. */
  483. } enet_ptp_time_data_ring_t;
  484. /*! @brief Defines the ENET PTP configuration structure. */
  485. typedef struct _enet_ptp_config
  486. {
  487. uint8_t ptpTsRxBuffNum; /*!< Receive 1588 timestamp buffer number*/
  488. uint8_t ptpTsTxBuffNum; /*!< Transmit 1588 timestamp buffer number*/
  489. enet_ptp_time_data_t *rxPtpTsData; /*!< The start address of 1588 receive timestamp buffers */
  490. enet_ptp_time_data_t *txPtpTsData; /*!< The start address of 1588 transmit timestamp buffers */
  491. enet_ptp_timer_channel_t channel; /*!< Used for ERRATA_2579: the PTP 1588 timer channel for time interrupt. */
  492. uint32_t ptp1588ClockSrc_Hz; /*!< The clock source of the PTP 1588 timer. */
  493. } enet_ptp_config_t;
  494. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  495. #if defined(FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE) && FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE
  496. /*! @brief Defines the interrupt coalescing configure structure. */
  497. typedef struct _enet_intcoalesce_config
  498. {
  499. uint8_t txCoalesceFrameCount[FSL_FEATURE_ENET_QUEUE]; /*!< Transmit interrupt coalescing frame count threshold. */
  500. uint16_t txCoalesceTimeCount[FSL_FEATURE_ENET_QUEUE]; /*!< Transmit interrupt coalescing timer count threshold. */
  501. uint8_t rxCoalesceFrameCount[FSL_FEATURE_ENET_QUEUE]; /*!< Receive interrupt coalescing frame count threshold. */
  502. uint16_t rxCoalesceTimeCount[FSL_FEATURE_ENET_QUEUE]; /*!< Receive interrupt coalescing timer count threshold. */
  503. } enet_intcoalesce_config_t;
  504. #endif /* FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE */
  505. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  506. /*! @brief Defines the ENET AVB Configure structure.
  507. *
  508. * This is used for to configure the extended ring 1 and ring 2.
  509. * 1. The classification match format is (CMP3 << 12) | (CMP2 << 8) | (CMP1 << 4) | CMP0.
  510. * composed of four 3-bit compared VLAN priority field cmp0~cmp3, cm0 ~ cmp3 are used in parallel.
  511. *
  512. * If CMP1,2,3 are not unused, please set them to the same value as CMP0.
  513. * 2. The idleSlope is used to calculate the Band Width fraction, BW fraction = 1 / (1 + 512/idleSlope).
  514. * For avb configuration, the BW fraction of Class 1 and Class 2 combined must not exceed 0.75.
  515. */
  516. typedef struct _enet_avb_config
  517. {
  518. uint16_t rxClassifyMatch[FSL_FEATURE_ENET_QUEUE - 1]; /*!< The classification match value for the ring. */
  519. enet_idle_slope_t idleSlope[FSL_FEATURE_ENET_QUEUE - 1]; /*!< The idle slope for certian bandwidth fraction. */
  520. } enet_avb_config_t;
  521. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  522. /*! @brief Defines the basic configuration structure for the ENET device.
  523. *
  524. * Note:
  525. * 1. macSpecialConfig is used for a special control configuration, A logical OR of
  526. * "enet_special_control_flag_t". For a special configuration for MAC,
  527. * set this parameter to 0.
  528. * 2. txWatermark is used for a cut-through operation. It is in steps of 64 bytes:
  529. * 0/1 - 64 bytes written to TX FIFO before transmission of a frame begins.
  530. * 2 - 128 bytes written to TX FIFO ....
  531. * 3 - 192 bytes written to TX FIFO ....
  532. * The maximum of txWatermark is 0x2F - 4032 bytes written to TX FIFO ....
  533. * txWatermark allows minimizing the transmit latency to set the txWatermark to 0 or 1
  534. * or for larger bus access latency 3 or larger due to contention for the system bus.
  535. * 3. rxFifoFullThreshold is similar to the txWatermark for cut-through operation in RX.
  536. * It is in 64-bit words. The minimum is ENET_FIFO_MIN_RX_FULL and the maximum is 0xFF.
  537. * If the end of the frame is stored in FIFO and the frame size if smaller than the
  538. * txWatermark, the frame is still transmitted. The rule is the
  539. * same for rxFifoFullThreshold in the receive direction.
  540. * 4. When "kENET_ControlFlowControlEnable" is set in the macSpecialConfig, ensure
  541. * that the pauseDuration, rxFifoEmptyThreshold, and rxFifoStatEmptyThreshold
  542. * are set for flow control enabled case.
  543. * 5. When "kENET_ControlStoreAndFwdDisabled" is set in the macSpecialConfig, ensure
  544. * that the rxFifoFullThreshold and txFifoWatermark are set for store and forward disable.
  545. * 6. The rxAccelerConfig and txAccelerConfig default setting with 0 - accelerator
  546. * are disabled. The "enet_tx_accelerator_t" and "enet_rx_accelerator_t" are
  547. * recommended to be used to enable the transmit and receive accelerator.
  548. * After the accelerators are enabled, the store and forward feature should be enabled.
  549. * As a result, kENET_ControlStoreAndFwdDisabled should not be set.
  550. * 7. The intCoalesceCfg can be used in the rx or tx enabled cases to decrese the CPU loading.
  551. */
  552. typedef struct _enet_config
  553. {
  554. uint32_t macSpecialConfig; /*!< Mac special configuration. A logical OR of "enet_special_control_flag_t". */
  555. uint32_t interrupt; /*!< Mac interrupt source. A logical OR of "enet_interrupt_enable_t". */
  556. uint16_t rxMaxFrameLen; /*!< Receive maximum frame length. */
  557. enet_mii_mode_t miiMode; /*!< MII mode. */
  558. enet_mii_speed_t miiSpeed; /*!< MII Speed. */
  559. enet_mii_duplex_t miiDuplex; /*!< MII duplex. */
  560. uint8_t rxAccelerConfig; /*!< Receive accelerator, A logical OR of "enet_rx_accelerator_t". */
  561. uint8_t txAccelerConfig; /*!< Transmit accelerator, A logical OR of "enet_rx_accelerator_t". */
  562. uint16_t pauseDuration; /*!< For flow control enabled case: Pause duration. */
  563. uint8_t rxFifoEmptyThreshold; /*!< For flow control enabled case: when RX FIFO level reaches this value,
  564. it makes MAC generate XOFF pause frame. */
  565. #if defined(FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD) && FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD
  566. uint8_t rxFifoStatEmptyThreshold; /*!< For flow control enabled case: number of frames in the receive FIFO,
  567. independent of size, that can be accept. If the limit is reached, reception
  568. continues and a pause frame is triggered. */
  569. #endif /* FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD */
  570. uint8_t rxFifoFullThreshold; /*!< For store and forward disable case, the data required in RX FIFO to notify
  571. the MAC receive ready status. */
  572. uint8_t txFifoWatermark; /*!< For store and forward disable case, the data required in TX FIFO
  573. before a frame transmit start. */
  574. #if defined(FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE) && FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE
  575. enet_intcoalesce_config_t
  576. *intCoalesceCfg; /* If the interrupt coalsecence is not required in the ring n(0,1,2), please set
  577. to NULL. */
  578. #endif /* FSL_FEATURE_ENET_HAS_INTERRUPT_COALESCE */
  579. uint8_t ringNum; /*!< Number of used rings. default with 1 -- single ring. */
  580. } enet_config_t;
  581. /* Forward declaration of the handle typedef. */
  582. typedef struct _enet_handle enet_handle_t;
  583. /*! @brief ENET callback function. */
  584. #if FSL_FEATURE_ENET_QUEUE > 1
  585. typedef void (*enet_callback_t)(
  586. ENET_Type *base, enet_handle_t *handle, uint32_t ringId, enet_event_t event, void *userData);
  587. #else
  588. typedef void (*enet_callback_t)(ENET_Type *base, enet_handle_t *handle, enet_event_t event, void *userData);
  589. #endif /* FSL_FEATURE_ENET_QUEUE > 1 */
  590. /*! @brief Defines the ENET handler structure. */
  591. struct _enet_handle
  592. {
  593. volatile enet_rx_bd_struct_t
  594. *rxBdBase[FSL_FEATURE_ENET_QUEUE]; /*!< Receive buffer descriptor base address pointer. */
  595. volatile enet_rx_bd_struct_t
  596. *rxBdCurrent[FSL_FEATURE_ENET_QUEUE]; /*!< The current available receive buffer descriptor pointer. */
  597. volatile enet_tx_bd_struct_t
  598. *txBdBase[FSL_FEATURE_ENET_QUEUE]; /*!< Transmit buffer descriptor base address pointer. */
  599. volatile enet_tx_bd_struct_t
  600. *txBdCurrent[FSL_FEATURE_ENET_QUEUE]; /*!< The current available transmit buffer descriptor pointer. */
  601. uint32_t rxBuffSizeAlign[FSL_FEATURE_ENET_QUEUE]; /*!< Receive buffer size alignment. */
  602. uint32_t txBuffSizeAlign[FSL_FEATURE_ENET_QUEUE]; /*!< Transmit buffer size alignment. */
  603. uint8_t ringNum; /*!< Number of used rings. */
  604. enet_callback_t callback; /*!< Callback function. */
  605. void *userData; /*!< Callback function parameter.*/
  606. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  607. volatile enet_tx_bd_struct_t
  608. *txBdDirtyStatic[FSL_FEATURE_ENET_QUEUE]; /*!< The dirty transmit buffer descriptor for error static update. */
  609. volatile enet_tx_bd_struct_t
  610. *txBdDirtyTime[FSL_FEATURE_ENET_QUEUE]; /*!< The dirty transmit buffer descriptor for time stamp update. */
  611. uint64_t msTimerSecond; /*!< The second for Master PTP timer .*/
  612. enet_ptp_time_data_ring_t rxPtpTsDataRing; /*!< Receive PTP 1588 time stamp data ring buffer. */
  613. enet_ptp_time_data_ring_t txPtpTsDataRing; /*!< Transmit PTP 1588 time stamp data ring buffer. */
  614. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  615. };
  616. /*******************************************************************************
  617. * API
  618. ******************************************************************************/
  619. #if defined(__cplusplus)
  620. extern "C" {
  621. #endif
  622. /*!
  623. * @name Initialization and De-initialization
  624. * @{
  625. */
  626. /*!
  627. * @brief Gets the ENET default configuration structure.
  628. *
  629. * The purpose of this API is to get the default ENET MAC controller
  630. * configure structure for ENET_Init(). User may use the initialized
  631. * structure unchanged in ENET_Init(), or modify some fields of the
  632. * structure before calling ENET_Init().
  633. * Example:
  634. @code
  635. enet_config_t config;
  636. ENET_GetDefaultConfig(&config);
  637. @endcode
  638. * @param config The ENET mac controller configuration structure pointer.
  639. */
  640. void ENET_GetDefaultConfig(enet_config_t *config);
  641. /*!
  642. * @brief Initializes the ENET module.
  643. *
  644. * This function ungates the module clock and initializes it with the ENET configuration.
  645. *
  646. * @param base ENET peripheral base address.
  647. * @param handle ENET handler pointer.
  648. * @param config ENET mac configuration structure pointer.
  649. * The "enet_config_t" type mac configuration return from ENET_GetDefaultConfig
  650. * can be used directly. It is also possible to verify the Mac configuration using other methods.
  651. * @param bufferConfig ENET buffer configuration structure pointer.
  652. * The buffer configuration should be prepared for ENET Initialization.
  653. * It is the start address of "ringNum" enet_buffer_config structures.
  654. * To support added multi-ring features in some soc and compatible with the previous
  655. * enet driver version. For single ring supported, this bufferConfig is a buffer
  656. * configure structure pointer, for multi-ring supported and used case, this bufferConfig
  657. * pointer should be a buffer configure structure array pointer.
  658. * @param macAddr ENET mac address of Ethernet device. This MAC address should be
  659. * provided.
  660. * @param srcClock_Hz The internal module clock source for MII clock.
  661. *
  662. * @note ENET has two buffer descriptors legacy buffer descriptors and
  663. * enhanced IEEE 1588 buffer descriptors. The legacy descriptor is used by default. To
  664. * use the IEEE 1588 feature, use the enhanced IEEE 1588 buffer descriptor
  665. * by defining "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" and calling ENET_Ptp1588Configure()
  666. * to configure the 1588 feature and related buffers after calling ENET_Init().
  667. */
  668. void ENET_Init(ENET_Type *base,
  669. enet_handle_t *handle,
  670. const enet_config_t *config,
  671. const enet_buffer_config_t *bufferConfig,
  672. uint8_t *macAddr,
  673. uint32_t srcClock_Hz);
  674. /*!
  675. * @brief Deinitializes the ENET module.
  676. * This function gates the module clock, clears ENET interrupts, and disables the ENET module.
  677. *
  678. * @param base ENET peripheral base address.
  679. */
  680. void ENET_Deinit(ENET_Type *base);
  681. /*!
  682. * @brief Resets the ENET module.
  683. *
  684. * This function restores the ENET module to reset state.
  685. * Note that this function sets all registers to
  686. * reset state. As a result, the ENET module can't work after calling this function.
  687. *
  688. * @param base ENET peripheral base address.
  689. */
  690. static inline void ENET_Reset(ENET_Type *base)
  691. {
  692. base->ECR |= ENET_ECR_RESET_MASK;
  693. }
  694. /* @} */
  695. /*!
  696. * @name MII interface operation
  697. * @{
  698. */
  699. /*!
  700. * @brief Sets the ENET MII speed and duplex.
  701. *
  702. * This API is provided to dynamically change the speed and dulpex for MAC.
  703. *
  704. * @param base ENET peripheral base address.
  705. * @param speed The speed of the RMII mode.
  706. * @param duplex The duplex of the RMII mode.
  707. */
  708. void ENET_SetMII(ENET_Type *base, enet_mii_speed_t speed, enet_mii_duplex_t duplex);
  709. /*!
  710. * @brief Sets the ENET SMI(serial management interface)- MII management interface.
  711. *
  712. * @param base ENET peripheral base address.
  713. * @param srcClock_Hz This is the ENET module clock frequency. Normally it's the system clock. See clock distribution.
  714. * @param isPreambleDisabled The preamble disable flag.
  715. * - true Enables the preamble.
  716. * - false Disables the preamble.
  717. */
  718. void ENET_SetSMI(ENET_Type *base, uint32_t srcClock_Hz, bool isPreambleDisabled);
  719. /*!
  720. * @brief Gets the ENET SMI- MII management interface configuration.
  721. *
  722. * This API is used to get the SMI configuration to check whether the MII management
  723. * interface has been set.
  724. *
  725. * @param base ENET peripheral base address.
  726. * @return The SMI setup status true or false.
  727. */
  728. static inline bool ENET_GetSMI(ENET_Type *base)
  729. {
  730. return (0 != (base->MSCR & 0x7E));
  731. }
  732. /*!
  733. * @brief Reads data from the PHY register through an SMI interface.
  734. *
  735. * @param base ENET peripheral base address.
  736. * @return The data read from PHY
  737. */
  738. static inline uint32_t ENET_ReadSMIData(ENET_Type *base)
  739. {
  740. return (uint32_t)((base->MMFR & ENET_MMFR_DATA_MASK) >> ENET_MMFR_DATA_SHIFT);
  741. }
  742. /*!
  743. * @brief Starts an SMI (Serial Management Interface) read command.
  744. *
  745. * Used for standard IEEE802.3 MDIO Clause 22 format.
  746. *
  747. * @param base ENET peripheral base address.
  748. * @param phyAddr The PHY address.
  749. * @param phyReg The PHY register. Range from 0 ~ 31.
  750. * @param operation The read operation.
  751. */
  752. void ENET_StartSMIRead(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_read_t operation);
  753. /*!
  754. * @brief Starts an SMI write command.
  755. *
  756. * Used for standard IEEE802.3 MDIO Clause 22 format.
  757. *
  758. * @param base ENET peripheral base address.
  759. * @param phyAddr The PHY address.
  760. * @param phyReg The PHY register. Range from 0 ~ 31.
  761. * @param operation The write operation.
  762. * @param data The data written to PHY.
  763. */
  764. void ENET_StartSMIWrite(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_write_t operation, uint32_t data);
  765. #if defined(FSL_FEATURE_ENET_HAS_EXTEND_MDIO) && FSL_FEATURE_ENET_HAS_EXTEND_MDIO
  766. /*!
  767. * @brief Starts the extended IEEE802.3 Clause 45 MDIO format SMI read command.
  768. *
  769. * @param base ENET peripheral base address.
  770. * @param phyAddr The PHY address.
  771. * @param phyReg The PHY register. For MDIO IEEE802.3 Clause 45,
  772. * the phyReg is a 21-bits combination of the devaddr (5 bits device address)
  773. * and the regAddr (16 bits phy register): phyReg = (devaddr << 16) | regAddr.
  774. */
  775. void ENET_StartExtC45SMIRead(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg);
  776. /*!
  777. * @brief Starts the extended IEEE802.3 Clause 45 MDIO format SMI write command.
  778. *
  779. * @param base ENET peripheral base address.
  780. * @param phyAddr The PHY address.
  781. * @param phyReg The PHY register. For MDIO IEEE802.3 Clause 45,
  782. * the phyReg is a 21-bits combination of the devaddr (5 bits device address)
  783. * and the regAddr (16 bits phy register): phyReg = (devaddr << 16) | regAddr.
  784. * @param data The data written to PHY.
  785. */
  786. void ENET_StartExtC45SMIWrite(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, uint32_t data);
  787. #endif /* FSL_FEATURE_ENET_HAS_EXTEND_MDIO */
  788. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  789. /*!
  790. * @brief Control the usage of the delayed tx/rx RGMII clock.
  791. *
  792. * @param base ENET peripheral base address.
  793. * @param txEnabled Enable or disable to generate the delayed version of RGMII_TXC.
  794. * @param rxEnabled Enable or disable to use the delayed version of RGMII_RXC.
  795. */
  796. static inline void ENET_SetRGMIIClockDelay(ENET_Type *base, bool txEnabled, bool rxEnabled)
  797. {
  798. uint32_t ecrReg = base->ECR;
  799. /* Set for transmit clock delay. */
  800. if (txEnabled)
  801. {
  802. ecrReg |= ENET_ECR_TXC_DLY_MASK;
  803. }
  804. else
  805. {
  806. ecrReg &= ~ENET_ECR_TXC_DLY_MASK;
  807. }
  808. /* Set for receive clock delay. */
  809. if (rxEnabled)
  810. {
  811. ecrReg |= ENET_ECR_RXC_DLY_MASK;
  812. }
  813. else
  814. {
  815. ecrReg &= ~ENET_ECR_RXC_DLY_MASK;
  816. }
  817. }
  818. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  819. /* @} */
  820. /*!
  821. * @name MAC Address Filter
  822. * @{
  823. */
  824. /*!
  825. * @brief Sets the ENET module Mac address.
  826. *
  827. * @param base ENET peripheral base address.
  828. * @param macAddr The six-byte Mac address pointer.
  829. * The pointer is allocated by application and input into the API.
  830. */
  831. void ENET_SetMacAddr(ENET_Type *base, uint8_t *macAddr);
  832. /*!
  833. * @brief Gets the ENET module Mac address.
  834. *
  835. * @param base ENET peripheral base address.
  836. * @param macAddr The six-byte Mac address pointer.
  837. * The pointer is allocated by application and input into the API.
  838. */
  839. void ENET_GetMacAddr(ENET_Type *base, uint8_t *macAddr);
  840. /*!
  841. * @brief Adds the ENET device to a multicast group.
  842. *
  843. * @param base ENET peripheral base address.
  844. * @param address The six-byte multicast group address which is provided by application.
  845. */
  846. void ENET_AddMulticastGroup(ENET_Type *base, uint8_t *address);
  847. /*!
  848. * @brief Moves the ENET device from a multicast group.
  849. *
  850. * @param base ENET peripheral base address.
  851. * @param address The six-byte multicast group address which is provided by application.
  852. */
  853. void ENET_LeaveMulticastGroup(ENET_Type *base, uint8_t *address);
  854. /* @} */
  855. /*!
  856. * @name Other basic operation
  857. * @{
  858. */
  859. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  860. #if defined(FSL_FEATURE_ENET_HAS_AVB) && FSL_FEATURE_ENET_HAS_AVB
  861. /*!
  862. * @brief Sets the ENET AVB feature.
  863. *
  864. * ENET AVB feature configuration, set the Receive classification match and transmit
  865. * bandwidth. This API is called when the AVB feature is required.
  866. *
  867. * Note: The AVB frames transmission scheme is credit-based tx scheme and it's only supported
  868. * with the Enhanced buffer descriptors. so the AVB configuration should only done with
  869. * Enhanced buffer descriptor. so when the AVB feature is required, please make sure the
  870. * the "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" is defined.
  871. *
  872. * @param base ENET peripheral base address.
  873. * @param handle ENET handler pointer.
  874. * @param config The ENET AVB feature configuration structure.
  875. */
  876. void ENET_AVBConfigure(ENET_Type *base, enet_handle_t *handle, const enet_avb_config_t *config);
  877. #endif /* FSL_FEATURE_ENET_HAS_AVB */
  878. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  879. /*!
  880. * @brief Activates ENET read or receive.
  881. *
  882. * This function is to active the enet read process. It is
  883. * used for single descriptor ring/queue.
  884. *
  885. * @param base ENET peripheral base address.
  886. *
  887. * @note This must be called after the MAC configuration and
  888. * state are ready. It must be called after the ENET_Init() and
  889. * ENET_Ptp1588Configure(). This should be called when the ENET receive required.
  890. */
  891. static inline void ENET_ActiveRead(ENET_Type *base)
  892. {
  893. base->RDAR = ENET_RDAR_RDAR_MASK;
  894. }
  895. #if FSL_FEATURE_ENET_QUEUE > 1
  896. /*!
  897. * @brief Activates ENET read or receive for multiple-queue/ring.
  898. *
  899. * This function is to active the enet read process. It is
  900. * used for extended multiple descriptor rings/queues.
  901. *
  902. * @param base ENET peripheral base address.
  903. *
  904. * @note This must be called after the MAC configuration and
  905. * state are ready. It must be called after the ENET_Init() and
  906. * ENET_Ptp1588Configure(). This should be called when the ENET receive required.
  907. */
  908. static inline void ENET_ActiveReadMultiRing(ENET_Type *base)
  909. {
  910. base->RDAR = ENET_RDAR_RDAR_MASK;
  911. base->RDAR1 = ENET_RDAR1_RDAR_MASK;
  912. base->RDAR2 = ENET_RDAR2_RDAR_MASK;
  913. }
  914. #endif /* FSL_FEATURE_ENET_QUEUE > 1 */
  915. /*!
  916. * @brief Enables/disables the MAC to enter sleep mode.
  917. * This function is used to set the MAC enter sleep mode.
  918. * When entering sleep mode, the magic frame wakeup interrupt should be enabled
  919. * to wake up MAC from the sleep mode and reset it to normal mode.
  920. *
  921. * @param base ENET peripheral base address.
  922. * @param enable True enable sleep mode, false disable sleep mode.
  923. */
  924. static inline void ENET_EnableSleepMode(ENET_Type *base, bool enable)
  925. {
  926. if (enable)
  927. {
  928. /* When this field is set, MAC enters sleep mode. */
  929. base->ECR |= ENET_ECR_SLEEP_MASK | ENET_ECR_MAGICEN_MASK;
  930. }
  931. else
  932. { /* MAC exits sleep mode. */
  933. base->ECR &= ~(ENET_ECR_SLEEP_MASK | ENET_ECR_MAGICEN_MASK);
  934. }
  935. }
  936. /*!
  937. * @brief Gets ENET transmit and receive accelerator functions from MAC controller.
  938. *
  939. * @param base ENET peripheral base address.
  940. * @param txAccelOption The transmit accelerator option. The "enet_tx_accelerator_t" is
  941. * recommended to be used to as the mask to get the exact the accelerator option.
  942. * @param rxAccelOption The receive accelerator option. The "enet_rx_accelerator_t" is
  943. * recommended to be used to as the mask to get the exact the accelerator option.
  944. */
  945. static inline void ENET_GetAccelFunction(ENET_Type *base, uint32_t *txAccelOption, uint32_t *rxAccelOption)
  946. {
  947. assert(txAccelOption);
  948. assert(txAccelOption);
  949. *txAccelOption = base->TACC;
  950. *rxAccelOption = base->RACC;
  951. }
  952. /* @} */
  953. /*!
  954. * @name Interrupts.
  955. * @{
  956. */
  957. /*!
  958. * @brief Enables the ENET interrupt.
  959. *
  960. * This function enables the ENET interrupt according to the provided mask. The mask
  961. * is a logical OR of enumeration members. See @ref enet_interrupt_enable_t.
  962. * For example, to enable the TX frame interrupt and RX frame interrupt, do the following.
  963. * @code
  964. * ENET_EnableInterrupts(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt);
  965. * @endcode
  966. *
  967. * @param base ENET peripheral base address.
  968. * @param mask ENET interrupts to enable. This is a logical OR of the
  969. * enumeration :: enet_interrupt_enable_t.
  970. */
  971. static inline void ENET_EnableInterrupts(ENET_Type *base, uint32_t mask)
  972. {
  973. base->EIMR |= mask;
  974. }
  975. /*!
  976. * @brief Disables the ENET interrupt.
  977. *
  978. * This function disables the ENET interrupts according to the provided mask. The mask
  979. * is a logical OR of enumeration members. See @ref enet_interrupt_enable_t.
  980. * For example, to disable the TX frame interrupt and RX frame interrupt, do the following.
  981. * @code
  982. * ENET_DisableInterrupts(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt);
  983. * @endcode
  984. *
  985. * @param base ENET peripheral base address.
  986. * @param mask ENET interrupts to disable. This is a logical OR of the
  987. * enumeration :: enet_interrupt_enable_t.
  988. */
  989. static inline void ENET_DisableInterrupts(ENET_Type *base, uint32_t mask)
  990. {
  991. base->EIMR &= ~mask;
  992. }
  993. /*!
  994. * @brief Gets the ENET interrupt status flag.
  995. *
  996. * @param base ENET peripheral base address.
  997. * @return The event status of the interrupt source. This is the logical OR of members
  998. * of the enumeration :: enet_interrupt_enable_t.
  999. */
  1000. static inline uint32_t ENET_GetInterruptStatus(ENET_Type *base)
  1001. {
  1002. return base->EIR;
  1003. }
  1004. /*!
  1005. * @brief Clears the ENET interrupt events status flag.
  1006. *
  1007. * This function clears enabled ENET interrupts according to the provided mask. The mask
  1008. * is a logical OR of enumeration members. See the @ref enet_interrupt_enable_t.
  1009. * For example, to clear the TX frame interrupt and RX frame interrupt, do the following.
  1010. * @code
  1011. * ENET_ClearInterruptStatus(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt);
  1012. * @endcode
  1013. *
  1014. * @param base ENET peripheral base address.
  1015. * @param mask ENET interrupt source to be cleared.
  1016. * This is the logical OR of members of the enumeration :: enet_interrupt_enable_t.
  1017. */
  1018. static inline void ENET_ClearInterruptStatus(ENET_Type *base, uint32_t mask)
  1019. {
  1020. base->EIR = mask;
  1021. }
  1022. /* @} */
  1023. /*!
  1024. * @name Transactional operation
  1025. * @{
  1026. */
  1027. /*!
  1028. * @brief Sets the callback function.
  1029. * This API is provided for the application callback required case when ENET
  1030. * interrupt is enabled. This API should be called after calling ENET_Init.
  1031. *
  1032. * @param handle ENET handler pointer. Should be provided by application.
  1033. * @param callback The ENET callback function.
  1034. * @param userData The callback function parameter.
  1035. */
  1036. void ENET_SetCallback(enet_handle_t *handle, enet_callback_t callback, void *userData);
  1037. /*!
  1038. * @brief Gets the error statistics of a received frame for ENET single ring.
  1039. *
  1040. * This API must be called after the ENET_GetRxFrameSize and before the ENET_ReadFrame().
  1041. * If the ENET_GetRxFrameSize returns kStatus_ENET_RxFrameError,
  1042. * the ENET_GetRxErrBeforeReadFrame can be used to get the exact error statistics.
  1043. * This is an example.
  1044. * @code
  1045. * status = ENET_GetRxFrameSize(&g_handle, &length);
  1046. * if (status == kStatus_ENET_RxFrameError)
  1047. * {
  1048. * // Get the error information of the received frame.
  1049. * ENET_GetRxErrBeforeReadFrame(&g_handle, &eErrStatic);
  1050. * // update the receive buffer.
  1051. * ENET_ReadFrame(EXAMPLE_ENET, &g_handle, NULL, 0);
  1052. * }
  1053. * @endcode
  1054. * @param handle The ENET handler structure pointer. This is the same handler pointer used in the ENET_Init.
  1055. * @param eErrorStatic The error statistics structure pointer.
  1056. */
  1057. void ENET_GetRxErrBeforeReadFrame(enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic);
  1058. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  1059. /*!
  1060. * @brief Gets the ENET transmit frame statistics after the data send for single ring.
  1061. *
  1062. * This interface gets the error statistics of the transmit frame.
  1063. * Because the error information is reported by the uDMA after the data delivery, this interface
  1064. * should be called after the data transmit API. It is recommended to call this function on
  1065. * transmit interrupt handler. After calling the ENET_SendFrame, the
  1066. * transmit interrupt notifies the transmit completion.
  1067. *
  1068. * @param handle The PTP handler pointer. This is the same handler pointer used in the ENET_Init.
  1069. * @param eErrorStatic The error statistics structure pointer.
  1070. * @return The execute status.
  1071. */
  1072. status_t ENET_GetTxErrAfterSendFrame(enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic);
  1073. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  1074. /*!
  1075. * @brief Gets the size of the read frame for single ring.
  1076. *
  1077. * This function gets a received frame size from the ENET buffer descriptors.
  1078. * @note The FCS of the frame is automatically removed by MAC and the size is the length without the FCS.
  1079. * After calling ENET_GetRxFrameSize, ENET_ReadFrame() should be called to update the
  1080. * receive buffers If the result is not "kStatus_ENET_RxFrameEmpty".
  1081. *
  1082. * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init.
  1083. * @param length The length of the valid frame received.
  1084. * @retval kStatus_ENET_RxFrameEmpty No frame received. Should not call ENET_ReadFrame to read frame.
  1085. * @retval kStatus_ENET_RxFrameError Data error happens. ENET_ReadFrame should be called with NULL data
  1086. * and NULL length to update the receive buffers.
  1087. * @retval kStatus_Success Receive a frame Successfully then the ENET_ReadFrame
  1088. * should be called with the right data buffer and the captured data length input.
  1089. */
  1090. status_t ENET_GetRxFrameSize(enet_handle_t *handle, uint32_t *length);
  1091. /*!
  1092. * @brief Reads a frame from the ENET device for single ring.
  1093. * This function reads a frame (both the data and the length) from the ENET buffer descriptors.
  1094. * The ENET_GetRxFrameSize should be used to get the size of the prepared data buffer.
  1095. * This is an example:
  1096. * @code
  1097. * uint32_t length;
  1098. * enet_handle_t g_handle;
  1099. * //Get the received frame size firstly.
  1100. * status = ENET_GetRxFrameSize(&g_handle, &length);
  1101. * if (length != 0)
  1102. * {
  1103. * //Allocate memory here with the size of "length"
  1104. * uint8_t *data = memory allocate interface;
  1105. * if (!data)
  1106. * {
  1107. * ENET_ReadFrame(ENET, &g_handle, NULL, 0);
  1108. * //Add the console warning log.
  1109. * }
  1110. * else
  1111. * {
  1112. * status = ENET_ReadFrame(ENET, &g_handle, data, length);
  1113. * //Call stack input API to deliver the data to stack
  1114. * }
  1115. * }
  1116. * else if (status == kStatus_ENET_RxFrameError)
  1117. * {
  1118. * //Update the received buffer when a error frame is received.
  1119. * ENET_ReadFrame(ENET, &g_handle, NULL, 0);
  1120. * }
  1121. * @endcode
  1122. * @param base ENET peripheral base address.
  1123. * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init.
  1124. * @param data The data buffer provided by user to store the frame which memory size should be at least "length".
  1125. * @param length The size of the data buffer which is still the length of the received frame.
  1126. * @return The execute status, successful or failure.
  1127. */
  1128. status_t ENET_ReadFrame(ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length);
  1129. /*!
  1130. * @brief Transmits an ENET frame for single ring.
  1131. * @note The CRC is automatically appended to the data. Input the data
  1132. * to send without the CRC.
  1133. *
  1134. *
  1135. * @param base ENET peripheral base address.
  1136. * @param handle The ENET handler pointer. This is the same handler pointer used in the ENET_Init.
  1137. * @param data The data buffer provided by user to be send.
  1138. * @param length The length of the data to be send.
  1139. * @retval kStatus_Success Send frame succeed.
  1140. * @retval kStatus_ENET_TxFrameBusy Transmit buffer descriptor is busy under transmission.
  1141. * The transmit busy happens when the data send rate is over the MAC capacity.
  1142. * The waiting mechanism is recommended to be added after each call return with
  1143. * kStatus_ENET_TxFrameBusy.
  1144. */
  1145. status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, const uint8_t *data, uint32_t length);
  1146. #if FSL_FEATURE_ENET_QUEUE > 1
  1147. /*!
  1148. * @brief Gets the error statistics of received frame for extended multi-ring.
  1149. *
  1150. * This API must be called after the ENET_GetRxFrameSizeMultiRing and before the ENET_ReadFrameMultiRing().
  1151. * If the ENET_GetRxFrameSizeMultiRing returns kStatus_ENET_RxFrameError,
  1152. * the ENET_GetRxErrBeforeReadFrameMultiRing can be used to get the exact error statistics.
  1153. *
  1154. * @param handle The ENET handler structure pointer. This is the same handler pointer used in the ENET_Init.
  1155. * @param eErrorStatic The error statistics structure pointer.
  1156. * @param ringId The ring index, range from 0 ~ FSL_FEATURE_ENET_QUEUE - 1.
  1157. */
  1158. void ENET_GetRxErrBeforeReadFrameMultiRing(enet_handle_t *handle,
  1159. enet_data_error_stats_t *eErrorStatic,
  1160. uint32_t ringId);
  1161. /*!
  1162. * @brief Transmits an ENET frame for extended multi-ring.
  1163. * @note The CRC is automatically appended to the data. Input the data
  1164. * to send without the CRC.
  1165. *
  1166. * In this API, multiple-ring are mainly used for extended avb frames are supported.
  1167. * The transmit scheme for avb frames is the credit-based scheme, the AVB class A, AVB class B
  1168. * and the non-AVB frame are transmitted in ring 1, ring 2 and ring 0 independently.
  1169. * So application should care about the transmit ring index when use multiple-ring transmission.
  1170. *
  1171. * @param base ENET peripheral base address.
  1172. * @param handle The ENET handler pointer. This is the same handler pointer used in the ENET_Init.
  1173. * @param data The data buffer provided by user to be send.
  1174. * @param length The length of the data to be send.
  1175. * @param ringId The ring index for transmission.
  1176. * @retval kStatus_Success Send frame succeed.
  1177. * @retval kStatus_ENET_TxFrameBusy Transmit buffer descriptor is busy under transmission.
  1178. * The transmit busy happens when the data send rate is over the MAC capacity.
  1179. * The waiting mechanism is recommended to be added after each call return with
  1180. * kStatus_ENET_TxFrameBusy.
  1181. */
  1182. status_t ENET_SendFrameMultiRing(
  1183. ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length, uint32_t ringId);
  1184. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  1185. /*!
  1186. * @brief Gets the ENET transmit frame statistics after the data send for extended multi-ring.
  1187. *
  1188. * This interface gets the error statistics of the transmit frame.
  1189. * Because the error information is reported by the uDMA after the data delivery, this interface
  1190. * should be called after the data transmit API and shall be called by transmit interrupt handler.
  1191. * After calling the ENET_SendFrame, the transmit interrupt notifies the transmit completion.
  1192. *
  1193. * @param handle The PTP handler pointer. This is the same handler pointer used in the ENET_Init.
  1194. * @param eErrorStatic The error statistics structure pointer.
  1195. * @param ringId The ring index.
  1196. * @return The execute status.
  1197. */
  1198. status_t ENET_GetTxErrAfterSendFrameMultiRing(enet_handle_t *handle,
  1199. enet_data_error_stats_t *eErrorStatic,
  1200. uint32_t ringId);
  1201. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  1202. /*!
  1203. * @brief Gets the size of the read frame for extended mutli-ring.
  1204. *
  1205. * This function gets a received frame size from the ENET buffer descriptors.
  1206. * @note The FCS of the frame is automatically removed by MAC and the size is the length without the FCS.
  1207. * After calling ENET_GetRxFrameSizeMultiRing, ENET_ReadFrameMultiRing() should be called to update the
  1208. * receive buffers If the result is not "kStatus_ENET_RxFrameEmpty". The usage is
  1209. * the same to the single ring, refer to ENET_GetRxFrameSize.
  1210. *
  1211. * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init.
  1212. * @param length The length of the valid frame received.
  1213. * @param ringId The ring index or ring number;
  1214. * @retval kStatus_ENET_RxFrameEmpty No frame received. Should not call ENET_ReadFrameMultiRing to read frame.
  1215. * @retval kStatus_ENET_RxFrameError Data error happens. ENET_ReadFrameMultiRing should be called with NULL data
  1216. * and NULL length to update the receive buffers.
  1217. * @retval kStatus_Success Receive a frame Successfully then the ENET_ReadFrame
  1218. * should be called with the right data buffer and the captured data length input.
  1219. */
  1220. status_t ENET_GetRxFrameSizeMultiRing(enet_handle_t *handle, uint32_t *length, uint32_t ringId);
  1221. /*!
  1222. * @brief Reads a frame from the ENET device for multi-ring.
  1223. *
  1224. * This function reads a frame (both the data and the length) from the ENET buffer descriptors.
  1225. * The ENET_GetRxFrameSizeMultiRing should be used to get the size of the prepared data buffer.
  1226. * This usage is the same as the single ring, refer to ENET_ReadFrame.
  1227. * @param base ENET peripheral base address.
  1228. * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init.
  1229. * @param data The data buffer provided by user to store the frame which memory size should be at least "length".
  1230. * @param length The size of the data buffer which is still the length of the received frame.
  1231. * @param ringId The ring index or ring number;
  1232. * @return The execute status, successful or failure.
  1233. */
  1234. status_t ENET_ReadFrameMultiRing(
  1235. ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length, uint32_t ringId);
  1236. /*!
  1237. * @brief The transmit IRQ handler.
  1238. *
  1239. * @param base ENET peripheral base address.
  1240. * @param handle The ENET handler pointer.
  1241. * @param ringId The ring id or ring number.
  1242. */
  1243. void ENET_TransmitIRQHandler(ENET_Type *base, enet_handle_t *handle, uint32_t ringId);
  1244. /*!
  1245. * @brief The receive IRQ handler.
  1246. *
  1247. * @param base ENET peripheral base address.
  1248. * @param handle The ENET handler pointer.
  1249. * @param ringId The ring id or ring number.
  1250. */
  1251. void ENET_ReceiveIRQHandler(ENET_Type *base, enet_handle_t *handle, uint32_t ringId);
  1252. /*!
  1253. * @brief the common IRQ handler for the tx/rx irq handler.
  1254. *
  1255. * This is used for the combined tx/rx interrupt for multi-ring (frame 1).
  1256. *
  1257. * @param base ENET peripheral base address.
  1258. */
  1259. void ENET_CommonFrame1IRQHandler(ENET_Type *base);
  1260. /*!
  1261. * @brief the common IRQ handler for the tx/rx irq handler.
  1262. *
  1263. * This is used for the combined tx/rx interrupt for multi-ring (frame 2).
  1264. *
  1265. * @param base ENET peripheral base address.
  1266. */
  1267. void ENET_CommonFrame2IRQHandler(ENET_Type *base);
  1268. #else
  1269. /*!
  1270. * @brief The transmit IRQ handler.
  1271. *
  1272. * @param base ENET peripheral base address.
  1273. * @param handle The ENET handler pointer.
  1274. */
  1275. void ENET_TransmitIRQHandler(ENET_Type *base, enet_handle_t *handle);
  1276. /*!
  1277. * @brief The receive IRQ handler.
  1278. *
  1279. * @param base ENET peripheral base address.
  1280. * @param handle The ENET handler pointer.
  1281. */
  1282. void ENET_ReceiveIRQHandler(ENET_Type *base, enet_handle_t *handle);
  1283. #endif /* FSL_FEATURE_ENET_QUEUE > 1 */
  1284. /*!
  1285. * @brief Some special IRQ handler including the error, mii, wakeup irq handler.
  1286. *
  1287. * @param base ENET peripheral base address.
  1288. * @param handle The ENET handler pointer.
  1289. */
  1290. void ENET_ErrorIRQHandler(ENET_Type *base, enet_handle_t *handle);
  1291. /*!
  1292. * @brief the common IRQ handler for the tx/rx/error etc irq handler.
  1293. *
  1294. * This is used for the combined tx/rx/error interrupt for single/mutli-ring (frame 0).
  1295. *
  1296. * @param base ENET peripheral base address.
  1297. */
  1298. void ENET_CommonFrame0IRQHandler(ENET_Type *base);
  1299. /* @} */
  1300. #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE
  1301. /*!
  1302. * @name ENET PTP 1588 function operation
  1303. * @{
  1304. */
  1305. /*!
  1306. * @brief Configures the ENET PTP IEEE 1588 feature with the basic configuration.
  1307. * The function sets the clock for PTP 1588 timer and enables
  1308. * time stamp interrupts and transmit interrupts for PTP 1588 features.
  1309. * This API should be called when the 1588 feature is enabled
  1310. * or the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is defined.
  1311. * ENET_Init should be called before calling this API.
  1312. *
  1313. * @note The PTP 1588 time-stamp second increase though time-stamp interrupt handler
  1314. * and the transmit time-stamp store is done through transmit interrupt handler.
  1315. * As a result, the TS interrupt and TX interrupt are enabled when you call this API.
  1316. *
  1317. * @param base ENET peripheral base address.
  1318. * @param handle ENET handler pointer.
  1319. * @param ptpConfig The ENET PTP1588 configuration.
  1320. */
  1321. void ENET_Ptp1588Configure(ENET_Type *base, enet_handle_t *handle, enet_ptp_config_t *ptpConfig);
  1322. /*!
  1323. * @brief Starts the ENET PTP 1588 Timer.
  1324. * This function is used to initialize the PTP timer. After the PTP starts,
  1325. * the PTP timer starts running.
  1326. *
  1327. * @param base ENET peripheral base address.
  1328. * @param ptpClkSrc The clock source of the PTP timer.
  1329. */
  1330. void ENET_Ptp1588StartTimer(ENET_Type *base, uint32_t ptpClkSrc);
  1331. /*!
  1332. * @brief Stops the ENET PTP 1588 Timer.
  1333. * This function is used to stops the ENET PTP timer.
  1334. *
  1335. * @param base ENET peripheral base address.
  1336. */
  1337. static inline void ENET_Ptp1588StopTimer(ENET_Type *base)
  1338. {
  1339. /* Disable PTP timer and reset the timer. */
  1340. base->ATCR &= ~ENET_ATCR_EN_MASK;
  1341. base->ATCR |= ENET_ATCR_RESTART_MASK;
  1342. }
  1343. /*!
  1344. * @brief Adjusts the ENET PTP 1588 timer.
  1345. *
  1346. * @param base ENET peripheral base address.
  1347. * @param corrIncrease The correction increment value. This value is added every time the correction
  1348. * timer expires. A value less than the PTP timer frequency(1/ptpClkSrc) slows down the timer,
  1349. * a value greater than the 1/ptpClkSrc speeds up the timer.
  1350. * @param corrPeriod The PTP timer correction counter wrap-around value. This defines after how
  1351. * many timer clock the correction counter should be reset and trigger a correction
  1352. * increment on the timer. A value of 0 disables the correction counter and no correction occurs.
  1353. */
  1354. void ENET_Ptp1588AdjustTimer(ENET_Type *base, uint32_t corrIncrease, uint32_t corrPeriod);
  1355. /*!
  1356. * @brief Sets the ENET PTP 1588 timer channel mode.
  1357. *
  1358. * @param base ENET peripheral base address.
  1359. * @param channel The ENET PTP timer channel number.
  1360. * @param mode The PTP timer channel mode, see "enet_ptp_timer_channel_mode_t".
  1361. * @param intEnable Enables or disables the interrupt.
  1362. */
  1363. static inline void ENET_Ptp1588SetChannelMode(ENET_Type *base,
  1364. enet_ptp_timer_channel_t channel,
  1365. enet_ptp_timer_channel_mode_t mode,
  1366. bool intEnable)
  1367. {
  1368. uint32_t tcrReg = 0;
  1369. tcrReg = ENET_TCSR_TMODE(mode) | (intEnable ? ENET_TCSR_TIE_MASK : 0);
  1370. /* Disable channel mode first. */
  1371. base->CHANNEL[channel].TCSR = 0;
  1372. base->CHANNEL[channel].TCSR = tcrReg;
  1373. }
  1374. #if defined(FSL_FEATURE_ENET_HAS_TIMER_PWCONTROL) && FSL_FEATURE_ENET_HAS_TIMER_PWCONTROL
  1375. /*!
  1376. * @brief Sets ENET PTP 1588 timer channel mode pulse width.
  1377. *
  1378. * For the input "mode" in ENET_Ptp1588SetChannelMode, the kENET_PtpChannelPulseLowonCompare
  1379. * kENET_PtpChannelPulseHighonCompare only support the pulse width for one 1588 clock.
  1380. * this function is extended for control the pulse width from 1 to 32 1588 clock cycles.
  1381. * so call this function if you need to set the timer channel mode for
  1382. * kENET_PtpChannelPulseLowonCompare or kENET_PtpChannelPulseHighonCompare
  1383. * with pulse width more than one 1588 clock,
  1384. *
  1385. * @param base ENET peripheral base address.
  1386. * @param channel The ENET PTP timer channel number.
  1387. * @param isOutputLow True --- timer channel is configured for output compare
  1388. * pulse output low.
  1389. * false --- timer channel is configured for output compare
  1390. * pulse output high.
  1391. * @param pulseWidth The pulse width control value, range from 0 ~ 31.
  1392. * 0 --- pulse width is one 1588 clock cycle.
  1393. * 31 --- pulse width is thirty two 1588 clock cycles.
  1394. * @param intEnable Enables or disables the interrupt.
  1395. */
  1396. static inline void ENET_Ptp1588SetChannelOutputPulseWidth(
  1397. ENET_Type *base, enet_ptp_timer_channel_t channel, bool isOutputLow, uint8_t pulseWidth, bool intEnable)
  1398. {
  1399. uint32_t tcrReg;
  1400. tcrReg = ENET_TCSR_TIE(intEnable) | ENET_TCSR_TPWC(pulseWidth);
  1401. if (isOutputLow)
  1402. {
  1403. tcrReg |= ENET_TCSR_TMODE(kENET_PtpChannelPulseLowonCompare);
  1404. }
  1405. else
  1406. {
  1407. tcrReg |= ENET_TCSR_TMODE(kENET_PtpChannelPulseHighonCompare);
  1408. }
  1409. /* Disable channel mode first. */
  1410. base->CHANNEL[channel].TCSR = 0;
  1411. base->CHANNEL[channel].TCSR = tcrReg;
  1412. }
  1413. #endif /* FSL_FEATURE_ENET_HAS_TIMER_PWCONTROL */
  1414. /*!
  1415. * @brief Sets the ENET PTP 1588 timer channel comparison value.
  1416. *
  1417. * @param base ENET peripheral base address.
  1418. * @param channel The PTP timer channel, see "enet_ptp_timer_channel_t".
  1419. * @param cmpValue The compare value for the compare setting.
  1420. */
  1421. static inline void ENET_Ptp1588SetChannelCmpValue(ENET_Type *base, enet_ptp_timer_channel_t channel, uint32_t cmpValue)
  1422. {
  1423. base->CHANNEL[channel].TCCR = cmpValue;
  1424. }
  1425. /*!
  1426. * @brief Gets the ENET PTP 1588 timer channel status.
  1427. *
  1428. * @param base ENET peripheral base address.
  1429. * @param channel The IEEE 1588 timer channel number.
  1430. * @return True or false, Compare or capture operation status
  1431. */
  1432. static inline bool ENET_Ptp1588GetChannelStatus(ENET_Type *base, enet_ptp_timer_channel_t channel)
  1433. {
  1434. return (0 != (base->CHANNEL[channel].TCSR & ENET_TCSR_TF_MASK));
  1435. }
  1436. /*!
  1437. * @brief Clears the ENET PTP 1588 timer channel status.
  1438. *
  1439. * @param base ENET peripheral base address.
  1440. * @param channel The IEEE 1588 timer channel number.
  1441. */
  1442. static inline void ENET_Ptp1588ClearChannelStatus(ENET_Type *base, enet_ptp_timer_channel_t channel)
  1443. {
  1444. base->CHANNEL[channel].TCSR |= ENET_TCSR_TF_MASK;
  1445. base->TGSR = (1U << channel);
  1446. }
  1447. /*!
  1448. * @brief Gets the current ENET time from the PTP 1588 timer.
  1449. *
  1450. * @param base ENET peripheral base address.
  1451. * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init.
  1452. * @param ptpTime The PTP timer structure.
  1453. */
  1454. void ENET_Ptp1588GetTimer(ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime);
  1455. /*!
  1456. * @brief Sets the ENET PTP 1588 timer to the assigned time.
  1457. *
  1458. * @param base ENET peripheral base address.
  1459. * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init.
  1460. * @param ptpTime The timer to be set to the PTP timer.
  1461. */
  1462. void ENET_Ptp1588SetTimer(ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime);
  1463. /*!
  1464. * @brief The IEEE 1588 PTP time stamp interrupt handler.
  1465. *
  1466. * @param base ENET peripheral base address.
  1467. * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init.
  1468. */
  1469. void ENET_Ptp1588TimerIRQHandler(ENET_Type *base, enet_handle_t *handle);
  1470. /*!
  1471. * @brief Gets the time stamp of the received frame.
  1472. *
  1473. * This function is used for PTP stack to get the timestamp captured by the ENET driver.
  1474. *
  1475. * @param handle The ENET handler pointer.This is the same state pointer used in
  1476. * ENET_Init.
  1477. * @param ptpTimeData The special PTP timestamp data for search the receive timestamp.
  1478. * @retval kStatus_Success Get 1588 timestamp success.
  1479. * @retval kStatus_ENET_PtpTsRingEmpty 1588 timestamp ring empty.
  1480. * @retval kStatus_ENET_PtpTsRingFull 1588 timestamp ring full.
  1481. */
  1482. status_t ENET_GetRxFrameTime(enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData);
  1483. /*!
  1484. * @brief Gets the time stamp of the transmit frame.
  1485. *
  1486. * This function is used for PTP stack to get the timestamp captured by the ENET driver.
  1487. *
  1488. * @param handle The ENET handler pointer.This is the same state pointer used in
  1489. * ENET_Init.
  1490. * @param ptpTimeData The special PTP timestamp data for search the receive timestamp.
  1491. * @retval kStatus_Success Get 1588 timestamp success.
  1492. * @retval kStatus_ENET_PtpTsRingEmpty 1588 timestamp ring empty.
  1493. * @retval kStatus_ENET_PtpTsRingFull 1588 timestamp ring full.
  1494. */
  1495. status_t ENET_GetTxFrameTime(enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData);
  1496. #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */
  1497. /* @} */
  1498. #if defined(__cplusplus)
  1499. }
  1500. #endif
  1501. /*! @}*/
  1502. #endif /* _FSL_ENET_H_ */