stm32h7xx_hal_eth_ex.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_eth_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of ETH HAL Extended 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_EX_H
  20. #define STM32H7xx_HAL_ETH_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #if defined(ETH)
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup ETHEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup ETHEx_Exported_Types ETHEx Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief ETH RX VLAN structure definition
  39. */
  40. typedef struct
  41. {
  42. FunctionalState InnerVLANTagInStatus; /*!< Enables or disables Inner VLAN Tag in Rx Status */
  43. uint32_t StripInnerVLANTag; /*!< Sets the Inner VLAN Tag Stripping on Receive
  44. This parameter can be a value of
  45. @ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */
  46. FunctionalState InnerVLANTag; /*!< Enables or disables Inner VLAN Tag */
  47. FunctionalState DoubleVLANProcessing; /*!< Enable or Disable double VLAN processing */
  48. FunctionalState VLANTagHashTableMatch; /*!< Enable or Disable VLAN Tag Hash Table Match */
  49. FunctionalState VLANTagInStatus; /*!< Enable or Disable VLAN Tag in Rx status */
  50. uint32_t StripVLANTag; /*!< Set the VLAN Tag Stripping on Receive
  51. This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */
  52. uint32_t VLANTypeCheck; /*!< Enable or Disable VLAN Type Check
  53. This parameter can be a value of @ref ETHEx_VLAN_Type_Check */
  54. FunctionalState VLANTagInverceMatch; /*!< Enable or disable VLAN Tag Inverse Match */
  55. } ETH_RxVLANConfigTypeDef;
  56. /**
  57. *
  58. */
  59. /**
  60. * @brief ETH TX VLAN structure definition
  61. */
  62. typedef struct
  63. {
  64. FunctionalState SourceTxDesc; /*!< Enable or Disable VLAN tag source from DMA tx descriptors */
  65. FunctionalState SVLANType; /*!< Enable or Disable insertion of SVLAN type */
  66. uint32_t VLANTagControl; /*!< Sets the VLAN tag control in tx packets
  67. This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
  68. } ETH_TxVLANConfigTypeDef;
  69. /**
  70. *
  71. */
  72. /**
  73. * @brief ETH L3 filter structure definition
  74. */
  75. typedef struct
  76. {
  77. uint32_t Protocol; /*!< Sets the L3 filter protocol to IPv4 or IPv6
  78. This parameter can be a value of @ref ETHEx_L3_Protocol */
  79. uint32_t SrcAddrFilterMatch; /*!< Sets the L3 filter source address match
  80. This parameter can be a value of @ref ETHEx_L3_Source_Match */
  81. uint32_t DestAddrFilterMatch; /*!< Sets the L3 filter destination address match
  82. This parameter can be a value of @ref ETHEx_L3_Destination_Match */
  83. uint32_t SrcAddrHigherBitsMatch; /*!< Sets the L3 filter source address higher bits match
  84. This parameter can be a value from 0 to 31 */
  85. uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
  86. This parameter can be a value from 0 to 31 */
  87. uint32_t Ip4SrcAddr; /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
  88. This parameter can be a value from 0x0 to 0xFFFFFFFF */
  89. uint32_t Ip4DestAddr; /*!< Sets the L3 filter IPv4 destination address if IPv4 protocol is used
  90. This parameter can be a value from 0 to 0xFFFFFFFF */
  91. uint32_t Ip6Addr[4]; /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
  92. This parameter must be a table of 4 words (4* 32 bits) */
  93. } ETH_L3FilterConfigTypeDef;
  94. /**
  95. *
  96. */
  97. /**
  98. * @brief ETH L4 filter structure definition
  99. */
  100. typedef struct
  101. {
  102. uint32_t Protocol; /*!< Sets the L4 filter protocol to TCP or UDP
  103. This parameter can be a value of @ref ETHEx_L4_Protocol */
  104. uint32_t SrcPortFilterMatch; /*!< Sets the L4 filter source port match
  105. This parameter can be a value of @ref ETHEx_L4_Source_Match */
  106. uint32_t DestPortFilterMatch; /*!< Sets the L4 filter destination port match
  107. This parameter can be a value of @ref ETHEx_L4_Destination_Match */
  108. uint32_t SourcePort; /*!< Sets the L4 filter source port
  109. This parameter must be a value from 0x0 to 0xFFFF */
  110. uint32_t DestinationPort; /*!< Sets the L4 filter destination port
  111. This parameter must be a value from 0x0 to 0xFFFF */
  112. } ETH_L4FilterConfigTypeDef;
  113. /**
  114. *
  115. */
  116. /**
  117. * @}
  118. */
  119. /* Exported constants --------------------------------------------------------*/
  120. /** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
  121. * @{
  122. */
  123. /** @defgroup ETHEx_LPI_Event ETHEx LPI Event
  124. * @{
  125. */
  126. #define ETH_TX_LPI_ENTRY ETH_MACLCSR_TLPIEN
  127. #define ETH_TX_LPI_EXIT ETH_MACLCSR_TLPIEX
  128. #define ETH_RX_LPI_ENTRY ETH_MACLCSR_RLPIEN
  129. #define ETH_RX_LPI_EXIT ETH_MACLCSR_RLPIEX
  130. /**
  131. * @}
  132. */
  133. /** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
  134. * @{
  135. */
  136. #define ETH_L3_FILTER_0 ((uint32_t)0x00000000)
  137. #define ETH_L3_FILTER_1 ((uint32_t)0x0000000C)
  138. /**
  139. * @}
  140. */
  141. /** @defgroup ETHEx_L4_Filter ETHEx L4 Filter
  142. * @{
  143. */
  144. #define ETH_L4_FILTER_0 ((uint32_t)0x00000000)
  145. #define ETH_L4_FILTER_1 ((uint32_t)0x0000000C)
  146. /**
  147. * @}
  148. */
  149. /** @defgroup ETHEx_L3_Protocol ETHEx L3 Protocol
  150. * @{
  151. */
  152. #define ETH_L3_IPV6_MATCH ETH_MACL3L4CR_L3PEN
  153. #define ETH_L3_IPV4_MATCH ((uint32_t)0x00000000)
  154. /**
  155. * @}
  156. */
  157. /** @defgroup ETHEx_L3_Source_Match ETHEx L3 Source Match
  158. * @{
  159. */
  160. #define ETH_L3_SRC_ADDR_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L3SAM
  161. #define ETH_L3_SRC_ADDR_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM)
  162. #define ETH_L3_SRC_ADDR_MATCH_DISABLE ((uint32_t)0x00000000)
  163. /**
  164. * @}
  165. */
  166. /** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
  167. * @{
  168. */
  169. #define ETH_L3_DEST_ADDR_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L3DAM
  170. #define ETH_L3_DEST_ADDR_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM)
  171. #define ETH_L3_DEST_ADDR_MATCH_DISABLE ((uint32_t)0x00000000)
  172. /**
  173. * @}
  174. */
  175. /** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
  176. * @{
  177. */
  178. #define ETH_L4_UDP_MATCH ETH_MACL3L4CR_L4PEN
  179. #define ETH_L4_TCP_MATCH ((uint32_t)0x00000000)
  180. /**
  181. * @}
  182. */
  183. /** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
  184. * @{
  185. */
  186. #define ETH_L4_SRC_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4SPM
  187. #define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
  188. #define ETH_L4_SRC_PORT_MATCH_DISABLE ((uint32_t)0x00000000)
  189. /**
  190. * @}
  191. */
  192. /** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
  193. * @{
  194. */
  195. #define ETH_L4_DEST_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4DPM
  196. #define ETH_L4_DEST_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM)
  197. #define ETH_L4_DEST_PORT_MATCH_DISABLE ((uint32_t)0x00000000)
  198. /**
  199. * @}
  200. */
  201. /** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
  202. * @{
  203. */
  204. #define ETH_INNERVLANTAGRXSTRIPPING_NONE ETH_MACVTR_EIVLS_DONOTSTRIP
  205. #define ETH_INNERVLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EIVLS_STRIPIFPASS
  206. #define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EIVLS_STRIPIFFAILS
  207. #define ETH_INNERVLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EIVLS_ALWAYSSTRIP
  208. /**
  209. * @}
  210. */
  211. /** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
  212. * @{
  213. */
  214. #define ETH_VLANTAGRXSTRIPPING_NONE ETH_MACVTR_EVLS_DONOTSTRIP
  215. #define ETH_VLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EVLS_STRIPIFPASS
  216. #define ETH_VLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EVLS_STRIPIFFAILS
  217. #define ETH_VLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EVLS_ALWAYSSTRIP
  218. /**
  219. * @}
  220. */
  221. /** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
  222. * @{
  223. */
  224. #define ETH_VLANTYPECHECK_DISABLE ETH_MACVTR_DOVLTC
  225. #define ETH_VLANTYPECHECK_SVLAN (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
  226. #define ETH_VLANTYPECHECK_CVLAN ((uint32_t)0x00000000)
  227. /**
  228. * @}
  229. */
  230. /** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
  231. * @{
  232. */
  233. #define ETH_VLANTAGCONTROL_NONE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_NOVLANTAG)
  234. #define ETH_VLANTAGCONTROL_DELETE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGDELETE)
  235. #define ETH_VLANTAGCONTROL_INSERT (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGINSERT)
  236. #define ETH_VLANTAGCONTROL_REPLACE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
  237. /**
  238. * @}
  239. */
  240. /** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
  241. * @{
  242. */
  243. #define ETH_INNER_TX_VLANTAG ((uint32_t)0x00000001U)
  244. #define ETH_OUTER_TX_VLANTAG ((uint32_t)0x00000000U)
  245. /**
  246. * @}
  247. */
  248. /**
  249. * @}
  250. */
  251. /* Exported functions --------------------------------------------------------*/
  252. /** @addtogroup ETHEx_Exported_Functions
  253. * @{
  254. */
  255. /** @addtogroup ETHEx_Exported_Functions_Group1
  256. * @{
  257. */
  258. /* MAC ARP Offloading APIs ***************************************************/
  259. void HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
  260. void HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
  261. void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
  262. /* MAC L3 L4 Filtering APIs ***************************************************/
  263. void HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
  264. void HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth);
  265. HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
  266. ETH_L3FilterConfigTypeDef *pL3FilterConfig);
  267. HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
  268. ETH_L4FilterConfigTypeDef *pL4FilterConfig);
  269. HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
  270. ETH_L3FilterConfigTypeDef *pL3FilterConfig);
  271. HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
  272. ETH_L4FilterConfigTypeDef *pL4FilterConfig);
  273. /* MAC VLAN Processing APIs ************************************************/
  274. void HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
  275. void HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
  276. HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
  277. HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
  278. void HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable);
  279. HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
  280. ETH_TxVLANConfigTypeDef *pVlanConfig);
  281. HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
  282. ETH_TxVLANConfigTypeDef *pVlanConfig);
  283. void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag, uint32_t VLANIdentifier);
  284. /* Energy Efficient Ethernet APIs *********************************************/
  285. void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate,
  286. FunctionalState TxClockStop);
  287. void HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
  288. uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);
  289. /**
  290. * @}
  291. */
  292. /**
  293. * @}
  294. */
  295. /**
  296. * @}
  297. */
  298. /**
  299. * @}
  300. */
  301. #endif /* ETH */
  302. #ifdef __cplusplus
  303. }
  304. #endif
  305. #endif /* STM32H7xx_HAL_ETH_EX_H */