fsl_enet.h 75 KB

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