Subversion Repositories DashDisplay

Rev

Rev 2 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**
  2.   ******************************************************************************
  3.   * @file    stm32f1xx_hal_eth.h
  4.   * @author  MCD Application Team
  5.   * @version V1.0.4
  6.   * @date    29-April-2016
  7.   * @brief   Header file of ETH HAL module.
  8.   ******************************************************************************
  9.   * @attention
  10.   *
  11.   * <h2><center>&copy; COPYRIGHT(c) 2016 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.  
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __STM32F1xx_HAL_ETH_H
  40. #define __STM32F1xx_HAL_ETH_H
  41.  
  42. #ifdef __cplusplus
  43.  extern "C" {
  44. #endif
  45.  
  46. /* Includes ------------------------------------------------------------------*/
  47. #include "stm32f1xx_hal_def.h"
  48.  
  49. /** @addtogroup STM32F1xx_HAL_Driver
  50.   * @{
  51.   */
  52. #if defined (STM32F107xC)
  53.  
  54. /** @addtogroup ETH
  55.   * @{
  56.   */
  57.  
  58. /** @addtogroup ETH_Private_Macros
  59.   * @{
  60.   */
  61. #define IS_ETH_PHY_ADDRESS(ADDRESS) ((ADDRESS) <= 0x20)
  62. #define IS_ETH_AUTONEGOTIATION(CMD) (((CMD) == ETH_AUTONEGOTIATION_ENABLE) || \
  63.                                      ((CMD) == ETH_AUTONEGOTIATION_DISABLE))
  64. #define IS_ETH_SPEED(SPEED) (((SPEED) == ETH_SPEED_10M) || \
  65.                              ((SPEED) == ETH_SPEED_100M))
  66. #define IS_ETH_DUPLEX_MODE(MODE)  (((MODE) == ETH_MODE_FULLDUPLEX) || \
  67.                                   ((MODE) == ETH_MODE_HALFDUPLEX))
  68. #define IS_ETH_RX_MODE(MODE)    (((MODE) == ETH_RXPOLLING_MODE) || \
  69.                                  ((MODE) == ETH_RXINTERRUPT_MODE))
  70. #define IS_ETH_CHECKSUM_MODE(MODE)    (((MODE) == ETH_CHECKSUM_BY_HARDWARE) || \
  71.                                       ((MODE) == ETH_CHECKSUM_BY_SOFTWARE))
  72. #define IS_ETH_MEDIA_INTERFACE(MODE)         (((MODE) == ETH_MEDIA_INTERFACE_MII) || \
  73.                                               ((MODE) == ETH_MEDIA_INTERFACE_RMII))
  74. #define IS_ETH_WATCHDOG(CMD) (((CMD) == ETH_WATCHDOG_ENABLE) || \
  75.                               ((CMD) == ETH_WATCHDOG_DISABLE))
  76. #define IS_ETH_JABBER(CMD) (((CMD) == ETH_JABBER_ENABLE) || \
  77.                             ((CMD) == ETH_JABBER_DISABLE))
  78. #define IS_ETH_INTER_FRAME_GAP(GAP) (((GAP) == ETH_INTERFRAMEGAP_96BIT) || \
  79.                                      ((GAP) == ETH_INTERFRAMEGAP_88BIT) || \
  80.                                      ((GAP) == ETH_INTERFRAMEGAP_80BIT) || \
  81.                                      ((GAP) == ETH_INTERFRAMEGAP_72BIT) || \
  82.                                      ((GAP) == ETH_INTERFRAMEGAP_64BIT) || \
  83.                                      ((GAP) == ETH_INTERFRAMEGAP_56BIT) || \
  84.                                      ((GAP) == ETH_INTERFRAMEGAP_48BIT) || \
  85.                                      ((GAP) == ETH_INTERFRAMEGAP_40BIT))
  86. #define IS_ETH_CARRIER_SENSE(CMD) (((CMD) == ETH_CARRIERSENCE_ENABLE) || \
  87.                                    ((CMD) == ETH_CARRIERSENCE_DISABLE))
  88. #define IS_ETH_RECEIVE_OWN(CMD) (((CMD) == ETH_RECEIVEOWN_ENABLE) || \
  89.                                  ((CMD) == ETH_RECEIVEOWN_DISABLE))
  90. #define IS_ETH_LOOPBACK_MODE(CMD) (((CMD) == ETH_LOOPBACKMODE_ENABLE) || \
  91.                                    ((CMD) == ETH_LOOPBACKMODE_DISABLE))
  92. #define IS_ETH_CHECKSUM_OFFLOAD(CMD) (((CMD) == ETH_CHECKSUMOFFLAOD_ENABLE) || \
  93.                                       ((CMD) == ETH_CHECKSUMOFFLAOD_DISABLE))
  94. #define IS_ETH_RETRY_TRANSMISSION(CMD) (((CMD) == ETH_RETRYTRANSMISSION_ENABLE) || \
  95.                                         ((CMD) == ETH_RETRYTRANSMISSION_DISABLE))
  96. #define IS_ETH_AUTOMATIC_PADCRC_STRIP(CMD) (((CMD) == ETH_AUTOMATICPADCRCSTRIP_ENABLE) || \
  97.                                             ((CMD) == ETH_AUTOMATICPADCRCSTRIP_DISABLE))
  98. #define IS_ETH_BACKOFF_LIMIT(LIMIT) (((LIMIT) == ETH_BACKOFFLIMIT_10) || \
  99.                                      ((LIMIT) == ETH_BACKOFFLIMIT_8) || \
  100.                                      ((LIMIT) == ETH_BACKOFFLIMIT_4) || \
  101.                                      ((LIMIT) == ETH_BACKOFFLIMIT_1))
  102. #define IS_ETH_DEFERRAL_CHECK(CMD) (((CMD) == ETH_DEFFERRALCHECK_ENABLE) || \
  103.                                     ((CMD) == ETH_DEFFERRALCHECK_DISABLE))
  104. #define IS_ETH_RECEIVE_ALL(CMD) (((CMD) == ETH_RECEIVEALL_ENABLE) || \
  105.                                  ((CMD) == ETH_RECEIVEAll_DISABLE))
  106. #define IS_ETH_SOURCE_ADDR_FILTER(CMD) (((CMD) == ETH_SOURCEADDRFILTER_NORMAL_ENABLE) || \
  107.                                         ((CMD) == ETH_SOURCEADDRFILTER_INVERSE_ENABLE) || \
  108.                                         ((CMD) == ETH_SOURCEADDRFILTER_DISABLE))
  109. #define IS_ETH_CONTROL_FRAMES(PASS) (((PASS) == ETH_PASSCONTROLFRAMES_BLOCKALL) || \
  110.                                      ((PASS) == ETH_PASSCONTROLFRAMES_FORWARDALL) || \
  111.                                      ((PASS) == ETH_PASSCONTROLFRAMES_FORWARDPASSEDADDRFILTER))
  112. #define IS_ETH_BROADCAST_FRAMES_RECEPTION(CMD) (((CMD) == ETH_BROADCASTFRAMESRECEPTION_ENABLE) || \
  113.                                                 ((CMD) == ETH_BROADCASTFRAMESRECEPTION_DISABLE))
  114. #define IS_ETH_DESTINATION_ADDR_FILTER(FILTER) (((FILTER) == ETH_DESTINATIONADDRFILTER_NORMAL) || \
  115.                                                 ((FILTER) == ETH_DESTINATIONADDRFILTER_INVERSE))
  116. #define IS_ETH_PROMISCUOUS_MODE(CMD) (((CMD) == ETH_PROMISCUOUS_MODE_ENABLE) || \
  117.                                       ((CMD) == ETH_PROMISCUOUS_MODE_DISABLE))
  118. #define IS_ETH_MULTICAST_FRAMES_FILTER(FILTER) (((FILTER) == ETH_MULTICASTFRAMESFILTER_PERFECTHASHTABLE) || \
  119.                                                 ((FILTER) == ETH_MULTICASTFRAMESFILTER_HASHTABLE) || \
  120.                                                 ((FILTER) == ETH_MULTICASTFRAMESFILTER_PERFECT) || \
  121.                                                 ((FILTER) == ETH_MULTICASTFRAMESFILTER_NONE))
  122. #define IS_ETH_UNICAST_FRAMES_FILTER(FILTER) (((FILTER) == ETH_UNICASTFRAMESFILTER_PERFECTHASHTABLE) || \
  123.                                               ((FILTER) == ETH_UNICASTFRAMESFILTER_HASHTABLE) || \
  124.                                               ((FILTER) == ETH_UNICASTFRAMESFILTER_PERFECT))
  125. #define IS_ETH_PAUSE_TIME(TIME) ((TIME) <= 0xFFFF)
  126. #define IS_ETH_ZEROQUANTA_PAUSE(CMD)   (((CMD) == ETH_ZEROQUANTAPAUSE_ENABLE) || \
  127.                                         ((CMD) == ETH_ZEROQUANTAPAUSE_DISABLE))
  128. #define IS_ETH_PAUSE_LOW_THRESHOLD(THRESHOLD) (((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS4) || \
  129.                                                ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS28) || \
  130.                                                ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS144) || \
  131.                                                ((THRESHOLD) == ETH_PAUSELOWTHRESHOLD_MINUS256))
  132. #define IS_ETH_UNICAST_PAUSE_FRAME_DETECT(CMD) (((CMD) == ETH_UNICASTPAUSEFRAMEDETECT_ENABLE) || \
  133.                                                 ((CMD) == ETH_UNICASTPAUSEFRAMEDETECT_DISABLE))
  134. #define IS_ETH_RECEIVE_FLOWCONTROL(CMD) (((CMD) == ETH_RECEIVEFLOWCONTROL_ENABLE) || \
  135.                                          ((CMD) == ETH_RECEIVEFLOWCONTROL_DISABLE))
  136. #define IS_ETH_TRANSMIT_FLOWCONTROL(CMD) (((CMD) == ETH_TRANSMITFLOWCONTROL_ENABLE) || \
  137.                                           ((CMD) == ETH_TRANSMITFLOWCONTROL_DISABLE))
  138. #define IS_ETH_VLAN_TAG_COMPARISON(COMPARISON) (((COMPARISON) == ETH_VLANTAGCOMPARISON_12BIT) || \
  139.                                                 ((COMPARISON) == ETH_VLANTAGCOMPARISON_16BIT))
  140. #define IS_ETH_VLAN_TAG_IDENTIFIER(IDENTIFIER) ((IDENTIFIER) <= 0xFFFF)
  141. #define IS_ETH_MAC_ADDRESS0123(ADDRESS) (((ADDRESS) == ETH_MAC_ADDRESS0) || \
  142.                                          ((ADDRESS) == ETH_MAC_ADDRESS1) || \
  143.                                          ((ADDRESS) == ETH_MAC_ADDRESS2) || \
  144.                                          ((ADDRESS) == ETH_MAC_ADDRESS3))
  145. #define IS_ETH_MAC_ADDRESS123(ADDRESS) (((ADDRESS) == ETH_MAC_ADDRESS1) || \
  146.                                         ((ADDRESS) == ETH_MAC_ADDRESS2) || \
  147.                                         ((ADDRESS) == ETH_MAC_ADDRESS3))
  148. #define IS_ETH_MAC_ADDRESS_FILTER(FILTER) (((FILTER) == ETH_MAC_ADDRESSFILTER_SA) || \
  149.                                            ((FILTER) == ETH_MAC_ADDRESSFILTER_DA))
  150. #define IS_ETH_MAC_ADDRESS_MASK(MASK) (((MASK) == ETH_MAC_ADDRESSMASK_BYTE6) || \
  151.                                        ((MASK) == ETH_MAC_ADDRESSMASK_BYTE5) || \
  152.                                        ((MASK) == ETH_MAC_ADDRESSMASK_BYTE4) || \
  153.                                        ((MASK) == ETH_MAC_ADDRESSMASK_BYTE3) || \
  154.                                        ((MASK) == ETH_MAC_ADDRESSMASK_BYTE2) || \
  155.                                        ((MASK) == ETH_MAC_ADDRESSMASK_BYTE1))
  156. #define IS_ETH_DROP_TCPIP_CHECKSUM_FRAME(CMD) (((CMD) == ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE) || \
  157.                                                ((CMD) == ETH_DROPTCPIPCHECKSUMERRORFRAME_DISABLE))
  158. #define IS_ETH_RECEIVE_STORE_FORWARD(CMD) (((CMD) == ETH_RECEIVESTOREFORWARD_ENABLE) || \
  159.                                            ((CMD) == ETH_RECEIVESTOREFORWARD_DISABLE))
  160. #define IS_ETH_FLUSH_RECEIVE_FRAME(CMD) (((CMD) == ETH_FLUSHRECEIVEDFRAME_ENABLE) || \
  161.                                          ((CMD) == ETH_FLUSHRECEIVEDFRAME_DISABLE))
  162. #define IS_ETH_TRANSMIT_STORE_FORWARD(CMD) (((CMD) == ETH_TRANSMITSTOREFORWARD_ENABLE) || \
  163.                                             ((CMD) == ETH_TRANSMITSTOREFORWARD_DISABLE))
  164. #define IS_ETH_TRANSMIT_THRESHOLD_CONTROL(THRESHOLD) (((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_64BYTES) || \
  165.                                                       ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_128BYTES) || \
  166.                                                       ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_192BYTES) || \
  167.                                                       ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_256BYTES) || \
  168.                                                       ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_40BYTES) || \
  169.                                                       ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_32BYTES) || \
  170.                                                       ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_24BYTES) || \
  171.                                                       ((THRESHOLD) == ETH_TRANSMITTHRESHOLDCONTROL_16BYTES))
  172. #define IS_ETH_FORWARD_ERROR_FRAMES(CMD) (((CMD) == ETH_FORWARDERRORFRAMES_ENABLE) || \
  173.                                           ((CMD) == ETH_FORWARDERRORFRAMES_DISABLE))
  174. #define IS_ETH_FORWARD_UNDERSIZED_GOOD_FRAMES(CMD) (((CMD) == ETH_FORWARDUNDERSIZEDGOODFRAMES_ENABLE) || \
  175.                                                     ((CMD) == ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE))
  176. #define IS_ETH_RECEIVE_THRESHOLD_CONTROL(THRESHOLD) (((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES) || \
  177.                                                      ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_32BYTES) || \
  178.                                                      ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_96BYTES) || \
  179.                                                      ((THRESHOLD) == ETH_RECEIVEDTHRESHOLDCONTROL_128BYTES))
  180. #define IS_ETH_SECOND_FRAME_OPERATE(CMD) (((CMD) == ETH_SECONDFRAMEOPERARTE_ENABLE) || \
  181.                                           ((CMD) == ETH_SECONDFRAMEOPERARTE_DISABLE))
  182. #define IS_ETH_ADDRESS_ALIGNED_BEATS(CMD) (((CMD) == ETH_ADDRESSALIGNEDBEATS_ENABLE) || \
  183.                                            ((CMD) == ETH_ADDRESSALIGNEDBEATS_DISABLE))
  184. #define IS_ETH_FIXED_BURST(CMD) (((CMD) == ETH_FIXEDBURST_ENABLE) || \
  185.                                  ((CMD) == ETH_FIXEDBURST_DISABLE))
  186. #define IS_ETH_RXDMA_BURST_LENGTH(LENGTH) (((LENGTH) == ETH_RXDMABURSTLENGTH_1BEAT) || \
  187.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_2BEAT) || \
  188.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_4BEAT) || \
  189.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_8BEAT) || \
  190.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_16BEAT) || \
  191.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_32BEAT) || \
  192.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_4BEAT) || \
  193.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_8BEAT) || \
  194.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_16BEAT) || \
  195.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_32BEAT) || \
  196.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_64BEAT) || \
  197.                                            ((LENGTH) == ETH_RXDMABURSTLENGTH_4XPBL_128BEAT))
  198. #define IS_ETH_TXDMA_BURST_LENGTH(LENGTH) (((LENGTH) == ETH_TXDMABURSTLENGTH_1BEAT) || \
  199.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_2BEAT) || \
  200.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_4BEAT) || \
  201.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_8BEAT) || \
  202.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_16BEAT) || \
  203.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_32BEAT) || \
  204.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_4BEAT) || \
  205.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_8BEAT) || \
  206.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_16BEAT) || \
  207.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_32BEAT) || \
  208.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_64BEAT) || \
  209.                                            ((LENGTH) == ETH_TXDMABURSTLENGTH_4XPBL_128BEAT))
  210. #define IS_ETH_DMA_DESC_SKIP_LENGTH(LENGTH) ((LENGTH) <= 0x1F)
  211. #define IS_ETH_DMA_ARBITRATION_ROUNDROBIN_RXTX(RATIO) (((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1) || \
  212.                                                        ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_2_1) || \
  213.                                                        ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_3_1) || \
  214.                                                        ((RATIO) == ETH_DMAARBITRATION_ROUNDROBIN_RXTX_4_1) || \
  215.                                                        ((RATIO) == ETH_DMAARBITRATION_RXPRIORTX))
  216.  
  217. #define IS_ETH_DMA_TXDESC_SEGMENT(SEGMENT) (((SEGMENT) == ETH_DMATXDESC_LASTSEGMENTS) || \
  218.                                             ((SEGMENT) == ETH_DMATXDESC_FIRSTSEGMENT))
  219. #define IS_ETH_DMA_TXDESC_CHECKSUM(CHECKSUM) (((CHECKSUM) == ETH_DMATXDESC_CHECKSUMBYPASS) || \
  220.                                               ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMIPV4HEADER) || \
  221.                                               ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT) || \
  222.                                               ((CHECKSUM) == ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL))
  223. #define IS_ETH_DMATXDESC_BUFFER_SIZE(SIZE) ((SIZE) <= 0x1FFF)
  224.  
  225. #define IS_ETH_DMA_RXDESC_BUFFER(BUFFER) (((BUFFER) == ETH_DMARXDESC_BUFFER1) || \
  226.                                           ((BUFFER) == ETH_DMARXDESC_BUFFER2))
  227.  
  228. #define IS_ETH_DMA_GET_OVERFLOW(OVERFLOW) (((OVERFLOW) == ETH_DMA_OVERFLOW_RXFIFOCOUNTER) || \
  229.                                            ((OVERFLOW) == ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER))
  230.  
  231. /**
  232.   * @}
  233.   */
  234.  
  235. /** @addtogroup ETH_Private_Constants
  236.   * @{
  237.   */
  238. /* Delay to wait when writing to some Ethernet registers */
  239. #define ETH_REG_WRITE_DELAY ((uint32_t)0x00000001)
  240.  
  241. /* ETHERNET Errors */
  242. #define  ETH_SUCCESS            ((uint32_t)0)
  243. #define  ETH_ERROR              ((uint32_t)1)
  244.  
  245. /* ETHERNET DMA Tx descriptors Collision Count Shift */
  246. #define  ETH_DMATXDESC_COLLISION_COUNTSHIFT         ((uint32_t)3)
  247.  
  248. /* ETHERNET DMA Tx descriptors Buffer2 Size Shift */
  249. #define  ETH_DMATXDESC_BUFFER2_SIZESHIFT           ((uint32_t)16)
  250.  
  251. /* ETHERNET DMA Rx descriptors Frame Length Shift */
  252. #define  ETH_DMARXDESC_FRAME_LENGTHSHIFT           ((uint32_t)16)
  253.  
  254. /* ETHERNET DMA Rx descriptors Buffer2 Size Shift */
  255. #define  ETH_DMARXDESC_BUFFER2_SIZESHIFT           ((uint32_t)16)
  256.  
  257. /* ETHERNET DMA Rx descriptors Frame length Shift */
  258. #define  ETH_DMARXDESC_FRAMELENGTHSHIFT            ((uint32_t)16)
  259.  
  260. /* ETHERNET MAC address offsets */
  261. #define ETH_MAC_ADDR_HBASE    (uint32_t)(ETH_MAC_BASE + (uint32_t)0x40)  /* ETHERNET MAC address high offset */
  262. #define ETH_MAC_ADDR_LBASE    (uint32_t)(ETH_MAC_BASE + (uint32_t)0x44)  /* ETHERNET MAC address low offset */
  263.  
  264. /* ETHERNET MACMIIAR register Mask */
  265. #define ETH_MACMIIAR_CR_MASK    ((uint32_t)0xFFFFFFE3)
  266.  
  267. /* ETHERNET MACCR register Mask */
  268. #define ETH_MACCR_CLEAR_MASK    ((uint32_t)0xFF20810F)  
  269.  
  270. /* ETHERNET MACFCR register Mask */
  271. #define ETH_MACFCR_CLEAR_MASK   ((uint32_t)0x0000FF41)
  272.  
  273. /* ETHERNET DMAOMR register Mask */
  274. #define ETH_DMAOMR_CLEAR_MASK   ((uint32_t)0xF8DE3F23)
  275.  
  276. /* ETHERNET Remote Wake-up frame register length */
  277. #define ETH_WAKEUP_REGISTER_LENGTH      8
  278.  
  279. /* ETHERNET Missed frames counter Shift */
  280. #define  ETH_DMA_RX_OVERFLOW_MISSEDFRAMES_COUNTERSHIFT     17
  281.  /**
  282.   * @}
  283.   */
  284.  
  285. /* Exported types ------------------------------------------------------------*/
  286. /** @defgroup ETH_Exported_Types ETH Exported Types
  287.   * @{
  288.   */
  289.  
  290. /**
  291.   * @brief  HAL State structures definition  
  292.   */
  293. typedef enum
  294. {
  295.   HAL_ETH_STATE_RESET             = 0x00,    /*!< Peripheral not yet Initialized or disabled         */
  296.   HAL_ETH_STATE_READY             = 0x01,    /*!< Peripheral Initialized and ready for use           */
  297.   HAL_ETH_STATE_BUSY              = 0x02,    /*!< an internal process is ongoing                     */
  298.   HAL_ETH_STATE_BUSY_TX           = 0x12,    /*!< Data Transmission process is ongoing               */
  299.   HAL_ETH_STATE_BUSY_RX           = 0x22,    /*!< Data Reception process is ongoing                  */
  300.   HAL_ETH_STATE_BUSY_TX_RX        = 0x32,    /*!< Data Transmission and Reception process is ongoing */
  301.   HAL_ETH_STATE_BUSY_WR           = 0x42,    /*!< Write process is ongoing                           */
  302.   HAL_ETH_STATE_BUSY_RD           = 0x82,    /*!< Read process is ongoing                            */
  303.   HAL_ETH_STATE_TIMEOUT           = 0x03,    /*!< Timeout state                                      */
  304.   HAL_ETH_STATE_ERROR             = 0x04     /*!< Reception process is ongoing                       */
  305. }HAL_ETH_StateTypeDef;
  306.  
  307. /**
  308.   * @brief  ETH Init Structure definition  
  309.   */
  310.  
  311. typedef struct
  312. {
  313.   uint32_t             AutoNegotiation;           /*!< Selects or not the AutoNegotiation mode for the external PHY
  314.                                                            The AutoNegotiation allows an automatic setting of the Speed (10/100Mbps)
  315.                                                            and the mode (half/full-duplex).
  316.                                                            This parameter can be a value of @ref ETH_AutoNegotiation */
  317.  
  318.   uint32_t             Speed;                     /*!< Sets the Ethernet speed: 10/100 Mbps.
  319.                                                            This parameter can be a value of @ref ETH_Speed */
  320.  
  321.   uint32_t             DuplexMode;                /*!< Selects the MAC duplex mode: Half-Duplex or Full-Duplex mode
  322.                                                            This parameter can be a value of @ref ETH_Duplex_Mode */
  323.  
  324.   uint16_t             PhyAddress;                /*!< Ethernet PHY address.
  325.                                                            This parameter must be a number between Min_Data = 0 and Max_Data = 32 */
  326.  
  327.   uint8_t             *MACAddr;                   /*!< MAC Address of used Hardware: must be pointer on an array of 6 bytes */
  328.  
  329.   uint32_t             RxMode;                    /*!< Selects the Ethernet Rx mode: Polling mode, Interrupt mode.
  330.                                                            This parameter can be a value of @ref ETH_Rx_Mode */
  331.  
  332.   uint32_t             ChecksumMode;              /*!< Selects if the checksum is check by hardware or by software.
  333.                                                          This parameter can be a value of @ref ETH_Checksum_Mode */
  334.  
  335.   uint32_t             MediaInterface    ;               /*!< Selects the media-independent interface or the reduced media-independent interface.
  336.                                                          This parameter can be a value of @ref ETH_Media_Interface */
  337.  
  338. } ETH_InitTypeDef;
  339.  
  340.  
  341.  /**
  342.   * @brief  ETH MAC Configuration Structure definition  
  343.   */
  344.  
  345. typedef struct
  346. {
  347.   uint32_t             Watchdog;                  /*!< Selects or not the Watchdog timer
  348.                                                            When enabled, the MAC allows no more then 2048 bytes to be received.
  349.                                                            When disabled, the MAC can receive up to 16384 bytes.
  350.                                                            This parameter can be a value of @ref ETH_Watchdog */  
  351.  
  352.   uint32_t             Jabber;                    /*!< Selects or not Jabber timer
  353.                                                            When enabled, the MAC allows no more then 2048 bytes to be sent.
  354.                                                            When disabled, the MAC can send up to 16384 bytes.
  355.                                                            This parameter can be a value of @ref ETH_Jabber */
  356.  
  357.   uint32_t             InterFrameGap;             /*!< Selects the minimum IFG between frames during transmission.
  358.                                                            This parameter can be a value of @ref ETH_Inter_Frame_Gap */  
  359.  
  360.   uint32_t             CarrierSense;              /*!< Selects or not the Carrier Sense.
  361.                                                            This parameter can be a value of @ref ETH_Carrier_Sense */
  362.  
  363.   uint32_t             ReceiveOwn;                /*!< Selects or not the ReceiveOwn,
  364.                                                            ReceiveOwn allows the reception of frames when the TX_EN signal is asserted
  365.                                                            in Half-Duplex mode.
  366.                                                            This parameter can be a value of @ref ETH_Receive_Own */  
  367.  
  368.   uint32_t             LoopbackMode;              /*!< Selects or not the internal MAC MII Loopback mode.
  369.                                                            This parameter can be a value of @ref ETH_Loop_Back_Mode */  
  370.  
  371.   uint32_t             ChecksumOffload;           /*!< Selects or not the IPv4 checksum checking for received frame payloads' TCP/UDP/ICMP headers.
  372.                                                            This parameter can be a value of @ref ETH_Checksum_Offload */    
  373.  
  374.   uint32_t             RetryTransmission;         /*!< Selects or not the MAC attempt retries transmission, based on the settings of BL,
  375.                                                            when a collision occurs (Half-Duplex mode).
  376.                                                            This parameter can be a value of @ref ETH_Retry_Transmission */
  377.  
  378.   uint32_t             AutomaticPadCRCStrip;      /*!< Selects or not the Automatic MAC Pad/CRC Stripping.
  379.                                                            This parameter can be a value of @ref ETH_Automatic_Pad_CRC_Strip */
  380.  
  381.   uint32_t             BackOffLimit;              /*!< Selects the BackOff limit value.
  382.                                                            This parameter can be a value of @ref ETH_Back_Off_Limit */
  383.  
  384.   uint32_t             DeferralCheck;             /*!< Selects or not the deferral check function (Half-Duplex mode).
  385.                                                            This parameter can be a value of @ref ETH_Deferral_Check */                                                                                                        
  386.  
  387.   uint32_t             ReceiveAll;                /*!< Selects or not all frames reception by the MAC (No filtering).
  388.                                                            This parameter can be a value of @ref ETH_Receive_All */  
  389.  
  390.   uint32_t             SourceAddrFilter;          /*!< Selects the Source Address Filter mode.                                                          
  391.                                                            This parameter can be a value of @ref ETH_Source_Addr_Filter */                  
  392.  
  393.   uint32_t             PassControlFrames;         /*!< Sets the forwarding mode of the control frames (including unicast and multicast PAUSE frames)                                                          
  394.                                                            This parameter can be a value of @ref ETH_Pass_Control_Frames */
  395.  
  396.   uint32_t             BroadcastFramesReception;  /*!< Selects or not the reception of Broadcast Frames.
  397.                                                            This parameter can be a value of @ref ETH_Broadcast_Frames_Reception */
  398.  
  399.   uint32_t             DestinationAddrFilter;     /*!< Sets the destination filter mode for both unicast and multicast frames.
  400.                                                            This parameter can be a value of @ref ETH_Destination_Addr_Filter */
  401.  
  402.   uint32_t             PromiscuousMode;           /*!< Selects or not the Promiscuous Mode
  403.                                                            This parameter can be a value of @ref ETH_Promiscuous_Mode */
  404.  
  405.   uint32_t             MulticastFramesFilter;     /*!< Selects the Multicast Frames filter mode: None/HashTableFilter/PerfectFilter/PerfectHashTableFilter.
  406.                                                            This parameter can be a value of @ref ETH_Multicast_Frames_Filter */
  407.  
  408.   uint32_t             UnicastFramesFilter;       /*!< Selects the Unicast Frames filter mode: HashTableFilter/PerfectFilter/PerfectHashTableFilter.
  409.                                                            This parameter can be a value of @ref ETH_Unicast_Frames_Filter */
  410.  
  411.   uint32_t             HashTableHigh;             /*!< This field holds the higher 32 bits of Hash table.
  412.                                                            This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF */
  413.  
  414.   uint32_t             HashTableLow;              /*!< This field holds the lower 32 bits of Hash table.
  415.                                                            This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFFFFFF  */    
  416.  
  417.   uint32_t             PauseTime;                 /*!< This field holds the value to be used in the Pause Time field in the transmit control frame.
  418.                                                            This parameter must be a number between Min_Data = 0x0 and Max_Data = 0xFFFF */
  419.  
  420.   uint32_t             ZeroQuantaPause;           /*!< Selects or not the automatic generation of Zero-Quanta Pause Control frames.
  421.                                                            This parameter can be a value of @ref ETH_Zero_Quanta_Pause */  
  422.  
  423.   uint32_t             PauseLowThreshold;         /*!< This field configures the threshold of the PAUSE to be checked for
  424.                                                            automatic retransmission of PAUSE Frame.
  425.                                                            This parameter can be a value of @ref ETH_Pause_Low_Threshold */
  426.                                                            
  427.   uint32_t             UnicastPauseFrameDetect;   /*!< Selects or not the MAC detection of the Pause frames (with MAC Address0
  428.                                                            unicast address and unique multicast address).
  429.                                                            This parameter can be a value of @ref ETH_Unicast_Pause_Frame_Detect */  
  430.  
  431.   uint32_t             ReceiveFlowControl;        /*!< Enables or disables the MAC to decode the received Pause frame and
  432.                                                            disable its transmitter for a specified time (Pause Time)
  433.                                                            This parameter can be a value of @ref ETH_Receive_Flow_Control */
  434.  
  435.   uint32_t             TransmitFlowControl;       /*!< Enables or disables the MAC to transmit Pause frames (Full-Duplex mode)
  436.                                                            or the MAC back-pressure operation (Half-Duplex mode)
  437.                                                            This parameter can be a value of @ref ETH_Transmit_Flow_Control */    
  438.  
  439.   uint32_t             VLANTagComparison;         /*!< Selects the 12-bit VLAN identifier or the complete 16-bit VLAN tag for
  440.                                                            comparison and filtering.
  441.                                                            This parameter can be a value of @ref ETH_VLAN_Tag_Comparison */
  442.  
  443.   uint32_t             VLANTagIdentifier;         /*!< Holds the VLAN tag identifier for receive frames */
  444.  
  445. } ETH_MACInitTypeDef;
  446.  
  447.  
  448. /**
  449.   * @brief  ETH DMA Configuration Structure definition  
  450.   */
  451.  
  452. typedef struct
  453. {
  454.  uint32_t              DropTCPIPChecksumErrorFrame; /*!< Selects or not the Dropping of TCP/IP Checksum Error Frames.
  455.                                                              This parameter can be a value of @ref ETH_Drop_TCP_IP_Checksum_Error_Frame */
  456.  
  457.   uint32_t             ReceiveStoreForward;         /*!< Enables or disables the Receive store and forward mode.
  458.                                                              This parameter can be a value of @ref ETH_Receive_Store_Forward */
  459.  
  460.   uint32_t             FlushReceivedFrame;          /*!< Enables or disables the flushing of received frames.
  461.                                                              This parameter can be a value of @ref ETH_Flush_Received_Frame */
  462.  
  463.   uint32_t             TransmitStoreForward;        /*!< Enables or disables Transmit store and forward mode.
  464.                                                              This parameter can be a value of @ref ETH_Transmit_Store_Forward */
  465.  
  466.   uint32_t             TransmitThresholdControl;    /*!< Selects or not the Transmit Threshold Control.
  467.                                                              This parameter can be a value of @ref ETH_Transmit_Threshold_Control */
  468.  
  469.   uint32_t             ForwardErrorFrames;          /*!< Selects or not the forward to the DMA of erroneous frames.
  470.                                                              This parameter can be a value of @ref ETH_Forward_Error_Frames */
  471.  
  472.   uint32_t             ForwardUndersizedGoodFrames; /*!< Enables or disables the Rx FIFO to forward Undersized frames (frames with no Error
  473.                                                              and length less than 64 bytes) including pad-bytes and CRC)
  474.                                                              This parameter can be a value of @ref ETH_Forward_Undersized_Good_Frames */
  475.  
  476.   uint32_t             ReceiveThresholdControl;     /*!< Selects the threshold level of the Receive FIFO.
  477.                                                              This parameter can be a value of @ref ETH_Receive_Threshold_Control */
  478.  
  479.   uint32_t             SecondFrameOperate;          /*!< Selects or not the Operate on second frame mode, which allows the DMA to process a second
  480.                                                              frame of Transmit data even before obtaining the status for the first frame.
  481.                                                              This parameter can be a value of @ref ETH_Second_Frame_Operate */
  482.  
  483.   uint32_t             AddressAlignedBeats;         /*!< Enables or disables the Address Aligned Beats.
  484.                                                              This parameter can be a value of @ref ETH_Address_Aligned_Beats */
  485.  
  486.   uint32_t             FixedBurst;                  /*!< Enables or disables the AHB Master interface fixed burst transfers.
  487.                                                              This parameter can be a value of @ref ETH_Fixed_Burst */
  488.                        
  489.   uint32_t             RxDMABurstLength;            /*!< Indicates the maximum number of beats to be transferred in one Rx DMA transaction.
  490.                                                              This parameter can be a value of @ref ETH_Rx_DMA_Burst_Length */
  491.  
  492.   uint32_t             TxDMABurstLength;            /*!< Indicates the maximum number of beats to be transferred in one Tx DMA transaction.
  493.                                                              This parameter can be a value of @ref ETH_Tx_DMA_Burst_Length */
  494.  
  495.   uint32_t             DescriptorSkipLength;        /*!< Specifies the number of word to skip between two unchained descriptors (Ring mode)
  496.                                                              This parameter must be a number between Min_Data = 0 and Max_Data = 32 */                                                            
  497.  
  498.   uint32_t             DMAArbitration;              /*!< Selects the DMA Tx/Rx arbitration.
  499.                                                              This parameter can be a value of @ref ETH_DMA_Arbitration */  
  500. } ETH_DMAInitTypeDef;
  501.  
  502.  
  503. /**
  504.   * @brief  ETH DMA Descriptors data structure definition
  505.   */
  506.  
  507. typedef struct  
  508. {
  509.   __IO uint32_t   Status;           /*!< Status */
  510.  
  511.   uint32_t   ControlBufferSize;     /*!< Control and Buffer1, Buffer2 lengths */
  512.  
  513.   uint32_t   Buffer1Addr;           /*!< Buffer1 address pointer */
  514.  
  515.   uint32_t   Buffer2NextDescAddr;   /*!< Buffer2 or next descriptor address pointer */
  516.  
  517. } ETH_DMADescTypeDef;
  518.  
  519.  
  520. /**
  521.   * @brief  Received Frame Informations structure definition
  522.   */
  523. typedef struct  
  524. {
  525.   ETH_DMADescTypeDef *FSRxDesc;          /*!< First Segment Rx Desc */
  526.  
  527.   ETH_DMADescTypeDef *LSRxDesc;          /*!< Last Segment Rx Desc */
  528.  
  529.   uint32_t  SegCount;                    /*!< Segment count */
  530.  
  531.   uint32_t length;                       /*!< Frame length */
  532.  
  533.   uint32_t buffer;                       /*!< Frame buffer */
  534.  
  535. } ETH_DMARxFrameInfos;
  536.  
  537.  
  538. /**
  539.   * @brief  ETH Handle Structure definition  
  540.   */
  541.  
  542. typedef struct
  543. {
  544.   ETH_TypeDef                *Instance;     /*!< Register base address       */
  545.  
  546.   ETH_InitTypeDef            Init;          /*!< Ethernet Init Configuration */
  547.  
  548.   uint32_t                   LinkStatus;    /*!< Ethernet link status        */
  549.  
  550.   ETH_DMADescTypeDef         *RxDesc;       /*!< Rx descriptor to Get        */
  551.  
  552.   ETH_DMADescTypeDef         *TxDesc;       /*!< Tx descriptor to Set        */
  553.  
  554.   ETH_DMARxFrameInfos        RxFrameInfos;  /*!< last Rx frame infos         */
  555.  
  556.   __IO HAL_ETH_StateTypeDef  State;         /*!< ETH communication state     */
  557.  
  558.   HAL_LockTypeDef            Lock;          /*!< ETH Lock                    */
  559.  
  560. } ETH_HandleTypeDef;
  561.  
  562.  /**
  563.   * @}
  564.   */
  565.  
  566. /* Exported constants --------------------------------------------------------*/
  567. /** @defgroup ETH_Exported_Constants ETH Exported Constants
  568.   * @{
  569.   */
  570.  
  571. /** @defgroup ETH_Buffers_setting ETH Buffers setting
  572.   * @{
  573.   */
  574. #define ETH_MAX_PACKET_SIZE    ((uint32_t)1524)    /*!< ETH_HEADER + ETH_EXTRA + ETH_VLAN_TAG + ETH_MAX_ETH_PAYLOAD + ETH_CRC */
  575. #define ETH_HEADER               ((uint32_t)14)    /*!< 6 byte Dest addr, 6 byte Src addr, 2 byte length/type */
  576. #define ETH_CRC                   ((uint32_t)4)    /*!< Ethernet CRC */
  577. #define ETH_EXTRA                 ((uint32_t)2)    /*!< Extra bytes in some cases */  
  578. #define ETH_VLAN_TAG                  ((uint32_t)4)    /*!< optional 802.1q VLAN Tag */
  579. #define ETH_MIN_ETH_PAYLOAD          ((uint32_t)46)    /*!< Minimum Ethernet payload size */
  580. #define ETH_MAX_ETH_PAYLOAD        ((uint32_t)1500)    /*!< Maximum Ethernet payload size */
  581. #define ETH_JUMBO_FRAME_PAYLOAD    ((uint32_t)9000)    /*!< Jumbo frame payload size */      
  582.  
  583.  /* Ethernet driver receive buffers are organized in a chained linked-list, when
  584.     an ethernet packet is received, the Rx-DMA will transfer the packet from RxFIFO
  585.     to the driver receive buffers memory.
  586.  
  587.     Depending on the size of the received ethernet packet and the size of
  588.     each ethernet driver receive buffer, the received packet can take one or more
  589.     ethernet driver receive buffer.
  590.  
  591.     In below are defined the size of one ethernet driver receive buffer ETH_RX_BUF_SIZE
  592.     and the total count of the driver receive buffers ETH_RXBUFNB.
  593.  
  594.     The configured value for ETH_RX_BUF_SIZE and ETH_RXBUFNB are only provided as
  595.     example, they can be reconfigured in the application layer to fit the application
  596.     needs */
  597.  
  598. /* Here we configure each Ethernet driver receive buffer to fit the Max size Ethernet
  599.    packet */
  600. #ifndef ETH_RX_BUF_SIZE
  601.  #define ETH_RX_BUF_SIZE         ETH_MAX_PACKET_SIZE
  602. #endif
  603.  
  604. /* 5 Ethernet driver receive buffers are used (in a chained linked list)*/
  605. #ifndef ETH_RXBUFNB
  606.  #define ETH_RXBUFNB             ((uint32_t)5     /*  5 Rx buffers of size ETH_RX_BUF_SIZE */
  607. #endif
  608.  
  609.  
  610.  /* Ethernet driver transmit buffers are organized in a chained linked-list, when
  611.     an ethernet packet is transmitted, Tx-DMA will transfer the packet from the
  612.     driver transmit buffers memory to the TxFIFO.
  613.  
  614.     Depending on the size of the Ethernet packet to be transmitted and the size of
  615.     each ethernet driver transmit buffer, the packet to be transmitted can take
  616.     one or more ethernet driver transmit buffer.
  617.  
  618.     In below are defined the size of one ethernet driver transmit buffer ETH_TX_BUF_SIZE
  619.     and the total count of the driver transmit buffers ETH_TXBUFNB.
  620.  
  621.     The configured value for ETH_TX_BUF_SIZE and ETH_TXBUFNB are only provided as
  622.     example, they can be reconfigured in the application layer to fit the application
  623.     needs */
  624.  
  625. /* Here we configure each Ethernet driver transmit buffer to fit the Max size Ethernet
  626.    packet */
  627. #ifndef ETH_TX_BUF_SIZE
  628.  #define ETH_TX_BUF_SIZE         ETH_MAX_PACKET_SIZE
  629. #endif
  630.  
  631. /* 5 ethernet driver transmit buffers are used (in a chained linked list)*/
  632. #ifndef ETH_TXBUFNB
  633.  #define ETH_TXBUFNB             ((uint32_t)5      /* 5  Tx buffers of size ETH_TX_BUF_SIZE */
  634. #endif
  635.  
  636.  /**
  637.   * @}
  638.   */
  639.  
  640. /** @defgroup ETH_DMA_TX_Descriptor ETH DMA TX Descriptor
  641.   * @{
  642.   */
  643.  
  644. /*
  645.    DMA Tx Desciptor
  646.   -----------------------------------------------------------------------------------------------
  647.   TDES0 | OWN(31) | CTRL[30:26] | Reserved[25:24] | CTRL[23:20] | Reserved[19:17] | Status[16:0] |
  648.   -----------------------------------------------------------------------------------------------
  649.   TDES1 | Reserved[31:29] | Buffer2 ByteCount[28:16] | Reserved[15:13] | Buffer1 ByteCount[12:0] |
  650.   -----------------------------------------------------------------------------------------------
  651.   TDES2 |                         Buffer1 Address [31:0]                                         |
  652.   -----------------------------------------------------------------------------------------------
  653.   TDES3 |                   Buffer2 Address [31:0] / Next Descriptor Address [31:0]              |
  654.   -----------------------------------------------------------------------------------------------
  655. */
  656.  
  657. /**
  658.   * @brief  Bit definition of TDES0 register: DMA Tx descriptor status register
  659.   */
  660. #define ETH_DMATXDESC_OWN                     ((uint32_t)0x80000000)  /*!< OWN bit: descriptor is owned by DMA engine */
  661. #define ETH_DMATXDESC_IC                      ((uint32_t)0x40000000)  /*!< Interrupt on Completion */
  662. #define ETH_DMATXDESC_LS                      ((uint32_t)0x20000000)  /*!< Last Segment */
  663. #define ETH_DMATXDESC_FS                      ((uint32_t)0x10000000)  /*!< First Segment */
  664. #define ETH_DMATXDESC_DC                      ((uint32_t)0x08000000)  /*!< Disable CRC */
  665. #define ETH_DMATXDESC_DP                      ((uint32_t)0x04000000)  /*!< Disable Padding */
  666. #define ETH_DMATXDESC_TTSE                    ((uint32_t)0x02000000)  /*!< Transmit Time Stamp Enable */
  667. #define ETH_DMATXDESC_CIC                     ((uint32_t)0x00C00000)  /*!< Checksum Insertion Control: 4 cases */
  668. #define ETH_DMATXDESC_CIC_BYPASS              ((uint32_t)0x00000000)  /*!< Do Nothing: Checksum Engine is bypassed */
  669. #define ETH_DMATXDESC_CIC_IPV4HEADER          ((uint32_t)0x00400000)  /*!< IPV4 header Checksum Insertion */
  670. #define ETH_DMATXDESC_CIC_TCPUDPICMP_SEGMENT  ((uint32_t)0x00800000)  /*!< TCP/UDP/ICMP Checksum Insertion calculated over segment only */
  671. #define ETH_DMATXDESC_CIC_TCPUDPICMP_FULL     ((uint32_t)0x00C00000)  /*!< TCP/UDP/ICMP Checksum Insertion fully calculated */
  672. #define ETH_DMATXDESC_TER                     ((uint32_t)0x00200000)  /*!< Transmit End of Ring */
  673. #define ETH_DMATXDESC_TCH                     ((uint32_t)0x00100000)  /*!< Second Address Chained */
  674. #define ETH_DMATXDESC_TTSS                    ((uint32_t)0x00020000)  /*!< Tx Time Stamp Status */
  675. #define ETH_DMATXDESC_IHE                     ((uint32_t)0x00010000)  /*!< IP Header Error */
  676. #define ETH_DMATXDESC_ES                      ((uint32_t)0x00008000)  /*!< Error summary: OR of the following bits: UE || ED || EC || LCO || NC || LCA || FF || JT */
  677. #define ETH_DMATXDESC_JT                      ((uint32_t)0x00004000)  /*!< Jabber Timeout */
  678. #define ETH_DMATXDESC_FF                      ((uint32_t)0x00002000)  /*!< Frame Flushed: DMA/MTL flushed the frame due to SW flush */
  679. #define ETH_DMATXDESC_PCE                     ((uint32_t)0x00001000)  /*!< Payload Checksum Error */
  680. #define ETH_DMATXDESC_LCA                     ((uint32_t)0x00000800)  /*!< Loss of Carrier: carrier lost during transmission */
  681. #define ETH_DMATXDESC_NC                      ((uint32_t)0x00000400)  /*!< No Carrier: no carrier signal from the transceiver */
  682. #define ETH_DMATXDESC_LCO                     ((uint32_t)0x00000200)  /*!< Late Collision: transmission aborted due to collision */
  683. #define ETH_DMATXDESC_EC                      ((uint32_t)0x00000100)  /*!< Excessive Collision: transmission aborted after 16 collisions */
  684. #define ETH_DMATXDESC_VF                      ((uint32_t)0x00000080)  /*!< VLAN Frame */
  685. #define ETH_DMATXDESC_CC                      ((uint32_t)0x00000078)  /*!< Collision Count */
  686. #define ETH_DMATXDESC_ED                      ((uint32_t)0x00000004)  /*!< Excessive Deferral */
  687. #define ETH_DMATXDESC_UF                      ((uint32_t)0x00000002)  /*!< Underflow Error: late data arrival from the memory */
  688. #define ETH_DMATXDESC_DB                      ((uint32_t)0x00000001)  /*!< Deferred Bit */
  689.  
  690. /**
  691.   * @brief  Bit definition of TDES1 register
  692.   */
  693. #define ETH_DMATXDESC_TBS2  ((uint32_t)0x1FFF0000)  /*!< Transmit Buffer2 Size */
  694. #define ETH_DMATXDESC_TBS1  ((uint32_t)0x00001FFF)  /*!< Transmit Buffer1 Size */
  695.  
  696. /**
  697.   * @brief  Bit definition of TDES2 register
  698.   */
  699. #define ETH_DMATXDESC_B1AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer1 Address Pointer */
  700.  
  701. /**
  702.   * @brief  Bit definition of TDES3 register
  703.   */
  704. #define ETH_DMATXDESC_B2AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer2 Address Pointer */
  705.  
  706. /**
  707.   * @}
  708.   */
  709. /** @defgroup ETH_DMA_RX_Descriptor ETH DMA RX Descriptor
  710.   * @{
  711.   */
  712.  
  713. /*
  714.   DMA Rx Descriptor
  715.   --------------------------------------------------------------------------------------------------------------------
  716.   RDES0 | OWN(31) |                                             Status [30:0]                                          |
  717.   ---------------------------------------------------------------------------------------------------------------------
  718.   RDES1 | CTRL(31) | Reserved[30:29] | Buffer2 ByteCount[28:16] | CTRL[15:14] | Reserved(13) | Buffer1 ByteCount[12:0] |
  719.   ---------------------------------------------------------------------------------------------------------------------
  720.   RDES2 |                                       Buffer1 Address [31:0]                                                 |
  721.   ---------------------------------------------------------------------------------------------------------------------
  722.   RDES3 |                          Buffer2 Address [31:0] / Next Descriptor Address [31:0]                             |
  723.   ---------------------------------------------------------------------------------------------------------------------
  724. */
  725.  
  726. /**
  727.   * @brief  Bit definition of RDES0 register: DMA Rx descriptor status register
  728.   */
  729. #define ETH_DMARXDESC_OWN         ((uint32_t)0x80000000)  /*!< OWN bit: descriptor is owned by DMA engine  */
  730. #define ETH_DMARXDESC_AFM         ((uint32_t)0x40000000)  /*!< DA Filter Fail for the rx frame  */
  731. #define ETH_DMARXDESC_FL          ((uint32_t)0x3FFF0000)  /*!< Receive descriptor frame length  */
  732. #define ETH_DMARXDESC_ES          ((uint32_t)0x00008000)  /*!< Error summary: OR of the following bits: DE || OE || IPC || LC || RWT || RE || CE */
  733. #define ETH_DMARXDESC_DE          ((uint32_t)0x00004000)  /*!< Descriptor error: no more descriptors for receive frame  */
  734. #define ETH_DMARXDESC_SAF         ((uint32_t)0x00002000)  /*!< SA Filter Fail for the received frame */
  735. #define ETH_DMARXDESC_LE          ((uint32_t)0x00001000)  /*!< Frame size not matching with length field */
  736. #define ETH_DMARXDESC_OE          ((uint32_t)0x00000800)  /*!< Overflow Error: Frame was damaged due to buffer overflow */
  737. #define ETH_DMARXDESC_VLAN        ((uint32_t)0x00000400)  /*!< VLAN Tag: received frame is a VLAN frame */
  738. #define ETH_DMARXDESC_FS          ((uint32_t)0x00000200)  /*!< First descriptor of the frame  */
  739. #define ETH_DMARXDESC_LS          ((uint32_t)0x00000100)  /*!< Last descriptor of the frame  */
  740. #define ETH_DMARXDESC_IPV4HCE     ((uint32_t)0x00000080)  /*!< IPC Checksum Error: Rx Ipv4 header checksum error   */    
  741. #define ETH_DMARXDESC_LC          ((uint32_t)0x00000040)  /*!< Late collision occurred during reception   */
  742. #define ETH_DMARXDESC_FT          ((uint32_t)0x00000020)  /*!< Frame type - Ethernet, otherwise 802.3    */
  743. #define ETH_DMARXDESC_RWT         ((uint32_t)0x00000010)  /*!< Receive Watchdog Timeout: watchdog timer expired during reception    */
  744. #define ETH_DMARXDESC_RE          ((uint32_t)0x00000008)  /*!< Receive error: error reported by MII interface  */
  745. #define ETH_DMARXDESC_DBE         ((uint32_t)0x00000004)  /*!< Dribble bit error: frame contains non int multiple of 8 bits  */
  746. #define ETH_DMARXDESC_CE          ((uint32_t)0x00000002)  /*!< CRC error */
  747. #define ETH_DMARXDESC_MAMPCE      ((uint32_t)0x00000001)  /*!< Rx MAC Address/Payload Checksum Error: Rx MAC address matched/ Rx Payload Checksum Error */
  748.  
  749. /**
  750.   * @brief  Bit definition of RDES1 register
  751.   */
  752. #define ETH_DMARXDESC_DIC   ((uint32_t)0x80000000)  /*!< Disable Interrupt on Completion */
  753. #define ETH_DMARXDESC_RBS2  ((uint32_t)0x1FFF0000)  /*!< Receive Buffer2 Size */
  754. #define ETH_DMARXDESC_RER   ((uint32_t)0x00008000)  /*!< Receive End of Ring */
  755. #define ETH_DMARXDESC_RCH   ((uint32_t)0x00004000)  /*!< Second Address Chained */
  756. #define ETH_DMARXDESC_RBS1  ((uint32_t)0x00001FFF)  /*!< Receive Buffer1 Size */
  757.  
  758. /**
  759.   * @brief  Bit definition of RDES2 register  
  760.   */
  761. #define ETH_DMARXDESC_B1AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer1 Address Pointer */
  762.  
  763. /**
  764.   * @brief  Bit definition of RDES3 register  
  765.   */
  766. #define ETH_DMARXDESC_B2AP  ((uint32_t)0xFFFFFFFF)  /*!< Buffer2 Address Pointer */
  767.  
  768. /**
  769.   * @}
  770.   */
  771.  /** @defgroup ETH_AutoNegotiation ETH AutoNegotiation
  772.   * @{
  773.   */
  774. #define ETH_AUTONEGOTIATION_ENABLE     ((uint32_t)0x00000001)
  775. #define ETH_AUTONEGOTIATION_DISABLE    ((uint32_t)0x00000000)
  776.  
  777. /**
  778.   * @}
  779.   */
  780. /** @defgroup ETH_Speed ETH Speed
  781.   * @{
  782.   */
  783. #define ETH_SPEED_10M        ((uint32_t)0x00000000)
  784. #define ETH_SPEED_100M       ((uint32_t)0x00004000)
  785.  
  786. /**
  787.   * @}
  788.   */
  789. /** @defgroup ETH_Duplex_Mode ETH Duplex Mode
  790.   * @{
  791.   */
  792. #define ETH_MODE_FULLDUPLEX       ((uint32_t)0x00000800)
  793. #define ETH_MODE_HALFDUPLEX       ((uint32_t)0x00000000)
  794. /**
  795.   * @}
  796.   */
  797. /** @defgroup ETH_Rx_Mode ETH Rx Mode
  798.   * @{
  799.   */
  800. #define ETH_RXPOLLING_MODE      ((uint32_t)0x00000000)
  801. #define ETH_RXINTERRUPT_MODE    ((uint32_t)0x00000001)
  802. /**
  803.   * @}
  804.   */
  805.  
  806. /** @defgroup ETH_Checksum_Mode ETH Checksum Mode
  807.   * @{
  808.   */
  809. #define ETH_CHECKSUM_BY_HARDWARE      ((uint32_t)0x00000000)
  810. #define ETH_CHECKSUM_BY_SOFTWARE      ((uint32_t)0x00000001)
  811. /**
  812.   * @}
  813.   */
  814.  
  815. /** @defgroup ETH_Media_Interface ETH Media Interface
  816.   * @{
  817.   */
  818. #define ETH_MEDIA_INTERFACE_MII       ((uint32_t)0x00000000)
  819. #define ETH_MEDIA_INTERFACE_RMII      ((uint32_t)AFIO_MAPR_MII_RMII_SEL)
  820.  
  821. /**
  822.   * @}
  823.   */
  824.  
  825. /** @defgroup ETH_Watchdog ETH Watchdog
  826.   * @{
  827.   */
  828. #define ETH_WATCHDOG_ENABLE       ((uint32_t)0x00000000)
  829. #define ETH_WATCHDOG_DISABLE      ((uint32_t)0x00800000)
  830.  
  831. /**
  832.   * @}
  833.   */
  834.  
  835. /** @defgroup ETH_Jabber ETH Jabber
  836.   * @{
  837.   */
  838. #define ETH_JABBER_ENABLE    ((uint32_t)0x00000000)
  839. #define ETH_JABBER_DISABLE   ((uint32_t)0x00400000)
  840.  
  841. /**
  842.   * @}
  843.   */
  844.  
  845. /** @defgroup ETH_Inter_Frame_Gap ETH Inter Frame Gap
  846.   * @{
  847.   */
  848. #define ETH_INTERFRAMEGAP_96BIT   ((uint32_t)0x00000000)  /*!< minimum IFG between frames during transmission is 96Bit */
  849. #define ETH_INTERFRAMEGAP_88BIT   ((uint32_t)0x00020000)  /*!< minimum IFG between frames during transmission is 88Bit */
  850. #define ETH_INTERFRAMEGAP_80BIT   ((uint32_t)0x00040000)  /*!< minimum IFG between frames during transmission is 80Bit */
  851. #define ETH_INTERFRAMEGAP_72BIT   ((uint32_t)0x00060000)  /*!< minimum IFG between frames during transmission is 72Bit */
  852. #define ETH_INTERFRAMEGAP_64BIT   ((uint32_t)0x00080000)  /*!< minimum IFG between frames during transmission is 64Bit */
  853. #define ETH_INTERFRAMEGAP_56BIT   ((uint32_t)0x000A0000)  /*!< minimum IFG between frames during transmission is 56Bit */
  854. #define ETH_INTERFRAMEGAP_48BIT   ((uint32_t)0x000C0000)  /*!< minimum IFG between frames during transmission is 48Bit */
  855. #define ETH_INTERFRAMEGAP_40BIT   ((uint32_t)0x000E0000)  /*!< minimum IFG between frames during transmission is 40Bit */
  856.  
  857. /**
  858.   * @}
  859.   */
  860.  
  861. /** @defgroup ETH_Carrier_Sense ETH Carrier Sense
  862.   * @{
  863.   */
  864. #define ETH_CARRIERSENCE_ENABLE   ((uint32_t)0x00000000)
  865. #define ETH_CARRIERSENCE_DISABLE ((uint32_t)0x00010000)
  866.  
  867. /**
  868.   * @}
  869.   */
  870.  
  871. /** @defgroup ETH_Receive_Own ETH Receive Own
  872.   * @{
  873.   */
  874. #define ETH_RECEIVEOWN_ENABLE     ((uint32_t)0x00000000)
  875. #define ETH_RECEIVEOWN_DISABLE   ((uint32_t)0x00002000)
  876.  
  877. /**
  878.   * @}
  879.   */
  880.  
  881. /** @defgroup ETH_Loop_Back_Mode ETH Loop Back Mode
  882.   * @{
  883.   */
  884. #define ETH_LOOPBACKMODE_ENABLE        ((uint32_t)0x00001000)
  885. #define ETH_LOOPBACKMODE_DISABLE       ((uint32_t)0x00000000)
  886.  
  887. /**
  888.   * @}
  889.   */
  890.  
  891. /** @defgroup ETH_Checksum_Offload ETH Checksum Offload
  892.   * @{
  893.   */
  894. #define ETH_CHECKSUMOFFLAOD_ENABLE     ((uint32_t)0x00000400)
  895. #define ETH_CHECKSUMOFFLAOD_DISABLE    ((uint32_t)0x00000000)
  896.  
  897. /**
  898.   * @}
  899.   */
  900.  
  901. /** @defgroup ETH_Retry_Transmission ETH Retry Transmission
  902.   * @{
  903.   */
  904. #define ETH_RETRYTRANSMISSION_ENABLE   ((uint32_t)0x00000000)
  905. #define ETH_RETRYTRANSMISSION_DISABLE  ((uint32_t)0x00000200)
  906.  
  907. /**
  908.   * @}
  909.   */
  910.  
  911. /** @defgroup ETH_Automatic_Pad_CRC_Strip ETH Automatic Pad CRC Strip
  912.   * @{
  913.   */
  914. #define ETH_AUTOMATICPADCRCSTRIP_ENABLE     ((uint32_t)0x00000080)
  915. #define ETH_AUTOMATICPADCRCSTRIP_DISABLE    ((uint32_t)0x00000000)
  916.  
  917. /**
  918.   * @}
  919.   */
  920.  
  921. /** @defgroup ETH_Back_Off_Limit ETH Back Off Limit
  922.   * @{
  923.   */
  924. #define ETH_BACKOFFLIMIT_10  ((uint32_t)0x00000000)
  925. #define ETH_BACKOFFLIMIT_8   ((uint32_t)0x00000020)
  926. #define ETH_BACKOFFLIMIT_4   ((uint32_t)0x00000040)
  927. #define ETH_BACKOFFLIMIT_1   ((uint32_t)0x00000060)
  928.  
  929. /**
  930.   * @}
  931.   */
  932.  
  933. /** @defgroup ETH_Deferral_Check ETH Deferral Check
  934.   * @{
  935.   */
  936. #define ETH_DEFFERRALCHECK_ENABLE       ((uint32_t)0x00000010)
  937. #define ETH_DEFFERRALCHECK_DISABLE      ((uint32_t)0x00000000)
  938.  
  939. /**
  940.   * @}
  941.   */
  942.  
  943. /** @defgroup ETH_Receive_All ETH Receive All
  944.   * @{
  945.   */
  946. #define ETH_RECEIVEALL_ENABLE     ((uint32_t)0x80000000)
  947. #define ETH_RECEIVEAll_DISABLE    ((uint32_t)0x00000000)
  948.  
  949. /**
  950.   * @}
  951.   */
  952.  
  953. /** @defgroup ETH_Source_Addr_Filter ETH Source Addr Filter
  954.   * @{
  955.   */
  956. #define ETH_SOURCEADDRFILTER_NORMAL_ENABLE       ((uint32_t)0x00000200)
  957. #define ETH_SOURCEADDRFILTER_INVERSE_ENABLE      ((uint32_t)0x00000300)
  958. #define ETH_SOURCEADDRFILTER_DISABLE             ((uint32_t)0x00000000)
  959.  
  960. /**
  961.   * @}
  962.   */
  963.  
  964. /** @defgroup ETH_Pass_Control_Frames ETH Pass Control Frames
  965.   * @{
  966.   */
  967. #define ETH_PASSCONTROLFRAMES_BLOCKALL                ((uint32_t)0x00000040)  /*!< MAC filters all control frames from reaching the application */
  968. #define ETH_PASSCONTROLFRAMES_FORWARDALL              ((uint32_t)0x00000080)  /*!< MAC forwards all control frames to application even if they fail the Address Filter */
  969. #define ETH_PASSCONTROLFRAMES_FORWARDPASSEDADDRFILTER ((uint32_t)0x000000C0)  /*!< MAC forwards control frames that pass the Address Filter. */
  970.  
  971. /**
  972.   * @}
  973.   */
  974.  
  975. /** @defgroup ETH_Broadcast_Frames_Reception ETH Broadcast Frames Reception
  976.   * @{
  977.   */
  978. #define ETH_BROADCASTFRAMESRECEPTION_ENABLE     ((uint32_t)0x00000000)
  979. #define ETH_BROADCASTFRAMESRECEPTION_DISABLE    ((uint32_t)0x00000020)
  980.  
  981. /**
  982.   * @}
  983.   */
  984.  
  985. /** @defgroup ETH_Destination_Addr_Filter ETH Destination Addr Filter
  986.   * @{
  987.   */
  988. #define ETH_DESTINATIONADDRFILTER_NORMAL    ((uint32_t)0x00000000)
  989. #define ETH_DESTINATIONADDRFILTER_INVERSE   ((uint32_t)0x00000008)
  990.  
  991. /**
  992.   * @}
  993.   */
  994.  
  995. /** @defgroup ETH_Promiscuous_Mode ETH Promiscuous Mode
  996.   * @{
  997.   */
  998. #define ETH_PROMISCUOUS_MODE_ENABLE     ((uint32_t)0x00000001)
  999. #define ETH_PROMISCUOUS_MODE_DISABLE    ((uint32_t)0x00000000)
  1000.  
  1001. /**
  1002.   * @}
  1003.   */
  1004.  
  1005. /** @defgroup ETH_Multicast_Frames_Filter ETH Multicast Frames Filter
  1006.   * @{
  1007.   */
  1008. #define ETH_MULTICASTFRAMESFILTER_PERFECTHASHTABLE    ((uint32_t)0x00000404)
  1009. #define ETH_MULTICASTFRAMESFILTER_HASHTABLE           ((uint32_t)0x00000004)
  1010. #define ETH_MULTICASTFRAMESFILTER_PERFECT             ((uint32_t)0x00000000)
  1011. #define ETH_MULTICASTFRAMESFILTER_NONE                ((uint32_t)0x00000010)
  1012.  
  1013. /**
  1014.   * @}
  1015.   */
  1016.  
  1017. /** @defgroup ETH_Unicast_Frames_Filter ETH Unicast Frames Filter
  1018.   * @{
  1019.   */
  1020. #define ETH_UNICASTFRAMESFILTER_PERFECTHASHTABLE ((uint32_t)0x00000402)
  1021. #define ETH_UNICASTFRAMESFILTER_HASHTABLE        ((uint32_t)0x00000002)
  1022. #define ETH_UNICASTFRAMESFILTER_PERFECT          ((uint32_t)0x00000000)
  1023.  
  1024. /**
  1025.   * @}
  1026.   */
  1027.  
  1028. /** @defgroup ETH_Zero_Quanta_Pause ETH Zero Quanta Pause
  1029.   * @{
  1030.   */
  1031. #define ETH_ZEROQUANTAPAUSE_ENABLE     ((uint32_t)0x00000000)
  1032. #define ETH_ZEROQUANTAPAUSE_DISABLE    ((uint32_t)0x00000080)
  1033.  
  1034. /**
  1035.   * @}
  1036.   */
  1037.  
  1038. /** @defgroup ETH_Pause_Low_Threshold ETH Pause Low Threshold
  1039.   * @{
  1040.   */
  1041. #define ETH_PAUSELOWTHRESHOLD_MINUS4        ((uint32_t)0x00000000)  /*!< Pause time minus 4 slot times */
  1042. #define ETH_PAUSELOWTHRESHOLD_MINUS28       ((uint32_t)0x00000010)  /*!< Pause time minus 28 slot times */
  1043. #define ETH_PAUSELOWTHRESHOLD_MINUS144      ((uint32_t)0x00000020)  /*!< Pause time minus 144 slot times */
  1044. #define ETH_PAUSELOWTHRESHOLD_MINUS256      ((uint32_t)0x00000030)  /*!< Pause time minus 256 slot times */
  1045.  
  1046. /**
  1047.   * @}
  1048.   */
  1049.  
  1050. /** @defgroup ETH_Unicast_Pause_Frame_Detect ETH Unicast Pause Frame Detect
  1051.   * @{
  1052.   */
  1053. #define ETH_UNICASTPAUSEFRAMEDETECT_ENABLE  ((uint32_t)0x00000008)
  1054. #define ETH_UNICASTPAUSEFRAMEDETECT_DISABLE ((uint32_t)0x00000000)
  1055.  
  1056. /**
  1057.   * @}
  1058.   */
  1059.  
  1060. /** @defgroup ETH_Receive_Flow_Control ETH Receive Flow Control
  1061.   * @{
  1062.   */
  1063. #define ETH_RECEIVEFLOWCONTROL_ENABLE       ((uint32_t)0x00000004)
  1064. #define ETH_RECEIVEFLOWCONTROL_DISABLE      ((uint32_t)0x00000000)
  1065.  
  1066. /**
  1067.   * @}
  1068.   */
  1069.  
  1070. /** @defgroup ETH_Transmit_Flow_Control ETH Transmit Flow Control
  1071.   * @{
  1072.   */
  1073. #define ETH_TRANSMITFLOWCONTROL_ENABLE      ((uint32_t)0x00000002)
  1074. #define ETH_TRANSMITFLOWCONTROL_DISABLE     ((uint32_t)0x00000000)
  1075.  
  1076. /**
  1077.   * @}
  1078.   */
  1079.  
  1080. /** @defgroup ETH_VLAN_Tag_Comparison ETH VLAN Tag Comparison
  1081.   * @{
  1082.   */
  1083. #define ETH_VLANTAGCOMPARISON_12BIT    ((uint32_t)0x00010000)
  1084. #define ETH_VLANTAGCOMPARISON_16BIT    ((uint32_t)0x00000000)
  1085.  
  1086. /**
  1087.   * @}
  1088.   */
  1089.  
  1090. /** @defgroup ETH_MAC_addresses ETH MAC addresses
  1091.   * @{
  1092.   */
  1093. #define ETH_MAC_ADDRESS0     ((uint32_t)0x00000000)
  1094. #define ETH_MAC_ADDRESS1     ((uint32_t)0x00000008)
  1095. #define ETH_MAC_ADDRESS2     ((uint32_t)0x00000010)
  1096. #define ETH_MAC_ADDRESS3     ((uint32_t)0x00000018)
  1097.  
  1098. /**
  1099.   * @}
  1100.   */
  1101.  
  1102. /** @defgroup ETH_MAC_Addresses_Filter_SA_DA ETH MAC Addresses Filter SA DA
  1103.   * @{
  1104.   */
  1105. #define ETH_MAC_ADDRESSFILTER_SA       ((uint32_t)0x00000000)
  1106. #define ETH_MAC_ADDRESSFILTER_DA       ((uint32_t)0x00000008)
  1107. /**
  1108.   * @}
  1109.   */
  1110.  
  1111. /** @defgroup ETH_MAC_Addresses_Filter_Mask_Bytes ETH_MAC Addresses Filter Mask Bytes
  1112.   * @{
  1113.   */
  1114. #define ETH_MAC_ADDRESSMASK_BYTE6      ((uint32_t)0x20000000)  /*!< Mask MAC Address high reg bits [15:8] */
  1115. #define ETH_MAC_ADDRESSMASK_BYTE5      ((uint32_t)0x10000000)  /*!< Mask MAC Address high reg bits [7:0] */
  1116. #define ETH_MAC_ADDRESSMASK_BYTE4      ((uint32_t)0x08000000)  /*!< Mask MAC Address low reg bits [31:24] */
  1117. #define ETH_MAC_ADDRESSMASK_BYTE3      ((uint32_t)0x04000000)  /*!< Mask MAC Address low reg bits [23:16] */
  1118. #define ETH_MAC_ADDRESSMASK_BYTE2      ((uint32_t)0x02000000)  /*!< Mask MAC Address low reg bits [15:8] */
  1119. #define ETH_MAC_ADDRESSMASK_BYTE1      ((uint32_t)0x01000000)  /*!< Mask MAC Address low reg bits [70] */
  1120.  
  1121. /**
  1122.   * @}
  1123.   */
  1124.  
  1125. /** @defgroup ETH_MAC_Debug_Flags ETH MAC Debug Flags
  1126.   * @{
  1127.   */
  1128. #define ETH_MAC_TXFIFO_FULL          ((uint32_t)0x02000000)  /* Tx FIFO full */
  1129. #define ETH_MAC_TXFIFONOT_EMPTY      ((uint32_t)0x01000000)  /* Tx FIFO not empty */
  1130. #define ETH_MAC_TXFIFO_WRITE_ACTIVE  ((uint32_t)0x00400000)  /* Tx FIFO write active */
  1131. #define ETH_MAC_TXFIFO_IDLE     ((uint32_t)0x00000000)  /* Tx FIFO read status: Idle */
  1132. #define ETH_MAC_TXFIFO_READ     ((uint32_t)0x00100000)  /* Tx FIFO read status: Read (transferring data to the MAC transmitter) */
  1133. #define ETH_MAC_TXFIFO_WAITING  ((uint32_t)0x00200000)  /* Tx FIFO read status: Waiting for TxStatus from MAC transmitter */
  1134. #define ETH_MAC_TXFIFO_WRITING  ((uint32_t)0x00300000)  /* Tx FIFO read status: Writing the received TxStatus or flushing the TxFIFO */
  1135. #define ETH_MAC_TRANSMISSION_PAUSE     ((uint32_t)0x00080000)  /* MAC transmitter in pause */
  1136. #define ETH_MAC_TRANSMITFRAMECONTROLLER_IDLE            ((uint32_t)0x00000000)  /* MAC transmit frame controller: Idle */
  1137. #define ETH_MAC_TRANSMITFRAMECONTROLLER_WAITING         ((uint32_t)0x00020000)  /* MAC transmit frame controller: Waiting for Status of previous frame or IFG/backoff period to be over */
  1138. #define ETH_MAC_TRANSMITFRAMECONTROLLER_GENRATING_PCF   ((uint32_t)0x00040000)  /* MAC transmit frame controller: Generating and transmitting a Pause control frame (in full duplex mode) */
  1139. #define ETH_MAC_TRANSMITFRAMECONTROLLER_TRANSFERRING    ((uint32_t)0x00060000)  /* MAC transmit frame controller: Transferring input frame for transmission */
  1140. #define ETH_MAC_MII_TRANSMIT_ACTIVE      ((uint32_t)0x00010000)  /* MAC MII transmit engine active */
  1141. #define ETH_MAC_RXFIFO_EMPTY             ((uint32_t)0x00000000)  /* Rx FIFO fill level: empty */
  1142. #define ETH_MAC_RXFIFO_BELOW_THRESHOLD   ((uint32_t)0x00000100)  /* Rx FIFO fill level: fill-level below flow-control de-activate threshold */
  1143. #define ETH_MAC_RXFIFO_ABOVE_THRESHOLD   ((uint32_t)0x00000200)  /* Rx FIFO fill level: fill-level above flow-control activate threshold */
  1144. #define ETH_MAC_RXFIFO_FULL              ((uint32_t)0x00000300)  /* Rx FIFO fill level: full */
  1145. #define ETH_MAC_READCONTROLLER_IDLE            ((uint32_t)0x00000060)  /* Rx FIFO read controller IDLE state */
  1146. #define ETH_MAC_READCONTROLLER_READING_DATA    ((uint32_t)0x00000060)  /* Rx FIFO read controller Reading frame data */
  1147. #define ETH_MAC_READCONTROLLER_READING_STATUS  ((uint32_t)0x00000060)  /* Rx FIFO read controller Reading frame status (or time-stamp) */
  1148. #define ETH_MAC_READCONTROLLER_FLUSHING        ((uint32_t)0x00000060)  /* Rx FIFO read controller Flushing the frame data and status */
  1149. #define ETH_MAC_RXFIFO_WRITE_ACTIVE     ((uint32_t)0x00000010)  /* Rx FIFO write controller active */
  1150. #define ETH_MAC_SMALL_FIFO_NOTACTIVE    ((uint32_t)0x00000000)  /* MAC small FIFO read / write controllers not active */
  1151. #define ETH_MAC_SMALL_FIFO_READ_ACTIVE  ((uint32_t)0x00000002)  /* MAC small FIFO read controller active */
  1152. #define ETH_MAC_SMALL_FIFO_WRITE_ACTIVE ((uint32_t)0x00000004)  /* MAC small FIFO write controller active */
  1153. #define ETH_MAC_SMALL_FIFO_RW_ACTIVE    ((uint32_t)0x00000006)  /* MAC small FIFO read / write controllers active */
  1154. #define ETH_MAC_MII_RECEIVE_PROTOCOL_ACTIVE   ((uint32_t)0x00000001)  /* MAC MII receive protocol engine active */
  1155.  
  1156. /**
  1157.   * @}
  1158.   */
  1159.  
  1160. /** @defgroup ETH_Drop_TCP_IP_Checksum_Error_Frame ETH Drop TCP IP Checksum Error Frame
  1161.   * @{
  1162.   */
  1163. #define ETH_DROPTCPIPCHECKSUMERRORFRAME_ENABLE   ((uint32_t)0x00000000)
  1164. #define ETH_DROPTCPIPCHECKSUMERRORFRAME_DISABLE  ((uint32_t)0x04000000)
  1165.  
  1166. /**
  1167.   * @}
  1168.   */
  1169.  
  1170. /** @defgroup ETH_Receive_Store_Forward ETH Receive Store Forward
  1171.   * @{
  1172.   */
  1173. #define ETH_RECEIVESTOREFORWARD_ENABLE      ((uint32_t)0x02000000)
  1174. #define ETH_RECEIVESTOREFORWARD_DISABLE     ((uint32_t)0x00000000)
  1175.  
  1176. /**
  1177.   * @}
  1178.   */
  1179.  
  1180. /** @defgroup ETH_Flush_Received_Frame ETH Flush Received Frame
  1181.   * @{
  1182.   */
  1183. #define ETH_FLUSHRECEIVEDFRAME_ENABLE       ((uint32_t)0x00000000)
  1184. #define ETH_FLUSHRECEIVEDFRAME_DISABLE      ((uint32_t)0x01000000)
  1185.  
  1186. /**
  1187.   * @}
  1188.   */
  1189.  
  1190. /** @defgroup ETH_Transmit_Store_Forward ETH Transmit Store Forward
  1191.   * @{
  1192.   */
  1193. #define ETH_TRANSMITSTOREFORWARD_ENABLE     ((uint32_t)0x00200000)
  1194. #define ETH_TRANSMITSTOREFORWARD_DISABLE    ((uint32_t)0x00000000)
  1195.  
  1196. /**
  1197.   * @}
  1198.   */
  1199.  
  1200. /** @defgroup ETH_Transmit_Threshold_Control ETH Transmit Threshold Control
  1201.   * @{
  1202.   */
  1203. #define ETH_TRANSMITTHRESHOLDCONTROL_64BYTES     ((uint32_t)0x00000000)  /*!< threshold level of the MTL Transmit FIFO is 64 Bytes */
  1204. #define ETH_TRANSMITTHRESHOLDCONTROL_128BYTES    ((uint32_t)0x00004000)  /*!< threshold level of the MTL Transmit FIFO is 128 Bytes */
  1205. #define ETH_TRANSMITTHRESHOLDCONTROL_192BYTES    ((uint32_t)0x00008000)  /*!< threshold level of the MTL Transmit FIFO is 192 Bytes */
  1206. #define ETH_TRANSMITTHRESHOLDCONTROL_256BYTES    ((uint32_t)0x0000C000)  /*!< threshold level of the MTL Transmit FIFO is 256 Bytes */
  1207. #define ETH_TRANSMITTHRESHOLDCONTROL_40BYTES     ((uint32_t)0x00010000)  /*!< threshold level of the MTL Transmit FIFO is 40 Bytes */
  1208. #define ETH_TRANSMITTHRESHOLDCONTROL_32BYTES     ((uint32_t)0x00014000)  /*!< threshold level of the MTL Transmit FIFO is 32 Bytes */
  1209. #define ETH_TRANSMITTHRESHOLDCONTROL_24BYTES     ((uint32_t)0x00018000)  /*!< threshold level of the MTL Transmit FIFO is 24 Bytes */
  1210. #define ETH_TRANSMITTHRESHOLDCONTROL_16BYTES     ((uint32_t)0x0001C000)  /*!< threshold level of the MTL Transmit FIFO is 16 Bytes */
  1211.  
  1212. /**
  1213.   * @}
  1214.   */
  1215.  
  1216. /** @defgroup ETH_Forward_Error_Frames ETH Forward Error Frames
  1217.   * @{
  1218.   */
  1219. #define ETH_FORWARDERRORFRAMES_ENABLE       ((uint32_t)0x00000080)
  1220. #define ETH_FORWARDERRORFRAMES_DISABLE      ((uint32_t)0x00000000)
  1221.  
  1222. /**
  1223.   * @}
  1224.   */
  1225.  
  1226. /** @defgroup ETH_Forward_Undersized_Good_Frames ETH Forward Undersized Good Frames
  1227.   * @{
  1228.   */
  1229. #define ETH_FORWARDUNDERSIZEDGOODFRAMES_ENABLE   ((uint32_t)0x00000040)
  1230. #define ETH_FORWARDUNDERSIZEDGOODFRAMES_DISABLE  ((uint32_t)0x00000000)    
  1231.  
  1232. /**
  1233.   * @}
  1234.   */
  1235.  
  1236. /** @defgroup ETH_Receive_Threshold_Control ETH Receive Threshold Control
  1237.   * @{
  1238.   */
  1239. #define ETH_RECEIVEDTHRESHOLDCONTROL_64BYTES      ((uint32_t)0x00000000)  /*!< threshold level of the MTL Receive FIFO is 64 Bytes */
  1240. #define ETH_RECEIVEDTHRESHOLDCONTROL_32BYTES      ((uint32_t)0x00000008)  /*!< threshold level of the MTL Receive FIFO is 32 Bytes */
  1241. #define ETH_RECEIVEDTHRESHOLDCONTROL_96BYTES      ((uint32_t)0x00000010)  /*!< threshold level of the MTL Receive FIFO is 96 Bytes */
  1242. #define ETH_RECEIVEDTHRESHOLDCONTROL_128BYTES     ((uint32_t)0x00000018)  /*!< threshold level of the MTL Receive FIFO is 128 Bytes */
  1243.  
  1244. /**
  1245.   * @}
  1246.   */
  1247.  
  1248. /** @defgroup ETH_Second_Frame_Operate ETH Second Frame Operate
  1249.   * @{
  1250.   */
  1251. #define ETH_SECONDFRAMEOPERARTE_ENABLE       ((uint32_t)0x00000004)
  1252. #define ETH_SECONDFRAMEOPERARTE_DISABLE      ((uint32_t)0x00000000)  
  1253.  
  1254. /**
  1255.   * @}
  1256.   */
  1257.  
  1258. /** @defgroup ETH_Address_Aligned_Beats ETH Address Aligned Beats
  1259.   * @{
  1260.   */
  1261. #define ETH_ADDRESSALIGNEDBEATS_ENABLE      ((uint32_t)0x02000000)
  1262. #define ETH_ADDRESSALIGNEDBEATS_DISABLE     ((uint32_t)0x00000000)
  1263.  
  1264. /**
  1265.   * @}
  1266.   */
  1267.  
  1268. /** @defgroup ETH_Fixed_Burst ETH Fixed Burst
  1269.   * @{
  1270.   */
  1271. #define ETH_FIXEDBURST_ENABLE     ((uint32_t)0x00010000)
  1272. #define ETH_FIXEDBURST_DISABLE    ((uint32_t)0x00000000)
  1273.  
  1274. /**
  1275.   * @}
  1276.   */
  1277.  
  1278. /** @defgroup ETH_Rx_DMA_Burst_Length ETH Rx DMA_Burst Length
  1279.   * @{
  1280.   */
  1281. #define ETH_RXDMABURSTLENGTH_1BEAT          ((uint32_t)0x00020000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 1 */
  1282. #define ETH_RXDMABURSTLENGTH_2BEAT          ((uint32_t)0x00040000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 2 */
  1283. #define ETH_RXDMABURSTLENGTH_4BEAT          ((uint32_t)0x00080000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 4 */
  1284. #define ETH_RXDMABURSTLENGTH_8BEAT          ((uint32_t)0x00100000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 8 */
  1285. #define ETH_RXDMABURSTLENGTH_16BEAT         ((uint32_t)0x00200000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 16 */
  1286. #define ETH_RXDMABURSTLENGTH_32BEAT         ((uint32_t)0x00400000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 32 */                
  1287. #define ETH_RXDMABURSTLENGTH_4XPBL_4BEAT    ((uint32_t)0x01020000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 4 */
  1288. #define ETH_RXDMABURSTLENGTH_4XPBL_8BEAT    ((uint32_t)0x01040000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 8 */
  1289. #define ETH_RXDMABURSTLENGTH_4XPBL_16BEAT   ((uint32_t)0x01080000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 16 */
  1290. #define ETH_RXDMABURSTLENGTH_4XPBL_32BEAT   ((uint32_t)0x01100000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 32 */
  1291. #define ETH_RXDMABURSTLENGTH_4XPBL_64BEAT   ((uint32_t)0x01200000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 64 */
  1292. #define ETH_RXDMABURSTLENGTH_4XPBL_128BEAT  ((uint32_t)0x01400000)  /*!< maximum number of beats to be transferred in one RxDMA transaction is 128 */
  1293.  
  1294. /**
  1295.   * @}
  1296.   */
  1297.  
  1298. /** @defgroup ETH_Tx_DMA_Burst_Length ETH Tx DMA Burst Length
  1299.   * @{
  1300.   */
  1301. #define ETH_TXDMABURSTLENGTH_1BEAT          ((uint32_t)0x00000100)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 1 */
  1302. #define ETH_TXDMABURSTLENGTH_2BEAT          ((uint32_t)0x00000200)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 2 */
  1303. #define ETH_TXDMABURSTLENGTH_4BEAT          ((uint32_t)0x00000400)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */
  1304. #define ETH_TXDMABURSTLENGTH_8BEAT          ((uint32_t)0x00000800)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */
  1305. #define ETH_TXDMABURSTLENGTH_16BEAT         ((uint32_t)0x00001000)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */
  1306. #define ETH_TXDMABURSTLENGTH_32BEAT         ((uint32_t)0x00002000)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */                
  1307. #define ETH_TXDMABURSTLENGTH_4XPBL_4BEAT    ((uint32_t)0x01000100)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 4 */
  1308. #define ETH_TXDMABURSTLENGTH_4XPBL_8BEAT    ((uint32_t)0x01000200)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 8 */
  1309. #define ETH_TXDMABURSTLENGTH_4XPBL_16BEAT   ((uint32_t)0x01000400)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 16 */
  1310. #define ETH_TXDMABURSTLENGTH_4XPBL_32BEAT   ((uint32_t)0x01000800)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 32 */
  1311. #define ETH_TXDMABURSTLENGTH_4XPBL_64BEAT   ((uint32_t)0x01001000)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 64 */
  1312. #define ETH_TXDMABURSTLENGTH_4XPBL_128BEAT  ((uint32_t)0x01002000)  /*!< maximum number of beats to be transferred in one TxDMA (or both) transaction is 128 */
  1313.  
  1314. /**
  1315.   * @}
  1316.   */
  1317.  
  1318. /** @defgroup ETH_DMA_Arbitration ETH DMA Arbitration
  1319.   * @{
  1320.   */
  1321. #define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_1_1   ((uint32_t)0x00000000)
  1322. #define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_2_1   ((uint32_t)0x00004000)
  1323. #define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_3_1   ((uint32_t)0x00008000)
  1324. #define ETH_DMAARBITRATION_ROUNDROBIN_RXTX_4_1   ((uint32_t)0x0000C000)
  1325. #define ETH_DMAARBITRATION_RXPRIORTX             ((uint32_t)0x00000002)
  1326.  
  1327. /**
  1328.   * @}
  1329.   */
  1330.  
  1331. /** @defgroup ETH_DMA_Tx_Descriptor_Segment ETH DMA Tx Descriptor Segment
  1332.   * @{
  1333.   */
  1334. #define ETH_DMATXDESC_LASTSEGMENTS      ((uint32_t)0x40000000)  /*!< Last Segment */
  1335. #define ETH_DMATXDESC_FIRSTSEGMENT      ((uint32_t)0x20000000)  /*!< First Segment */
  1336.  
  1337. /**
  1338.   * @}
  1339.   */
  1340.  
  1341. /** @defgroup ETH_DMA_Tx_Descriptor_Checksum_Insertion_Control ETH DMA Tx Descriptor Checksum Insertion Control
  1342.   * @{
  1343.   */
  1344. #define ETH_DMATXDESC_CHECKSUMBYPASS             ((uint32_t)0x00000000)   /*!< Checksum engine bypass */
  1345. #define ETH_DMATXDESC_CHECKSUMIPV4HEADER         ((uint32_t)0x00400000)   /*!< IPv4 header checksum insertion  */
  1346. #define ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT  ((uint32_t)0x00800000)   /*!< TCP/UDP/ICMP checksum insertion. Pseudo header checksum is assumed to be present */
  1347. #define ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL     ((uint32_t)0x00C00000)   /*!< TCP/UDP/ICMP checksum fully in hardware including pseudo header */
  1348.  
  1349. /**
  1350.   * @}
  1351.   */
  1352.  
  1353. /** @defgroup ETH_DMA_Rx_Descriptor_Buffers ETH DMA Rx Descriptor Buffers
  1354.   * @{
  1355.   */
  1356. #define ETH_DMARXDESC_BUFFER1     ((uint32_t)0x00000000)  /*!< DMA Rx Desc Buffer1 */
  1357. #define ETH_DMARXDESC_BUFFER2     ((uint32_t)0x00000001)  /*!< DMA Rx Desc Buffer2 */
  1358.  
  1359. /**
  1360.   * @}
  1361.   */
  1362.  
  1363. /** @defgroup ETH_PMT_Flags ETH PMT Flags
  1364.   * @{
  1365.   */
  1366. #define ETH_PMT_FLAG_WUFFRPR      ((uint32_t)0x80000000)  /*!< Wake-Up Frame Filter Register Pointer Reset */
  1367. #define ETH_PMT_FLAG_WUFR         ((uint32_t)0x00000040)  /*!< Wake-Up Frame Received */
  1368. #define ETH_PMT_FLAG_MPR          ((uint32_t)0x00000020)  /*!< Magic Packet Received */
  1369.  
  1370. /**
  1371.   * @}
  1372.   */
  1373.  
  1374. /** @defgroup ETH_MMC_Tx_Interrupts ETH MMC Tx Interrupts
  1375.   * @{
  1376.   */
  1377. #define ETH_MMC_IT_TGF       ((uint32_t)0x00200000)  /*!< When Tx good frame counter reaches half the maximum value */
  1378. #define ETH_MMC_IT_TGFMSC    ((uint32_t)0x00008000)  /*!< When Tx good multi col counter reaches half the maximum value */
  1379. #define ETH_MMC_IT_TGFSC     ((uint32_t)0x00004000)  /*!< When Tx good single col counter reaches half the maximum value */
  1380.  
  1381. /**
  1382.   * @}
  1383.   */
  1384.  
  1385. /** @defgroup ETH_MMC_Rx_Interrupts ETH MMC Rx Interrupts
  1386.   * @{
  1387.   */
  1388. #define ETH_MMC_IT_RGUF      ((uint32_t)0x10020000)  /*!< When Rx good unicast frames counter reaches half the maximum value */
  1389. #define ETH_MMC_IT_RFAE      ((uint32_t)0x10000040)  /*!< When Rx alignment error counter reaches half the maximum value */
  1390. #define ETH_MMC_IT_RFCE      ((uint32_t)0x10000020)  /*!< When Rx crc error counter reaches half the maximum value */
  1391.  
  1392. /**
  1393.   * @}
  1394.   */
  1395.  
  1396. /** @defgroup ETH_MAC_Flags ETH MAC Flags
  1397.   * @{
  1398.   */
  1399. #define ETH_MAC_FLAG_TST     ((uint32_t)0x00000200)  /*!< Time stamp trigger flag (on MAC) */
  1400. #define ETH_MAC_FLAG_MMCT    ((uint32_t)0x00000040)  /*!< MMC transmit flag  */
  1401. #define ETH_MAC_FLAG_MMCR    ((uint32_t)0x00000020)  /*!< MMC receive flag */
  1402. #define ETH_MAC_FLAG_MMC     ((uint32_t)0x00000010)  /*!< MMC flag (on MAC) */
  1403. #define ETH_MAC_FLAG_PMT     ((uint32_t)0x00000008)  /*!< PMT flag (on MAC) */
  1404.  
  1405. /**
  1406.   * @}
  1407.   */
  1408.  
  1409. /** @defgroup ETH_DMA_Flags ETH DMA Flags
  1410.   * @{
  1411.   */
  1412. #define ETH_DMA_FLAG_TST               ((uint32_t)0x20000000)  /*!< Time-stamp trigger interrupt (on DMA) */
  1413. #define ETH_DMA_FLAG_PMT               ((uint32_t)0x10000000)  /*!< PMT interrupt (on DMA) */
  1414. #define ETH_DMA_FLAG_MMC               ((uint32_t)0x08000000)  /*!< MMC interrupt (on DMA) */
  1415. #define ETH_DMA_FLAG_DATATRANSFERERROR ((uint32_t)0x00800000)  /*!< Error bits 0-Rx DMA, 1-Tx DMA */
  1416. #define ETH_DMA_FLAG_READWRITEERROR    ((uint32_t)0x01000000)  /*!< Error bits 0-write trnsf, 1-read transfr */
  1417. #define ETH_DMA_FLAG_ACCESSERROR       ((uint32_t)0x02000000)  /*!< Error bits 0-data buffer, 1-desc. access */
  1418. #define ETH_DMA_FLAG_NIS               ((uint32_t)0x00010000)  /*!< Normal interrupt summary flag */
  1419. #define ETH_DMA_FLAG_AIS               ((uint32_t)0x00008000)  /*!< Abnormal interrupt summary flag */
  1420. #define ETH_DMA_FLAG_ER                ((uint32_t)0x00004000)  /*!< Early receive flag */
  1421. #define ETH_DMA_FLAG_FBE               ((uint32_t)0x00002000)  /*!< Fatal bus error flag */
  1422. #define ETH_DMA_FLAG_ET                ((uint32_t)0x00000400)  /*!< Early transmit flag */
  1423. #define ETH_DMA_FLAG_RWT               ((uint32_t)0x00000200)  /*!< Receive watchdog timeout flag */
  1424. #define ETH_DMA_FLAG_RPS               ((uint32_t)0x00000100)  /*!< Receive process stopped flag */
  1425. #define ETH_DMA_FLAG_RBU               ((uint32_t)0x00000080)  /*!< Receive buffer unavailable flag */
  1426. #define ETH_DMA_FLAG_R                 ((uint32_t)0x00000040)  /*!< Receive flag */
  1427. #define ETH_DMA_FLAG_TU                ((uint32_t)0x00000020)  /*!< Underflow flag */
  1428. #define ETH_DMA_FLAG_RO                ((uint32_t)0x00000010)  /*!< Overflow flag */
  1429. #define ETH_DMA_FLAG_TJT               ((uint32_t)0x00000008)  /*!< Transmit jabber timeout flag */
  1430. #define ETH_DMA_FLAG_TBU               ((uint32_t)0x00000004)  /*!< Transmit buffer unavailable flag */
  1431. #define ETH_DMA_FLAG_TPS               ((uint32_t)0x00000002)  /*!< Transmit process stopped flag */
  1432. #define ETH_DMA_FLAG_T                 ((uint32_t)0x00000001)  /*!< Transmit flag */
  1433.  
  1434. /**
  1435.   * @}
  1436.   */
  1437.  
  1438. /** @defgroup ETH_MAC_Interrupts ETH MAC Interrupts
  1439.   * @{
  1440.   */
  1441. #define ETH_MAC_IT_TST       ((uint32_t)0x00000200)  /*!< Time stamp trigger interrupt (on MAC) */
  1442. #define ETH_MAC_IT_MMCT      ((uint32_t)0x00000040)  /*!< MMC transmit interrupt */
  1443. #define ETH_MAC_IT_MMCR      ((uint32_t)0x00000020)  /*!< MMC receive interrupt */
  1444. #define ETH_MAC_IT_MMC       ((uint32_t)0x00000010)  /*!< MMC interrupt (on MAC) */
  1445. #define ETH_MAC_IT_PMT       ((uint32_t)0x00000008)  /*!< PMT interrupt (on MAC) */
  1446.  
  1447. /**
  1448.   * @}
  1449.   */
  1450.  
  1451. /** @defgroup ETH_DMA_Interrupts ETH DMA Interrupts
  1452.   * @{
  1453.   */
  1454. #define ETH_DMA_IT_TST       ((uint32_t)0x20000000)  /*!< Time-stamp trigger interrupt (on DMA) */
  1455. #define ETH_DMA_IT_PMT       ((uint32_t)0x10000000)  /*!< PMT interrupt (on DMA) */
  1456. #define ETH_DMA_IT_MMC       ((uint32_t)0x08000000)  /*!< MMC interrupt (on DMA) */
  1457. #define ETH_DMA_IT_NIS       ((uint32_t)0x00010000)  /*!< Normal interrupt summary */
  1458. #define ETH_DMA_IT_AIS       ((uint32_t)0x00008000)  /*!< Abnormal interrupt summary */
  1459. #define ETH_DMA_IT_ER        ((uint32_t)0x00004000)  /*!< Early receive interrupt */
  1460. #define ETH_DMA_IT_FBE       ((uint32_t)0x00002000)  /*!< Fatal bus error interrupt */
  1461. #define ETH_DMA_IT_ET        ((uint32_t)0x00000400)  /*!< Early transmit interrupt */
  1462. #define ETH_DMA_IT_RWT       ((uint32_t)0x00000200)  /*!< Receive watchdog timeout interrupt */
  1463. #define ETH_DMA_IT_RPS       ((uint32_t)0x00000100)  /*!< Receive process stopped interrupt */
  1464. #define ETH_DMA_IT_RBU       ((uint32_t)0x00000080)  /*!< Receive buffer unavailable interrupt */
  1465. #define ETH_DMA_IT_R         ((uint32_t)0x00000040)  /*!< Receive interrupt */
  1466. #define ETH_DMA_IT_TU        ((uint32_t)0x00000020)  /*!< Underflow interrupt */
  1467. #define ETH_DMA_IT_RO        ((uint32_t)0x00000010)  /*!< Overflow interrupt */
  1468. #define ETH_DMA_IT_TJT       ((uint32_t)0x00000008)  /*!< Transmit jabber timeout interrupt */
  1469. #define ETH_DMA_IT_TBU       ((uint32_t)0x00000004)  /*!< Transmit buffer unavailable interrupt */
  1470. #define ETH_DMA_IT_TPS       ((uint32_t)0x00000002)  /*!< Transmit process stopped interrupt */
  1471. #define ETH_DMA_IT_T         ((uint32_t)0x00000001)  /*!< Transmit interrupt */
  1472.  
  1473. /**
  1474.   * @}
  1475.   */
  1476.  
  1477. /** @defgroup ETH_DMA_transmit_process_state ETH DMA transmit process state
  1478.   * @{
  1479.   */
  1480. #define ETH_DMA_TRANSMITPROCESS_STOPPED     ((uint32_t)0x00000000)  /*!< Stopped - Reset or Stop Tx Command issued */
  1481. #define ETH_DMA_TRANSMITPROCESS_FETCHING    ((uint32_t)0x00100000)  /*!< Running - fetching the Tx descriptor */
  1482. #define ETH_DMA_TRANSMITPROCESS_WAITING     ((uint32_t)0x00200000)  /*!< Running - waiting for status */
  1483. #define ETH_DMA_TRANSMITPROCESS_READING     ((uint32_t)0x00300000)  /*!< Running - reading the data from host memory */
  1484. #define ETH_DMA_TRANSMITPROCESS_SUSPENDED   ((uint32_t)0x00600000)  /*!< Suspended - Tx Descriptor unavailable */
  1485. #define ETH_DMA_TRANSMITPROCESS_CLOSING     ((uint32_t)0x00700000)  /*!< Running - closing Rx descriptor */
  1486.  
  1487. /**
  1488.   * @}
  1489.   */
  1490.  
  1491.  
  1492. /** @defgroup ETH_DMA_receive_process_state ETH DMA receive process state
  1493.   * @{
  1494.   */
  1495. #define ETH_DMA_RECEIVEPROCESS_STOPPED      ((uint32_t)0x00000000)  /*!< Stopped - Reset or Stop Rx Command issued */
  1496. #define ETH_DMA_RECEIVEPROCESS_FETCHING     ((uint32_t)0x00020000)  /*!< Running - fetching the Rx descriptor */
  1497. #define ETH_DMA_RECEIVEPROCESS_WAITING      ((uint32_t)0x00060000)  /*!< Running - waiting for packet */
  1498. #define ETH_DMA_RECEIVEPROCESS_SUSPENDED    ((uint32_t)0x00080000)  /*!< Suspended - Rx Descriptor unavailable */
  1499. #define ETH_DMA_RECEIVEPROCESS_CLOSING      ((uint32_t)0x000A0000)  /*!< Running - closing descriptor */
  1500. #define ETH_DMA_RECEIVEPROCESS_QUEUING      ((uint32_t)0x000E0000)  /*!< Running - queuing the receive frame into host memory */
  1501.  
  1502. /**
  1503.   * @}
  1504.   */
  1505.  
  1506. /** @defgroup ETH_DMA_overflow ETH DMA overflow
  1507.   * @{
  1508.   */
  1509. #define ETH_DMA_OVERFLOW_RXFIFOCOUNTER      ((uint32_t)0x10000000)  /*!< Overflow bit for FIFO overflow counter */
  1510. #define ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER ((uint32_t)0x00010000)  /*!< Overflow bit for missed frame counter */
  1511.  
  1512. /**
  1513.   * @}
  1514.   */
  1515.  
  1516.   /** @defgroup ETH_EXTI_LINE_WAKEUP ETH EXTI LINE WAKEUP
  1517.   * @{
  1518.   */
  1519. #define ETH_EXTI_LINE_WAKEUP              ((uint32_t)0x00080000)  /*!< External interrupt line 19 Connected to the ETH EXTI Line */
  1520.  
  1521. /**
  1522.   * @}
  1523.   */
  1524.  
  1525. /**
  1526.   * @}
  1527.   */
  1528.  
  1529. /* Exported macro ------------------------------------------------------------*/
  1530. /** @defgroup ETH_Exported_Macros ETH Exported Macros
  1531.  *  @brief macros to handle interrupts and specific clock configurations
  1532.  * @{
  1533.  */
  1534.  
  1535. /** @brief Reset ETH handle state
  1536.   * @param  __HANDLE__: specifies the ETH handle.
  1537.   * @retval None
  1538.   */
  1539. #define __HAL_ETH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ETH_STATE_RESET)
  1540.  
  1541. /**
  1542.   * @brief  Checks whether the specified ETHERNET DMA Tx Desc flag is set or not.
  1543.   * @param  __HANDLE__: ETH Handle
  1544.   * @param  __FLAG__: specifies the flag of TDES0 to check .
  1545.   * @retval the ETH_DMATxDescFlag (SET or RESET).
  1546.   */
  1547. #define __HAL_ETH_DMATXDESC_GET_FLAG(__HANDLE__, __FLAG__)             ((__HANDLE__)->TxDesc->Status & (__FLAG__) == (__FLAG__))
  1548.  
  1549. /**
  1550.   * @brief  Checks whether the specified ETHERNET DMA Rx Desc flag is set or not.
  1551.   * @param  __HANDLE__: ETH Handle
  1552.   * @param  __FLAG__: specifies the flag of RDES0 to check.
  1553.   * @retval the ETH_DMATxDescFlag (SET or RESET).
  1554.   */
  1555. #define __HAL_ETH_DMARXDESC_GET_FLAG(__HANDLE__, __FLAG__)             ((__HANDLE__)->RxDesc->Status & (__FLAG__) == (__FLAG__))
  1556.  
  1557. /**
  1558.   * @brief  Enables the specified DMA Rx Desc receive interrupt.
  1559.   * @param  __HANDLE__: ETH Handle
  1560.   * @retval None
  1561.   */
  1562. #define __HAL_ETH_DMARXDESC_ENABLE_IT(__HANDLE__)                          ((__HANDLE__)->RxDesc->ControlBufferSize &=(~(uint32_t)ETH_DMARXDESC_DIC))
  1563.  
  1564. /**
  1565.   * @brief  Disables the specified DMA Rx Desc receive interrupt.
  1566.   * @param  __HANDLE__: ETH Handle
  1567.   * @retval None
  1568.   */
  1569. #define __HAL_ETH_DMARXDESC_DISABLE_IT(__HANDLE__)                         ((__HANDLE__)->RxDesc->ControlBufferSize |= ETH_DMARXDESC_DIC)
  1570.  
  1571. /**
  1572.   * @brief  Set the specified DMA Rx Desc Own bit.
  1573.   * @param  __HANDLE__: ETH Handle
  1574.   * @retval None
  1575.   */
  1576. #define __HAL_ETH_DMARXDESC_SET_OWN_BIT(__HANDLE__)                           ((__HANDLE__)->RxDesc->Status |= ETH_DMARXDESC_OWN)
  1577.  
  1578. /**
  1579.   * @brief  Returns the specified ETHERNET DMA Tx Desc collision count.
  1580.   * @param  __HANDLE__: ETH Handle                    
  1581.   * @retval The Transmit descriptor collision counter value.
  1582.   */
  1583. #define __HAL_ETH_DMATXDESC_GET_COLLISION_COUNT(__HANDLE__)                   (((__HANDLE__)->TxDesc->Status & ETH_DMATXDESC_CC) >> ETH_DMATXDESC_COLLISION_COUNTSHIFT)
  1584.  
  1585. /**
  1586.   * @brief  Set the specified DMA Tx Desc Own bit.
  1587.   * @param  __HANDLE__: ETH Handle
  1588.   * @retval None
  1589.   */
  1590. #define __HAL_ETH_DMATXDESC_SET_OWN_BIT(__HANDLE__)                       ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_OWN)
  1591.  
  1592. /**
  1593.   * @brief  Enables the specified DMA Tx Desc Transmit interrupt.
  1594.   * @param  __HANDLE__: ETH Handle                  
  1595.   * @retval None
  1596.   */
  1597. #define __HAL_ETH_DMATXDESC_ENABLE_IT(__HANDLE__)                          ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_IC)
  1598.  
  1599. /**
  1600.   * @brief  Disables the specified DMA Tx Desc Transmit interrupt.
  1601.   * @param  __HANDLE__: ETH Handle            
  1602.   * @retval None
  1603.   */
  1604. #define __HAL_ETH_DMATXDESC_DISABLE_IT(__HANDLE__)                          ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_IC)
  1605.  
  1606. /**
  1607.   * @brief  Selects the specified ETHERNET DMA Tx Desc Checksum Insertion.
  1608.   * @param  __HANDLE__: ETH Handle  
  1609.   * @param  __CHECKSUM__: specifies is the DMA Tx desc checksum insertion.
  1610.   *   This parameter can be one of the following values:
  1611.   *     @arg ETH_DMATXDESC_CHECKSUMBYPASS : Checksum bypass
  1612.   *     @arg ETH_DMATXDESC_CHECKSUMIPV4HEADER : IPv4 header checksum
  1613.   *     @arg ETH_DMATXDESC_CHECKSUMTCPUDPICMPSEGMENT : TCP/UDP/ICMP checksum. Pseudo header checksum is assumed to be present
  1614.   *     @arg ETH_DMATXDESC_CHECKSUMTCPUDPICMPFULL : TCP/UDP/ICMP checksum fully in hardware including pseudo header                                                                
  1615.   * @retval None
  1616.   */
  1617. #define __HAL_ETH_DMATXDESC_CHECKSUM_INSERTION(__HANDLE__, __CHECKSUM__)     ((__HANDLE__)->TxDesc->Status |= (__CHECKSUM__))
  1618.  
  1619. /**
  1620.   * @brief  Enables the DMA Tx Desc CRC.
  1621.   * @param  __HANDLE__: ETH Handle
  1622.   * @retval None
  1623.   */
  1624. #define __HAL_ETH_DMATXDESC_CRC_ENABLE(__HANDLE__)                          ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_DC)
  1625.  
  1626. /**
  1627.   * @brief  Disables the DMA Tx Desc CRC.
  1628.   * @param  __HANDLE__: ETH Handle
  1629.   * @retval None
  1630.   */
  1631. #define __HAL_ETH_DMATXDESC_CRC_DISABLE(__HANDLE__)                         ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_DC)
  1632.  
  1633. /**
  1634.   * @brief  Enables the DMA Tx Desc padding for frame shorter than 64 bytes.
  1635.   * @param  __HANDLE__: ETH Handle
  1636.   * @retval None
  1637.   */
  1638. #define __HAL_ETH_DMATXDESC_SHORT_FRAME_PADDING_ENABLE(__HANDLE__)            ((__HANDLE__)->TxDesc->Status &= ~ETH_DMATXDESC_DP)
  1639.  
  1640. /**
  1641.   * @brief  Disables the DMA Tx Desc padding for frame shorter than 64 bytes.
  1642.   * @param  __HANDLE__: ETH Handle
  1643.   * @retval None
  1644.   */
  1645. #define __HAL_ETH_DMATXDESC_SHORT_FRAME_PADDING_DISABLE(__HANDLE__)           ((__HANDLE__)->TxDesc->Status |= ETH_DMATXDESC_DP)
  1646.  
  1647. /**
  1648.  * @brief  Enables the specified ETHERNET MAC interrupts.
  1649.   * @param  __HANDLE__   : ETH Handle
  1650.   * @param  __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be
  1651.   *   enabled or disabled.
  1652.   *   This parameter can be any combination of the following values:
  1653.   *     @arg ETH_MAC_IT_TST : Time stamp trigger interrupt
  1654.   *     @arg ETH_MAC_IT_PMT : PMT interrupt
  1655.   * @retval None
  1656.   */
  1657. #define __HAL_ETH_MAC_ENABLE_IT(__HANDLE__, __INTERRUPT__)                 ((__HANDLE__)->Instance->MACIMR |= (__INTERRUPT__))
  1658.  
  1659. /**
  1660.   * @brief  Disables the specified ETHERNET MAC interrupts.
  1661.   * @param  __HANDLE__   : ETH Handle
  1662.   * @param  __INTERRUPT__: specifies the ETHERNET MAC interrupt sources to be
  1663.   *   enabled or disabled.
  1664.   *   This parameter can be any combination of the following values:
  1665.   *     @arg ETH_MAC_IT_TST : Time stamp trigger interrupt
  1666.   *     @arg ETH_MAC_IT_PMT : PMT interrupt
  1667.   * @retval None
  1668.   */
  1669. #define __HAL_ETH_MAC_DISABLE_IT(__HANDLE__, __INTERRUPT__)                ((__HANDLE__)->Instance->MACIMR &= ~(__INTERRUPT__))
  1670.  
  1671. /**
  1672.   * @brief  Initiate a Pause Control Frame (Full-duplex only).
  1673.   * @param  __HANDLE__: ETH Handle
  1674.   * @retval None
  1675.   */
  1676. #define __HAL_ETH_INITIATE_PAUSE_CONTROL_FRAME(__HANDLE__)              ((__HANDLE__)->Instance->MACFCR |= ETH_MACFCR_FCBBPA)
  1677.  
  1678. /**
  1679.   * @brief  Checks whether the ETHERNET flow control busy bit is set or not.
  1680.   * @param  __HANDLE__: ETH Handle
  1681.   * @retval The new state of flow control busy status bit (SET or RESET).
  1682.   */
  1683. #define __HAL_ETH_GET_FLOW_CONTROL_BUSY_STATUS(__HANDLE__)               (((__HANDLE__)->Instance->MACFCR & ETH_MACFCR_FCBBPA) == ETH_MACFCR_FCBBPA)
  1684.  
  1685. /**
  1686.   * @brief  Enables the MAC Back Pressure operation activation (Half-duplex only).
  1687.   * @param  __HANDLE__: ETH Handle
  1688.   * @retval None
  1689.   */
  1690. #define __HAL_ETH_BACK_PRESSURE_ACTIVATION_ENABLE(__HANDLE__)          ((__HANDLE__)->Instance->MACFCR |= ETH_MACFCR_FCBBPA)
  1691.  
  1692. /**
  1693.   * @brief  Disables the MAC BackPressure operation activation (Half-duplex only).
  1694.   * @param  __HANDLE__: ETH Handle
  1695.   * @retval None
  1696.   */
  1697. #define __HAL_ETH_BACK_PRESSURE_ACTIVATION_DISABLE(__HANDLE__)         ((__HANDLE__)->Instance->MACFCR &= ~ETH_MACFCR_FCBBPA)
  1698.  
  1699. /**
  1700.   * @brief  Checks whether the specified ETHERNET MAC flag is set or not.
  1701.   * @param  __HANDLE__: ETH Handle
  1702.   * @param  __FLAG__: specifies the flag to check.
  1703.   *   This parameter can be one of the following values:
  1704.   *     @arg ETH_MAC_FLAG_TST  : Time stamp trigger flag  
  1705.   *     @arg ETH_MAC_FLAG_MMCT : MMC transmit flag  
  1706.   *     @arg ETH_MAC_FLAG_MMCR : MMC receive flag  
  1707.   *     @arg ETH_MAC_FLAG_MMC  : MMC flag  
  1708.   *     @arg ETH_MAC_FLAG_PMT  : PMT flag  
  1709.   * @retval The state of ETHERNET MAC flag.
  1710.   */
  1711. #define __HAL_ETH_MAC_GET_FLAG(__HANDLE__, __FLAG__)                   (((__HANDLE__)->Instance->MACSR &( __FLAG__)) == ( __FLAG__))
  1712.  
  1713. /**
  1714.   * @brief  Enables the specified ETHERNET DMA interrupts.
  1715.   * @param  __HANDLE__   : ETH Handle
  1716.   * @param  __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be
  1717.   *   enabled @ref ETH_DMA_Interrupts
  1718.   * @retval None
  1719.   */
  1720. #define __HAL_ETH_DMA_ENABLE_IT(__HANDLE__, __INTERRUPT__)                 ((__HANDLE__)->Instance->DMAIER |= (__INTERRUPT__))
  1721.  
  1722. /**
  1723.   * @brief  Disables the specified ETHERNET DMA interrupts.
  1724.   * @param  __HANDLE__   : ETH Handle
  1725.   * @param  __INTERRUPT__: specifies the ETHERNET DMA interrupt sources to be
  1726.   *   disabled. @ref ETH_DMA_Interrupts
  1727.   * @retval None
  1728.   */
  1729. #define __HAL_ETH_DMA_DISABLE_IT(__HANDLE__, __INTERRUPT__)                ((__HANDLE__)->Instance->DMAIER &= ~(__INTERRUPT__))
  1730.  
  1731. /**
  1732.   * @brief  Clears the ETHERNET DMA IT pending bit.
  1733.   * @param  __HANDLE__   : ETH Handle
  1734.   * @param  __INTERRUPT__: specifies the interrupt pending bit to clear. @ref ETH_DMA_Interrupts
  1735.   * @retval None
  1736.   */
  1737. #define __HAL_ETH_DMA_CLEAR_IT(__HANDLE__, __INTERRUPT__)      ((__HANDLE__)->Instance->DMASR =(__INTERRUPT__))
  1738.  
  1739. /**
  1740.   * @brief  Checks whether the specified ETHERNET DMA flag is set or not.
  1741. * @param  __HANDLE__: ETH Handle
  1742.   * @param  __FLAG__: specifies the flag to check. @ref ETH_DMA_Flags
  1743.   * @retval The new state of ETH_DMA_FLAG (SET or RESET).
  1744.   */
  1745. #define __HAL_ETH_DMA_GET_FLAG(__HANDLE__, __FLAG__)                   (((__HANDLE__)->Instance->DMASR &( __FLAG__)) == ( __FLAG__))
  1746.  
  1747. /**
  1748.   * @brief  Checks whether the specified ETHERNET DMA flag is set or not.
  1749.   * @param  __HANDLE__: ETH Handle
  1750.   * @param  __FLAG__: specifies the flag to clear. @ref ETH_DMA_Flags
  1751.   * @retval The new state of ETH_DMA_FLAG (SET or RESET).
  1752.   */
  1753. #define __HAL_ETH_DMA_CLEAR_FLAG(__HANDLE__, __FLAG__)                 ((__HANDLE__)->Instance->DMASR = (__FLAG__))
  1754.  
  1755. /**
  1756.   * @brief  Checks whether the specified ETHERNET DMA overflow flag is set or not.
  1757.   * @param  __HANDLE__: ETH Handle
  1758.   * @param  __OVERFLOW__: specifies the DMA overflow flag to check.
  1759.   *   This parameter can be one of the following values:
  1760.   *     @arg ETH_DMA_OVERFLOW_RXFIFOCOUNTER : Overflow for FIFO Overflows Counter
  1761.   *     @arg ETH_DMA_OVERFLOW_MISSEDFRAMECOUNTER : Overflow for Buffer Unavailable Missed Frame Counter
  1762.   * @retval The state of ETHERNET DMA overflow Flag (SET or RESET).
  1763.   */
  1764. #define __HAL_ETH_GET_DMA_OVERFLOW_STATUS(__HANDLE__, __OVERFLOW__)       (((__HANDLE__)->Instance->DMAMFBOCR & (__OVERFLOW__)) == (__OVERFLOW__))
  1765.  
  1766. /**
  1767.   * @brief  Set the DMA Receive status watchdog timer register value
  1768.   * @param  __HANDLE__: ETH Handle
  1769.   * @param  __VALUE__: DMA Receive status watchdog timer register value  
  1770.   * @retval None
  1771.   */
  1772. #define __HAL_ETH_SET_RECEIVE_WATCHDOG_TIMER(__HANDLE__, __VALUE__)       ((__HANDLE__)->Instance->DMARSWTR = (__VALUE__))
  1773.  
  1774. /**
  1775.   * @brief  Enables any unicast packet filtered by the MAC address
  1776.   *   recognition to be a wake-up frame.
  1777.   * @param  __HANDLE__: ETH Handle.
  1778.   * @retval None
  1779.   */
  1780. #define __HAL_ETH_GLOBAL_UNICAST_WAKEUP_ENABLE(__HANDLE__)               ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_GU)
  1781.  
  1782. /**
  1783.   * @brief  Disables any unicast packet filtered by the MAC address
  1784.   *   recognition to be a wake-up frame.
  1785.   * @param  __HANDLE__: ETH Handle.
  1786.   * @retval None
  1787.   */
  1788. #define __HAL_ETH_GLOBAL_UNICAST_WAKEUP_DISABLE(__HANDLE__)              ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_GU)
  1789.  
  1790. /**
  1791.   * @brief  Enables the MAC Wake-Up Frame Detection.
  1792.   * @param  __HANDLE__: ETH Handle.
  1793.   * @retval None
  1794.   */
  1795. #define __HAL_ETH_WAKEUP_FRAME_DETECTION_ENABLE(__HANDLE__)              ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_WFE)
  1796.  
  1797. /**
  1798.   * @brief  Disables the MAC Wake-Up Frame Detection.
  1799.   * @param  __HANDLE__: ETH Handle.
  1800.   * @retval None
  1801.   */
  1802. #define __HAL_ETH_WAKEUP_FRAME_DETECTION_DISABLE(__HANDLE__)             ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_WFE)
  1803.  
  1804. /**
  1805.   * @brief  Enables the MAC Magic Packet Detection.
  1806.   * @param  __HANDLE__: ETH Handle.
  1807.   * @retval None
  1808.   */
  1809. #define __HAL_ETH_MAGIC_PACKET_DETECTION_ENABLE(__HANDLE__)              ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_MPE)
  1810.  
  1811. /**
  1812.   * @brief  Disables the MAC Magic Packet Detection.
  1813.   * @param  __HANDLE__: ETH Handle.
  1814.   * @retval None
  1815.   */
  1816. #define __HAL_ETH_MAGIC_PACKET_DETECTION_DISABLE(__HANDLE__)             ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_WFE)
  1817.  
  1818. /**
  1819.   * @brief  Enables the MAC Power Down.
  1820.   * @param  __HANDLE__: ETH Handle
  1821.   * @retval None
  1822.   */
  1823. #define __HAL_ETH_POWER_DOWN_ENABLE(__HANDLE__)                         ((__HANDLE__)->Instance->MACPMTCSR |= ETH_MACPMTCSR_PD)
  1824.  
  1825. /**
  1826.   * @brief  Disables the MAC Power Down.
  1827.   * @param  __HANDLE__: ETH Handle
  1828.   * @retval None
  1829.   */
  1830. #define __HAL_ETH_POWER_DOWN_DISABLE(__HANDLE__)                        ((__HANDLE__)->Instance->MACPMTCSR &= ~ETH_MACPMTCSR_PD)
  1831.  
  1832. /**
  1833.   * @brief  Checks whether the specified ETHERNET PMT flag is set or not.
  1834.   * @param  __HANDLE__: ETH Handle.
  1835.   * @param  __FLAG__: specifies the flag to check.
  1836.   *   This parameter can be one of the following values:
  1837.   *     @arg ETH_PMT_FLAG_WUFFRPR : Wake-Up Frame Filter Register Pointer Reset
  1838.   *     @arg ETH_PMT_FLAG_WUFR    : Wake-Up Frame Received
  1839.   *     @arg ETH_PMT_FLAG_MPR     : Magic Packet Received
  1840.   * @retval The new state of ETHERNET PMT Flag (SET or RESET).
  1841.   */
  1842. #define __HAL_ETH_GET_PMT_FLAG_STATUS(__HANDLE__, __FLAG__)               (((__HANDLE__)->Instance->MACPMTCSR &( __FLAG__)) == ( __FLAG__))
  1843.  
  1844. /**
  1845.   * @brief  Preset and Initialize the MMC counters to almost-full value: 0xFFFF_FFF0 (full - 16)
  1846.   * @param   __HANDLE__: ETH Handle.
  1847.   * @retval None
  1848.   */
  1849. #define __HAL_ETH_MMC_COUNTER_FULL_PRESET(__HANDLE__)                     ((__HANDLE__)->Instance->MMCCR |= (ETH_MMCCR_MCFHP | ETH_MMCCR_MCP))
  1850.  
  1851. /**
  1852.   * @brief  Preset and Initialize the MMC counters to almost-half value: 0x7FFF_FFF0 (half - 16)
  1853.   * @param  __HANDLE__: ETH Handle.
  1854.   * @retval None
  1855.   */
  1856. #define __HAL_ETH_MMC_COUNTER_HALF_PRESET(__HANDLE__)                     do{(__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_MCFHP;\
  1857.                                                                           (__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_MCP;} while (0)
  1858.  
  1859. /**
  1860.   * @brief  Enables the MMC Counter Freeze.
  1861.   * @param  __HANDLE__: ETH Handle.
  1862.   * @retval None
  1863.   */
  1864. #define __HAL_ETH_MMC_COUNTER_FREEZE_ENABLE(__HANDLE__)                  ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_MCF)
  1865.  
  1866. /**
  1867.   * @brief  Disables the MMC Counter Freeze.
  1868.   * @param  __HANDLE__: ETH Handle.
  1869.   * @retval None
  1870.   */
  1871. #define __HAL_ETH_MMC_COUNTER_FREEZE_DISABLE(__HANDLE__)                 ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_MCF)
  1872.  
  1873. /**
  1874.   * @brief  Enables the MMC Reset On Read.
  1875.   * @param  __HANDLE__: ETH Handle.
  1876.   * @retval None
  1877.   */
  1878. #define __HAL_ETH_ETH_MMC_RESET_ONREAD_ENABLE(__HANDLE__)                ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_ROR)
  1879.  
  1880. /**
  1881.   * @brief  Disables the MMC Reset On Read.
  1882.   * @param  __HANDLE__: ETH Handle.
  1883.   * @retval None
  1884.   */
  1885. #define __HAL_ETH_ETH_MMC_RESET_ONREAD_DISABLE(__HANDLE__)               ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_ROR)
  1886.  
  1887. /**
  1888.   * @brief  Enables the MMC Counter Stop Rollover.
  1889.   * @param  __HANDLE__: ETH Handle.
  1890.   * @retval None
  1891.   */
  1892. #define __HAL_ETH_ETH_MMC_COUNTER_ROLLOVER_ENABLE(__HANDLE__)            ((__HANDLE__)->Instance->MMCCR &= ~ETH_MMCCR_CSR)
  1893.  
  1894. /**
  1895.   * @brief  Disables the MMC Counter Stop Rollover.
  1896.   * @param  __HANDLE__: ETH Handle.
  1897.   * @retval None
  1898.   */
  1899. #define __HAL_ETH_ETH_MMC_COUNTER_ROLLOVER_DISABLE(__HANDLE__)           ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_CSR)
  1900.  
  1901. /**
  1902.   * @brief  Resets the MMC Counters.
  1903.   * @param   __HANDLE__: ETH Handle.
  1904.   * @retval None
  1905.   */
  1906. #define __HAL_ETH_MMC_COUNTERS_RESET(__HANDLE__)                         ((__HANDLE__)->Instance->MMCCR |= ETH_MMCCR_CR)
  1907.  
  1908. /**
  1909.   * @brief  Enables the specified ETHERNET MMC Rx interrupts.
  1910.   * @param   __HANDLE__: ETH Handle.
  1911.   * @param  __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled.
  1912.   *   This parameter can be one of the following values:  
  1913.   *     @arg ETH_MMC_IT_RGUF  : When Rx good unicast frames counter reaches half the maximum value
  1914.   *     @arg ETH_MMC_IT_RFAE  : When Rx alignment error counter reaches half the maximum value
  1915.   *     @arg ETH_MMC_IT_RFCE  : When Rx crc error counter reaches half the maximum value
  1916.   * @retval None
  1917.   */
  1918. #define __HAL_ETH_MMC_RX_IT_ENABLE(__HANDLE__, __INTERRUPT__)               (__HANDLE__)->Instance->MMCRIMR &= ~((__INTERRUPT__) & 0xEFFFFFFF)
  1919. /**
  1920.   * @brief  Disables the specified ETHERNET MMC Rx interrupts.
  1921.   * @param   __HANDLE__: ETH Handle.
  1922.   * @param  __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled.
  1923.   *   This parameter can be one of the following values:
  1924.   *     @arg ETH_MMC_IT_RGUF  : When Rx good unicast frames counter reaches half the maximum value
  1925.   *     @arg ETH_MMC_IT_RFAE  : When Rx alignment error counter reaches half the maximum value
  1926.   *     @arg ETH_MMC_IT_RFCE  : When Rx crc error counter reaches half the maximum value
  1927.   * @retval None
  1928.   */
  1929. #define __HAL_ETH_MMC_RX_IT_DISABLE(__HANDLE__, __INTERRUPT__)              (__HANDLE__)->Instance->MMCRIMR |= ((__INTERRUPT__) & 0xEFFFFFFF)
  1930. /**
  1931.   * @brief  Enables the specified ETHERNET MMC Tx interrupts.
  1932.   * @param   __HANDLE__: ETH Handle.
  1933.   * @param  __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled.
  1934.   *   This parameter can be one of the following values:  
  1935.   *     @arg ETH_MMC_IT_TGF   : When Tx good frame counter reaches half the maximum value
  1936.   *     @arg ETH_MMC_IT_TGFMSC: When Tx good multi col counter reaches half the maximum value
  1937.   *     @arg ETH_MMC_IT_TGFSC : When Tx good single col counter reaches half the maximum value
  1938.   * @retval None
  1939.   */
  1940. #define __HAL_ETH_MMC_TX_IT_ENABLE(__HANDLE__, __INTERRUPT__)            ((__HANDLE__)->Instance->MMCRIMR &= ~ (__INTERRUPT__))
  1941.  
  1942. /**
  1943.   * @brief  Disables the specified ETHERNET MMC Tx interrupts.
  1944.   * @param   __HANDLE__: ETH Handle.
  1945.   * @param  __INTERRUPT__: specifies the ETHERNET MMC interrupt sources to be enabled or disabled.
  1946.   *   This parameter can be one of the following values:  
  1947.   *     @arg ETH_MMC_IT_TGF   : When Tx good frame counter reaches half the maximum value
  1948.   *     @arg ETH_MMC_IT_TGFMSC: When Tx good multi col counter reaches half the maximum value
  1949.   *     @arg ETH_MMC_IT_TGFSC : When Tx good single col counter reaches half the maximum value
  1950.   * @retval None
  1951.   */
  1952. #define __HAL_ETH_MMC_TX_IT_DISABLE(__HANDLE__, __INTERRUPT__)           ((__HANDLE__)->Instance->MMCRIMR |= (__INTERRUPT__))
  1953.  
  1954. /**
  1955.   * @brief  Enables the ETH External interrupt line.
  1956.   * @retval None
  1957.   */
  1958. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_IT()    EXTI->IMR |= (ETH_EXTI_LINE_WAKEUP)
  1959.  
  1960. /**
  1961.   * @brief  Disables the ETH External interrupt line.
  1962.   * @retval None
  1963.   */
  1964. #define __HAL_ETH_WAKEUP_EXTI_DISABLE_IT()   EXTI->IMR &= ~(ETH_EXTI_LINE_WAKEUP)
  1965.  
  1966. /**
  1967.   * @brief Enable event on ETH External event line.
  1968.   * @retval None.
  1969.   */
  1970. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_EVENT()  EXTI->EMR |= (ETH_EXTI_LINE_WAKEUP)
  1971.  
  1972. /**
  1973.   * @brief Disable event on ETH External event line
  1974.   * @retval None.
  1975.   */
  1976. #define __HAL_ETH_WAKEUP_EXTI_DISABLE_EVENT() EXTI->EMR &= ~(ETH_EXTI_LINE_WAKEUP)
  1977.  
  1978. /**
  1979.   * @brief  Get flag of the ETH External interrupt line.
  1980.   * @retval None
  1981.   */
  1982. #define __HAL_ETH_WAKEUP_EXTI_GET_FLAG()     EXTI->PR & (ETH_EXTI_LINE_WAKEUP)
  1983.  
  1984. /**
  1985.   * @brief  Clear flag of the ETH External interrupt line.
  1986.   * @retval None
  1987.   */
  1988. #define __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG()   EXTI->PR = (ETH_EXTI_LINE_WAKEUP)
  1989.  
  1990. /**
  1991.   * @brief  Enables rising edge trigger to the ETH External interrupt line.
  1992.   * @retval None
  1993.   */
  1994. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_RISING_EDGE_TRIGGER()  EXTI->RTSR |= ETH_EXTI_LINE_WAKEUP
  1995.                                                            
  1996. /**
  1997.   * @brief  Disables the rising edge trigger to the ETH External interrupt line.
  1998.   * @retval None
  1999.   */
  2000. #define __HAL_ETH_WAKEUP_EXTI_DISABLE_RISING_EDGE_TRIGGER()  EXTI->RTSR &= ~(ETH_EXTI_LINE_WAKEUP)                                                          
  2001.  
  2002. /**
  2003.   * @brief  Enables falling edge trigger to the ETH External interrupt line.
  2004.   * @retval None
  2005.   */                                                      
  2006. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLING_EDGE_TRIGGER()  EXTI->FTSR |= (ETH_EXTI_LINE_WAKEUP)
  2007.  
  2008. /**
  2009.   * @brief  Disables falling edge trigger to the ETH External interrupt line.
  2010.   * @retval None
  2011.   */
  2012. #define __HAL_ETH_WAKEUP_EXTI_DISABLE_FALLING_EDGE_TRIGGER()  EXTI->FTSR &= ~(ETH_EXTI_LINE_WAKEUP)
  2013.                                                  
  2014.  
  2015. /**
  2016.   * @brief  Enables rising/falling edge trigger to the ETH External interrupt line.
  2017.   * @retval None
  2018.   */
  2019. #define __HAL_ETH_WAKEUP_EXTI_ENABLE_FALLINGRISING_TRIGGER()   \
  2020.                         do{                                    \
  2021.                             EXTI->RTSR |= ETH_EXTI_LINE_WAKEUP;\
  2022.                             EXTI->FTSR |= ETH_EXTI_LINE_WAKEUP;\
  2023.                           } while(0)
  2024.  
  2025. /**
  2026.   * @brief  Disables rising/falling edge trigger to the ETH External interrupt line.
  2027.   * @retval None
  2028.   */
  2029. #define __HAL_ETH_WAKEUP_EXTI_DISABLE_FALLINGRISING_TRIGGER()     \
  2030.                         do{                                       \
  2031.                             EXTI->RTSR &= ~(ETH_EXTI_LINE_WAKEUP);\
  2032.                             EXTI->FTSR &= ~(ETH_EXTI_LINE_WAKEUP);\
  2033.                           } while(0)
  2034.  
  2035. /**
  2036.   * @brief Generate a Software interrupt on selected EXTI line.
  2037.   * @retval None.
  2038.   */
  2039. #define __HAL_ETH_WAKEUP_EXTI_GENERATE_SWIT()                  EXTI->SWIER|= ETH_EXTI_LINE_WAKEUP
  2040.  
  2041. /**
  2042.   * @}
  2043.   */
  2044.  
  2045. /* Exported functions --------------------------------------------------------*/
  2046.  
  2047. /** @addtogroup ETH_Exported_Functions
  2048.   * @{
  2049.   */
  2050.  
  2051. /* Initialization and de-initialization functions  ****************************/
  2052.  
  2053. /** @addtogroup ETH_Exported_Functions_Group1
  2054.   * @{
  2055.   */
  2056.  
  2057. HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth);
  2058. HAL_StatusTypeDef HAL_ETH_DeInit(ETH_HandleTypeDef *heth);
  2059. void HAL_ETH_MspInit(ETH_HandleTypeDef *heth);
  2060. void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth);
  2061. HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMATxDescTab, uint8_t* TxBuff, uint32_t TxBuffCount);
  2062. HAL_StatusTypeDef HAL_ETH_DMARxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADescTypeDef *DMARxDescTab, uint8_t *RxBuff, uint32_t RxBuffCount);
  2063.  
  2064. /**
  2065.   * @}
  2066.   */
  2067.  
  2068. /* IO operation functions  ****************************************************/
  2069.  
  2070. /** @addtogroup ETH_Exported_Functions_Group2
  2071.   * @{
  2072.   */
  2073. HAL_StatusTypeDef HAL_ETH_TransmitFrame(ETH_HandleTypeDef *heth, uint32_t FrameLength);
  2074. HAL_StatusTypeDef HAL_ETH_GetReceivedFrame(ETH_HandleTypeDef *heth);
  2075. /* Communication with PHY functions*/
  2076. HAL_StatusTypeDef HAL_ETH_ReadPHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t *RegValue);
  2077. HAL_StatusTypeDef HAL_ETH_WritePHYRegister(ETH_HandleTypeDef *heth, uint16_t PHYReg, uint32_t RegValue);
  2078.  /* Non-Blocking mode: Interrupt */
  2079. HAL_StatusTypeDef HAL_ETH_GetReceivedFrame_IT(ETH_HandleTypeDef *heth);
  2080. void HAL_ETH_IRQHandler(ETH_HandleTypeDef *heth);
  2081.  /* Callback in non blocking modes (Interrupt) */
  2082. void HAL_ETH_TxCpltCallback(ETH_HandleTypeDef *heth);
  2083. void HAL_ETH_RxCpltCallback(ETH_HandleTypeDef *heth);
  2084. void HAL_ETH_ErrorCallback(ETH_HandleTypeDef *heth);
  2085.  
  2086. /**
  2087.   * @}
  2088.   */
  2089.  
  2090. /* Peripheral Control functions  **********************************************/
  2091.  
  2092. /** @addtogroup ETH_Exported_Functions_Group3
  2093.   * @{
  2094.   */
  2095. HAL_StatusTypeDef HAL_ETH_Start(ETH_HandleTypeDef *heth);
  2096. HAL_StatusTypeDef HAL_ETH_Stop(ETH_HandleTypeDef *heth);
  2097. HAL_StatusTypeDef HAL_ETH_ConfigMAC(ETH_HandleTypeDef *heth, ETH_MACInitTypeDef *macconf);
  2098. HAL_StatusTypeDef HAL_ETH_ConfigDMA(ETH_HandleTypeDef *heth, ETH_DMAInitTypeDef *dmaconf);
  2099. /**
  2100.   * @}
  2101.   */
  2102.  
  2103. /* Peripheral State functions  ************************************************/
  2104.  
  2105. /** @addtogroup ETH_Exported_Functions_Group4
  2106.   * @{
  2107.   */
  2108. HAL_ETH_StateTypeDef HAL_ETH_GetState(ETH_HandleTypeDef *heth);
  2109.  
  2110. /**
  2111.   * @}
  2112.   */
  2113.  
  2114. /**
  2115.   * @}
  2116.   */
  2117.  
  2118. /**
  2119.   * @}
  2120.   */
  2121.  
  2122. #endif /* STM32F107xC */
  2123. /**
  2124.   * @}
  2125.   */
  2126.  
  2127. #ifdef __cplusplus
  2128. }
  2129. #endif
  2130.  
  2131. #endif /* __STM32F1xx_HAL_ETH_H */
  2132.  
  2133.  
  2134.  
  2135. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  2136.