You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

354 lines
12 KiB

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