Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:35

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_eth_ex.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of ETH HAL Extended module.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file
0013   * in the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   *
0016   ******************************************************************************
0017   */
0018 
0019 /* Define to prevent recursive inclusion -------------------------------------*/
0020 #ifndef STM32H7xx_HAL_ETH_EX_H
0021 #define STM32H7xx_HAL_ETH_EX_H
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 #if defined(ETH)
0028 
0029 /* Includes ------------------------------------------------------------------*/
0030 #include "stm32h7xx_hal_def.h"
0031 
0032 /** @addtogroup STM32H7xx_HAL_Driver
0033   * @{
0034   */
0035 
0036 /** @addtogroup ETHEx
0037   * @{
0038   */
0039 
0040 /* Exported types ------------------------------------------------------------*/
0041 /** @defgroup ETHEx_Exported_Types ETHEx Exported Types
0042   * @ingroup RTEMSBSPsARMSTM32H7
0043   * @{
0044   */
0045 
0046 /**
0047   * @brief  ETH RX VLAN structure definition
0048   */
0049 typedef struct
0050 {
0051   FunctionalState InnerVLANTagInStatus;      /*!< Enables or disables Inner VLAN Tag in Rx Status  */
0052 
0053   uint32_t StripInnerVLANTag;                /*!< Sets the Inner VLAN Tag Stripping on Receive
0054                                                   This parameter can be a value of
0055                                                   @ref ETHEx_Rx_Inner_VLAN_Tag_Stripping */
0056 
0057   FunctionalState InnerVLANTag;              /*!< Enables or disables Inner VLAN Tag */
0058 
0059   FunctionalState DoubleVLANProcessing;      /*!< Enable or Disable double VLAN processing */
0060 
0061   FunctionalState VLANTagHashTableMatch;     /*!< Enable or Disable VLAN Tag Hash Table Match */
0062 
0063   FunctionalState VLANTagInStatus;           /*!< Enable or Disable VLAN Tag in Rx status */
0064 
0065   uint32_t StripVLANTag;                     /*!< Set the VLAN Tag Stripping on Receive
0066                                                   This parameter can be a value of @ref ETHEx_Rx_VLAN_Tag_Stripping */
0067 
0068   uint32_t VLANTypeCheck;                    /*!< Enable or Disable VLAN Type Check
0069                                                   This parameter can be a value of @ref ETHEx_VLAN_Type_Check */
0070 
0071   FunctionalState VLANTagInverceMatch;       /*!< Enable or disable VLAN Tag Inverse Match */
0072 } ETH_RxVLANConfigTypeDef;
0073 /**
0074   *
0075   */
0076 
0077 /**
0078   * @brief  ETH TX VLAN structure definition
0079   */
0080 typedef struct
0081 {
0082   FunctionalState SourceTxDesc;   /*!< Enable or Disable VLAN tag source from DMA tx descriptors */
0083 
0084   FunctionalState SVLANType;      /*!< Enable or Disable insertion of SVLAN type */
0085 
0086   uint32_t VLANTagControl;        /*!< Sets the VLAN tag control in tx packets
0087                                       This parameter can be a value of @ref ETHEx_VLAN_Tag_Control */
0088 } ETH_TxVLANConfigTypeDef;
0089 /**
0090   *
0091   */
0092 
0093 /**
0094   * @brief  ETH L3 filter structure definition
0095   */
0096 typedef struct
0097 {
0098   uint32_t Protocol;                /*!< Sets the L3 filter protocol to IPv4 or IPv6
0099                                          This parameter can be a value of @ref ETHEx_L3_Protocol */
0100 
0101   uint32_t SrcAddrFilterMatch;      /*!< Sets the L3 filter source address match
0102                                          This parameter can be a value of @ref ETHEx_L3_Source_Match */
0103 
0104   uint32_t DestAddrFilterMatch;     /*!< Sets the L3 filter destination address match
0105                                          This parameter can be a value of @ref ETHEx_L3_Destination_Match */
0106 
0107   uint32_t SrcAddrHigherBitsMatch;  /*!< Sets the L3 filter source address higher bits match
0108                                          This parameter can be a value from 0 to 31 */
0109 
0110   uint32_t DestAddrHigherBitsMatch; /*!< Sets the L3 filter destination address higher bits match
0111                                          This parameter can be a value from 0 to 31 */
0112 
0113   uint32_t Ip4SrcAddr;              /*!< Sets the L3 filter IPv4 source address if IPv4 protocol is used
0114                                          This parameter can be a value from 0x0 to 0xFFFFFFFF */
0115 
0116   uint32_t Ip4DestAddr;             /*!< Sets the L3 filter IPv4 destination  address if IPv4 protocol is used
0117                                          This parameter can be a value from 0 to 0xFFFFFFFF  */
0118 
0119   uint32_t Ip6Addr[4];                 /*!< Sets the L3 filter IPv6 address if IPv6 protocol is used
0120                                           This parameter must be a table of 4 words (4* 32 bits) */
0121 } ETH_L3FilterConfigTypeDef;
0122 /**
0123   *
0124   */
0125 
0126 /**
0127   * @brief  ETH L4 filter structure definition
0128   */
0129 typedef struct
0130 {
0131   uint32_t Protocol;               /*!< Sets the L4 filter protocol to TCP or UDP
0132                                         This parameter can be a value of @ref ETHEx_L4_Protocol */
0133 
0134   uint32_t SrcPortFilterMatch;     /*!< Sets the L4 filter source port match
0135                                         This parameter can be a value of @ref ETHEx_L4_Source_Match */
0136 
0137   uint32_t DestPortFilterMatch;    /*!< Sets the L4 filter destination port match
0138                                         This parameter can be a value of @ref ETHEx_L4_Destination_Match */
0139 
0140   uint32_t SourcePort;             /*!< Sets the L4 filter source port
0141                                         This parameter must be a value from 0x0 to 0xFFFF */
0142 
0143   uint32_t DestinationPort;        /*!< Sets the L4 filter destination port
0144                                         This parameter must be a value from 0x0 to 0xFFFF */
0145 } ETH_L4FilterConfigTypeDef;
0146 /**
0147   *
0148   */
0149 
0150 /**
0151   * @}
0152   */
0153 
0154 /* Exported constants --------------------------------------------------------*/
0155 /** @defgroup ETHEx_Exported_Constants ETHEx Exported Constants
0156   * @ingroup RTEMSBSPsARMSTM32H7
0157   * @{
0158   */
0159 
0160 /** @defgroup ETHEx_LPI_Event ETHEx LPI Event
0161   * @ingroup RTEMSBSPsARMSTM32H7
0162   * @{
0163   */
0164 #define ETH_TX_LPI_ENTRY    ETH_MACLCSR_TLPIEN
0165 #define ETH_TX_LPI_EXIT     ETH_MACLCSR_TLPIEX
0166 #define ETH_RX_LPI_ENTRY    ETH_MACLCSR_RLPIEN
0167 #define ETH_RX_LPI_EXIT     ETH_MACLCSR_RLPIEX
0168 /**
0169   * @}
0170   */
0171 
0172 /** @defgroup ETHEx_L3_Filter ETHEx L3 Filter
0173   * @ingroup RTEMSBSPsARMSTM32H7
0174   * @{
0175   */
0176 #define ETH_L3_FILTER_0                 0x00000000U
0177 #define ETH_L3_FILTER_1                 0x0000000CU
0178 /**
0179   * @}
0180   */
0181 
0182 /** @defgroup ETHEx_L4_Filter ETHEx L4 Filter
0183   * @ingroup RTEMSBSPsARMSTM32H7
0184   * @{
0185   */
0186 #define ETH_L4_FILTER_0                 0x00000000U
0187 #define ETH_L4_FILTER_1                 0x0000000CU
0188 /**
0189   * @}
0190   */
0191 
0192 /** @defgroup ETHEx_L3_Protocol ETHEx L3 Protocol
0193   * @ingroup RTEMSBSPsARMSTM32H7
0194   * @{
0195   */
0196 #define ETH_L3_IPV6_MATCH                       ETH_MACL3L4CR_L3PEN
0197 #define ETH_L3_IPV4_MATCH                       0x00000000U
0198 /**
0199   * @}
0200   */
0201 
0202 /** @defgroup ETHEx_L3_Source_Match ETHEx L3 Source Match
0203   * @ingroup RTEMSBSPsARMSTM32H7
0204   * @{
0205   */
0206 #define ETH_L3_SRC_ADDR_PERFECT_MATCH_ENABLE    ETH_MACL3L4CR_L3SAM
0207 #define ETH_L3_SRC_ADDR_INVERSE_MATCH_ENABLE    (ETH_MACL3L4CR_L3SAM | ETH_MACL3L4CR_L3SAIM)
0208 #define ETH_L3_SRC_ADDR_MATCH_DISABLE           0x00000000U
0209 /**
0210   * @}
0211   */
0212 
0213 /** @defgroup ETHEx_L3_Destination_Match ETHEx L3 Destination Match
0214   * @ingroup RTEMSBSPsARMSTM32H7
0215   * @{
0216   */
0217 #define ETH_L3_DEST_ADDR_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L3DAM
0218 #define ETH_L3_DEST_ADDR_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L3DAM | ETH_MACL3L4CR_L3DAIM)
0219 #define ETH_L3_DEST_ADDR_MATCH_DISABLE          0x00000000U
0220 /**
0221   * @}
0222   */
0223 
0224 /** @defgroup ETHEx_L4_Protocol ETHEx L4 Protocol
0225   * @ingroup RTEMSBSPsARMSTM32H7
0226   * @{
0227   */
0228 #define ETH_L4_UDP_MATCH                        ETH_MACL3L4CR_L4PEN
0229 #define ETH_L4_TCP_MATCH                        0x00000000U
0230 /**
0231   * @}
0232   */
0233 
0234 /** @defgroup ETHEx_L4_Source_Match ETHEx L4 Source Match
0235   * @ingroup RTEMSBSPsARMSTM32H7
0236   * @{
0237   */
0238 #define ETH_L4_SRC_PORT_PERFECT_MATCH_ENABLE    ETH_MACL3L4CR_L4SPM
0239 #define ETH_L4_SRC_PORT_INVERSE_MATCH_ENABLE    (ETH_MACL3L4CR_L4SPM |ETH_MACL3L4CR_L4SPIM)
0240 #define ETH_L4_SRC_PORT_MATCH_DISABLE           0x00000000U
0241 /**
0242   * @}
0243   */
0244 
0245 /** @defgroup ETHEx_L4_Destination_Match ETHEx L4 Destination Match
0246   * @ingroup RTEMSBSPsARMSTM32H7
0247   * @{
0248   */
0249 #define ETH_L4_DEST_PORT_PERFECT_MATCH_ENABLE   ETH_MACL3L4CR_L4DPM
0250 #define ETH_L4_DEST_PORT_INVERSE_MATCH_ENABLE   (ETH_MACL3L4CR_L4DPM | ETH_MACL3L4CR_L4DPIM)
0251 #define ETH_L4_DEST_PORT_MATCH_DISABLE          0x00000000U
0252 /**
0253   * @}
0254   */
0255 
0256 /** @defgroup ETHEx_Rx_Inner_VLAN_Tag_Stripping ETHEx Rx Inner VLAN Tag Stripping
0257   * @ingroup RTEMSBSPsARMSTM32H7
0258   * @{
0259   */
0260 #define ETH_INNERVLANTAGRXSTRIPPING_NONE      ETH_MACVTR_EIVLS_DONOTSTRIP
0261 #define ETH_INNERVLANTAGRXSTRIPPING_IFPASS    ETH_MACVTR_EIVLS_STRIPIFPASS
0262 #define ETH_INNERVLANTAGRXSTRIPPING_IFFAILS   ETH_MACVTR_EIVLS_STRIPIFFAILS
0263 #define ETH_INNERVLANTAGRXSTRIPPING_ALWAYS    ETH_MACVTR_EIVLS_ALWAYSSTRIP
0264 /**
0265   * @}
0266   */
0267 
0268 /** @defgroup ETHEx_Rx_VLAN_Tag_Stripping ETHEx Rx VLAN Tag Stripping
0269   * @ingroup RTEMSBSPsARMSTM32H7
0270   * @{
0271   */
0272 #define ETH_VLANTAGRXSTRIPPING_NONE      ETH_MACVTR_EVLS_DONOTSTRIP
0273 #define ETH_VLANTAGRXSTRIPPING_IFPASS    ETH_MACVTR_EVLS_STRIPIFPASS
0274 #define ETH_VLANTAGRXSTRIPPING_IFFAILS   ETH_MACVTR_EVLS_STRIPIFFAILS
0275 #define ETH_VLANTAGRXSTRIPPING_ALWAYS    ETH_MACVTR_EVLS_ALWAYSSTRIP
0276 /**
0277   * @}
0278   */
0279 
0280 /** @defgroup ETHEx_VLAN_Type_Check ETHEx VLAN Type Check
0281   * @ingroup RTEMSBSPsARMSTM32H7
0282   * @{
0283   */
0284 #define ETH_VLANTYPECHECK_DISABLE    ETH_MACVTR_DOVLTC
0285 #define ETH_VLANTYPECHECK_SVLAN      (ETH_MACVTR_ERSVLM | ETH_MACVTR_ESVL)
0286 #define ETH_VLANTYPECHECK_CVLAN      0x00000000U
0287 /**
0288   * @}
0289   */
0290 
0291 /** @defgroup ETHEx_VLAN_Tag_Control ETHEx_VLAN_Tag_Control
0292   * @ingroup RTEMSBSPsARMSTM32H7
0293   * @{
0294   */
0295 #define ETH_VLANTAGCONTROL_NONE       (ETH_MACVIR_VLP | ETH_MACVIR_VLC_NOVLANTAG)
0296 #define ETH_VLANTAGCONTROL_DELETE     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGDELETE)
0297 #define ETH_VLANTAGCONTROL_INSERT     (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGINSERT)
0298 #define ETH_VLANTAGCONTROL_REPLACE    (ETH_MACVIR_VLP | ETH_MACVIR_VLC_VLANTAGREPLACE)
0299 /**
0300   * @}
0301   */
0302 
0303 /** @defgroup ETHEx_Tx_VLAN_Tag ETHEx Tx VLAN Tag
0304   * @ingroup RTEMSBSPsARMSTM32H7
0305   * @{
0306   */
0307 #define ETH_INNER_TX_VLANTAG    0x00000001U
0308 #define ETH_OUTER_TX_VLANTAG    0x00000000U
0309 /**
0310   * @}
0311   */
0312 
0313 /**
0314   * @}
0315   */
0316 
0317 /* Exported functions --------------------------------------------------------*/
0318 /** @addtogroup ETHEx_Exported_Functions
0319   * @{
0320   */
0321 
0322 /** @addtogroup ETHEx_Exported_Functions_Group1
0323   * @{
0324   */
0325 /* MAC ARP Offloading APIs  ***************************************************/
0326 void              HAL_ETHEx_EnableARPOffload(ETH_HandleTypeDef *heth);
0327 void              HAL_ETHEx_DisableARPOffload(ETH_HandleTypeDef *heth);
0328 void              HAL_ETHEx_SetARPAddressMatch(ETH_HandleTypeDef *heth, uint32_t IpAddress);
0329 
0330 /* MAC L3 L4 Filtering APIs ***************************************************/
0331 void              HAL_ETHEx_EnableL3L4Filtering(ETH_HandleTypeDef *heth);
0332 void              HAL_ETHEx_DisableL3L4Filtering(ETH_HandleTypeDef *heth);
0333 HAL_StatusTypeDef HAL_ETHEx_GetL3FilterConfig(const ETH_HandleTypeDef *heth, uint32_t Filter,
0334                                               ETH_L3FilterConfigTypeDef *pL3FilterConfig);
0335 HAL_StatusTypeDef HAL_ETHEx_GetL4FilterConfig(const ETH_HandleTypeDef *heth, uint32_t Filter,
0336                                               ETH_L4FilterConfigTypeDef *pL4FilterConfig);
0337 HAL_StatusTypeDef HAL_ETHEx_SetL3FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
0338                                               const ETH_L3FilterConfigTypeDef *pL3FilterConfig);
0339 HAL_StatusTypeDef HAL_ETHEx_SetL4FilterConfig(ETH_HandleTypeDef *heth, uint32_t Filter,
0340                                               const ETH_L4FilterConfigTypeDef *pL4FilterConfig);
0341 
0342 /* MAC VLAN Processing APIs    ************************************************/
0343 void              HAL_ETHEx_EnableVLANProcessing(ETH_HandleTypeDef *heth);
0344 void              HAL_ETHEx_DisableVLANProcessing(ETH_HandleTypeDef *heth);
0345 HAL_StatusTypeDef HAL_ETHEx_GetRxVLANConfig(const ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
0346 HAL_StatusTypeDef HAL_ETHEx_SetRxVLANConfig(ETH_HandleTypeDef *heth, ETH_RxVLANConfigTypeDef *pVlanConfig);
0347 void              HAL_ETHEx_SetVLANHashTable(ETH_HandleTypeDef *heth, uint32_t VLANHashTable);
0348 HAL_StatusTypeDef HAL_ETHEx_GetTxVLANConfig(const ETH_HandleTypeDef *heth, uint32_t VLANTag,
0349                                             ETH_TxVLANConfigTypeDef *pVlanConfig);
0350 HAL_StatusTypeDef HAL_ETHEx_SetTxVLANConfig(ETH_HandleTypeDef *heth, uint32_t VLANTag,
0351                                             const ETH_TxVLANConfigTypeDef *pVlanConfig);
0352 void              HAL_ETHEx_SetTxVLANIdentifier(ETH_HandleTypeDef *heth, uint32_t VLANTag, uint32_t VLANIdentifier);
0353 
0354 /* Energy Efficient Ethernet APIs *********************************************/
0355 void              HAL_ETHEx_EnterLPIMode(ETH_HandleTypeDef *heth, FunctionalState TxAutomate,
0356                                          FunctionalState TxClockStop);
0357 void              HAL_ETHEx_ExitLPIMode(ETH_HandleTypeDef *heth);
0358 uint32_t          HAL_ETHEx_GetMACLPIEvent(const ETH_HandleTypeDef *heth);
0359 
0360 /**
0361   * @}
0362   */
0363 
0364 /**
0365   * @}
0366   */
0367 
0368 /**
0369   * @}
0370   */
0371 
0372 /**
0373   * @}
0374   */
0375 
0376 #endif /* ETH */
0377 
0378 #ifdef __cplusplus
0379 }
0380 #endif
0381 
0382 #endif /* STM32H7xx_HAL_ETH_EX_H */