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.
 
 
 

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