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.
 
 
 

372 lines
14 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_eth_ex.h
  4. * @author MCD Application Team
  5. * @version V1.2.0
  6. * @date 29-December-2017
  7. * @brief Header file of ETH HAL Extended module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef STM32H7xx_HAL_ETH_EX_H
  39. #define STM32H7xx_HAL_ETH_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32h7xx_hal_def.h"
  45. /** @addtogroup STM32H7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup ETHEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup ETHEx_Exported_Types ETHEx Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief ETH RX VLAN structure definition
  57. */
  58. typedef struct{
  59. FunctionalState InnerVLANTagInStatus; /*!< Enables or disables Inner VLAN Tag in Rx Status */
  60. uint32_t StripInnerVLANTag; /*!< Sets the Inner VLAN Tag Stripping on Receive
  61. This parameter can be a value of @ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */
  62. FunctionalState InnerVLANTag; /*!< Enables or disables Inner VLAN Tag */
  63. FunctionalState DoubleVLANProcessing; /*!< Enable or Disable double VLAN processing */
  64. FunctionalState VLANTagHashTableMatch; /*!< Enable or Disable VLAN Tag Hash Table Match */
  65. FunctionalState VLANTagInStatus; /*!< Enable or Disable VLAN Tag in Rx status */
  66. uint32_t StripVLANTag; /*!< Set the VLAN Tag Stripping on Receive
  67. This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */
  68. uint32_t VLANTypeCheck; /*!< Enable or Disable VLAN Type Check
  69. This parameter can be a value of @ref ETHEx_VLAN_Type_Check */
  70. FunctionalState VLANTagInverceMatch; /*!< Enable or disable VLAN Tag Inverse Match */
  71. }ETH_RxVLANConfigTypeDef;
  72. /**
  73. *
  74. */
  75. /**
  76. * @brief ETH TX VLAN structure definition
  77. */
  78. typedef struct{
  79. FunctionalState SourceTxDesc; /*!< Enable or Disable VLAN tag source from DMA tx descriptors */
  80. FunctionalState SVLANType; /*!< Enable or Disable insertion of SVLAN type */
  81. uint32_t VLANTagControl; /*!< Sets the VLAN tag control in tx packets
  82. This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
  83. }ETH_TxVLANConfigTypeDef;
  84. /**
  85. *
  86. */
  87. /**
  88. * @brief ETH L3 filter structure definition
  89. */
  90. typedef struct{
  91. uint32_t Protocol; /*!< Sets the L3 filter protocol to IPv4 or IPv6
  92. This parameter can be a value of @ref ETHEx_L3_Protocol */
  93. uint32_t SrcAddrFilterMatch; /*!< Sets the L3 filter source address match
  94. This parameter can be a value of @ref ETHEx_L3_Source_Match */
  95. uint32_t DestAddrFilterMatch; /*!< Sets the L3 filter destination address match
  96. This parameter can be a value of @ref ETHEx_L3_Destination_Match */
  97. uint32_t SrcAddrHigherBitsMatch; /*!< Sets the L3 filter source address higher bits match
  98. This parameter can be a value from 0 to 31 */
  99. uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
  100. This parameter can be a value from 0 to 31 */
  101. uint32_t Ip4SrcAddr; /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
  102. This parameter can be a value from 0x0 to 0xFFFFFFFF */
  103. uint32_t Ip4DestAddr; /*!< Sets the L3 filter IPv4 destination address if IPv4 protocol is used
  104. This parameter can be a value from 0 to 0xFFFFFFFF */
  105. uint32_t Ip6Addr[4]; /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
  106. This parameter must be a table of 4 words (4* 32 bits) */
  107. }ETH_L3FilterConfigTypeDef;
  108. /**
  109. *
  110. */
  111. /**
  112. * @brief ETH L4 filter structure definition
  113. */
  114. typedef struct{
  115. uint32_t Protocol; /*!< Sets the L4 filter protocol to TCP or UDP
  116. This parameter can be a value of @ref ETHEx_L4_Protocol */
  117. uint32_t SrcPortFilterMatch; /*!< Sets the L4 filter source port match
  118. This parameter can be a value of @ref ETHEx_L4_Source_Match */
  119. uint32_t DestPortFilterMatch; /*!< Sets the L4 filter destination port match
  120. This parameter can be a value of @ref ETHEx_L4_Destination_Match */
  121. uint32_t SourcePort; /*!< Sets the L4 filter source port
  122. This parameter must be a value from 0x0 to 0xFFFF */
  123. uint32_t DestinationPort; /*!< Sets the L4 filter destination port
  124. This parameter must be a value from 0x0 to 0xFFFF */
  125. }ETH_L4FilterConfigTypeDef;
  126. /**
  127. *
  128. */
  129. /**
  130. * @}
  131. */
  132. /* Exported constants --------------------------------------------------------*/
  133. /** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
  134. * @{
  135. */
  136. /** @defgroup ETHEx_LPI_Event ETHEx LPI Event
  137. * @{
  138. */
  139. #define ETH_TX_LPI_ENTRY ETH_MACLCSR_TLPIEN
  140. #define ETH_TX_LPI_EXIT ETH_MACLCSR_TLPIEX
  141. #define ETH_RX_LPI_ENTRY ETH_MACLCSR_RLPIEN
  142. #define ETH_RX_LPI_EXIT ETH_MACLCSR_RLPIEX
  143. /**
  144. * @}
  145. */
  146. /** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
  147. * @{
  148. */
  149. #define ETH_L3_FILTER_0 ((uint32_t)0x00000000)
  150. #define ETH_L3_FILTER_1 ((uint32_t)0x0000000C)
  151. /**
  152. * @}
  153. */
  154. /** @defgroup ETHEx_L4_Filter ETHEx L4 Filter
  155. * @{
  156. */
  157. #define ETH_L4_FILTER_0 ((uint32_t)0x00000000)
  158. #define ETH_L4_FILTER_1 ((uint32_t)0x0000000C)
  159. /**
  160. * @}
  161. */
  162. /** @defgroup ETHEx_L3_Protocol ETHEx L3 Protocol
  163. * @{
  164. */
  165. #define ETH_L3_IPV6_MATCH ETH_MACL3L4CR_L3PEN
  166. #define ETH_L3_IPV4_MATCH ((uint32_t)0x00000000)
  167. /**
  168. * @}
  169. */
  170. /** @defgroup ETHEx_L3_Source_Match ETHEx L3 Source Match
  171. * @{
  172. */
  173. #define ETH_L3_SRC_ADDR_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L3SAM
  174. #define ETH_L3_SRC_ADDR_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM)
  175. #define ETH_L3_SRC_ADDR_MATCH_DISABLE ((uint32_t)0x00000000)
  176. /**
  177. * @}
  178. */
  179. /** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
  180. * @{
  181. */
  182. #define ETH_L3_DEST_ADDR_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L3DAM
  183. #define ETH_L3_DEST_ADDR_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM)
  184. #define ETH_L3_DEST_ADDR_MATCH_DISABLE ((uint32_t)0x00000000)
  185. /**
  186. * @}
  187. */
  188. /** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
  189. * @{
  190. */
  191. #define ETH_L4_UDP_MATCH ETH_MACL3L4CR_L4PEN
  192. #define ETH_L4_TCP_MATCH ((uint32_t)0x00000000)
  193. /**
  194. * @}
  195. */
  196. /** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
  197. * @{
  198. */
  199. #define ETH_L4_SRC_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4SPM
  200. #define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
  201. #define ETH_L4_SRC_PORT_MATCH_DISABLE ((uint32_t)0x00000000)
  202. /**
  203. * @}
  204. */
  205. /** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
  206. * @{
  207. */
  208. #define ETH_L4_DEST_PORT_PERFECT_MATCH_ENABLE ETH_MACL3L4CR_L4DPM
  209. #define ETH_L4_DEST_PORT_INVERSE_MATCH_ENABLE (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM)
  210. #define ETH_L4_DEST_PORT_MATCH_DISABLE ((uint32_t)0x00000000)
  211. /**
  212. * @}
  213. */
  214. /** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
  215. * @{
  216. */
  217. #define ETH_INNERVLANTAGRXSTRIPPING_NONE ETH_MACVTR_EIVLS_DONOTSTRIP
  218. #define ETH_INNERVLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EIVLS_STRIPIFPASS
  219. #define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EIVLS_STRIPIFFAILS
  220. #define ETH_INNERVLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EIVLS_ALWAYSSTRIP
  221. /**
  222. * @}
  223. */
  224. /** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
  225. * @{
  226. */
  227. #define ETH_VLANTAGRXSTRIPPING_NONE ETH_MACVTR_EVLS_DONOTSTRIP
  228. #define ETH_VLANTAGRXSTRIPPING_IFPASS ETH_MACVTR_EVLS_STRIPIFPASS
  229. #define ETH_VLANTAGRXSTRIPPING_IFFAILS ETH_MACVTR_EVLS_STRIPIFFAILS
  230. #define ETH_VLANTAGRXSTRIPPING_ALWAYS ETH_MACVTR_EVLS_ALWAYSSTRIP
  231. /**
  232. * @}
  233. */
  234. /** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
  235. * @{
  236. */
  237. #define ETH_VLANTYPECHECK_DISABLE ETH_MACVTR_DOVLTC
  238. #define ETH_VLANTYPECHECK_SVLAN (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
  239. #define ETH_VLANTYPECHECK_CVLAN ((uint32_t)0x00000000)
  240. /**
  241. * @}
  242. */
  243. /** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
  244. * @{
  245. */
  246. #define ETH_VLANTAGCONTROL_NONE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_NOVLANTAG)
  247. #define ETH_VLANTAGCONTROL_DELETE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGDELETE)
  248. #define ETH_VLANTAGCONTROL_INSERT (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGINSERT)
  249. #define ETH_VLANTAGCONTROL_REPLACE (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
  250. /**
  251. * @}
  252. */
  253. /** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
  254. * @{
  255. */
  256. #define ETH_INNER_TX_VLANTAG ((uint32_t)0x00000001U)
  257. #define ETH_OUTER_TX_VLANTAG ((uint32_t)0x00000000U)
  258. /**
  259. * @}
  260. */
  261. /**
  262. * @}
  263. */
  264. /* Exported functions --------------------------------------------------------*/
  265. /** @addtogroup ETHEx_Exported_Functions
  266. * @{
  267. */
  268. /** @addtogroup ETHEx_Exported_Functions_Group1
  269. * @{
  270. */
  271. /* MAC ARP Offloading APIs ***************************************************/
  272. void HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
  273. void HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
  274. void HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
  275. /* MAC L3 L4 Filtering APIs ***************************************************/
  276. void HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
  277. void HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth);
  278. HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L3FilterConfigTypeDef *pL3FilterConfig);
  279. HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L4FilterConfigTypeDef *pL4FilterConfig);
  280. HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L3FilterConfigTypeDef *pL3FilterConfig);
  281. HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter, ETH_L4FilterConfigTypeDef *pL4FilterConfig);
  282. /* MAC VLAN Processing APIs ************************************************/
  283. void HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
  284. void HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
  285. HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
  286. HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
  287. void HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable);
  288. HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag ,ETH_TxVLANConfigTypeDef *pVlanConfig);
  289. HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag ,ETH_TxVLANConfigTypeDef *pVlanConfig);
  290. void HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag ,uint32_t VLANIdentifier);
  291. /* Energy Efficient Ethernet APIs *********************************************/
  292. void HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate, FunctionalState TxClockStop);
  293. void HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
  294. uint32_t HAL_ETHEx_GetMACLPIEvent(ETH_HandleTypeDef *heth);
  295. /**
  296. * @}
  297. */
  298. /**
  299. * @}
  300. */
  301. /**
  302. * @}
  303. */
  304. /**
  305. * @}
  306. */
  307. #ifdef __cplusplus
  308. }
  309. #endif
  310. #endif /* STM32H7xx_HAL_ETH_EX_H */
  311. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/