stm32h7xx_hal_eth.h 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_eth.h
  4. * @author MCD Application Team
  5. * @brief Header file of ETH HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32H7xx_HAL_ETH_H
  20. #define STM32H7xx_HAL_ETH_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32h7xx_hal_def.h"
  26. #if defined(ETH)
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup ETH
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. #ifndef ETH_TX_DESC_CNT
  35. #define ETH_TX_DESC_CNT 4U
  36. #endif /* ETH_TX_DESC_CNT */
  37. #ifndef ETH_RX_DESC_CNT
  38. #define ETH_RX_DESC_CNT 4U
  39. #endif /* ETH_RX_DESC_CNT */
  40. #ifndef ETH_SWRESET_TIMEOUT
  41. #define ETH_SWRESET_TIMEOUT 500U
  42. #endif /* ETH_SWRESET_TIMEOUT */
  43. #ifndef ETH_MDIO_BUS_TIMEOUT
  44. #define ETH_MDIO_BUS_TIMEOUT 1000U
  45. #endif /* ETH_MDIO_BUS_TIMEOUT */
  46. #ifndef ETH_MAC_US_TICK
  47. #define ETH_MAC_US_TICK 1000000U
  48. #endif /* ETH_MAC_US_TICK */
  49. /*********************** Descriptors struct def section ************************/
  50. /** @defgroup ETH_Exported_Types ETH Exported Types
  51. * @{
  52. */
  53. /**
  54. * @brief ETH DMA Descriptor structure definition
  55. */
  56. typedef struct
  57. {
  58. __IO uint32_t DESC0;
  59. __IO uint32_t DESC1;
  60. __IO uint32_t DESC2;
  61. __IO uint32_t DESC3;
  62. uint32_t BackupAddr0; /* used to store rx buffer 1 address */
  63. uint32_t BackupAddr1; /* used to store rx buffer 2 address */
  64. } ETH_DMADescTypeDef;
  65. /**
  66. *
  67. */
  68. /**
  69. * @brief ETH Buffers List structure definition
  70. */
  71. typedef struct __ETH_BufferTypeDef
  72. {
  73. uint8_t *buffer; /*<! buffer address */
  74. uint32_t len; /*<! buffer length */
  75. struct __ETH_BufferTypeDef *next; /*<! Pointer to the next buffer in the list */
  76. } ETH_BufferTypeDef;
  77. /**
  78. *
  79. */
  80. /**
  81. * @brief DMA Transmit Descriptors Wrapper structure definition
  82. */
  83. typedef struct
  84. {
  85. uint32_t TxDesc[ETH_TX_DESC_CNT]; /*<! Tx DMA descriptors addresses */
  86. uint32_t CurTxDesc; /*<! Current Tx descriptor index for packet transmission */
  87. uint32_t *PacketAddress[ETH_TX_DESC_CNT]; /*<! Ethernet packet addresses array */
  88. uint32_t *CurrentPacketAddress; /*<! Current transmit NX_PACKET addresses */
  89. uint32_t BuffersInUse; /*<! Buffers in Use */
  90. uint32_t releaseIndex; /*<! Release index */
  91. } ETH_TxDescListTypeDef;
  92. /**
  93. *
  94. */
  95. /**
  96. * @brief Transmit Packet Configuration structure definition
  97. */
  98. typedef struct
  99. {
  100. uint32_t Attributes; /*!< Tx packet HW features capabilities.
  101. This parameter can be a combination of @ref ETH_Tx_Packet_Attributes*/
  102. uint32_t Length; /*!< Total packet length */
  103. ETH_BufferTypeDef *TxBuffer; /*!< Tx buffers pointers */
  104. uint32_t SrcAddrCtrl; /*!< Specifies the source address insertion control.
  105. This parameter can be a value of @ref ETH_Tx_Packet_Source_Addr_Control */
  106. uint32_t CRCPadCtrl; /*!< Specifies the CRC and Pad insertion and replacement control.
  107. This parameter can be a value of @ref ETH_Tx_Packet_CRC_Pad_Control */
  108. uint32_t ChecksumCtrl; /*!< Specifies the checksum insertion control.
  109. This parameter can be a value of @ref ETH_Tx_Packet_Checksum_Control */
  110. uint32_t MaxSegmentSize; /*!< Sets TCP maximum segment size only when TCP segmentation is enabled.
  111. This parameter can be a value from 0x0 to 0x3FFF */
  112. uint32_t PayloadLen; /*!< Sets Total payload length only when TCP segmentation is enabled.
  113. This parameter can be a value from 0x0 to 0x3FFFF */
  114. uint32_t TCPHeaderLen; /*!< Sets TCP header length only when TCP segmentation is enabled.
  115. This parameter can be a value from 0x5 to 0xF */
  116. uint32_t VlanTag; /*!< Sets VLAN Tag only when VLAN is enabled.
  117. This parameter can be a value from 0x0 to 0xFFFF*/
  118. uint32_t VlanCtrl; /*!< Specifies VLAN Tag insertion control only when VLAN is enabled.
  119. This parameter can be a value of @ref ETH_Tx_Packet_VLAN_Control */
  120. uint32_t InnerVlanTag; /*!< Sets Inner VLAN Tag only when Inner VLAN is enabled.
  121. This parameter can be a value from 0x0 to 0x3FFFF */
  122. uint32_t InnerVlanCtrl; /*!< Specifies Inner VLAN Tag insertion control only when Inner VLAN is enabled.
  123. This parameter can be a value of @ref ETH_Tx_Packet_Inner_VLAN_Control */
  124. void *pData; /*!< Specifies Application packet pointer to save */
  125. } ETH_TxPacketConfigTypeDef;
  126. /**
  127. *
  128. */
  129. /**
  130. * @brief ETH Timestamp structure definition
  131. */
  132. typedef struct
  133. {
  134. uint32_t TimeStampLow;
  135. uint32_t TimeStampHigh;
  136. } ETH_TimeStampTypeDef;
  137. /**
  138. *
  139. */
  140. #ifdef HAL_ETH_USE_PTP
  141. /**
  142. * @brief ETH Timeupdate structure definition
  143. */
  144. typedef struct
  145. {
  146. uint32_t Seconds;
  147. uint32_t NanoSeconds;
  148. } ETH_TimeTypeDef;
  149. /**
  150. *
  151. */
  152. #endif /* HAL_ETH_USE_PTP */
  153. /**
  154. * @brief DMA Receive Descriptors Wrapper structure definition
  155. */
  156. typedef struct
  157. {
  158. uint32_t RxDesc[ETH_RX_DESC_CNT]; /*<! Rx DMA descriptors addresses. */
  159. uint32_t ItMode; /*<! If 1, DMA will generate the Rx complete interrupt.
  160. If 0, DMA will not generate the Rx complete interrupt. */
  161. uint32_t RxDescIdx; /*<! Current Rx descriptor. */
  162. uint32_t RxDescCnt; /*<! Number of descriptors . */
  163. uint32_t RxDataLength; /*<! Received Data Length. */
  164. uint32_t RxBuildDescIdx; /*<! Current Rx Descriptor for building descriptors. */
  165. uint32_t RxBuildDescCnt; /*<! Number of Rx Descriptors awaiting building. */
  166. uint32_t pRxLastRxDesc; /*<! Last received descriptor. */
  167. ETH_TimeStampTypeDef TimeStamp; /*<! Time Stamp Low value for receive. */
  168. void *pRxStart; /*<! Pointer to the first buff. */
  169. void *pRxEnd; /*<! Pointer to the last buff. */
  170. } ETH_RxDescListTypeDef;
  171. /**
  172. *
  173. */
  174. /**
  175. * @brief ETH MAC Configuration Structure definition
  176. */
  177. typedef struct
  178. {
  179. uint32_t
  180. SourceAddrControl; /*!< Selects the Source Address Insertion or Replacement Control.
  181. This parameter can be a value of @ref ETH_Source_Addr_Control */
  182. FunctionalState
  183. ChecksumOffload; /*!< Enables or Disable the checksum checking for received packet payloads TCP, UDP or ICMP headers */
  184. uint32_t InterPacketGapVal; /*!< Sets the minimum IPG between Packet during transmission.
  185. This parameter can be a value of @ref ETH_Inter_Packet_Gap */
  186. FunctionalState GiantPacketSizeLimitControl; /*!< Enables or disables the Giant Packet Size Limit Control. */
  187. FunctionalState Support2KPacket; /*!< Enables or disables the IEEE 802.3as Support for 2K length Packets */
  188. FunctionalState CRCStripTypePacket; /*!< Enables or disables the CRC stripping for Type packets.*/
  189. FunctionalState AutomaticPadCRCStrip; /*!< Enables or disables the Automatic MAC Pad/CRC Stripping.*/
  190. FunctionalState Watchdog; /*!< Enables or disables the Watchdog timer on Rx path.*/
  191. FunctionalState Jabber; /*!< Enables or disables Jabber timer on Tx path.*/
  192. FunctionalState JumboPacket; /*!< Enables or disables receiving Jumbo Packet
  193. When enabled, the MAC allows jumbo packets of 9,018 bytes
  194. without reporting a giant packet error */
  195. uint32_t Speed; /*!< Sets the Ethernet speed: 10/100 Mbps.
  196. This parameter can be a value of @ref ETH_Speed */
  197. uint32_t DuplexMode; /*!< Selects the MAC duplex mode: Half-Duplex or Full-Duplex mode
  198. This parameter can be a value of @ref ETH_Duplex_Mode */
  199. FunctionalState LoopbackMode; /*!< Enables or disables the loopback mode */
  200. FunctionalState
  201. CarrierSenseBeforeTransmit; /*!< Enables or disables the Carrier Sense Before Transmission in Full Duplex Mode. */
  202. FunctionalState ReceiveOwn; /*!< Enables or disables the Receive Own in Half Duplex mode. */
  203. FunctionalState
  204. CarrierSenseDuringTransmit; /*!< Enables or disables the Carrier Sense During Transmission in the Half Duplex mode */
  205. FunctionalState
  206. RetryTransmission; /*!< Enables or disables the MAC retry transmission, when a collision occurs in Half Duplex mode.*/
  207. uint32_t BackOffLimit; /*!< Selects the BackOff limit value.
  208. This parameter can be a value of @ref ETH_Back_Off_Limit */
  209. FunctionalState
  210. DeferralCheck; /*!< Enables or disables the deferral check function in Half Duplex mode. */
  211. uint32_t
  212. PreambleLength; /*!< Selects or not the Preamble Length for Transmit packets (Full Duplex mode).
  213. This parameter can be a value of @ref ETH_Preamble_Length */
  214. FunctionalState
  215. UnicastSlowProtocolPacketDetect; /*!< Enable or disables the Detection of Slow Protocol Packets with unicast address. */
  216. FunctionalState SlowProtocolDetect; /*!< Enable or disables the Slow Protocol Detection. */
  217. FunctionalState CRCCheckingRxPackets; /*!< Enable or disables the CRC Checking for Received Packets. */
  218. uint32_t
  219. GiantPacketSizeLimit; /*!< Specifies the packet size that the MAC will declare it as Giant, If it's size is
  220. greater than the value programmed in this field in units of bytes
  221. This parameter must be a number between
  222. Min_Data = 0x618 (1518 byte) and Max_Data = 0x3FFF (32 Kbyte). */
  223. FunctionalState ExtendedInterPacketGap; /*!< Enable or disables the extended inter packet gap. */
  224. uint32_t ExtendedInterPacketGapVal; /*!< Sets the Extended IPG between Packet during transmission.
  225. This parameter can be a value from 0x0 to 0xFF */
  226. FunctionalState ProgrammableWatchdog; /*!< Enable or disables the Programmable Watchdog.*/
  227. uint32_t WatchdogTimeout; /*!< This field is used as watchdog timeout for a received packet
  228. This parameter can be a value of @ref ETH_Watchdog_Timeout */
  229. uint32_t
  230. PauseTime; /*!< This field holds the value to be used in the Pause Time field in the transmit control packet.
  231. This parameter must be a number between
  232. Min_Data = 0x0 and Max_Data = 0xFFFF.*/
  233. FunctionalState
  234. ZeroQuantaPause; /*!< Enable or disables the automatic generation of Zero Quanta Pause Control packets.*/
  235. uint32_t
  236. PauseLowThreshold; /*!< This field configures the threshold of the PAUSE to be checked for automatic retransmission of PAUSE Packet.
  237. This parameter can be a value of @ref ETH_Pause_Low_Threshold */
  238. FunctionalState
  239. TransmitFlowControl; /*!< Enables or disables the MAC to transmit Pause packets in Full Duplex mode
  240. or the MAC back pressure operation in Half Duplex mode */
  241. FunctionalState
  242. UnicastPausePacketDetect; /*!< Enables or disables the MAC to detect Pause packets with unicast address of the station */
  243. FunctionalState ReceiveFlowControl; /*!< Enables or disables the MAC to decodes the received Pause packet
  244. and disables its transmitter for a specified (Pause) time */
  245. uint32_t TransmitQueueMode; /*!< Specifies the Transmit Queue operating mode.
  246. This parameter can be a value of @ref ETH_Transmit_Mode */
  247. uint32_t ReceiveQueueMode; /*!< Specifies the Receive Queue operating mode.
  248. This parameter can be a value of @ref ETH_Receive_Mode */
  249. FunctionalState DropTCPIPChecksumErrorPacket; /*!< Enables or disables Dropping of TCPIP Checksum Error Packets. */
  250. FunctionalState ForwardRxErrorPacket; /*!< Enables or disables forwarding Error Packets. */
  251. FunctionalState ForwardRxUndersizedGoodPacket; /*!< Enables or disables forwarding Undersized Good Packets.*/
  252. } ETH_MACConfigTypeDef;
  253. /**
  254. *
  255. */
  256. /**
  257. * @brief ETH DMA Configuration Structure definition
  258. */
  259. typedef struct
  260. {
  261. uint32_t DMAArbitration; /*!< Sets the arbitration scheme between DMA Tx and Rx
  262. This parameter can be a value of @ref ETH_DMA_Arbitration */
  263. FunctionalState AddressAlignedBeats; /*!< Enables or disables the AHB Master interface address aligned
  264. burst transfers on Read and Write channels */
  265. uint32_t BurstMode; /*!< Sets the AHB Master interface burst transfers.
  266. This parameter can be a value of @ref ETH_Burst_Mode */
  267. FunctionalState RebuildINCRxBurst; /*!< Enables or disables the AHB Master to rebuild the pending beats
  268. of any initiated burst transfer with INCRx and SINGLE transfers. */
  269. FunctionalState PBLx8Mode; /*!< Enables or disables the PBL multiplication by eight. */
  270. uint32_t
  271. TxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Tx DMA transaction.
  272. This parameter can be a value of @ref ETH_Tx_DMA_Burst_Length */
  273. FunctionalState
  274. SecondPacketOperate; /*!< Enables or disables the Operate on second Packet mode, which allows the DMA to process a second
  275. Packet of Transmit data even before
  276. obtaining the status for the first one. */
  277. uint32_t
  278. RxDMABurstLength; /*!< Indicates the maximum number of beats to be transferred in one Rx DMA transaction.
  279. This parameter can be a value of @ref ETH_Rx_DMA_Burst_Length */
  280. FunctionalState FlushRxPacket; /*!< Enables or disables the Rx Packet Flush */
  281. FunctionalState TCPSegmentation; /*!< Enables or disables the TCP Segmentation */
  282. uint32_t
  283. MaximumSegmentSize; /*!< Sets the maximum segment size that should be used while segmenting the packet
  284. This parameter can be a value from 0x40 to 0x3FFF */
  285. } ETH_DMAConfigTypeDef;
  286. /**
  287. *
  288. */
  289. /**
  290. * @brief HAL ETH Media Interfaces enum definition
  291. */
  292. typedef enum
  293. {
  294. HAL_ETH_MII_MODE = 0x00U, /*!< Media Independent Interface */
  295. HAL_ETH_RMII_MODE = 0x01U /*!< Reduced Media Independent Interface */
  296. } ETH_MediaInterfaceTypeDef;
  297. /**
  298. *
  299. */
  300. #ifdef HAL_ETH_USE_PTP
  301. /**
  302. * @brief HAL ETH PTP Update type enum definition
  303. */
  304. typedef enum
  305. {
  306. HAL_ETH_PTP_POSITIVE_UPDATE = 0x00000000U, /*!< PTP positive time update */
  307. HAL_ETH_PTP_NEGATIVE_UPDATE = 0x00000001U /*!< PTP negative time update */
  308. } ETH_PtpUpdateTypeDef;
  309. /**
  310. *
  311. */
  312. #endif /* HAL_ETH_USE_PTP */
  313. /**
  314. * @brief ETH Init Structure definition
  315. */
  316. typedef struct
  317. {
  318. uint8_t
  319. *MACAddr; /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */
  320. ETH_MediaInterfaceTypeDef MediaInterface; /*!< Selects the MII interface or the RMII interface. */
  321. ETH_DMADescTypeDef
  322. *TxDesc; /*!< Provides the address of the first DMA Tx descriptor in the list */
  323. ETH_DMADescTypeDef
  324. *RxDesc; /*!< Provides the address of the first DMA Rx descriptor in the list */
  325. uint32_t RxBuffLen; /*!< Provides the length of Rx buffers size */
  326. } ETH_InitTypeDef;
  327. /**
  328. *
  329. */
  330. #ifdef HAL_ETH_USE_PTP
  331. /**
  332. * @brief ETH PTP Init Structure definition
  333. */
  334. typedef struct
  335. {
  336. uint32_t Timestamp; /*!< Enable Timestamp */
  337. uint32_t TimestampUpdateMode; /*!< Fine or Coarse Timestamp Update */
  338. uint32_t TimestampInitialize; /*!< Initialize Timestamp */
  339. uint32_t TimestampUpdate; /*!< Timestamp Update */
  340. uint32_t TimestampAddendUpdate; /*!< Timestamp Addend Update */
  341. uint32_t TimestampAll; /*!< Enable Timestamp for All Packets */
  342. uint32_t TimestampRolloverMode; /*!< Timestamp Digital or Binary Rollover Control */
  343. uint32_t TimestampV2; /*!< Enable PTP Packet Processing for Version 2 Format */
  344. uint32_t TimestampEthernet; /*!< Enable Processing of PTP over Ethernet Packets */
  345. uint32_t TimestampIPv6; /*!< Enable Processing of PTP Packets Sent over IPv6-UDP */
  346. uint32_t TimestampIPv4; /*!< Enable Processing of PTP Packets Sent over IPv4-UDP */
  347. uint32_t TimestampEvent; /*!< Enable Timestamp Snapshot for Event Messages */
  348. uint32_t TimestampMaster; /*!< Enable Timestamp Snapshot for Event Messages */
  349. uint32_t TimestampSnapshots; /*!< Select PTP packets for Taking Snapshots */
  350. uint32_t TimestampFilter; /*!< Enable MAC Address for PTP Packet Filtering */
  351. uint32_t
  352. TimestampChecksumCorrection; /*!< Enable checksum correction during OST for PTP over UDP/IPv4 packets */
  353. uint32_t TimestampStatusMode; /*!< Transmit Timestamp Status Mode */
  354. uint32_t TimestampAddend; /*!< Timestamp addend value */
  355. uint32_t TimestampSubsecondInc; /*!< Subsecond Increment */
  356. } ETH_PTP_ConfigTypeDef;
  357. /**
  358. *
  359. */
  360. #endif /* HAL_ETH_USE_PTP */
  361. /**
  362. * @brief HAL State structures definition
  363. */
  364. typedef uint32_t HAL_ETH_StateTypeDef;
  365. /**
  366. *
  367. */
  368. /**
  369. * @brief HAL ETH Rx Get Buffer Function definition
  370. */
  371. typedef void (*pETH_rxAllocateCallbackTypeDef)(uint8_t **buffer); /*!< pointer to an ETH Rx Get Buffer Function */
  372. /**
  373. *
  374. */
  375. /**
  376. * @brief HAL ETH Rx Set App Data Function definition
  377. */
  378. typedef void (*pETH_rxLinkCallbackTypeDef)(void **pStart, void **pEnd, uint8_t *buff,
  379. uint16_t Length); /*!< pointer to an ETH Rx Set App Data Function */
  380. /**
  381. *
  382. */
  383. /**
  384. * @brief HAL ETH Tx Free Function definition
  385. */
  386. typedef void (*pETH_txFreeCallbackTypeDef)(uint32_t *buffer); /*!< pointer to an ETH Tx Free function */
  387. /**
  388. *
  389. */
  390. /**
  391. * @brief HAL ETH Tx Free Function definition
  392. */
  393. typedef void (*pETH_txPtpCallbackTypeDef)(uint32_t *buffer,
  394. ETH_TimeStampTypeDef *timestamp); /*!< pointer to an ETH Tx Free function */
  395. /**
  396. *
  397. */
  398. /**
  399. * @brief ETH Handle Structure definition
  400. */
  401. #if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
  402. typedef struct __ETH_HandleTypeDef
  403. #else
  404. typedef struct
  405. #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
  406. {
  407. ETH_TypeDef *Instance; /*!< Register base address */
  408. ETH_InitTypeDef Init; /*!< Ethernet Init Configuration */
  409. ETH_TxDescListTypeDef TxDescList; /*!< Tx descriptor wrapper: holds all Tx descriptors list
  410. addresses and current descriptor index */
  411. ETH_RxDescListTypeDef RxDescList; /*!< Rx descriptor wrapper: holds all Rx descriptors list
  412. addresses and current descriptor index */
  413. #ifdef HAL_ETH_USE_PTP
  414. ETH_TimeStampTypeDef TxTimestamp; /*!< Tx Timestamp */
  415. #endif /* HAL_ETH_USE_PTP */
  416. __IO HAL_ETH_StateTypeDef gState; /*!< ETH state information related to global Handle management
  417. and also related to Tx operations. This parameter can
  418. be a value of @ref ETH_State_Codes */
  419. __IO uint32_t ErrorCode; /*!< Holds the global Error code of the ETH HAL status machine
  420. This parameter can be a value of @ref ETH_Error_Code.*/
  421. __IO uint32_t
  422. DMAErrorCode; /*!< Holds the DMA Rx Tx Error code when a DMA AIS interrupt occurs
  423. This parameter can be a combination of
  424. @ref ETH_DMA_Status_Flags */
  425. __IO uint32_t
  426. MACErrorCode; /*!< Holds the MAC Rx Tx Error code when a MAC Rx or Tx status interrupt occurs
  427. This parameter can be a combination of
  428. @ref ETH_MAC_Rx_Tx_Status */
  429. __IO uint32_t MACWakeUpEvent; /*!< Holds the Wake Up event when the MAC exit the power down mode
  430. This parameter can be a value of
  431. @ref ETH_MAC_Wake_Up_Event */
  432. __IO uint32_t MACLPIEvent; /*!< Holds the LPI event when the an LPI status interrupt occurs.
  433. This parameter can be a value of @ref ETHEx_LPI_Event */
  434. __IO uint32_t IsPtpConfigured; /*!< Holds the PTP configuration status.
  435. This parameter can be a value of
  436. @ref ETH_PTP_Config_Status */
  437. #if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
  438. void (* TxCpltCallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH Tx Complete Callback */
  439. void (* RxCpltCallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH Rx Complete Callback */
  440. void (* ErrorCallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH Error Callback */
  441. void (* PMTCallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH Power Management Callback */
  442. void (* EEECallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH EEE Callback */
  443. void (* WakeUpCallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH Wake UP Callback */
  444. void (* MspInitCallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH Msp Init callback */
  445. void (* MspDeInitCallback)(struct __ETH_HandleTypeDef *heth); /*!< ETH Msp DeInit callback */
  446. #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
  447. pETH_rxAllocateCallbackTypeDef rxAllocateCallback; /*!< ETH Rx Get Buffer Function */
  448. pETH_rxLinkCallbackTypeDef rxLinkCallback; /*!< ETH Rx Set App Data Function */
  449. pETH_txFreeCallbackTypeDef txFreeCallback; /*!< ETH Tx Free Function */
  450. pETH_txPtpCallbackTypeDef txPtpCallback; /*!< ETH Tx Handle Ptp Function */
  451. } ETH_HandleTypeDef;
  452. /**
  453. *
  454. */
  455. #if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
  456. /**
  457. * @brief HAL ETH Callback ID enumeration definition
  458. */
  459. typedef enum
  460. {
  461. HAL_ETH_MSPINIT_CB_ID = 0x00U, /*!< ETH MspInit callback ID */
  462. HAL_ETH_MSPDEINIT_CB_ID = 0x01U, /*!< ETH MspDeInit callback ID */
  463. HAL_ETH_TX_COMPLETE_CB_ID = 0x02U, /*!< ETH Tx Complete Callback ID */
  464. HAL_ETH_RX_COMPLETE_CB_ID = 0x03U, /*!< ETH Rx Complete Callback ID */
  465. HAL_ETH_ERROR_CB_ID = 0x04U, /*!< ETH Error Callback ID */
  466. HAL_ETH_PMT_CB_ID = 0x06U, /*!< ETH Power Management Callback ID */
  467. HAL_ETH_EEE_CB_ID = 0x07U, /*!< ETH EEE Callback ID */
  468. HAL_ETH_WAKEUP_CB_ID = 0x08U /*!< ETH Wake UP Callback ID */
  469. } HAL_ETH_CallbackIDTypeDef;
  470. /**
  471. * @brief HAL ETH Callback pointer definition
  472. */
  473. typedef void (*pETH_CallbackTypeDef)(ETH_HandleTypeDef *heth); /*!< pointer to an ETH callback function */
  474. #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
  475. /**
  476. * @brief ETH MAC filter structure definition
  477. */
  478. typedef struct
  479. {
  480. FunctionalState PromiscuousMode; /*!< Enable or Disable Promiscuous Mode */
  481. FunctionalState ReceiveAllMode; /*!< Enable or Disable Receive All Mode */
  482. FunctionalState HachOrPerfectFilter; /*!< Enable or Disable Perfect filtering in addition to Hash filtering */
  483. FunctionalState HashUnicast; /*!< Enable or Disable Hash filtering on unicast packets */
  484. FunctionalState HashMulticast; /*!< Enable or Disable Hash filtering on multicast packets */
  485. FunctionalState PassAllMulticast; /*!< Enable or Disable passing all multicast packets */
  486. FunctionalState SrcAddrFiltering; /*!< Enable or Disable source address filtering module */
  487. FunctionalState SrcAddrInverseFiltering; /*!< Enable or Disable source address inverse filtering */
  488. FunctionalState DestAddrInverseFiltering; /*!< Enable or Disable destination address inverse filtering */
  489. FunctionalState BroadcastFilter; /*!< Enable or Disable broadcast filter */
  490. uint32_t ControlPacketsFilter; /*!< Set the control packets filter
  491. This parameter can be a value of @ref ETH_Control_Packets_Filter */
  492. } ETH_MACFilterConfigTypeDef;
  493. /**
  494. *
  495. */
  496. /**
  497. * @brief ETH Power Down structure definition
  498. */
  499. typedef struct
  500. {
  501. FunctionalState WakeUpPacket; /*!< Enable or Disable Wake up packet detection in power down mode */
  502. FunctionalState MagicPacket; /*!< Enable or Disable Magic packet detection in power down mode */
  503. FunctionalState GlobalUnicast; /*!< Enable or Disable Global unicast packet detection in power down mode */
  504. FunctionalState WakeUpForward; /*!< Enable or Disable Forwarding Wake up packets */
  505. } ETH_PowerDownConfigTypeDef;
  506. /**
  507. *
  508. */
  509. /**
  510. * @}
  511. */
  512. /* Exported constants --------------------------------------------------------*/
  513. /** @defgroup ETH_Exported_Constants ETH Exported Constants
  514. * @{
  515. */
  516. /** @defgroup ETH_DMA_Tx_Descriptor_Bit_Definition ETH DMA Tx Descriptor Bit Definition
  517. * @{
  518. */
  519. /*
  520. DMA Tx Normal Descriptor Read Format
  521. -----------------------------------------------------------------------------------------------
  522. TDES0 | Buffer1 or Header Address [31:0] |
  523. -----------------------------------------------------------------------------------------------
  524. TDES1 | Buffer2 Address [31:0] / Next Descriptor Address [31:0] |
  525. -----------------------------------------------------------------------------------------------
  526. TDES2 | IOC(31) | TTSE(30) | Buff2 Length[29:16] | VTIR[15:14] | Header or Buff1 Length[13:0] |
  527. -----------------------------------------------------------------------------------------------
  528. TDES3 | OWN(31) | CTRL[30:26] | Reserved[25:24] | CTRL[23:20] | Reserved[19:17] | Status[16:0] |
  529. -----------------------------------------------------------------------------------------------
  530. */
  531. /**
  532. * @brief Bit definition of TDES0 RF register
  533. */
  534. #define ETH_DMATXNDESCRF_B1AP 0xFFFFFFFFU /*!< Transmit Packet Timestamp Low */
  535. /**
  536. * @brief Bit definition of TDES1 RF register
  537. */
  538. #define ETH_DMATXNDESCRF_B2AP 0xFFFFFFFFU /*!< Transmit Packet Timestamp High */
  539. /**
  540. * @brief Bit definition of TDES2 RF register
  541. */
  542. #define ETH_DMATXNDESCRF_IOC 0x80000000U /*!< Interrupt on Completion */
  543. #define ETH_DMATXNDESCRF_TTSE 0x40000000U /*!< Transmit Timestamp Enable */
  544. #define ETH_DMATXNDESCRF_B2L 0x3FFF0000U /*!< Buffer 2 Length */
  545. #define ETH_DMATXNDESCRF_VTIR 0x0000C000U /*!< VLAN Tag Insertion or Replacement mask */
  546. #define ETH_DMATXNDESCRF_VTIR_DISABLE 0x00000000U /*!< Do not add a VLAN tag. */
  547. #define ETH_DMATXNDESCRF_VTIR_REMOVE 0x00004000U /*!< Remove the VLAN tag from the packets before transmission. */
  548. #define ETH_DMATXNDESCRF_VTIR_INSERT 0x00008000U /*!< Insert a VLAN tag. */
  549. #define ETH_DMATXNDESCRF_VTIR_REPLACE 0x0000C000U /*!< Replace the VLAN tag. */
  550. #define ETH_DMATXNDESCRF_B1L 0x00003FFFU /*!< Buffer 1 Length */
  551. #define ETH_DMATXNDESCRF_HL 0x000003FFU /*!< Header Length */
  552. /**
  553. * @brief Bit definition of TDES3 RF register
  554. */
  555. #define ETH_DMATXNDESCRF_OWN 0x80000000U /*!< OWN bit: descriptor is owned by DMA engine */
  556. #define ETH_DMATXNDESCRF_CTXT 0x40000000U /*!< Context Type */
  557. #define ETH_DMATXNDESCRF_FD 0x20000000U /*!< First Descriptor */
  558. #define ETH_DMATXNDESCRF_LD 0x10000000U /*!< Last Descriptor */
  559. #define ETH_DMATXNDESCRF_CPC 0x0C000000U /*!< CRC Pad Control mask */
  560. #define ETH_DMATXNDESCRF_CPC_CRCPAD_INSERT 0x00000000U /*!< CRC Pad Control: CRC and Pad Insertion */
  561. #define ETH_DMATXNDESCRF_CPC_CRC_INSERT 0x04000000U /*!< CRC Pad Control: CRC Insertion (Disable Pad Insertion) */
  562. #define ETH_DMATXNDESCRF_CPC_DISABLE 0x08000000U /*!< CRC Pad Control: Disable CRC Insertion */
  563. #define ETH_DMATXNDESCRF_CPC_CRC_REPLACE 0x0C000000U /*!< CRC Pad Control: CRC Replacement */
  564. #define ETH_DMATXNDESCRF_SAIC 0x03800000U /*!< SA Insertion Control mask*/
  565. #define ETH_DMATXNDESCRF_SAIC_DISABLE 0x00000000U /*!< SA Insertion Control: Do not include the source address */
  566. #define ETH_DMATXNDESCRF_SAIC_INSERT 0x00800000U /*!< SA Insertion Control: Include or insert the source address */
  567. #define ETH_DMATXNDESCRF_SAIC_REPLACE 0x01000000U /*!< SA Insertion Control: Replace the source address */
  568. #define ETH_DMATXNDESCRF_THL 0x00780000U /*!< TCP Header Length */
  569. #define ETH_DMATXNDESCRF_TSE 0x00040000U /*!< TCP segmentation enable */
  570. #define ETH_DMATXNDESCRF_CIC 0x00030000U /*!< Checksum Insertion Control: 4 cases */
  571. #define ETH_DMATXNDESCRF_CIC_DISABLE 0x00000000U /*!< Do Nothing: Checksum Engine is disabled */
  572. #define ETH_DMATXNDESCRF_CIC_IPHDR_INSERT 0x00010000U /*!< Only IP header checksum calculation and insertion are enabled. */
  573. #define ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT 0x00020000U /*!< IP header checksum and payload checksum calculation and insertion are
  574. enabled, but pseudo header
  575. checksum is not
  576. calculated in hardware */
  577. #define ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC 0x00030000U /*!< IP Header checksum and payload checksum calculation and insertion are
  578. enabled, and pseudo header
  579. checksum is
  580. calculated in hardware. */
  581. #define ETH_DMATXNDESCRF_TPL 0x0003FFFFU /*!< TCP Payload Length */
  582. #define ETH_DMATXNDESCRF_FL 0x00007FFFU /*!< Transmit End of Ring */
  583. /*
  584. DMA Tx Normal Descriptor Write Back Format
  585. -----------------------------------------------------------------------------------------------
  586. TDES0 | Timestamp Low |
  587. -----------------------------------------------------------------------------------------------
  588. TDES1 | Timestamp High |
  589. -----------------------------------------------------------------------------------------------
  590. TDES2 | Reserved[31:0] |
  591. -----------------------------------------------------------------------------------------------
  592. TDES3 | OWN(31) | Status[30:0] |
  593. -----------------------------------------------------------------------------------------------
  594. */
  595. /**
  596. * @brief Bit definition of TDES0 WBF register
  597. */
  598. #define ETH_DMATXNDESCWBF_TTSL 0xFFFFFFFFU /*!< Buffer1 Address Pointer or TSO Header Address Pointer */
  599. /**
  600. * @brief Bit definition of TDES1 WBF register
  601. */
  602. #define ETH_DMATXNDESCWBF_TTSH 0xFFFFFFFFU /*!< Buffer2 Address Pointer */
  603. /**
  604. * @brief Bit definition of TDES3 WBF register
  605. */
  606. #define ETH_DMATXNDESCWBF_OWN 0x80000000U /*!< OWN bit: descriptor is owned by DMA engine */
  607. #define ETH_DMATXNDESCWBF_CTXT 0x40000000U /*!< Context Type */
  608. #define ETH_DMATXNDESCWBF_FD 0x20000000U /*!< First Descriptor */
  609. #define ETH_DMATXNDESCWBF_LD 0x10000000U /*!< Last Descriptor */
  610. #define ETH_DMATXNDESCWBF_TTSS 0x00020000U /*!< Tx Timestamp Status */
  611. #define ETH_DMATXNDESCWBF_DP 0x04000000U /*!< Disable Padding */
  612. #define ETH_DMATXNDESCWBF_TTSE 0x02000000U /*!< Transmit Timestamp Enable */
  613. #define ETH_DMATXNDESCWBF_ES 0x00008000U /*!< Error summary: OR of the following bits: IHE || UF || ED || EC || LCO || PCE || NC || LCA || FF || JT */
  614. #define ETH_DMATXNDESCWBF_JT 0x00004000U /*!< Jabber Timeout */
  615. #define ETH_DMATXNDESCWBF_FF 0x00002000U /*!< Packet Flushed: DMA/MTL flushed the packet due to SW flush */
  616. #define ETH_DMATXNDESCWBF_PCE 0x00001000U /*!< Payload Checksum Error */
  617. #define ETH_DMATXNDESCWBF_LCA 0x00000800U /*!< Loss of Carrier: carrier lost during transmission */
  618. #define ETH_DMATXNDESCWBF_NC 0x00000400U /*!< No Carrier: no carrier signal from the transceiver */
  619. #define ETH_DMATXNDESCWBF_LCO 0x00000200U /*!< Late Collision: transmission aborted due to collision */
  620. #define ETH_DMATXNDESCWBF_EC 0x00000100U /*!< Excessive Collision: transmission aborted after 16 collisions */
  621. #define ETH_DMATXNDESCWBF_CC 0x000000F0U /*!< Collision Count */
  622. #define ETH_DMATXNDESCWBF_ED 0x00000008U /*!< Excessive Deferral */
  623. #define ETH_DMATXNDESCWBF_UF 0x00000004U /*!< Underflow Error: late data arrival from the memory */
  624. #define ETH_DMATXNDESCWBF_DB 0x00000002U /*!< Deferred Bit */
  625. #define ETH_DMATXNDESCWBF_IHE 0x00000004U /*!< IP Header Error */
  626. /*
  627. DMA Tx Context Descriptor
  628. -----------------------------------------------------------------------------------------------
  629. TDES0 | Timestamp Low |
  630. -----------------------------------------------------------------------------------------------
  631. TDES1 | Timestamp High |
  632. -----------------------------------------------------------------------------------------------
  633. TDES2 | Inner VLAN Tag[31:16] | Reserved(15) | Maximum Segment Size [14:0] |
  634. -----------------------------------------------------------------------------------------------
  635. TDES3 | OWN(31) | Status[30:0] |
  636. -----------------------------------------------------------------------------------------------
  637. */
  638. /**
  639. * @brief Bit definition of Tx context descriptor register 0
  640. */
  641. #define ETH_DMATXCDESC_TTSL 0xFFFFFFFFU /*!< Transmit Packet Timestamp Low */
  642. /**
  643. * @brief Bit definition of Tx context descriptor register 1
  644. */
  645. #define ETH_DMATXCDESC_TTSH 0xFFFFFFFFU /*!< Transmit Packet Timestamp High */
  646. /**
  647. * @brief Bit definition of Tx context descriptor register 2
  648. */
  649. #define ETH_DMATXCDESC_IVT 0xFFFF0000U /*!< Inner VLAN Tag */
  650. #define ETH_DMATXCDESC_MSS 0x00003FFFU /*!< Maximum Segment Size */
  651. /**
  652. * @brief Bit definition of Tx context descriptor register 3
  653. */
  654. #define ETH_DMATXCDESC_OWN 0x80000000U /*!< OWN bit: descriptor is owned by DMA engine */
  655. #define ETH_DMATXCDESC_CTXT 0x40000000U /*!< Context Type */
  656. #define ETH_DMATXCDESC_OSTC 0x08000000U /*!< One-Step Timestamp Correction Enable */
  657. #define ETH_DMATXCDESC_TCMSSV 0x04000000U /*!< One-Step Timestamp Correction Input or MSS Valid */
  658. #define ETH_DMATXCDESC_CDE 0x00800000U /*!< Context Descriptor Error */
  659. #define ETH_DMATXCDESC_IVTIR 0x000C0000U /*!< Inner VLAN Tag Insert or Replace Mask */
  660. #define ETH_DMATXCDESC_IVTIR_DISABLE 0x00000000U /*!< Do not add the inner VLAN tag. */
  661. #define ETH_DMATXCDESC_IVTIR_REMOVE 0x00040000U /*!< Remove the inner VLAN tag from the packets before transmission. */
  662. #define ETH_DMATXCDESC_IVTIR_INSERT 0x00080000U /*!< Insert the inner VLAN tag. */
  663. #define ETH_DMATXCDESC_IVTIR_REPLACE 0x000C0000U /*!< Replace the inner VLAN tag. */
  664. #define ETH_DMATXCDESC_IVLTV 0x00020000U /*!< Inner VLAN Tag Valid */
  665. #define ETH_DMATXCDESC_VLTV 0x00010000U /*!< VLAN Tag Valid */
  666. #define ETH_DMATXCDESC_VT 0x0000FFFFU /*!< VLAN Tag */
  667. /**
  668. * @}
  669. */
  670. /** @defgroup ETH_DMA_Rx_Descriptor_Bit_Definition ETH DMA Rx Descriptor Bit Definition
  671. * @{
  672. */
  673. /*
  674. DMA Rx Normal Descriptor read format
  675. -----------------------------------------------------------------------------------------------------------
  676. RDES0 | Buffer1 or Header Address [31:0] |
  677. -----------------------------------------------------------------------------------------------------------
  678. RDES1 | Reserved |
  679. -----------------------------------------------------------------------------------------------------------
  680. RDES2 | Payload or Buffer2 Address[31:0] |
  681. -----------------------------------------------------------------------------------------------------------
  682. RDES3 | OWN(31) | IOC(30) | Reserved [29:26] | BUF2V(25) | BUF1V(24) | Reserved [23:0] |
  683. -----------------------------------------------------------------------------------------------------------
  684. */
  685. /**
  686. * @brief Bit definition of Rx normal descriptor register 0 read format
  687. */
  688. #define ETH_DMARXNDESCRF_BUF1AP 0xFFFFFFFFU /*!< Header or Buffer 1 Address Pointer */
  689. /**
  690. * @brief Bit definition of Rx normal descriptor register 2 read format
  691. */
  692. #define ETH_DMARXNDESCRF_BUF2AP 0xFFFFFFFFU /*!< Buffer 2 Address Pointer */
  693. /**
  694. * @brief Bit definition of Rx normal descriptor register 3 read format
  695. */
  696. #define ETH_DMARXNDESCRF_OWN 0x80000000U /*!< OWN bit: descriptor is owned by DMA engine */
  697. #define ETH_DMARXNDESCRF_IOC 0x40000000U /*!< Interrupt Enabled on Completion */
  698. #define ETH_DMARXNDESCRF_BUF2V 0x02000000U /*!< Buffer 2 Address Valid */
  699. #define ETH_DMARXNDESCRF_BUF1V 0x01000000U /*!< Buffer 1 Address Valid */
  700. /*
  701. DMA Rx Normal Descriptor write back format
  702. ---------------------------------------------------------------------------------------------------------------------
  703. RDES0 | Inner VLAN Tag[31:16] | Outer VLAN Tag[15:0] |
  704. ---------------------------------------------------------------------------------------------------------------------
  705. RDES1 | OAM code, or MAC Control Opcode [31:16] | Extended Status |
  706. ---------------------------------------------------------------------------------------------------------------------
  707. RDES2 | MAC Filter Status[31:16] | VF(15) | Reserved [14:12] | ARP Status [11:10] | Header Length [9:0] |
  708. ---------------------------------------------------------------------------------------------------------------------
  709. RDES3 | OWN(31) | CTXT(30) | FD(29) | LD(28) | Status[27:16] | ES(15) | Packet Length[14:0] |
  710. ---------------------------------------------------------------------------------------------------------------------
  711. */
  712. /**
  713. * @brief Bit definition of Rx normal descriptor register 0 write back format
  714. */
  715. #define ETH_DMARXNDESCWBF_IVT 0xFFFF0000U /*!< Inner VLAN Tag */
  716. #define ETH_DMARXNDESCWBF_OVT 0x0000FFFFU /*!< Outer VLAN Tag */
  717. /**
  718. * @brief Bit definition of Rx normal descriptor register 1 write back format
  719. */
  720. #define ETH_DMARXNDESCWBF_OPC 0xFFFF0000U /*!< OAM Sub-Type Code, or MAC Control Packet opcode */
  721. #define ETH_DMARXNDESCWBF_TD 0x00008000U /*!< Timestamp Dropped */
  722. #define ETH_DMARXNDESCWBF_TSA 0x00004000U /*!< Timestamp Available */
  723. #define ETH_DMARXNDESCWBF_PV 0x00002000U /*!< PTP Version */
  724. #define ETH_DMARXNDESCWBF_PFT 0x00001000U /*!< PTP Packet Type */
  725. #define ETH_DMARXNDESCWBF_PMT_NO 0x00000000U /*!< PTP Message Type: No PTP message received */
  726. #define ETH_DMARXNDESCWBF_PMT_SYNC 0x00000100U /*!< PTP Message Type: SYNC (all clock types) */
  727. #define ETH_DMARXNDESCWBF_PMT_FUP 0x00000200U /*!< PTP Message Type: Follow_Up (all clock types) */
  728. #define ETH_DMARXNDESCWBF_PMT_DREQ 0x00000300U /*!< PTP Message Type: Delay_Req (all clock types) */
  729. #define ETH_DMARXNDESCWBF_PMT_DRESP 0x00000400U /*!< PTP Message Type: Delay_Resp (all clock types) */
  730. #define ETH_DMARXNDESCWBF_PMT_PDREQ 0x00000500U /*!< PTP Message Type: Pdelay_Req (in peer-to-peer transparent clock) */
  731. #define ETH_DMARXNDESCWBF_PMT_PDRESP 0x00000600U /*!< PTP Message Type: Pdelay_Resp (in peer-to-peer transparent clock) */
  732. #define ETH_DMARXNDESCWBF_PMT_PDRESPFUP 0x00000700U /*!< PTP Message Type: Pdelay_Resp_Follow_Up (in peer-to-peer transparent clock) */
  733. #define ETH_DMARXNDESCWBF_PMT_ANNOUNCE 0x00000800U /*!< PTP Message Type: Announce */
  734. #define ETH_DMARXNDESCWBF_PMT_MANAG 0x00000900U /*!< PTP Message Type: Management */
  735. #define ETH_DMARXNDESCWBF_PMT_SIGN 0x00000A00U /*!< PTP Message Type: Signaling */
  736. #define ETH_DMARXNDESCWBF_PMT_RESERVED 0x00000F00U /*!< PTP Message Type: PTP packet with Reserved message type */
  737. #define ETH_DMARXNDESCWBF_IPCE 0x00000080U /*!< IP Payload Error */
  738. #define ETH_DMARXNDESCWBF_IPCB 0x00000040U /*!< IP Checksum Bypassed */
  739. #define ETH_DMARXNDESCWBF_IPV6 0x00000020U /*!< IPv6 header Present */
  740. #define ETH_DMARXNDESCWBF_IPV4 0x00000010U /*!< IPv4 header Present */
  741. #define ETH_DMARXNDESCWBF_IPHE 0x00000008U /*!< IP Header Error */
  742. #define ETH_DMARXNDESCWBF_PT 0x00000003U /*!< Payload Type mask */
  743. #define ETH_DMARXNDESCWBF_PT_UNKNOWN 0x00000000U /*!< Payload Type: Unknown type or IP/AV payload not processed */
  744. #define ETH_DMARXNDESCWBF_PT_UDP 0x00000001U /*!< Payload Type: UDP */
  745. #define ETH_DMARXNDESCWBF_PT_TCP 0x00000002U /*!< Payload Type: TCP */
  746. #define ETH_DMARXNDESCWBF_PT_ICMP 0x00000003U /*!< Payload Type: ICMP */
  747. /**
  748. * @brief Bit definition of Rx normal descriptor register 2 write back format
  749. */
  750. #define ETH_DMARXNDESCWBF_L3L4FM 0x20000000U /*!< L3 and L4 Filter Number Matched: if reset filter 0 is matched , if set filter 1 is matched */
  751. #define ETH_DMARXNDESCWBF_L4FM 0x10000000U /*!< Layer 4 Filter Match */
  752. #define ETH_DMARXNDESCWBF_L3FM 0x08000000U /*!< Layer 3 Filter Match */
  753. #define ETH_DMARXNDESCWBF_MADRM 0x07F80000U /*!< MAC Address Match or Hash Value */
  754. #define ETH_DMARXNDESCWBF_HF 0x00040000U /*!< Hash Filter Status */
  755. #define ETH_DMARXNDESCWBF_DAF 0x00020000U /*!< Destination Address Filter Fail */
  756. #define ETH_DMARXNDESCWBF_SAF 0x00010000U /*!< SA Address Filter Fail */
  757. #define ETH_DMARXNDESCWBF_VF 0x00008000U /*!< VLAN Filter Status */
  758. #define ETH_DMARXNDESCWBF_ARPNR 0x00000400U /*!< ARP Reply Not Generated */
  759. /**
  760. * @brief Bit definition of Rx normal descriptor register 3 write back format
  761. */
  762. #define ETH_DMARXNDESCWBF_OWN 0x80000000U /*!< Own Bit */
  763. #define ETH_DMARXNDESCWBF_CTXT 0x40000000U /*!< Receive Context Descriptor */
  764. #define ETH_DMARXNDESCWBF_FD 0x20000000U /*!< First Descriptor */
  765. #define ETH_DMARXNDESCWBF_LD 0x10000000U /*!< Last Descriptor */
  766. #define ETH_DMARXNDESCWBF_RS2V 0x08000000U /*!< Receive Status RDES2 Valid */
  767. #define ETH_DMARXNDESCWBF_RS1V 0x04000000U /*!< Receive Status RDES1 Valid */
  768. #define ETH_DMARXNDESCWBF_RS0V 0x02000000U /*!< Receive Status RDES0 Valid */
  769. #define ETH_DMARXNDESCWBF_CE 0x01000000U /*!< CRC Error */
  770. #define ETH_DMARXNDESCWBF_GP 0x00800000U /*!< Giant Packet */
  771. #define ETH_DMARXNDESCWBF_RWT 0x00400000U /*!< Receive Watchdog Timeout */
  772. #define ETH_DMARXNDESCWBF_OE 0x00200000U /*!< Overflow Error */
  773. #define ETH_DMARXNDESCWBF_RE 0x00100000U /*!< Receive Error */
  774. #define ETH_DMARXNDESCWBF_DE 0x00080000U /*!< Dribble Bit Error */
  775. #define ETH_DMARXNDESCWBF_LT 0x00070000U /*!< Length/Type Field */
  776. #define ETH_DMARXNDESCWBF_LT_LP 0x00000000U /*!< The packet is a length packet */
  777. #define ETH_DMARXNDESCWBF_LT_TP 0x00010000U /*!< The packet is a type packet */
  778. #define ETH_DMARXNDESCWBF_LT_ARP 0x00030000U /*!< The packet is a ARP Request packet type */
  779. #define ETH_DMARXNDESCWBF_LT_VLAN 0x00040000U /*!< The packet is a type packet with VLAN Tag */
  780. #define ETH_DMARXNDESCWBF_LT_DVLAN 0x00050000U /*!< The packet is a type packet with Double VLAN Tag */
  781. #define ETH_DMARXNDESCWBF_LT_MAC 0x00060000U /*!< The packet is a MAC Control packet type */
  782. #define ETH_DMARXNDESCWBF_LT_OAM 0x00070000U /*!< The packet is a OAM packet type */
  783. #define ETH_DMARXNDESCWBF_ES 0x00008000U /*!< Error Summary */
  784. #define ETH_DMARXNDESCWBF_PL 0x00007FFFU /*!< Packet Length */
  785. /*
  786. DMA Rx context Descriptor
  787. ---------------------------------------------------------------------------------------------------------------------
  788. RDES0 | Timestamp Low[31:0] |
  789. ---------------------------------------------------------------------------------------------------------------------
  790. RDES1 | Timestamp High[31:0] |
  791. ---------------------------------------------------------------------------------------------------------------------
  792. RDES2 | Reserved |
  793. ---------------------------------------------------------------------------------------------------------------------
  794. RDES3 | OWN(31) | CTXT(30) | Reserved[29:0] |
  795. ---------------------------------------------------------------------------------------------------------------------
  796. */
  797. /**
  798. * @brief Bit definition of Rx context descriptor register 0
  799. */
  800. #define ETH_DMARXCDESC_RTSL 0xFFFFFFFFU /*!< Receive Packet Timestamp Low */
  801. /**
  802. * @brief Bit definition of Rx context descriptor register 1
  803. */
  804. #define ETH_DMARXCDESC_RTSH 0xFFFFFFFFU /*!< Receive Packet Timestamp High */
  805. /**
  806. * @brief Bit definition of Rx context descriptor register 3
  807. */
  808. #define ETH_DMARXCDESC_OWN 0x80000000U /*!< Own Bit */
  809. #define ETH_DMARXCDESC_CTXT 0x40000000U /*!< Receive Context Descriptor */
  810. /**
  811. * @}
  812. */
  813. /** @defgroup ETH_Frame_settings ETH frame settings
  814. * @{
  815. */
  816. #define ETH_MAX_PACKET_SIZE 1528U /*!< ETH_HEADER + 2*VLAN_TAG + MAX_ETH_PAYLOAD + ETH_CRC */
  817. #define ETH_HEADER 14U /*!< 6 byte Dest addr, 6 byte Src addr, 2 byte length/type */
  818. #define ETH_CRC 4U /*!< Ethernet CRC */
  819. #define ETH_VLAN_TAG 4U /*!< optional 802.1q VLAN Tag */
  820. #define ETH_MIN_PAYLOAD 46U /*!< Minimum Ethernet payload size */
  821. #define ETH_MAX_PAYLOAD 1500U /*!< Maximum Ethernet payload size */
  822. #define ETH_JUMBO_FRAME_PAYLOAD 9000U /*!< Jumbo frame payload size */
  823. /**
  824. * @}
  825. */
  826. /** @defgroup ETH_Error_Code ETH Error Code
  827. * @{
  828. */
  829. #define HAL_ETH_ERROR_NONE 0x00000000U /*!< No error */
  830. #define HAL_ETH_ERROR_PARAM 0x00000001U /*!< Busy error */
  831. #define HAL_ETH_ERROR_BUSY 0x00000002U /*!< Parameter error */
  832. #define HAL_ETH_ERROR_TIMEOUT 0x00000004U /*!< Timeout error */
  833. #define HAL_ETH_ERROR_DMA 0x00000008U /*!< DMA transfer error */
  834. #define HAL_ETH_ERROR_MAC 0x00000010U /*!< MAC transfer error */
  835. #if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
  836. #define HAL_ETH_ERROR_INVALID_CALLBACK 0x00000020U /*!< Invalid Callback error */
  837. #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
  838. /**
  839. * @}
  840. */
  841. /** @defgroup ETH_Tx_Packet_Attributes ETH Tx Packet Attributes
  842. * @{
  843. */
  844. #define ETH_TX_PACKETS_FEATURES_CSUM 0x00000001U
  845. #define ETH_TX_PACKETS_FEATURES_SAIC 0x00000002U
  846. #define ETH_TX_PACKETS_FEATURES_VLANTAG 0x00000004U
  847. #define ETH_TX_PACKETS_FEATURES_INNERVLANTAG 0x00000008U
  848. #define ETH_TX_PACKETS_FEATURES_TSO 0x00000010U
  849. #define ETH_TX_PACKETS_FEATURES_CRCPAD 0x00000020U
  850. /**
  851. * @}
  852. */
  853. /** @defgroup ETH_Tx_Packet_Source_Addr_Control ETH Tx Packet Source Addr Control
  854. * @{
  855. */
  856. #define ETH_SRC_ADDR_CONTROL_DISABLE ETH_DMATXNDESCRF_SAIC_DISABLE
  857. #define ETH_SRC_ADDR_INSERT ETH_DMATXNDESCRF_SAIC_INSERT
  858. #define ETH_SRC_ADDR_REPLACE ETH_DMATXNDESCRF_SAIC_REPLACE
  859. /**
  860. * @}
  861. */
  862. /** @defgroup ETH_Tx_Packet_CRC_Pad_Control ETH Tx Packet CRC Pad Control
  863. * @{
  864. */
  865. #define ETH_CRC_PAD_DISABLE ETH_DMATXNDESCRF_CPC_DISABLE
  866. #define ETH_CRC_PAD_INSERT ETH_DMATXNDESCRF_CPC_CRCPAD_INSERT
  867. #define ETH_CRC_INSERT ETH_DMATXNDESCRF_CPC_CRC_INSERT
  868. #define ETH_CRC_REPLACE ETH_DMATXNDESCRF_CPC_CRC_REPLACE
  869. /**
  870. * @}
  871. */
  872. /** @defgroup ETH_Tx_Packet_Checksum_Control ETH Tx Packet Checksum Control
  873. * @{
  874. */
  875. #define ETH_CHECKSUM_DISABLE ETH_DMATXNDESCRF_CIC_DISABLE
  876. #define ETH_CHECKSUM_IPHDR_INSERT ETH_DMATXNDESCRF_CIC_IPHDR_INSERT
  877. #define ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT
  878. #define ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC
  879. /**
  880. * @}
  881. */
  882. /** @defgroup ETH_Tx_Packet_VLAN_Control ETH Tx Packet VLAN Control
  883. * @{
  884. */
  885. #define ETH_VLAN_DISABLE ETH_DMATXNDESCRF_VTIR_DISABLE
  886. #define ETH_VLAN_REMOVE ETH_DMATXNDESCRF_VTIR_REMOVE
  887. #define ETH_VLAN_INSERT ETH_DMATXNDESCRF_VTIR_INSERT
  888. #define ETH_VLAN_REPLACE ETH_DMATXNDESCRF_VTIR_REPLACE
  889. /**
  890. * @}
  891. */
  892. /** @defgroup ETH_Tx_Packet_Inner_VLAN_Control ETH Tx Packet Inner VLAN Control
  893. * @{
  894. */
  895. #define ETH_INNER_VLAN_DISABLE ETH_DMATXCDESC_IVTIR_DISABLE
  896. #define ETH_INNER_VLAN_REMOVE ETH_DMATXCDESC_IVTIR_REMOVE
  897. #define ETH_INNER_VLAN_INSERT ETH_DMATXCDESC_IVTIR_INSERT
  898. #define ETH_INNER_VLAN_REPLACE ETH_DMATXCDESC_IVTIR_REPLACE
  899. /**
  900. * @}
  901. */
  902. /** @defgroup ETH_Rx_Checksum_Status ETH Rx Checksum Status
  903. * @{
  904. */
  905. #define ETH_CHECKSUM_BYPASSED ETH_DMARXNDESCWBF_IPCB
  906. #define ETH_CHECKSUM_IP_HEADER_ERROR ETH_DMARXNDESCWBF_IPHE
  907. #define ETH_CHECKSUM_IP_PAYLOAD_ERROR ETH_DMARXNDESCWBF_IPCE
  908. /**
  909. * @}
  910. */
  911. /** @defgroup ETH_Rx_IP_Header_Type ETH Rx IP Header Type
  912. * @{
  913. */
  914. #define ETH_IP_HEADER_IPV4 ETH_DMARXNDESCWBF_IPV4
  915. #define ETH_IP_HEADER_IPV6 ETH_DMARXNDESCWBF_IPV6
  916. /**
  917. * @}
  918. */
  919. /** @defgroup ETH_Rx_Payload_Type ETH Rx Payload Type
  920. * @{
  921. */
  922. #define ETH_IP_PAYLOAD_UNKNOWN ETH_DMARXNDESCWBF_PT_UNKNOWN
  923. #define ETH_IP_PAYLOAD_UDP ETH_DMARXNDESCWBF_PT_UDP
  924. #define ETH_IP_PAYLOAD_TCP ETH_DMARXNDESCWBF_PT_TCP
  925. #define ETH_IP_PAYLOAD_ICMPN ETH_DMARXNDESCWBF_PT_ICMP
  926. /**
  927. * @}
  928. */
  929. /** @defgroup ETH_Rx_MAC_Filter_Status ETH Rx MAC Filter Status
  930. * @{
  931. */
  932. #define ETH_HASH_FILTER_PASS ETH_DMARXNDESCWBF_HF
  933. #define ETH_VLAN_FILTER_PASS ETH_DMARXNDESCWBF_VF
  934. #define ETH_DEST_ADDRESS_FAIL ETH_DMARXNDESCWBF_DAF
  935. #define ETH_SOURCE_ADDRESS_FAIL ETH_DMARXNDESCWBF_SAF
  936. /**
  937. * @}
  938. */
  939. /** @defgroup ETH_Rx_L3_Filter_Status ETH Rx L3 Filter Status
  940. * @{
  941. */
  942. #define ETH_L3_FILTER0_MATCH ETH_DMARXNDESCWBF_L3FM
  943. #define ETH_L3_FILTER1_MATCH (ETH_DMARXNDESCWBF_L3FM | ETH_DMARXNDESCWBF_L3L4FM)
  944. /**
  945. * @}
  946. */
  947. /** @defgroup ETH_Rx_L4_Filter_Status ETH Rx L4 Filter Status
  948. * @{
  949. */
  950. #define ETH_L4_FILTER0_MATCH ETH_DMARXNDESCWBF_L4FM
  951. #define ETH_L4_FILTER1_MATCH (ETH_DMARXNDESCWBF_L4FM | ETH_DMARXNDESCWBF_L3L4FM)
  952. /**
  953. * @}
  954. */
  955. /** @defgroup ETH_Rx_Error_Code ETH Rx Error Code
  956. * @{
  957. */
  958. #define ETH_DRIBBLE_BIT_ERROR ETH_DMARXNDESCWBF_DE
  959. #define ETH_RECEIVE_ERROR ETH_DMARXNDESCWBF_RE
  960. #define ETH_RECEIVE_OVERFLOW ETH_DMARXNDESCWBF_OE
  961. #define ETH_WATCHDOG_TIMEOUT ETH_DMARXNDESCWBF_RWT
  962. #define ETH_GIANT_PACKET ETH_DMARXNDESCWBF_GP
  963. #define ETH_CRC_ERROR ETH_DMARXNDESCWBF_CE
  964. /**
  965. * @}
  966. */
  967. /** @defgroup ETH_DMA_Arbitration ETH DMA Arbitration
  968. * @{
  969. */
  970. #define ETH_DMAARBITRATION_RX ETH_DMAMR_DA
  971. #define ETH_DMAARBITRATION_RX1_TX1 0x00000000U
  972. #define ETH_DMAARBITRATION_RX2_TX1 ETH_DMAMR_PR_2_1
  973. #define ETH_DMAARBITRATION_RX3_TX1 ETH_DMAMR_PR_3_1
  974. #define ETH_DMAARBITRATION_RX4_TX1 ETH_DMAMR_PR_4_1
  975. #define ETH_DMAARBITRATION_RX5_TX1 ETH_DMAMR_PR_5_1
  976. #define ETH_DMAARBITRATION_RX6_TX1 ETH_DMAMR_PR_6_1
  977. #define ETH_DMAARBITRATION_RX7_TX1 ETH_DMAMR_PR_7_1
  978. #define ETH_DMAARBITRATION_RX8_TX1 ETH_DMAMR_PR_8_1
  979. #define ETH_DMAARBITRATION_TX (ETH_DMAMR_TXPR | ETH_DMAMR_DA)
  980. #define ETH_DMAARBITRATION_TX1_RX1 0x00000000U
  981. #define ETH_DMAARBITRATION_TX2_RX1 (ETH_DMAMR_TXPR | ETH_DMAMR_PR_2_1)
  982. #define ETH_DMAARBITRATION_TX3_RX1 (ETH_DMAMR_TXPR | ETH_DMAMR_PR_3_1)
  983. #define ETH_DMAARBITRATION_TX4_RX1 (ETH_DMAMR_TXPR | ETH_DMAMR_PR_4_1)
  984. #define ETH_DMAARBITRATION_TX5_RX1 (ETH_DMAMR_TXPR | ETH_DMAMR_PR_5_1)
  985. #define ETH_DMAARBITRATION_TX6_RX1 (ETH_DMAMR_TXPR | ETH_DMAMR_PR_6_1)
  986. #define ETH_DMAARBITRATION_TX7_RX1 (ETH_DMAMR_TXPR | ETH_DMAMR_PR_7_1)
  987. #define ETH_DMAARBITRATION_TX8_RX1 (ETH_DMAMR_TXPR | ETH_DMAMR_PR_8_1)
  988. /**
  989. * @}
  990. */
  991. /** @defgroup ETH_Burst_Mode ETH Burst Mode
  992. * @{
  993. */
  994. #define ETH_BURSTLENGTH_FIXED ETH_DMASBMR_FB
  995. #define ETH_BURSTLENGTH_MIXED ETH_DMASBMR_MB
  996. #define ETH_BURSTLENGTH_UNSPECIFIED 0x00000000U
  997. /**
  998. * @}
  999. */
  1000. /** @defgroup ETH_Tx_DMA_Burst_Length ETH Tx DMA Burst Length
  1001. * @{
  1002. */
  1003. #define ETH_TXDMABURSTLENGTH_1BEAT ETH_DMACTCR_TPBL_1PBL
  1004. #define ETH_TXDMABURSTLENGTH_2BEAT ETH_DMACTCR_TPBL_2PBL
  1005. #define ETH_TXDMABURSTLENGTH_4BEAT ETH_DMACTCR_TPBL_4PBL
  1006. #define ETH_TXDMABURSTLENGTH_8BEAT ETH_DMACTCR_TPBL_8PBL
  1007. #define ETH_TXDMABURSTLENGTH_16BEAT ETH_DMACTCR_TPBL_16PBL
  1008. #define ETH_TXDMABURSTLENGTH_32BEAT ETH_DMACTCR_TPBL_32PBL
  1009. /**
  1010. * @}
  1011. */
  1012. /** @defgroup ETH_Rx_DMA_Burst_Length ETH Rx DMA Burst Length
  1013. * @{
  1014. */
  1015. #define ETH_RXDMABURSTLENGTH_1BEAT ETH_DMACRCR_RPBL_1PBL
  1016. #define ETH_RXDMABURSTLENGTH_2BEAT ETH_DMACRCR_RPBL_2PBL
  1017. #define ETH_RXDMABURSTLENGTH_4BEAT ETH_DMACRCR_RPBL_4PBL
  1018. #define ETH_RXDMABURSTLENGTH_8BEAT ETH_DMACRCR_RPBL_8PBL
  1019. #define ETH_RXDMABURSTLENGTH_16BEAT ETH_DMACRCR_RPBL_16PBL
  1020. #define ETH_RXDMABURSTLENGTH_32BEAT ETH_DMACRCR_RPBL_32PBL
  1021. /**
  1022. * @}
  1023. */
  1024. /** @defgroup ETH_DMA_Interrupts ETH DMA Interrupts
  1025. * @{
  1026. */
  1027. #define ETH_DMA_NORMAL_IT ETH_DMACIER_NIE
  1028. #define ETH_DMA_ABNORMAL_IT ETH_DMACIER_AIE
  1029. #define ETH_DMA_CONTEXT_DESC_ERROR_IT ETH_DMACIER_CDEE
  1030. #define ETH_DMA_FATAL_BUS_ERROR_IT ETH_DMACIER_FBEE
  1031. #define ETH_DMA_EARLY_RX_IT ETH_DMACIER_ERIE
  1032. #define ETH_DMA_EARLY_TX_IT ETH_DMACIER_ETIE
  1033. #define ETH_DMA_RX_WATCHDOG_TIMEOUT_IT ETH_DMACIER_RWTE
  1034. #define ETH_DMA_RX_PROCESS_STOPPED_IT ETH_DMACIER_RSE
  1035. #define ETH_DMA_RX_BUFFER_UNAVAILABLE_IT ETH_DMACIER_RBUE
  1036. #define ETH_DMA_RX_IT ETH_DMACIER_RIE
  1037. #define ETH_DMA_TX_BUFFER_UNAVAILABLE_IT ETH_DMACIER_TBUE
  1038. #define ETH_DMA_TX_PROCESS_STOPPED_IT ETH_DMACIER_TXSE
  1039. #define ETH_DMA_TX_IT ETH_DMACIER_TIE
  1040. /**
  1041. * @}
  1042. */
  1043. /** @defgroup ETH_DMA_Status_Flags ETH DMA Status Flags
  1044. * @{
  1045. */
  1046. #define ETH_DMA_RX_NO_ERROR_FLAG 0x00000000U
  1047. #define ETH_DMA_RX_DESC_READ_ERROR_FLAG (ETH_DMACSR_REB_BIT_2 | ETH_DMACSR_REB_BIT_1 | ETH_DMACSR_REB_BIT_0)
  1048. #define ETH_DMA_RX_DESC_WRITE_ERROR_FLAG (ETH_DMACSR_REB_BIT_2 | ETH_DMACSR_REB_BIT_1)
  1049. #define ETH_DMA_RX_BUFFER_READ_ERROR_FLAG (ETH_DMACSR_REB_BIT_2 | ETH_DMACSR_REB_BIT_0)
  1050. #define ETH_DMA_RX_BUFFER_WRITE_ERROR_FLAG ETH_DMACSR_REB_BIT_2
  1051. #define ETH_DMA_TX_NO_ERROR_FLAG 0x00000000U
  1052. #define ETH_DMA_TX_DESC_READ_ERROR_FLAG (ETH_DMACSR_TEB_BIT_2 | ETH_DMACSR_TEB_BIT_1 | ETH_DMACSR_TEB_BIT_0)
  1053. #define ETH_DMA_TX_DESC_WRITE_ERROR_FLAG (ETH_DMACSR_TEB_BIT_2 | ETH_DMACSR_TEB_BIT_1)
  1054. #define ETH_DMA_TX_BUFFER_READ_ERROR_FLAG (ETH_DMACSR_TEB_BIT_2 | ETH_DMACSR_TEB_BIT_0)
  1055. #define ETH_DMA_TX_BUFFER_WRITE_ERROR_FLAG ETH_DMACSR_TEB_BIT_2
  1056. #define ETH_DMA_CONTEXT_DESC_ERROR_FLAG ETH_DMACSR_CDE
  1057. #define ETH_DMA_FATAL_BUS_ERROR_FLAG ETH_DMACSR_FBE
  1058. #define ETH_DMA_EARLY_TX_IT_FLAG ETH_DMACSR_ERI
  1059. #define ETH_DMA_RX_WATCHDOG_TIMEOUT_FLAG ETH_DMACSR_RWT
  1060. #define ETH_DMA_RX_PROCESS_STOPPED_FLAG ETH_DMACSR_RPS
  1061. #define ETH_DMA_RX_BUFFER_UNAVAILABLE_FLAG ETH_DMACSR_RBU
  1062. #define ETH_DMA_TX_PROCESS_STOPPED_FLAG ETH_DMACSR_TPS
  1063. /**
  1064. * @}
  1065. */
  1066. /** @defgroup ETH_Transmit_Mode ETH Transmit Mode
  1067. * @{
  1068. */
  1069. #define ETH_TRANSMITSTOREFORWARD ETH_MTLTQOMR_TSF
  1070. #define ETH_TRANSMITTHRESHOLD_32 ETH_MTLTQOMR_TTC_32BITS
  1071. #define ETH_TRANSMITTHRESHOLD_64 ETH_MTLTQOMR_TTC_64BITS
  1072. #define ETH_TRANSMITTHRESHOLD_96 ETH_MTLTQOMR_TTC_96BITS
  1073. #define ETH_TRANSMITTHRESHOLD_128 ETH_MTLTQOMR_TTC_128BITS
  1074. #define ETH_TRANSMITTHRESHOLD_192 ETH_MTLTQOMR_TTC_192BITS
  1075. #define ETH_TRANSMITTHRESHOLD_256 ETH_MTLTQOMR_TTC_256BITS
  1076. #define ETH_TRANSMITTHRESHOLD_384 ETH_MTLTQOMR_TTC_384BITS
  1077. #define ETH_TRANSMITTHRESHOLD_512 ETH_MTLTQOMR_TTC_512BITS
  1078. /**
  1079. * @}
  1080. */
  1081. /** @defgroup ETH_Receive_Mode ETH Receive Mode
  1082. * @{
  1083. */
  1084. #define ETH_RECEIVESTOREFORWARD ETH_MTLRQOMR_RSF
  1085. #define ETH_RECEIVETHRESHOLD8_64 ETH_MTLRQOMR_RTC_64BITS
  1086. #define ETH_RECEIVETHRESHOLD8_32 ETH_MTLRQOMR_RTC_32BITS
  1087. #define ETH_RECEIVETHRESHOLD8_96 ETH_MTLRQOMR_RTC_96BITS
  1088. #define ETH_RECEIVETHRESHOLD8_128 ETH_MTLRQOMR_RTC_128BITS
  1089. /**
  1090. * @}
  1091. */
  1092. /** @defgroup ETH_Pause_Low_Threshold ETH Pause Low Threshold
  1093. * @{
  1094. */
  1095. #define ETH_PAUSELOWTHRESHOLD_MINUS_4 ETH_MACTFCR_PLT_MINUS4
  1096. #define ETH_PAUSELOWTHRESHOLD_MINUS_28 ETH_MACTFCR_PLT_MINUS28
  1097. #define ETH_PAUSELOWTHRESHOLD_MINUS_36 ETH_MACTFCR_PLT_MINUS36
  1098. #define ETH_PAUSELOWTHRESHOLD_MINUS_144 ETH_MACTFCR_PLT_MINUS144
  1099. #define ETH_PAUSELOWTHRESHOLD_MINUS_256 ETH_MACTFCR_PLT_MINUS256
  1100. #define ETH_PAUSELOWTHRESHOLD_MINUS_512 ETH_MACTFCR_PLT_MINUS512
  1101. /**
  1102. * @}
  1103. */
  1104. /** @defgroup ETH_Watchdog_Timeout ETH Watchdog Timeout
  1105. * @{
  1106. */
  1107. #define ETH_WATCHDOGTIMEOUT_2KB ETH_MACWTR_WTO_2KB
  1108. #define ETH_WATCHDOGTIMEOUT_3KB ETH_MACWTR_WTO_3KB
  1109. #define ETH_WATCHDOGTIMEOUT_4KB ETH_MACWTR_WTO_4KB
  1110. #define ETH_WATCHDOGTIMEOUT_5KB ETH_MACWTR_WTO_5KB
  1111. #define ETH_WATCHDOGTIMEOUT_6KB ETH_MACWTR_WTO_6KB
  1112. #define ETH_WATCHDOGTIMEOUT_7KB ETH_MACWTR_WTO_7KB
  1113. #define ETH_WATCHDOGTIMEOUT_8KB ETH_MACWTR_WTO_8KB
  1114. #define ETH_WATCHDOGTIMEOUT_9KB ETH_MACWTR_WTO_9KB
  1115. #define ETH_WATCHDOGTIMEOUT_10KB ETH_MACWTR_WTO_10KB
  1116. #define ETH_WATCHDOGTIMEOUT_11KB ETH_MACWTR_WTO_12KB
  1117. #define ETH_WATCHDOGTIMEOUT_12KB ETH_MACWTR_WTO_12KB
  1118. #define ETH_WATCHDOGTIMEOUT_13KB ETH_MACWTR_WTO_13KB
  1119. #define ETH_WATCHDOGTIMEOUT_14KB ETH_MACWTR_WTO_14KB
  1120. #define ETH_WATCHDOGTIMEOUT_15KB ETH_MACWTR_WTO_15KB
  1121. #define ETH_WATCHDOGTIMEOUT_16KB ETH_MACWTR_WTO_16KB
  1122. /**
  1123. * @}
  1124. */
  1125. /** @defgroup ETH_Inter_Packet_Gap ETH Inter Packet Gap
  1126. * @{
  1127. */
  1128. #define ETH_INTERPACKETGAP_96BIT ETH_MACCR_IPG_96BIT
  1129. #define ETH_INTERPACKETGAP_88BIT ETH_MACCR_IPG_88BIT
  1130. #define ETH_INTERPACKETGAP_80BIT ETH_MACCR_IPG_80BIT
  1131. #define ETH_INTERPACKETGAP_72BIT ETH_MACCR_IPG_72BIT
  1132. #define ETH_INTERPACKETGAP_64BIT ETH_MACCR_IPG_64BIT
  1133. #define ETH_INTERPACKETGAP_56BIT ETH_MACCR_IPG_56BIT
  1134. #define ETH_INTERPACKETGAP_48BIT ETH_MACCR_IPG_48BIT
  1135. #define ETH_INTERPACKETGAP_40BIT ETH_MACCR_IPG_40BIT
  1136. /**
  1137. * @}
  1138. */
  1139. /** @defgroup ETH_Speed ETH Speed
  1140. * @{
  1141. */
  1142. #define ETH_SPEED_10M 0x00000000U
  1143. #define ETH_SPEED_100M ETH_MACCR_FES
  1144. /**
  1145. * @}
  1146. */
  1147. /** @defgroup ETH_Duplex_Mode ETH Duplex Mode
  1148. * @{
  1149. */
  1150. #define ETH_FULLDUPLEX_MODE ETH_MACCR_DM
  1151. #define ETH_HALFDUPLEX_MODE 0x00000000U
  1152. /**
  1153. * @}
  1154. */
  1155. /** @defgroup ETH_Back_Off_Limit ETH Back Off Limit
  1156. * @{
  1157. */
  1158. #define ETH_BACKOFFLIMIT_10 ETH_MACCR_BL_10
  1159. #define ETH_BACKOFFLIMIT_8 ETH_MACCR_BL_8
  1160. #define ETH_BACKOFFLIMIT_4 ETH_MACCR_BL_4
  1161. #define ETH_BACKOFFLIMIT_1 ETH_MACCR_BL_1
  1162. /**
  1163. * @}
  1164. */
  1165. /** @defgroup ETH_Preamble_Length ETH Preamble Length
  1166. * @{
  1167. */
  1168. #define ETH_PREAMBLELENGTH_7 ETH_MACCR_PRELEN_7
  1169. #define ETH_PREAMBLELENGTH_5 ETH_MACCR_PRELEN_5
  1170. #define ETH_PREAMBLELENGTH_3 ETH_MACCR_PRELEN_3
  1171. /**
  1172. * @}
  1173. */
  1174. /** @defgroup ETH_Source_Addr_Control ETH Source Addr Control
  1175. * @{
  1176. */
  1177. #define ETH_SOURCEADDRESS_DISABLE 0x00000000U
  1178. #define ETH_SOURCEADDRESS_INSERT_ADDR0 ETH_MACCR_SARC_INSADDR0
  1179. #define ETH_SOURCEADDRESS_INSERT_ADDR1 ETH_MACCR_SARC_INSADDR1
  1180. #define ETH_SOURCEADDRESS_REPLACE_ADDR0 ETH_MACCR_SARC_REPADDR0
  1181. #define ETH_SOURCEADDRESS_REPLACE_ADDR1 ETH_MACCR_SARC_REPADDR1
  1182. /**
  1183. * @}
  1184. */
  1185. /** @defgroup ETH_Control_Packets_Filter ETH Control Packets Filter
  1186. * @{
  1187. */
  1188. #define ETH_CTRLPACKETS_BLOCK_ALL ETH_MACPFR_PCF_BLOCKALL
  1189. #define ETH_CTRLPACKETS_FORWARD_ALL_EXCEPT_PA ETH_MACPFR_PCF_FORWARDALLEXCEPTPA
  1190. #define ETH_CTRLPACKETS_FORWARD_ALL ETH_MACPFR_PCF_FORWARDALL
  1191. #define ETH_CTRLPACKETS_FORWARD_PASSED_ADDR_FILTER ETH_MACPFR_PCF_FORWARDPASSEDADDRFILTER
  1192. /**
  1193. * @}
  1194. */
  1195. /** @defgroup ETH_VLAN_Tag_Comparison ETH VLAN Tag Comparison
  1196. * @{
  1197. */
  1198. #define ETH_VLANTAGCOMPARISON_16BIT 0x00000000U
  1199. #define ETH_VLANTAGCOMPARISON_12BIT ETH_MACVTR_ETV
  1200. /**
  1201. * @}
  1202. */
  1203. /** @defgroup ETH_MAC_addresses ETH MAC addresses
  1204. * @{
  1205. */
  1206. #define ETH_MAC_ADDRESS0 0x00000000U
  1207. #define ETH_MAC_ADDRESS1 0x00000008U
  1208. #define ETH_MAC_ADDRESS2 0x00000010U
  1209. #define ETH_MAC_ADDRESS3 0x00000018U
  1210. /**
  1211. * @}
  1212. */
  1213. /** @defgroup ETH_MAC_Interrupts ETH MAC Interrupts
  1214. * @{
  1215. */
  1216. #define ETH_MAC_RX_STATUS_IT ETH_MACIER_RXSTSIE
  1217. #define ETH_MAC_TX_STATUS_IT ETH_MACIER_TXSTSIE
  1218. #define ETH_MAC_TIMESTAMP_IT ETH_MACIER_TSIE
  1219. #define ETH_MAC_LPI_IT ETH_MACIER_LPIIE
  1220. #define ETH_MAC_PMT_IT ETH_MACIER_PMTIE
  1221. #define ETH_MAC_PHY_IT ETH_MACIER_PHYIE
  1222. /**
  1223. * @}
  1224. */
  1225. /** @defgroup ETH_MAC_Wake_Up_Event ETH MAC Wake Up Event
  1226. * @{
  1227. */
  1228. #define ETH_WAKEUP_PACKET_RECIEVED ETH_MACPCSR_RWKPRCVD
  1229. #define ETH_MAGIC_PACKET_RECIEVED ETH_MACPCSR_MGKPRCVD
  1230. /**
  1231. * @}
  1232. */
  1233. /** @defgroup ETH_MAC_Rx_Tx_Status ETH MAC Rx Tx Status
  1234. * @{
  1235. */
  1236. #define ETH_RECEIVE_WATCHDOG_TIMEOUT ETH_MACRXTXSR_RWT
  1237. #define ETH_EXECESSIVE_COLLISIONS ETH_MACRXTXSR_EXCOL
  1238. #define ETH_LATE_COLLISIONS ETH_MACRXTXSR_LCOL
  1239. #define ETH_EXECESSIVE_DEFERRAL ETH_MACRXTXSR_EXDEF
  1240. #define ETH_LOSS_OF_CARRIER ETH_MACRXTXSR_LCARR
  1241. #define ETH_NO_CARRIER ETH_MACRXTXSR_NCARR
  1242. #define ETH_TRANSMIT_JABBR_TIMEOUT ETH_MACRXTXSR_TJT
  1243. /**
  1244. * @}
  1245. */
  1246. /** @defgroup ETH_State_Codes ETH States
  1247. * @{
  1248. */
  1249. #define HAL_ETH_STATE_RESET 0x00000000U /*!< Peripheral not yet Initialized or disabled */
  1250. #define HAL_ETH_STATE_READY 0x00000010U /*!< Peripheral Communication started */
  1251. #define HAL_ETH_STATE_BUSY 0x00000023U /*!< an internal process is ongoing */
  1252. #define HAL_ETH_STATE_STARTED 0x00000023U /*!< an internal process is started */
  1253. #define HAL_ETH_STATE_ERROR 0x000000E0U /*!< Error State */
  1254. /**
  1255. * @}
  1256. */
  1257. /** @defgroup ETH_PTP_Config_Status ETH PTP Config Status
  1258. * @{
  1259. */
  1260. #define HAL_ETH_PTP_NOT_CONFIGURED 0x00000000U /*!< ETH PTP Configuration not done */
  1261. #define HAL_ETH_PTP_CONFIGURED 0x00000001U /*!< ETH PTP Configuration done */
  1262. /**
  1263. * @}
  1264. */
  1265. /**
  1266. * @}
  1267. */
  1268. /* Exported macro ------------------------------------------------------------*/
  1269. /** @defgroup ETH_Exported_Macros ETH Exported Macros
  1270. * @{
  1271. */
  1272. /** @brief Reset ETH handle state
  1273. * @param __HANDLE__: specifies the ETH handle.
  1274. * @retval None
  1275. */
  1276. #if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
  1277. #define __HAL_ETH_RESET_HANDLE_STATE(__HANDLE__) do{ \
  1278. (__HANDLE__)->gState = HAL_ETH_STATE_RESET; \
  1279. (__HANDLE__)->MspInitCallback = NULL; \
  1280. (__HANDLE__)->MspDeInitCallback = NULL; \
  1281. } while(0)
  1282. #else
  1283. #define __HAL_ETH_RESET_HANDLE_STATE(__HANDLE__) do{ \
  1284. (__HANDLE__)->gState = HAL_ETH_STATE_RESET; \
  1285. } while(0)
  1286. #endif /*USE_HAL_ETH_REGISTER_CALLBACKS */
  1287. /**
  1288. * @brief Enables the specified ETHERNET DMA interrupts.
  1289. * @param __HANDLE__ : ETH Handle
  1290. * @param __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be
  1291. * enabled @ref ETH_DMA_Interrupts
  1292. * @retval None
  1293. */
  1294. #define __HAL_ETH_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMACIER |= (__INTERRUPT__))
  1295. /**
  1296. * @brief Disables the specified ETHERNET DMA interrupts.
  1297. * @param __HANDLE__ : ETH Handle
  1298. * @param __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be
  1299. * disabled. @ref ETH_DMA_Interrupts
  1300. * @retval None
  1301. */
  1302. #define __HAL_ETH_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMACIER &= ~(__INTERRUPT__))
  1303. /**
  1304. * @brief Gets the ETHERNET DMA IT source enabled or disabled.
  1305. * @param __HANDLE__ : ETH Handle
  1306. * @param __INTERRUPT__: specifies the interrupt source to get . @ref ETH_DMA_Interrupts
  1307. * @retval The ETH DMA IT Source enabled or disabled
  1308. */
  1309. #define __HAL_ETH_DMA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
  1310. (((__HANDLE__)->Instance->DMACIER & (__INTERRUPT__)) == (__INTERRUPT__))
  1311. /**
  1312. * @brief Gets the ETHERNET DMA IT pending bit.
  1313. * @param __HANDLE__ : ETH Handle
  1314. * @param __INTERRUPT__: specifies the interrupt source to get . @ref ETH_DMA_Interrupts
  1315. * @retval The state of ETH DMA IT (SET or RESET)
  1316. */
  1317. #define __HAL_ETH_DMA_GET_IT(__HANDLE__, __INTERRUPT__) \
  1318. (((__HANDLE__)->Instance->DMACSR & (__INTERRUPT__)) == (__INTERRUPT__))
  1319. /**
  1320. * @brief Clears the ETHERNET DMA IT pending bit.
  1321. * @param __HANDLE__ : ETH Handle
  1322. * @param __INTERRUPT__: specifies the interrupt pending bit to clear. @ref ETH_DMA_Interrupts
  1323. * @retval None
  1324. */
  1325. #define __HAL_ETH_DMA_CLEAR_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->DMACSR = (__INTERRUPT__))
  1326. /**
  1327. * @brief Checks whether the specified ETHERNET DMA flag is set or not.
  1328. * @param __HANDLE__: ETH Handle
  1329. * @param __FLAG__: specifies the flag to check. @ref ETH_DMA_Status_Flags
  1330. * @retval The state of ETH DMA FLAG (SET or RESET).
  1331. */
  1332. #define __HAL_ETH_DMA_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->DMACSR &( __FLAG__)) == ( __FLAG__))
  1333. /**
  1334. * @brief Clears the specified ETHERNET DMA flag.
  1335. * @param __HANDLE__: ETH Handle
  1336. * @param __FLAG__: specifies the flag to check. @ref ETH_DMA_Status_Flags
  1337. * @retval The state of ETH DMA FLAG (SET or RESET).
  1338. */
  1339. #define __HAL_ETH_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->DMACSR = ( __FLAG__))
  1340. /**
  1341. * @brief Enables the specified ETHERNET MAC interrupts.
  1342. * @param __HANDLE__ : ETH Handle
  1343. * @param __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be
  1344. * enabled @ref ETH_MAC_Interrupts
  1345. * @retval None
  1346. */
  1347. #define __HAL_ETH_MAC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIER |= (__INTERRUPT__))
  1348. /**
  1349. * @brief Disables the specified ETHERNET MAC interrupts.
  1350. * @param __HANDLE__ : ETH Handle
  1351. * @param __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be
  1352. * enabled @ref ETH_MAC_Interrupts
  1353. * @retval None
  1354. */
  1355. #define __HAL_ETH_MAC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MACIER &= ~(__INTERRUPT__))
  1356. /**
  1357. * @brief Checks whether the specified ETHERNET MAC flag is set or not.
  1358. * @param __HANDLE__: ETH Handle
  1359. * @param __INTERRUPT__: specifies the flag to check. @ref ETH_MAC_Interrupts
  1360. * @retval The state of ETH MAC IT (SET or RESET).
  1361. */
  1362. #define __HAL_ETH_MAC_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->MACISR &\
  1363. ( __INTERRUPT__)) == ( __INTERRUPT__))
  1364. /*!< External interrupt line 86 Connected to the ETH wakeup EXTI Line */
  1365. #define ETH_WAKEUP_EXTI_LINE 0x00400000U /* !< 86 - 64 = 22 */
  1366. /**
  1367. * @brief Enable the ETH WAKEUP Exti Line.
  1368. * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be enabled.
  1369. * @arg ETH_WAKEUP_EXTI_LINE
  1370. * @retval None.
  1371. */
  1372. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_IT(__EXTI_LINE__) (EXTI_D1->IMR3 |= (__EXTI_LINE__))
  1373. /**
  1374. * @brief checks whether the specified ETH WAKEUP Exti interrupt flag is set or not.
  1375. * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
  1376. * @arg ETH_WAKEUP_EXTI_LINE
  1377. * @retval EXTI ETH WAKEUP Line Status.
  1378. */
  1379. #define __HAL_ETH_WAKEUP_EXTI_GET_FLAG(__EXTI_LINE__) (EXTI_D1->PR3 & (__EXTI_LINE__))
  1380. /**
  1381. * @brief Clear the ETH WAKEUP Exti flag.
  1382. * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
  1383. * @arg ETH_WAKEUP_EXTI_LINE
  1384. * @retval None.
  1385. */
  1386. #define __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG(__EXTI_LINE__) (EXTI_D1->PR3 = (__EXTI_LINE__))
  1387. #if defined(DUAL_CORE)
  1388. /**
  1389. * @brief Enable the ETH WAKEUP Exti Line by Core2.
  1390. * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be enabled.
  1391. * @arg ETH_WAKEUP_EXTI_LINE
  1392. * @retval None.
  1393. */
  1394. #define __HAL_ETH_WAKEUP_EXTID2_ENABLE_IT(__EXTI_LINE__) (EXTI_D2->IMR3 |= (__EXTI_LINE__))
  1395. /**
  1396. * @brief checks whether the specified ETH WAKEUP Exti interrupt flag is set or not.
  1397. * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
  1398. * @arg ETH_WAKEUP_EXTI_LINE
  1399. * @retval EXTI ETH WAKEUP Line Status.
  1400. */
  1401. #define __HAL_ETH_WAKEUP_EXTID2_GET_FLAG(__EXTI_LINE__) (EXTI_D2->PR3 & (__EXTI_LINE__))
  1402. /**
  1403. * @brief Clear the ETH WAKEUP Exti flag.
  1404. * @param __EXTI_LINE__: specifies the ETH WAKEUP Exti sources to be cleared.
  1405. * @arg ETH_WAKEUP_EXTI_LINE
  1406. * @retval None.
  1407. */
  1408. #define __HAL_ETH_WAKEUP_EXTID2_CLEAR_FLAG(__EXTI_LINE__) (EXTI_D2->PR3 = (__EXTI_LINE__))
  1409. #endif /* DUAL_CORE */
  1410. /**
  1411. * @brief enable rising edge interrupt on selected EXTI line.
  1412. * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
  1413. * @arg ETH_WAKEUP_EXTI_LINE
  1414. * @retval None
  1415. */
  1416. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_RISING_EDGE(__EXTI_LINE__) (EXTI->FTSR3 &= ~(__EXTI_LINE__)); \
  1417. (EXTI->RTSR3 |= (__EXTI_LINE__))
  1418. /**
  1419. * @brief enable falling edge interrupt on selected EXTI line.
  1420. * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
  1421. * @arg ETH_WAKEUP_EXTI_LINE
  1422. * @retval None
  1423. */
  1424. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLING_EDGE(__EXTI_LINE__) (EXTI->RTSR3 &= ~(__EXTI_LINE__));\
  1425. (EXTI->FTSR3 |= (__EXTI_LINE__))
  1426. /**
  1427. * @brief enable falling edge interrupt on selected EXTI line.
  1428. * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
  1429. * @arg ETH_WAKEUP_EXTI_LINE
  1430. * @retval None
  1431. */
  1432. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_RISING_FALLING_EDGE(__EXTI_LINE__) (EXTI->RTSR3 |= (__EXTI_LINE__));\
  1433. (EXTI->FTSR3 |= (__EXTI_LINE__))
  1434. /**
  1435. * @brief Generates a Software interrupt on selected EXTI line.
  1436. * @param __EXTI_LINE__: specifies the ETH WAKEUP EXTI sources to be disabled.
  1437. * @arg ETH_WAKEUP_EXTI_LINE
  1438. * @retval None
  1439. */
  1440. #define __HAL_ETH_WAKEUP_EXTI_GENERATE_SWIT(__EXTI_LINE__) (EXTI->SWIER3 |= (__EXTI_LINE__))
  1441. #define __HAL_ETH_GET_PTP_CONTROL(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->MACTSCR) & \
  1442. (__FLAG__)) == (__FLAG__)) ? SET : RESET)
  1443. #define __HAL_ETH_SET_PTP_CONTROL(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->MACTSCR |= (__FLAG__))
  1444. /**
  1445. * @}
  1446. */
  1447. /* Include ETH HAL Extension module */
  1448. #include "stm32h7xx_hal_eth_ex.h"
  1449. /* Exported functions --------------------------------------------------------*/
  1450. /** @addtogroup ETH_Exported_Functions
  1451. * @{
  1452. */
  1453. /** @addtogroup ETH_Exported_Functions_Group1
  1454. * @{
  1455. */
  1456. /* Initialization and de initialization functions **********************************/
  1457. HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth);
  1458. HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth);
  1459. void HAL_ETH_MspInit(ETH_HandleTypeDef *heth);
  1460. void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth);
  1461. /* Callbacks Register/UnRegister functions ***********************************/
  1462. #if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
  1463. HAL_StatusTypeDef HAL_ETH_RegisterCallback(ETH_HandleTypeDef *heth, HAL_ETH_CallbackIDTypeDef CallbackID,
  1464. pETH_CallbackTypeDef pCallback);
  1465. HAL_StatusTypeDef HAL_ETH_UnRegisterCallback(ETH_HandleTypeDef *heth, HAL_ETH_CallbackIDTypeDef CallbackID);
  1466. #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */
  1467. /**
  1468. * @}
  1469. */
  1470. /** @addtogroup ETH_Exported_Functions_Group2
  1471. * @{
  1472. */
  1473. /* IO operation functions *******************************************************/
  1474. HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth);
  1475. HAL_StatusTypeDef HAL_ETH_Start_IT(ETH_HandleTypeDef *heth);
  1476. HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth);
  1477. HAL_StatusTypeDef HAL_ETH_Stop_IT(ETH_HandleTypeDef *heth);
  1478. HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff);
  1479. HAL_StatusTypeDef HAL_ETH_RegisterRxAllocateCallback(ETH_HandleTypeDef *heth,
  1480. pETH_rxAllocateCallbackTypeDef rxAllocateCallback);
  1481. HAL_StatusTypeDef HAL_ETH_UnRegisterRxAllocateCallback(ETH_HandleTypeDef *heth);
  1482. HAL_StatusTypeDef HAL_ETH_RegisterRxLinkCallback(ETH_HandleTypeDef *heth, pETH_rxLinkCallbackTypeDef rxLinkCallback);
  1483. HAL_StatusTypeDef HAL_ETH_UnRegisterRxLinkCallback(ETH_HandleTypeDef *heth);
  1484. HAL_StatusTypeDef HAL_ETH_GetRxDataErrorCode(const ETH_HandleTypeDef *heth, uint32_t *pErrorCode);
  1485. HAL_StatusTypeDef HAL_ETH_RegisterTxFreeCallback(ETH_HandleTypeDef *heth, pETH_txFreeCallbackTypeDef txFreeCallback);
  1486. HAL_StatusTypeDef HAL_ETH_UnRegisterTxFreeCallback(ETH_HandleTypeDef *heth);
  1487. HAL_StatusTypeDef HAL_ETH_ReleaseTxPacket(ETH_HandleTypeDef *heth);
  1488. #ifdef HAL_ETH_USE_PTP
  1489. HAL_StatusTypeDef HAL_ETH_PTP_SetConfig(ETH_HandleTypeDef *heth, ETH_PTP_ConfigTypeDef *ptpconfig);
  1490. HAL_StatusTypeDef HAL_ETH_PTP_GetConfig(ETH_HandleTypeDef *heth, ETH_PTP_ConfigTypeDef *ptpconfig);
  1491. HAL_StatusTypeDef HAL_ETH_PTP_SetTime(ETH_HandleTypeDef *heth, ETH_TimeTypeDef *time);
  1492. HAL_StatusTypeDef HAL_ETH_PTP_GetTime(ETH_HandleTypeDef *heth, ETH_TimeTypeDef *time);
  1493. HAL_StatusTypeDef HAL_ETH_PTP_AddTimeOffset(ETH_HandleTypeDef *heth, ETH_PtpUpdateTypeDef ptpoffsettype,
  1494. ETH_TimeTypeDef *timeoffset);
  1495. HAL_StatusTypeDef HAL_ETH_PTP_InsertTxTimestamp(ETH_HandleTypeDef *heth);
  1496. HAL_StatusTypeDef HAL_ETH_PTP_GetTxTimestamp(ETH_HandleTypeDef *heth, ETH_TimeStampTypeDef *timestamp);
  1497. HAL_StatusTypeDef HAL_ETH_PTP_GetRxTimestamp(ETH_HandleTypeDef *heth, ETH_TimeStampTypeDef *timestamp);
  1498. HAL_StatusTypeDef HAL_ETH_RegisterTxPtpCallback(ETH_HandleTypeDef *heth, pETH_txPtpCallbackTypeDef txPtpCallback);
  1499. HAL_StatusTypeDef HAL_ETH_UnRegisterTxPtpCallback(ETH_HandleTypeDef *heth);
  1500. #endif /* HAL_ETH_USE_PTP */
  1501. HAL_StatusTypeDef HAL_ETH_Transmit(ETH_HandleTypeDef *heth, ETH_TxPacketConfigTypeDef *pTxConfig, uint32_t Timeout);
  1502. HAL_StatusTypeDef HAL_ETH_Transmit_IT(ETH_HandleTypeDef *heth, ETH_TxPacketConfigTypeDef *pTxConfig);
  1503. HAL_StatusTypeDef HAL_ETH_WritePHYRegister(const ETH_HandleTypeDef *heth, uint32_t PHYAddr, uint32_t PHYReg,
  1504. uint32_t RegValue);
  1505. HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint32_t PHYAddr, uint32_t PHYReg,
  1506. uint32_t *pRegValue);
  1507. void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth);
  1508. void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth);
  1509. void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth);
  1510. void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth);
  1511. void HAL_ETH_PMTCallback(ETH_HandleTypeDef *heth);
  1512. void HAL_ETH_EEECallback(ETH_HandleTypeDef *heth);
  1513. void HAL_ETH_WakeUpCallback(ETH_HandleTypeDef *heth);
  1514. void HAL_ETH_RxAllocateCallback(uint8_t **buff);
  1515. void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t Length);
  1516. void HAL_ETH_TxFreeCallback(uint32_t *buff);
  1517. void HAL_ETH_TxPtpCallback(uint32_t *buff, ETH_TimeStampTypeDef *timestamp);
  1518. /**
  1519. * @}
  1520. */
  1521. /** @addtogroup ETH_Exported_Functions_Group3
  1522. * @{
  1523. */
  1524. /* Peripheral Control functions **********************************************/
  1525. /* MAC & DMA Configuration APIs **********************************************/
  1526. HAL_StatusTypeDef HAL_ETH_GetMACConfig(const ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf);
  1527. HAL_StatusTypeDef HAL_ETH_GetDMAConfig(const ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf);
  1528. HAL_StatusTypeDef HAL_ETH_SetMACConfig(ETH_HandleTypeDef *heth, ETH_MACConfigTypeDef *macconf);
  1529. HAL_StatusTypeDef HAL_ETH_SetDMAConfig(ETH_HandleTypeDef *heth, ETH_DMAConfigTypeDef *dmaconf);
  1530. void HAL_ETH_SetMDIOClockRange(ETH_HandleTypeDef *heth);
  1531. /* MAC VLAN Processing APIs ************************************************/
  1532. void HAL_ETH_SetRxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t ComparisonBits,
  1533. uint32_t VLANIdentifier);
  1534. /* MAC L2 Packet Filtering APIs **********************************************/
  1535. HAL_StatusTypeDef HAL_ETH_GetMACFilterConfig(const ETH_HandleTypeDef *heth, ETH_MACFilterConfigTypeDef *pFilterConfig);
  1536. HAL_StatusTypeDef HAL_ETH_SetMACFilterConfig(ETH_HandleTypeDef *heth, const ETH_MACFilterConfigTypeDef *pFilterConfig);
  1537. HAL_StatusTypeDef HAL_ETH_SetHashTable(ETH_HandleTypeDef *heth, uint32_t *pHashTable);
  1538. HAL_StatusTypeDef HAL_ETH_SetSourceMACAddrMatch(const ETH_HandleTypeDef *heth, uint32_t AddrNbr,
  1539. const uint8_t *pMACAddr);
  1540. /* MAC Power Down APIs *****************************************************/
  1541. void HAL_ETH_EnterPowerDownMode(ETH_HandleTypeDef *heth,
  1542. const ETH_PowerDownConfigTypeDef *pPowerDownConfig);
  1543. void HAL_ETH_ExitPowerDownMode(ETH_HandleTypeDef *heth);
  1544. HAL_StatusTypeDef HAL_ETH_SetWakeUpFilter(ETH_HandleTypeDef *heth, uint32_t *pFilter, uint32_t Count);
  1545. /**
  1546. * @}
  1547. */
  1548. /** @addtogroup ETH_Exported_Functions_Group4
  1549. * @{
  1550. */
  1551. /* Peripheral State functions **************************************************/
  1552. HAL_ETH_StateTypeDef HAL_ETH_GetState(const ETH_HandleTypeDef *heth);
  1553. uint32_t HAL_ETH_GetError(const ETH_HandleTypeDef *heth);
  1554. uint32_t HAL_ETH_GetDMAError(const ETH_HandleTypeDef *heth);
  1555. uint32_t HAL_ETH_GetMACError(const ETH_HandleTypeDef *heth);
  1556. uint32_t HAL_ETH_GetMACWakeUpSource(const ETH_HandleTypeDef *heth);
  1557. /**
  1558. * @}
  1559. */
  1560. /**
  1561. * @}
  1562. */
  1563. /**
  1564. * @}
  1565. */
  1566. /**
  1567. * @}
  1568. */
  1569. #endif /* ETH */
  1570. #ifdef __cplusplus
  1571. }
  1572. #endif
  1573. #endif /* STM32H7xx_HAL_ETH_H */