The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_K64F/TOOLCHAIN_IAR/fsl_enet.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 171:3a7713b1edbc | 1 | /* |
AnnaBridge | 171:3a7713b1edbc | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
AnnaBridge | 171:3a7713b1edbc | 3 | * All rights reserved. |
AnnaBridge | 171:3a7713b1edbc | 4 | * |
AnnaBridge | 171:3a7713b1edbc | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 171:3a7713b1edbc | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 171:3a7713b1edbc | 7 | * |
AnnaBridge | 171:3a7713b1edbc | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 171:3a7713b1edbc | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 171:3a7713b1edbc | 10 | * |
AnnaBridge | 171:3a7713b1edbc | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 171:3a7713b1edbc | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 171:3a7713b1edbc | 13 | * other materials provided with the distribution. |
AnnaBridge | 171:3a7713b1edbc | 14 | * |
AnnaBridge | 171:3a7713b1edbc | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 171:3a7713b1edbc | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 171:3a7713b1edbc | 17 | * software without specific prior written permission. |
AnnaBridge | 171:3a7713b1edbc | 18 | * |
AnnaBridge | 171:3a7713b1edbc | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 171:3a7713b1edbc | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 171:3a7713b1edbc | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 171:3a7713b1edbc | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 171:3a7713b1edbc | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 171:3a7713b1edbc | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 171:3a7713b1edbc | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 171:3a7713b1edbc | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 171:3a7713b1edbc | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 171:3a7713b1edbc | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 171:3a7713b1edbc | 29 | */ |
AnnaBridge | 171:3a7713b1edbc | 30 | #ifndef _FSL_ENET_H_ |
AnnaBridge | 171:3a7713b1edbc | 31 | #define _FSL_ENET_H_ |
AnnaBridge | 171:3a7713b1edbc | 32 | |
AnnaBridge | 171:3a7713b1edbc | 33 | #include "fsl_common.h" |
AnnaBridge | 171:3a7713b1edbc | 34 | |
AnnaBridge | 171:3a7713b1edbc | 35 | /*! |
AnnaBridge | 171:3a7713b1edbc | 36 | * @addtogroup enet |
AnnaBridge | 171:3a7713b1edbc | 37 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 38 | */ |
AnnaBridge | 171:3a7713b1edbc | 39 | |
AnnaBridge | 171:3a7713b1edbc | 40 | |
AnnaBridge | 171:3a7713b1edbc | 41 | /******************************************************************************* |
AnnaBridge | 171:3a7713b1edbc | 42 | * Definitions |
AnnaBridge | 171:3a7713b1edbc | 43 | ******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 44 | |
AnnaBridge | 171:3a7713b1edbc | 45 | /*! @name Driver version */ |
AnnaBridge | 171:3a7713b1edbc | 46 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 47 | /*! @brief Defines the driver version. */ |
AnnaBridge | 171:3a7713b1edbc | 48 | #define FSL_ENET_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) /*!< Version 2.0.1. */ |
AnnaBridge | 171:3a7713b1edbc | 49 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 50 | |
AnnaBridge | 171:3a7713b1edbc | 51 | /*! @name Control and status region bit masks of the receive buffer descriptor. */ |
AnnaBridge | 171:3a7713b1edbc | 52 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 53 | #define ENET_BUFFDESCRIPTOR_RX_EMPTY_MASK 0x8000U /*!< Empty bit mask. */ |
AnnaBridge | 171:3a7713b1edbc | 54 | #define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER1_MASK 0x4000U /*!< Software owner one mask. */ |
AnnaBridge | 171:3a7713b1edbc | 55 | #define ENET_BUFFDESCRIPTOR_RX_WRAP_MASK 0x2000U /*!< Next buffer descriptor is the start address. */ |
AnnaBridge | 171:3a7713b1edbc | 56 | #define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER2_Mask 0x1000U /*!< Software owner two mask. */ |
AnnaBridge | 171:3a7713b1edbc | 57 | #define ENET_BUFFDESCRIPTOR_RX_LAST_MASK 0x0800U /*!< Last BD of the frame mask. */ |
AnnaBridge | 171:3a7713b1edbc | 58 | #define ENET_BUFFDESCRIPTOR_RX_MISS_MASK 0x0100U /*!< Received because of the promiscuous mode. */ |
AnnaBridge | 171:3a7713b1edbc | 59 | #define ENET_BUFFDESCRIPTOR_RX_BROADCAST_MASK 0x0080U /*!< Broadcast packet mask. */ |
AnnaBridge | 171:3a7713b1edbc | 60 | #define ENET_BUFFDESCRIPTOR_RX_MULTICAST_MASK 0x0040U /*!< Multicast packet mask. */ |
AnnaBridge | 171:3a7713b1edbc | 61 | #define ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK 0x0020U /*!< Length violation mask. */ |
AnnaBridge | 171:3a7713b1edbc | 62 | #define ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK 0x0010U /*!< Non-octet aligned frame mask. */ |
AnnaBridge | 171:3a7713b1edbc | 63 | #define ENET_BUFFDESCRIPTOR_RX_CRC_MASK 0x0004U /*!< CRC error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 64 | #define ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK 0x0002U /*!< FIFO overrun mask. */ |
AnnaBridge | 171:3a7713b1edbc | 65 | #define ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK 0x0001U /*!< Frame is truncated mask. */ |
AnnaBridge | 171:3a7713b1edbc | 66 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 67 | |
AnnaBridge | 171:3a7713b1edbc | 68 | /*! @name Control and status bit masks of the transmit buffer descriptor. */ |
AnnaBridge | 171:3a7713b1edbc | 69 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 70 | #define ENET_BUFFDESCRIPTOR_TX_READY_MASK 0x8000U /*!< Ready bit mask. */ |
AnnaBridge | 171:3a7713b1edbc | 71 | #define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER1_MASK 0x4000U /*!< Software owner one mask. */ |
AnnaBridge | 171:3a7713b1edbc | 72 | #define ENET_BUFFDESCRIPTOR_TX_WRAP_MASK 0x2000U /*!< Wrap buffer descriptor mask. */ |
AnnaBridge | 171:3a7713b1edbc | 73 | #define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER2_MASK 0x1000U /*!< Software owner two mask. */ |
AnnaBridge | 171:3a7713b1edbc | 74 | #define ENET_BUFFDESCRIPTOR_TX_LAST_MASK 0x0800U /*!< Last BD of the frame mask. */ |
AnnaBridge | 171:3a7713b1edbc | 75 | #define ENET_BUFFDESCRIPTOR_TX_TRANMITCRC_MASK 0x0400U /*!< Transmit CRC mask. */ |
AnnaBridge | 171:3a7713b1edbc | 76 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 77 | |
AnnaBridge | 171:3a7713b1edbc | 78 | /* Extended control regions for enhanced buffer descriptors. */ |
AnnaBridge | 171:3a7713b1edbc | 79 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 80 | /*! @name First extended control region bit masks of the receive buffer descriptor. */ |
AnnaBridge | 171:3a7713b1edbc | 81 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 82 | #define ENET_BUFFDESCRIPTOR_RX_IPV4_MASK 0x0001U /*!< Ipv4 frame mask. */ |
AnnaBridge | 171:3a7713b1edbc | 83 | #define ENET_BUFFDESCRIPTOR_RX_IPV6_MASK 0x0002U /*!< Ipv6 frame mask. */ |
AnnaBridge | 171:3a7713b1edbc | 84 | #define ENET_BUFFDESCRIPTOR_RX_VLAN_MASK 0x0004U /*!< VLAN frame mask. */ |
AnnaBridge | 171:3a7713b1edbc | 85 | #define ENET_BUFFDESCRIPTOR_RX_PROTOCOLCHECKSUM_MASK 0x0010U /*!< Protocol checksum error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 86 | #define ENET_BUFFDESCRIPTOR_RX_IPHEADCHECKSUM_MASK 0x0020U /*!< IP header checksum error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 87 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 88 | |
AnnaBridge | 171:3a7713b1edbc | 89 | /*! @name Second extended control region bit masks of the receive buffer descriptor. */ |
AnnaBridge | 171:3a7713b1edbc | 90 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 91 | #define ENET_BUFFDESCRIPTOR_RX_INTERRUPT_MASK 0x0080U /*!< BD interrupt mask. */ |
AnnaBridge | 171:3a7713b1edbc | 92 | #define ENET_BUFFDESCRIPTOR_RX_UNICAST_MASK 0x0100U /*!< Unicast frame mask. */ |
AnnaBridge | 171:3a7713b1edbc | 93 | #define ENET_BUFFDESCRIPTOR_RX_COLLISION_MASK 0x0200U /*!< BD collision mask. */ |
AnnaBridge | 171:3a7713b1edbc | 94 | #define ENET_BUFFDESCRIPTOR_RX_PHYERR_MASK 0x0400U /*!< PHY error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 95 | #define ENET_BUFFDESCRIPTOR_RX_MACERR_MASK 0x8000U /*!< Mac error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 96 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 97 | |
AnnaBridge | 171:3a7713b1edbc | 98 | /*! @name First extended control region bit masks of the transmit buffer descriptor. */ |
AnnaBridge | 171:3a7713b1edbc | 99 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 100 | #define ENET_BUFFDESCRIPTOR_TX_ERR_MASK 0x8000U /*!< Transmit error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 101 | #define ENET_BUFFDESCRIPTOR_TX_UNDERFLOWERR_MASK 0x2000U /*!< Underflow error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 102 | #define ENET_BUFFDESCRIPTOR_TX_EXCCOLLISIONERR_MASK 0x1000U /*!< Excess collision error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 103 | #define ENET_BUFFDESCRIPTOR_TX_FRAMEERR_MASK 0x0800U /*!< Frame error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 104 | #define ENET_BUFFDESCRIPTOR_TX_LATECOLLISIONERR_MASK 0x0400U /*!< Late collision error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 105 | #define ENET_BUFFDESCRIPTOR_TX_OVERFLOWERR_MASK 0x0200U /*!< Overflow error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 106 | #define ENET_BUFFDESCRIPTOR_TX_TIMESTAMPERR_MASK 0x0100U /*!< Timestamp error mask. */ |
AnnaBridge | 171:3a7713b1edbc | 107 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 108 | |
AnnaBridge | 171:3a7713b1edbc | 109 | /*! @name Second extended control region bit masks of the transmit buffer descriptor. */ |
AnnaBridge | 171:3a7713b1edbc | 110 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 111 | #define ENET_BUFFDESCRIPTOR_TX_INTERRUPT_MASK 0x4000U /*!< Interrupt mask. */ |
AnnaBridge | 171:3a7713b1edbc | 112 | #define ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK 0x2000U /*!< Timestamp flag mask. */ |
AnnaBridge | 171:3a7713b1edbc | 113 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 114 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 115 | |
AnnaBridge | 171:3a7713b1edbc | 116 | /*! @brief Defines the receive error status flag mask. */ |
AnnaBridge | 171:3a7713b1edbc | 117 | #define ENET_BUFFDESCRIPTOR_RX_ERR_MASK \ |
AnnaBridge | 171:3a7713b1edbc | 118 | (ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK | ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK | \ |
AnnaBridge | 171:3a7713b1edbc | 119 | ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK | ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK | ENET_BUFFDESCRIPTOR_RX_CRC_MASK) |
AnnaBridge | 171:3a7713b1edbc | 120 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 121 | #define ENET_BUFFDESCRIPTOR_RX_EXT_ERR_MASK \ |
AnnaBridge | 171:3a7713b1edbc | 122 | (ENET_BUFFDESCRIPTOR_RX_MACERR_MASK | ENET_BUFFDESCRIPTOR_RX_PHYERR_MASK | ENET_BUFFDESCRIPTOR_RX_COLLISION_MASK) |
AnnaBridge | 171:3a7713b1edbc | 123 | #endif |
AnnaBridge | 171:3a7713b1edbc | 124 | #define ENET_TX_INTERRUPT (kENET_TxFrameInterrupt | kENET_TxBufferInterrupt) |
AnnaBridge | 171:3a7713b1edbc | 125 | #define ENET_RX_INTERRUPT (kENET_RxFrameInterrupt | kENET_RxBufferInterrupt) |
AnnaBridge | 171:3a7713b1edbc | 126 | #define ENET_ERR_INTERRUPT (kENET_BabrInterrupt | kENET_BabtInterrupt | kENET_EBusERInterrupt | \ |
AnnaBridge | 171:3a7713b1edbc | 127 | kENET_LateCollisionInterrupt | kENET_RetryLimitInterrupt | kENET_UnderrunInterrupt | kENET_PayloadRxInterrupt) |
AnnaBridge | 171:3a7713b1edbc | 128 | |
AnnaBridge | 171:3a7713b1edbc | 129 | /*! @name Defines the maximum Ethernet frame size. */ |
AnnaBridge | 171:3a7713b1edbc | 130 | /*@{*/ |
AnnaBridge | 171:3a7713b1edbc | 131 | #define ENET_FRAME_MAX_FRAMELEN 1518U /*!< Maximum Ethernet frame size. */ |
AnnaBridge | 171:3a7713b1edbc | 132 | #define ENET_FRAME_MAX_VALNFRAMELEN 1522U /*!< Maximum VLAN frame size. */ |
AnnaBridge | 171:3a7713b1edbc | 133 | /*@}*/ |
AnnaBridge | 171:3a7713b1edbc | 134 | |
AnnaBridge | 171:3a7713b1edbc | 135 | #define ENET_FIFO_MIN_RX_FULL 5U /*!< ENET minimum receive FIFO full. */ |
AnnaBridge | 171:3a7713b1edbc | 136 | #define ENET_RX_MIN_BUFFERSIZE 256U /*!< ENET minimum buffer size. */ |
AnnaBridge | 171:3a7713b1edbc | 137 | #define ENET_BUFF_ALIGNMENT 16U /*!< Ethernet buffer alignment. */ |
AnnaBridge | 171:3a7713b1edbc | 138 | |
AnnaBridge | 171:3a7713b1edbc | 139 | /*! @brief Defines the PHY address scope for the ENET. */ |
AnnaBridge | 171:3a7713b1edbc | 140 | #define ENET_PHY_MAXADDRESS (ENET_MMFR_PA_MASK >> ENET_MMFR_PA_SHIFT) |
AnnaBridge | 171:3a7713b1edbc | 141 | |
AnnaBridge | 171:3a7713b1edbc | 142 | /*! @brief Defines the status return codes for transaction. */ |
AnnaBridge | 171:3a7713b1edbc | 143 | enum _enet_status |
AnnaBridge | 171:3a7713b1edbc | 144 | { |
AnnaBridge | 171:3a7713b1edbc | 145 | kStatus_ENET_RxFrameError = MAKE_STATUS(kStatusGroup_ENET, 0U), /*!< A frame received but data error happen. */ |
AnnaBridge | 171:3a7713b1edbc | 146 | kStatus_ENET_RxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 1U), /*!< Failed to receive a frame. */ |
AnnaBridge | 171:3a7713b1edbc | 147 | kStatus_ENET_RxFrameEmpty = MAKE_STATUS(kStatusGroup_ENET, 2U), /*!< No frame arrive. */ |
AnnaBridge | 171:3a7713b1edbc | 148 | kStatus_ENET_TxFrameBusy = |
AnnaBridge | 171:3a7713b1edbc | 149 | MAKE_STATUS(kStatusGroup_ENET, 3U), /*!< Transmit buffer descriptors are under process. */ |
AnnaBridge | 171:3a7713b1edbc | 150 | kStatus_ENET_TxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 4U) /*!< Transmit frame fail. */ |
AnnaBridge | 171:3a7713b1edbc | 151 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 152 | , |
AnnaBridge | 171:3a7713b1edbc | 153 | kStatus_ENET_PtpTsRingFull = MAKE_STATUS(kStatusGroup_ENET, 5U), /*!< Timestamp ring full. */ |
AnnaBridge | 171:3a7713b1edbc | 154 | kStatus_ENET_PtpTsRingEmpty = MAKE_STATUS(kStatusGroup_ENET, 6U) /*!< Timestamp ring empty. */ |
AnnaBridge | 171:3a7713b1edbc | 155 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 156 | }; |
AnnaBridge | 171:3a7713b1edbc | 157 | |
AnnaBridge | 171:3a7713b1edbc | 158 | /*! @brief Defines the RMII or MII mode for data interface between the MAC and the PHY. */ |
AnnaBridge | 171:3a7713b1edbc | 159 | typedef enum _enet_mii_mode |
AnnaBridge | 171:3a7713b1edbc | 160 | { |
AnnaBridge | 171:3a7713b1edbc | 161 | kENET_MiiMode = 0U, /*!< MII mode for data interface. */ |
AnnaBridge | 171:3a7713b1edbc | 162 | kENET_RmiiMode /*!< RMII mode for data interface. */ |
AnnaBridge | 171:3a7713b1edbc | 163 | } enet_mii_mode_t; |
AnnaBridge | 171:3a7713b1edbc | 164 | |
AnnaBridge | 171:3a7713b1edbc | 165 | /*! @brief Defines the 10 Mbps or 100 Mbps speed for the MII data interface. */ |
AnnaBridge | 171:3a7713b1edbc | 166 | typedef enum _enet_mii_speed |
AnnaBridge | 171:3a7713b1edbc | 167 | { |
AnnaBridge | 171:3a7713b1edbc | 168 | kENET_MiiSpeed10M = 0U, /*!< Speed 10 Mbps. */ |
AnnaBridge | 171:3a7713b1edbc | 169 | kENET_MiiSpeed100M /*!< Speed 100 Mbps. */ |
AnnaBridge | 171:3a7713b1edbc | 170 | } enet_mii_speed_t; |
AnnaBridge | 171:3a7713b1edbc | 171 | |
AnnaBridge | 171:3a7713b1edbc | 172 | /*! @brief Defines the half or full duplex for the MII data interface. */ |
AnnaBridge | 171:3a7713b1edbc | 173 | typedef enum _enet_mii_duplex |
AnnaBridge | 171:3a7713b1edbc | 174 | { |
AnnaBridge | 171:3a7713b1edbc | 175 | kENET_MiiHalfDuplex = 0U, /*!< Half duplex mode. */ |
AnnaBridge | 171:3a7713b1edbc | 176 | kENET_MiiFullDuplex /*!< Full duplex mode. */ |
AnnaBridge | 171:3a7713b1edbc | 177 | } enet_mii_duplex_t; |
AnnaBridge | 171:3a7713b1edbc | 178 | |
AnnaBridge | 171:3a7713b1edbc | 179 | /*! @brief Defines the write operation for the MII management frame. */ |
AnnaBridge | 171:3a7713b1edbc | 180 | typedef enum _enet_mii_write |
AnnaBridge | 171:3a7713b1edbc | 181 | { |
AnnaBridge | 171:3a7713b1edbc | 182 | kENET_MiiWriteNoCompliant = 0U, /*!< Write frame operation, but not MII-compliant. */ |
AnnaBridge | 171:3a7713b1edbc | 183 | kENET_MiiWriteValidFrame /*!< Write frame operation for a valid MII management frame. */ |
AnnaBridge | 171:3a7713b1edbc | 184 | } enet_mii_write_t; |
AnnaBridge | 171:3a7713b1edbc | 185 | |
AnnaBridge | 171:3a7713b1edbc | 186 | /*! @brief Defines the read operation for the MII management frame. */ |
AnnaBridge | 171:3a7713b1edbc | 187 | typedef enum _enet_mii_read |
AnnaBridge | 171:3a7713b1edbc | 188 | { |
AnnaBridge | 171:3a7713b1edbc | 189 | kENET_MiiReadValidFrame = 2U, /*!< Read frame operation for a valid MII management frame. */ |
AnnaBridge | 171:3a7713b1edbc | 190 | kENET_MiiReadNoCompliant = 3U /*!< Read frame operation, but not MII-compliant. */ |
AnnaBridge | 171:3a7713b1edbc | 191 | } enet_mii_read_t; |
AnnaBridge | 171:3a7713b1edbc | 192 | |
AnnaBridge | 171:3a7713b1edbc | 193 | /*! @brief Defines a special configuration for ENET MAC controller. |
AnnaBridge | 171:3a7713b1edbc | 194 | * |
AnnaBridge | 171:3a7713b1edbc | 195 | * These control flags are provided for special user requirements. |
AnnaBridge | 171:3a7713b1edbc | 196 | * Normally, these control flags are unused for ENET initialization. |
AnnaBridge | 171:3a7713b1edbc | 197 | * For special requirements, set the flags to |
AnnaBridge | 171:3a7713b1edbc | 198 | * macSpecialConfig in the enet_config_t. |
AnnaBridge | 171:3a7713b1edbc | 199 | * The kENET_ControlStoreAndFwdDisable is used to disable the FIFO store |
AnnaBridge | 171:3a7713b1edbc | 200 | * and forward. FIFO store and forward means that the FIFO read/send is started |
AnnaBridge | 171:3a7713b1edbc | 201 | * when a complete frame is stored in TX/RX FIFO. If this flag is set, |
AnnaBridge | 171:3a7713b1edbc | 202 | * configure rxFifoFullThreshold and txFifoWatermark |
AnnaBridge | 171:3a7713b1edbc | 203 | * in the enet_config_t. |
AnnaBridge | 171:3a7713b1edbc | 204 | */ |
AnnaBridge | 171:3a7713b1edbc | 205 | typedef enum _enet_special_control_flag |
AnnaBridge | 171:3a7713b1edbc | 206 | { |
AnnaBridge | 171:3a7713b1edbc | 207 | kENET_ControlFlowControlEnable = 0x0001U, /*!< Enable ENET flow control: pause frame. */ |
AnnaBridge | 171:3a7713b1edbc | 208 | kENET_ControlRxPayloadCheckEnable = 0x0002U, /*!< Enable ENET receive payload length check. */ |
AnnaBridge | 171:3a7713b1edbc | 209 | kENET_ControlRxPadRemoveEnable = 0x0004U, /*!< Padding is removed from received frames. */ |
AnnaBridge | 171:3a7713b1edbc | 210 | kENET_ControlRxBroadCastRejectEnable = 0x0008U, /*!< Enable broadcast frame reject. */ |
AnnaBridge | 171:3a7713b1edbc | 211 | kENET_ControlMacAddrInsert = 0x0010U, /*!< Enable MAC address insert. */ |
AnnaBridge | 171:3a7713b1edbc | 212 | kENET_ControlStoreAndFwdDisable = 0x0020U, /*!< Enable FIFO store and forward. */ |
AnnaBridge | 171:3a7713b1edbc | 213 | kENET_ControlSMIPreambleDisable = 0x0040U, /*!< Enable SMI preamble. */ |
AnnaBridge | 171:3a7713b1edbc | 214 | kENET_ControlPromiscuousEnable = 0x0080U, /*!< Enable promiscuous mode. */ |
AnnaBridge | 171:3a7713b1edbc | 215 | kENET_ControlMIILoopEnable = 0x0100U, /*!< Enable ENET MII loop back. */ |
AnnaBridge | 171:3a7713b1edbc | 216 | kENET_ControlVLANTagEnable = 0x0200U /*!< Enable VLAN tag frame. */ |
AnnaBridge | 171:3a7713b1edbc | 217 | } enet_special_control_flag_t; |
AnnaBridge | 171:3a7713b1edbc | 218 | |
AnnaBridge | 171:3a7713b1edbc | 219 | /*! @brief List of interrupts supported by the peripheral. This |
AnnaBridge | 171:3a7713b1edbc | 220 | * enumeration uses one-bot encoding to allow a logical OR of multiple |
AnnaBridge | 171:3a7713b1edbc | 221 | * members. Members usually map to interrupt enable bits in one or more |
AnnaBridge | 171:3a7713b1edbc | 222 | * peripheral registers. |
AnnaBridge | 171:3a7713b1edbc | 223 | */ |
AnnaBridge | 171:3a7713b1edbc | 224 | typedef enum _enet_interrupt_enable |
AnnaBridge | 171:3a7713b1edbc | 225 | { |
AnnaBridge | 171:3a7713b1edbc | 226 | kENET_BabrInterrupt = ENET_EIR_BABR_MASK, /*!< Babbling receive error interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 227 | kENET_BabtInterrupt = ENET_EIR_BABT_MASK, /*!< Babbling transmit error interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 228 | kENET_GraceStopInterrupt = ENET_EIR_GRA_MASK, /*!< Graceful stop complete interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 229 | kENET_TxFrameInterrupt = ENET_EIR_TXF_MASK, /*!< TX FRAME interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 230 | kENET_TxBufferInterrupt = ENET_EIR_TXB_MASK, /*!< TX BUFFER interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 231 | kENET_RxFrameInterrupt = ENET_EIR_RXF_MASK, /*!< RX FRAME interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 232 | kENET_RxBufferInterrupt = ENET_EIR_RXB_MASK, /*!< RX BUFFER interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 233 | kENET_MiiInterrupt = ENET_EIR_MII_MASK, /*!< MII interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 234 | kENET_EBusERInterrupt = ENET_EIR_EBERR_MASK, /*!< Ethernet bus error interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 235 | kENET_LateCollisionInterrupt = ENET_EIR_LC_MASK, /*!< Late collision interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 236 | kENET_RetryLimitInterrupt = ENET_EIR_RL_MASK, /*!< Collision Retry Limit interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 237 | kENET_UnderrunInterrupt = ENET_EIR_UN_MASK, /*!< Transmit FIFO underrun interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 238 | kENET_PayloadRxInterrupt = ENET_EIR_PLR_MASK, /*!< Payload Receive interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 239 | kENET_WakeupInterrupt = ENET_EIR_WAKEUP_MASK /*!< WAKEUP interrupt source */ |
AnnaBridge | 171:3a7713b1edbc | 240 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 241 | , |
AnnaBridge | 171:3a7713b1edbc | 242 | kENET_TsAvailInterrupt = ENET_EIR_TS_AVAIL_MASK, /*!< TS AVAIL interrupt source for PTP */ |
AnnaBridge | 171:3a7713b1edbc | 243 | kENET_TsTimerInterrupt = ENET_EIR_TS_TIMER_MASK /*!< TS WRAP interrupt source for PTP */ |
AnnaBridge | 171:3a7713b1edbc | 244 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 245 | } enet_interrupt_enable_t; |
AnnaBridge | 171:3a7713b1edbc | 246 | |
AnnaBridge | 171:3a7713b1edbc | 247 | /*! @brief Defines the common interrupt event for callback use. */ |
AnnaBridge | 171:3a7713b1edbc | 248 | typedef enum _enet_event |
AnnaBridge | 171:3a7713b1edbc | 249 | { |
AnnaBridge | 171:3a7713b1edbc | 250 | kENET_RxEvent, /*!< Receive event. */ |
AnnaBridge | 171:3a7713b1edbc | 251 | kENET_TxEvent, /*!< Transmit event. */ |
AnnaBridge | 171:3a7713b1edbc | 252 | kENET_ErrEvent, /*!< Error event: BABR/BABT/EBERR/LC/RL/UN/PLR . */ |
AnnaBridge | 171:3a7713b1edbc | 253 | kENET_WakeUpEvent, /*!< Wake up from sleep mode event. */ |
AnnaBridge | 171:3a7713b1edbc | 254 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 255 | kENET_TimeStampEvent, /*!< Time stamp event. */ |
AnnaBridge | 171:3a7713b1edbc | 256 | kENET_TimeStampAvailEvent /*!< Time stamp available event.*/ |
AnnaBridge | 171:3a7713b1edbc | 257 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 258 | } enet_event_t; |
AnnaBridge | 171:3a7713b1edbc | 259 | |
AnnaBridge | 171:3a7713b1edbc | 260 | /*! @brief Defines the transmit accelerator configuration. */ |
AnnaBridge | 171:3a7713b1edbc | 261 | typedef enum _enet_tx_accelerator |
AnnaBridge | 171:3a7713b1edbc | 262 | { |
AnnaBridge | 171:3a7713b1edbc | 263 | kENET_TxAccelIsShift16Enabled = ENET_TACC_SHIFT16_MASK, /*!< Transmit FIFO shift-16. */ |
AnnaBridge | 171:3a7713b1edbc | 264 | kENET_TxAccelIpCheckEnabled = ENET_TACC_IPCHK_MASK, /*!< Insert IP header checksum. */ |
AnnaBridge | 171:3a7713b1edbc | 265 | kENET_TxAccelProtoCheckEnabled = ENET_TACC_PROCHK_MASK /*!< Insert protocol checksum. */ |
AnnaBridge | 171:3a7713b1edbc | 266 | } enet_tx_accelerator_t; |
AnnaBridge | 171:3a7713b1edbc | 267 | |
AnnaBridge | 171:3a7713b1edbc | 268 | /*! @brief Defines the receive accelerator configuration. */ |
AnnaBridge | 171:3a7713b1edbc | 269 | typedef enum _enet_rx_accelerator |
AnnaBridge | 171:3a7713b1edbc | 270 | { |
AnnaBridge | 171:3a7713b1edbc | 271 | kENET_RxAccelPadRemoveEnabled = ENET_RACC_PADREM_MASK, /*!< Padding removal for short IP frames. */ |
AnnaBridge | 171:3a7713b1edbc | 272 | kENET_RxAccelIpCheckEnabled = ENET_RACC_IPDIS_MASK, /*!< Discard with wrong IP header checksum. */ |
AnnaBridge | 171:3a7713b1edbc | 273 | kENET_RxAccelProtoCheckEnabled = ENET_RACC_PRODIS_MASK, /*!< Discard with wrong protocol checksum. */ |
AnnaBridge | 171:3a7713b1edbc | 274 | kENET_RxAccelMacCheckEnabled = ENET_RACC_LINEDIS_MASK, /*!< Discard with Mac layer errors. */ |
AnnaBridge | 171:3a7713b1edbc | 275 | kENET_RxAccelisShift16Enabled = ENET_RACC_SHIFT16_MASK /*!< Receive FIFO shift-16. */ |
AnnaBridge | 171:3a7713b1edbc | 276 | } enet_rx_accelerator_t; |
AnnaBridge | 171:3a7713b1edbc | 277 | |
AnnaBridge | 171:3a7713b1edbc | 278 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 279 | /*! @brief Defines the ENET PTP message related constant. */ |
AnnaBridge | 171:3a7713b1edbc | 280 | typedef enum _enet_ptp_event_type |
AnnaBridge | 171:3a7713b1edbc | 281 | { |
AnnaBridge | 171:3a7713b1edbc | 282 | kENET_PtpEventMsgType = 3U, /*!< PTP event message type. */ |
AnnaBridge | 171:3a7713b1edbc | 283 | kENET_PtpSrcPortIdLen = 10U, /*!< PTP message sequence id length. */ |
AnnaBridge | 171:3a7713b1edbc | 284 | kENET_PtpEventPort = 319U, /*!< PTP event port number. */ |
AnnaBridge | 171:3a7713b1edbc | 285 | kENET_PtpGnrlPort = 320U /*!< PTP general port number. */ |
AnnaBridge | 171:3a7713b1edbc | 286 | } enet_ptp_event_type_t; |
AnnaBridge | 171:3a7713b1edbc | 287 | |
AnnaBridge | 171:3a7713b1edbc | 288 | /*! @brief Defines the IEEE 1588 PTP timer channel numbers. */ |
AnnaBridge | 171:3a7713b1edbc | 289 | typedef enum _enet_ptp_timer_channel |
AnnaBridge | 171:3a7713b1edbc | 290 | { |
AnnaBridge | 171:3a7713b1edbc | 291 | kENET_PtpTimerChannel1 = 0U, /*!< IEEE 1588 PTP timer Channel 1. */ |
AnnaBridge | 171:3a7713b1edbc | 292 | kENET_PtpTimerChannel2, /*!< IEEE 1588 PTP timer Channel 2. */ |
AnnaBridge | 171:3a7713b1edbc | 293 | kENET_PtpTimerChannel3, /*!< IEEE 1588 PTP timer Channel 3. */ |
AnnaBridge | 171:3a7713b1edbc | 294 | kENET_PtpTimerChannel4 /*!< IEEE 1588 PTP timer Channel 4. */ |
AnnaBridge | 171:3a7713b1edbc | 295 | } enet_ptp_timer_channel_t; |
AnnaBridge | 171:3a7713b1edbc | 296 | |
AnnaBridge | 171:3a7713b1edbc | 297 | /*! @brief Defines the capture or compare mode for IEEE 1588 PTP timer channels. */ |
AnnaBridge | 171:3a7713b1edbc | 298 | typedef enum _enet_ptp_timer_channel_mode |
AnnaBridge | 171:3a7713b1edbc | 299 | { |
AnnaBridge | 171:3a7713b1edbc | 300 | kENET_PtpChannelDisable = 0U, /*!< Disable timer channel. */ |
AnnaBridge | 171:3a7713b1edbc | 301 | kENET_PtpChannelRisingCapture = 1U, /*!< Input capture on rising edge. */ |
AnnaBridge | 171:3a7713b1edbc | 302 | kENET_PtpChannelFallingCapture = 2U, /*!< Input capture on falling edge. */ |
AnnaBridge | 171:3a7713b1edbc | 303 | kENET_PtpChannelBothCapture = 3U, /*!< Input capture on both edges. */ |
AnnaBridge | 171:3a7713b1edbc | 304 | kENET_PtpChannelSoftCompare = 4U, /*!< Output compare software only. */ |
AnnaBridge | 171:3a7713b1edbc | 305 | kENET_PtpChannelToggleCompare = 5U, /*!< Toggle output on compare. */ |
AnnaBridge | 171:3a7713b1edbc | 306 | kENET_PtpChannelClearCompare = 6U, /*!< Clear output on compare. */ |
AnnaBridge | 171:3a7713b1edbc | 307 | kENET_PtpChannelSetCompare = 7U, /*!< Set output on compare. */ |
AnnaBridge | 171:3a7713b1edbc | 308 | kENET_PtpChannelClearCompareSetOverflow = 10U, /*!< Clear output on compare, set output on overflow. */ |
AnnaBridge | 171:3a7713b1edbc | 309 | kENET_PtpChannelSetCompareClearOverflow = 11U, /*!< Set output on compare, clear output on overflow. */ |
AnnaBridge | 171:3a7713b1edbc | 310 | kENET_PtpChannelPulseLowonCompare = 14U, /*!< Pulse output low on compare for one IEEE 1588 clock cycle. */ |
AnnaBridge | 171:3a7713b1edbc | 311 | kENET_PtpChannelPulseHighonCompare = 15U /*!< Pulse output high on compare for one IEEE 1588 clock cycle. */ |
AnnaBridge | 171:3a7713b1edbc | 312 | } enet_ptp_timer_channel_mode_t; |
AnnaBridge | 171:3a7713b1edbc | 313 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 314 | |
AnnaBridge | 171:3a7713b1edbc | 315 | /*! @brief Defines the receive buffer descriptor structure for the little endian system.*/ |
AnnaBridge | 171:3a7713b1edbc | 316 | typedef struct _enet_rx_bd_struct |
AnnaBridge | 171:3a7713b1edbc | 317 | { |
AnnaBridge | 171:3a7713b1edbc | 318 | uint16_t length; /*!< Buffer descriptor data length. */ |
AnnaBridge | 171:3a7713b1edbc | 319 | uint16_t control; /*!< Buffer descriptor control and status. */ |
AnnaBridge | 171:3a7713b1edbc | 320 | uint8_t *buffer; /*!< Data buffer pointer. */ |
AnnaBridge | 171:3a7713b1edbc | 321 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 322 | uint16_t controlExtend0; /*!< Extend buffer descriptor control0. */ |
AnnaBridge | 171:3a7713b1edbc | 323 | uint16_t controlExtend1; /*!< Extend buffer descriptor control1. */ |
AnnaBridge | 171:3a7713b1edbc | 324 | uint16_t payloadCheckSum; /*!< Internal payload checksum. */ |
AnnaBridge | 171:3a7713b1edbc | 325 | uint8_t headerLength; /*!< Header length. */ |
AnnaBridge | 171:3a7713b1edbc | 326 | uint8_t protocolTyte; /*!< Protocol type. */ |
AnnaBridge | 171:3a7713b1edbc | 327 | uint16_t reserved0; |
AnnaBridge | 171:3a7713b1edbc | 328 | uint16_t controlExtend2; /*!< Extend buffer descriptor control2. */ |
AnnaBridge | 171:3a7713b1edbc | 329 | uint32_t timestamp; /*!< Timestamp. */ |
AnnaBridge | 171:3a7713b1edbc | 330 | uint16_t reserved1; |
AnnaBridge | 171:3a7713b1edbc | 331 | uint16_t reserved2; |
AnnaBridge | 171:3a7713b1edbc | 332 | uint16_t reserved3; |
AnnaBridge | 171:3a7713b1edbc | 333 | uint16_t reserved4; |
AnnaBridge | 171:3a7713b1edbc | 334 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 335 | } enet_rx_bd_struct_t; |
AnnaBridge | 171:3a7713b1edbc | 336 | |
AnnaBridge | 171:3a7713b1edbc | 337 | /*! @brief Defines the enhanced transmit buffer descriptor structure for the little endian system. */ |
AnnaBridge | 171:3a7713b1edbc | 338 | typedef struct _enet_tx_bd_struct |
AnnaBridge | 171:3a7713b1edbc | 339 | { |
AnnaBridge | 171:3a7713b1edbc | 340 | uint16_t length; /*!< Buffer descriptor data length. */ |
AnnaBridge | 171:3a7713b1edbc | 341 | uint16_t control; /*!< Buffer descriptor control and status. */ |
AnnaBridge | 171:3a7713b1edbc | 342 | uint8_t *buffer; /*!< Data buffer pointer. */ |
AnnaBridge | 171:3a7713b1edbc | 343 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 344 | uint16_t controlExtend0; /*!< Extend buffer descriptor control0. */ |
AnnaBridge | 171:3a7713b1edbc | 345 | uint16_t controlExtend1; /*!< Extend buffer descriptor control1. */ |
AnnaBridge | 171:3a7713b1edbc | 346 | uint16_t reserved0; |
AnnaBridge | 171:3a7713b1edbc | 347 | uint16_t reserved1; |
AnnaBridge | 171:3a7713b1edbc | 348 | uint16_t reserved2; |
AnnaBridge | 171:3a7713b1edbc | 349 | uint16_t controlExtend2; /*!< Extend buffer descriptor control2. */ |
AnnaBridge | 171:3a7713b1edbc | 350 | uint32_t timestamp; /*!< Timestamp. */ |
AnnaBridge | 171:3a7713b1edbc | 351 | uint16_t reserved3; |
AnnaBridge | 171:3a7713b1edbc | 352 | uint16_t reserved4; |
AnnaBridge | 171:3a7713b1edbc | 353 | uint16_t reserved5; |
AnnaBridge | 171:3a7713b1edbc | 354 | uint16_t reserved6; |
AnnaBridge | 171:3a7713b1edbc | 355 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 356 | } enet_tx_bd_struct_t; |
AnnaBridge | 171:3a7713b1edbc | 357 | |
AnnaBridge | 171:3a7713b1edbc | 358 | /*! @brief Defines the ENET data error statistic structure. */ |
AnnaBridge | 171:3a7713b1edbc | 359 | typedef struct _enet_data_error_stats |
AnnaBridge | 171:3a7713b1edbc | 360 | { |
AnnaBridge | 171:3a7713b1edbc | 361 | uint32_t statsRxLenGreaterErr; /*!< Receive length greater than RCR[MAX_FL]. */ |
AnnaBridge | 171:3a7713b1edbc | 362 | uint32_t statsRxAlignErr; /*!< Receive non-octet alignment/ */ |
AnnaBridge | 171:3a7713b1edbc | 363 | uint32_t statsRxFcsErr; /*!< Receive CRC error. */ |
AnnaBridge | 171:3a7713b1edbc | 364 | uint32_t statsRxOverRunErr; /*!< Receive over run. */ |
AnnaBridge | 171:3a7713b1edbc | 365 | uint32_t statsRxTruncateErr; /*!< Receive truncate. */ |
AnnaBridge | 171:3a7713b1edbc | 366 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 367 | uint32_t statsRxProtocolChecksumErr; /*!< Receive protocol checksum error. */ |
AnnaBridge | 171:3a7713b1edbc | 368 | uint32_t statsRxIpHeadChecksumErr; /*!< Receive IP header checksum error. */ |
AnnaBridge | 171:3a7713b1edbc | 369 | uint32_t statsRxMacErr; /*!< Receive Mac error. */ |
AnnaBridge | 171:3a7713b1edbc | 370 | uint32_t statsRxPhyErr; /*!< Receive PHY error. */ |
AnnaBridge | 171:3a7713b1edbc | 371 | uint32_t statsRxCollisionErr; /*!< Receive collision. */ |
AnnaBridge | 171:3a7713b1edbc | 372 | uint32_t statsTxErr; /*!< The error happen when transmit the frame. */ |
AnnaBridge | 171:3a7713b1edbc | 373 | uint32_t statsTxFrameErr; /*!< The transmit frame is error. */ |
AnnaBridge | 171:3a7713b1edbc | 374 | uint32_t statsTxOverFlowErr; /*!< Transmit overflow. */ |
AnnaBridge | 171:3a7713b1edbc | 375 | uint32_t statsTxLateCollisionErr; /*!< Transmit late collision. */ |
AnnaBridge | 171:3a7713b1edbc | 376 | uint32_t statsTxExcessCollisionErr; /*!< Transmit excess collision.*/ |
AnnaBridge | 171:3a7713b1edbc | 377 | uint32_t statsTxUnderFlowErr; /*!< Transmit under flow error. */ |
AnnaBridge | 171:3a7713b1edbc | 378 | uint32_t statsTxTsErr; /*!< Transmit time stamp error. */ |
AnnaBridge | 171:3a7713b1edbc | 379 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 380 | } enet_data_error_stats_t; |
AnnaBridge | 171:3a7713b1edbc | 381 | |
AnnaBridge | 171:3a7713b1edbc | 382 | /*! @brief Defines the receive buffer descriptor configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 383 | * |
AnnaBridge | 171:3a7713b1edbc | 384 | * Note that for the internal DMA requirements, the buffers have a corresponding alignment requirements. |
AnnaBridge | 171:3a7713b1edbc | 385 | * 1. The aligned receive and transmit buffer size must be evenly divisible by 16. |
AnnaBridge | 171:3a7713b1edbc | 386 | * 2. The aligned transmit and receive buffer descriptor start address must be at |
AnnaBridge | 171:3a7713b1edbc | 387 | * least 64 bit aligned. However, it's recommended to be evenly divisible by 16. |
AnnaBridge | 171:3a7713b1edbc | 388 | * 3. The aligned transmit and receive buffer start address must be evenly divisible by 16. |
AnnaBridge | 171:3a7713b1edbc | 389 | * Receive buffers should be continuous with the total size equal to "rxBdNumber * rxBuffSizeAlign". |
AnnaBridge | 171:3a7713b1edbc | 390 | * Transmit buffers should be continuous with the total size equal to "txBdNumber * txBuffSizeAlign". |
AnnaBridge | 171:3a7713b1edbc | 391 | */ |
AnnaBridge | 171:3a7713b1edbc | 392 | typedef struct _enet_buffer_config |
AnnaBridge | 171:3a7713b1edbc | 393 | { |
AnnaBridge | 171:3a7713b1edbc | 394 | uint16_t rxBdNumber; /*!< Receive buffer descriptor number. */ |
AnnaBridge | 171:3a7713b1edbc | 395 | uint16_t txBdNumber; /*!< Transmit buffer descriptor number. */ |
AnnaBridge | 171:3a7713b1edbc | 396 | uint32_t rxBuffSizeAlign; /*!< Aligned receive data buffer size. */ |
AnnaBridge | 171:3a7713b1edbc | 397 | uint32_t txBuffSizeAlign; /*!< Aligned transmit data buffer size. */ |
AnnaBridge | 171:3a7713b1edbc | 398 | volatile enet_rx_bd_struct_t *rxBdStartAddrAlign; /*!< Aligned receive buffer descriptor start address. */ |
AnnaBridge | 171:3a7713b1edbc | 399 | volatile enet_tx_bd_struct_t *txBdStartAddrAlign; /*!< Aligned transmit buffer descriptor start address. */ |
AnnaBridge | 171:3a7713b1edbc | 400 | uint8_t *rxBufferAlign; /*!< Receive data buffer start address. */ |
AnnaBridge | 171:3a7713b1edbc | 401 | uint8_t *txBufferAlign; /*!< Transmit data buffer start address. */ |
AnnaBridge | 171:3a7713b1edbc | 402 | } enet_buffer_config_t; |
AnnaBridge | 171:3a7713b1edbc | 403 | |
AnnaBridge | 171:3a7713b1edbc | 404 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 405 | /*! @brief Defines the ENET PTP time stamp structure. */ |
AnnaBridge | 171:3a7713b1edbc | 406 | typedef struct _enet_ptp_time |
AnnaBridge | 171:3a7713b1edbc | 407 | { |
AnnaBridge | 171:3a7713b1edbc | 408 | uint64_t second; /*!< Second. */ |
AnnaBridge | 171:3a7713b1edbc | 409 | uint32_t nanosecond; /*!< Nanosecond. */ |
AnnaBridge | 171:3a7713b1edbc | 410 | } enet_ptp_time_t; |
AnnaBridge | 171:3a7713b1edbc | 411 | |
AnnaBridge | 171:3a7713b1edbc | 412 | /*! @brief Defines the structure for the ENET PTP message data and timestamp data.*/ |
AnnaBridge | 171:3a7713b1edbc | 413 | typedef struct _enet_ptp_time_data |
AnnaBridge | 171:3a7713b1edbc | 414 | { |
AnnaBridge | 171:3a7713b1edbc | 415 | uint8_t version; /*!< PTP version. */ |
AnnaBridge | 171:3a7713b1edbc | 416 | uint8_t sourcePortId[kENET_PtpSrcPortIdLen]; /*!< PTP source port ID. */ |
AnnaBridge | 171:3a7713b1edbc | 417 | uint16_t sequenceId; /*!< PTP sequence ID. */ |
AnnaBridge | 171:3a7713b1edbc | 418 | uint8_t messageType; /*!< PTP message type. */ |
AnnaBridge | 171:3a7713b1edbc | 419 | enet_ptp_time_t timeStamp; /*!< PTP timestamp. */ |
AnnaBridge | 171:3a7713b1edbc | 420 | } enet_ptp_time_data_t; |
AnnaBridge | 171:3a7713b1edbc | 421 | |
AnnaBridge | 171:3a7713b1edbc | 422 | /*! @brief Defines the ENET PTP ring buffer structure for the PTP message timestamp store.*/ |
AnnaBridge | 171:3a7713b1edbc | 423 | typedef struct _enet_ptp_time_data_ring |
AnnaBridge | 171:3a7713b1edbc | 424 | { |
AnnaBridge | 171:3a7713b1edbc | 425 | uint32_t front; /*!< The first index of the ring. */ |
AnnaBridge | 171:3a7713b1edbc | 426 | uint32_t end; /*!< The end index of the ring. */ |
AnnaBridge | 171:3a7713b1edbc | 427 | uint32_t size; /*!< The size of the ring. */ |
AnnaBridge | 171:3a7713b1edbc | 428 | enet_ptp_time_data_t *ptpTsData; /*!< PTP message data structure. */ |
AnnaBridge | 171:3a7713b1edbc | 429 | } enet_ptp_time_data_ring_t; |
AnnaBridge | 171:3a7713b1edbc | 430 | |
AnnaBridge | 171:3a7713b1edbc | 431 | /*! @brief Defines the ENET PTP configuration structure. */ |
AnnaBridge | 171:3a7713b1edbc | 432 | typedef struct _enet_ptp_config |
AnnaBridge | 171:3a7713b1edbc | 433 | { |
AnnaBridge | 171:3a7713b1edbc | 434 | uint8_t ptpTsRxBuffNum; /*!< Receive 1588 timestamp buffer number*/ |
AnnaBridge | 171:3a7713b1edbc | 435 | uint8_t ptpTsTxBuffNum; /*!< Transmit 1588 timestamp buffer number*/ |
AnnaBridge | 171:3a7713b1edbc | 436 | enet_ptp_time_data_t *rxPtpTsData; /*!< The start address of 1588 receive timestamp buffers */ |
AnnaBridge | 171:3a7713b1edbc | 437 | enet_ptp_time_data_t *txPtpTsData; /*!< The start address of 1588 transmit timestamp buffers */ |
AnnaBridge | 171:3a7713b1edbc | 438 | enet_ptp_timer_channel_t channel; /*!< Used for ERRATA_2579: the PTP 1588 timer channel for time interrupt. */ |
AnnaBridge | 171:3a7713b1edbc | 439 | uint32_t ptp1588ClockSrc_Hz; /*!< The clock source of the PTP 1588 timer. */ |
AnnaBridge | 171:3a7713b1edbc | 440 | } enet_ptp_config_t; |
AnnaBridge | 171:3a7713b1edbc | 441 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 442 | |
AnnaBridge | 171:3a7713b1edbc | 443 | |
AnnaBridge | 171:3a7713b1edbc | 444 | |
AnnaBridge | 171:3a7713b1edbc | 445 | /*! @brief Defines the basic configuration structure for the ENET device. |
AnnaBridge | 171:3a7713b1edbc | 446 | * |
AnnaBridge | 171:3a7713b1edbc | 447 | * Note: |
AnnaBridge | 171:3a7713b1edbc | 448 | * 1. macSpecialConfig is used for a special control configuration, a logical OR of |
AnnaBridge | 171:3a7713b1edbc | 449 | * "enet_special_control_flag_t". For a special configuration for MAC, |
AnnaBridge | 171:3a7713b1edbc | 450 | * set this parameter to 0. |
AnnaBridge | 171:3a7713b1edbc | 451 | * 2. txWatermark is used for a cut-through operation. It is in steps of 64 bytes. |
AnnaBridge | 171:3a7713b1edbc | 452 | * 0/1 - 64 bytes written to TX FIFO before transmission of a frame begins. |
AnnaBridge | 171:3a7713b1edbc | 453 | * 2 - 128 bytes written to TX FIFO .... |
AnnaBridge | 171:3a7713b1edbc | 454 | * 3 - 192 bytes written to TX FIFO .... |
AnnaBridge | 171:3a7713b1edbc | 455 | * The maximum of txWatermark is 0x2F - 4032 bytes written to TX FIFO. |
AnnaBridge | 171:3a7713b1edbc | 456 | * txWatermark allows minimizing the transmit latency to set the txWatermark to 0 or 1 |
AnnaBridge | 171:3a7713b1edbc | 457 | * or for larger bus access latency 3 or larger due to contention for the system bus. |
AnnaBridge | 171:3a7713b1edbc | 458 | * 3. rxFifoFullThreshold is similar to the txWatermark for cut-through operation in RX. |
AnnaBridge | 171:3a7713b1edbc | 459 | * It is in 64-bit words. The minimum is ENET_FIFO_MIN_RX_FULL and the maximum is 0xFF. |
AnnaBridge | 171:3a7713b1edbc | 460 | * If the end of the frame is stored in FIFO and the frame size if smaller than the |
AnnaBridge | 171:3a7713b1edbc | 461 | * txWatermark, the frame is still transmitted. The rule is the |
AnnaBridge | 171:3a7713b1edbc | 462 | * same for rxFifoFullThreshold in the receive direction. |
AnnaBridge | 171:3a7713b1edbc | 463 | * 4. When "kENET_ControlFlowControlEnable" is set in the macSpecialConfig, ensure |
AnnaBridge | 171:3a7713b1edbc | 464 | * that the pauseDuration, rxFifoEmptyThreshold, and rxFifoStatEmptyThreshold |
AnnaBridge | 171:3a7713b1edbc | 465 | * are set for flow control enabled case. |
AnnaBridge | 171:3a7713b1edbc | 466 | * 5. When "kENET_ControlStoreAndFwdDisabled" is set in the macSpecialConfig, ensure |
AnnaBridge | 171:3a7713b1edbc | 467 | * that the rxFifoFullThreshold and txFifoWatermark are set for store and forward disable. |
AnnaBridge | 171:3a7713b1edbc | 468 | * 6. The rxAccelerConfig and txAccelerConfig default setting with 0 - accelerator |
AnnaBridge | 171:3a7713b1edbc | 469 | * are disabled. The "enet_tx_accelerator_t" and "enet_rx_accelerator_t" are |
AnnaBridge | 171:3a7713b1edbc | 470 | * recommended to be used to enable the transmit and receive accelerator. |
AnnaBridge | 171:3a7713b1edbc | 471 | * After the accelerators are enabled, the store and forward feature should be enabled. |
AnnaBridge | 171:3a7713b1edbc | 472 | * As a result, kENET_ControlStoreAndFwdDisabled should not be set. |
AnnaBridge | 171:3a7713b1edbc | 473 | */ |
AnnaBridge | 171:3a7713b1edbc | 474 | typedef struct _enet_config |
AnnaBridge | 171:3a7713b1edbc | 475 | { |
AnnaBridge | 171:3a7713b1edbc | 476 | uint32_t macSpecialConfig; /*!< Mac special configuration. A logical OR of "enet_special_control_flag_t". */ |
AnnaBridge | 171:3a7713b1edbc | 477 | uint32_t interrupt; /*!< Mac interrupt source. A logical OR of "enet_interrupt_enable_t". */ |
AnnaBridge | 171:3a7713b1edbc | 478 | uint16_t rxMaxFrameLen; /*!< Receive maximum frame length. */ |
AnnaBridge | 171:3a7713b1edbc | 479 | enet_mii_mode_t miiMode; /*!< MII mode. */ |
AnnaBridge | 171:3a7713b1edbc | 480 | enet_mii_speed_t miiSpeed; /*!< MII Speed. */ |
AnnaBridge | 171:3a7713b1edbc | 481 | enet_mii_duplex_t miiDuplex; /*!< MII duplex. */ |
AnnaBridge | 171:3a7713b1edbc | 482 | uint8_t rxAccelerConfig; /*!< Receive accelerator, A logical OR of "enet_rx_accelerator_t". */ |
AnnaBridge | 171:3a7713b1edbc | 483 | uint8_t txAccelerConfig; /*!< Transmit accelerator, A logical OR of "enet_rx_accelerator_t". */ |
AnnaBridge | 171:3a7713b1edbc | 484 | uint16_t pauseDuration; /*!< For flow control enabled case: Pause duration. */ |
AnnaBridge | 171:3a7713b1edbc | 485 | uint8_t rxFifoEmptyThreshold; /*!< For flow control enabled case: when RX FIFO level reaches this value, |
AnnaBridge | 171:3a7713b1edbc | 486 | it makes MAC generate XOFF pause frame. */ |
AnnaBridge | 171:3a7713b1edbc | 487 | #if FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD |
AnnaBridge | 171:3a7713b1edbc | 488 | uint8_t rxFifoStatEmptyThreshold; /*!< For flow control enabled case: number of frames in the receive FIFO, |
AnnaBridge | 171:3a7713b1edbc | 489 | independent of size, that can be accept. If the limit is reached, reception |
AnnaBridge | 171:3a7713b1edbc | 490 | continues and a pause frame is triggered. */ |
AnnaBridge | 171:3a7713b1edbc | 491 | #endif /* FSL_FEATURE_ENET_HAS_RECEIVE_STATUS_THRESHOLD */ |
AnnaBridge | 171:3a7713b1edbc | 492 | uint8_t rxFifoFullThreshold; /*!< For store and forward disable case, the data required in RX FIFO to notify |
AnnaBridge | 171:3a7713b1edbc | 493 | the MAC receive ready status. */ |
AnnaBridge | 171:3a7713b1edbc | 494 | uint8_t txFifoWatermark; /*!< For store and forward disable case, the data required in TX FIFO |
AnnaBridge | 171:3a7713b1edbc | 495 | before a frame transmit start. */ |
AnnaBridge | 171:3a7713b1edbc | 496 | } enet_config_t; |
AnnaBridge | 171:3a7713b1edbc | 497 | |
AnnaBridge | 171:3a7713b1edbc | 498 | /* Forward declaration of the handle typedef. */ |
AnnaBridge | 171:3a7713b1edbc | 499 | typedef struct _enet_handle enet_handle_t; |
AnnaBridge | 171:3a7713b1edbc | 500 | |
AnnaBridge | 171:3a7713b1edbc | 501 | /*! @brief ENET callback function. */ |
AnnaBridge | 171:3a7713b1edbc | 502 | typedef void (*enet_callback_t)(ENET_Type *base, enet_handle_t *handle, enet_event_t event, void *userData); |
AnnaBridge | 171:3a7713b1edbc | 503 | |
AnnaBridge | 171:3a7713b1edbc | 504 | /*! @brief Defines the ENET handler structure. */ |
AnnaBridge | 171:3a7713b1edbc | 505 | struct _enet_handle |
AnnaBridge | 171:3a7713b1edbc | 506 | { |
AnnaBridge | 171:3a7713b1edbc | 507 | volatile enet_rx_bd_struct_t *rxBdBase; /*!< Receive buffer descriptor base address pointer. */ |
AnnaBridge | 171:3a7713b1edbc | 508 | volatile enet_rx_bd_struct_t *rxBdCurrent; /*!< The current available receive buffer descriptor pointer. */ |
AnnaBridge | 171:3a7713b1edbc | 509 | volatile enet_tx_bd_struct_t *txBdBase; /*!< Transmit buffer descriptor base address pointer. */ |
AnnaBridge | 171:3a7713b1edbc | 510 | volatile enet_tx_bd_struct_t *txBdCurrent; /*!< The current available transmit buffer descriptor pointer. */ |
AnnaBridge | 171:3a7713b1edbc | 511 | volatile enet_tx_bd_struct_t *txBdDirty; /*!< The dirty transmit buffer descriptor needed to be updated from. */ |
AnnaBridge | 171:3a7713b1edbc | 512 | uint32_t rxBuffSizeAlign; /*!< Receive buffer size alignment. */ |
AnnaBridge | 171:3a7713b1edbc | 513 | uint32_t txBuffSizeAlign; /*!< Transmit buffer size alignment. */ |
AnnaBridge | 171:3a7713b1edbc | 514 | enet_callback_t callback; /*!< Callback function. */ |
AnnaBridge | 171:3a7713b1edbc | 515 | void *userData; /*!< Callback function parameter.*/ |
AnnaBridge | 171:3a7713b1edbc | 516 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 517 | volatile enet_tx_bd_struct_t *txBdDirtyStatic; /*!< The dirty transmit buffer descriptor for error static update. */ |
AnnaBridge | 171:3a7713b1edbc | 518 | volatile enet_tx_bd_struct_t *txBdDirtyTime; /*!< The dirty transmit buffer descriptor for time stamp update. */ |
AnnaBridge | 171:3a7713b1edbc | 519 | uint64_t msTimerSecond; /*!< The second for Master PTP timer .*/ |
AnnaBridge | 171:3a7713b1edbc | 520 | enet_ptp_time_data_ring_t rxPtpTsDataRing; /*!< Receive PTP 1588 time stamp data ring buffer. */ |
AnnaBridge | 171:3a7713b1edbc | 521 | enet_ptp_time_data_ring_t txPtpTsDataRing; /*!< Transmit PTP 1588 time stamp data ring buffer. */ |
AnnaBridge | 171:3a7713b1edbc | 522 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 523 | }; |
AnnaBridge | 171:3a7713b1edbc | 524 | |
AnnaBridge | 171:3a7713b1edbc | 525 | /******************************************************************************* |
AnnaBridge | 171:3a7713b1edbc | 526 | * API |
AnnaBridge | 171:3a7713b1edbc | 527 | ******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 528 | |
AnnaBridge | 171:3a7713b1edbc | 529 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 530 | extern "C" { |
AnnaBridge | 171:3a7713b1edbc | 531 | #endif |
AnnaBridge | 171:3a7713b1edbc | 532 | |
AnnaBridge | 171:3a7713b1edbc | 533 | /*! |
AnnaBridge | 171:3a7713b1edbc | 534 | * @name Initialization and de-initialization |
AnnaBridge | 171:3a7713b1edbc | 535 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 536 | */ |
AnnaBridge | 171:3a7713b1edbc | 537 | |
AnnaBridge | 171:3a7713b1edbc | 538 | /*! |
AnnaBridge | 171:3a7713b1edbc | 539 | * @brief Gets the ENET default configuration structure. |
AnnaBridge | 171:3a7713b1edbc | 540 | * |
AnnaBridge | 171:3a7713b1edbc | 541 | * The purpose of this API is to get the default ENET MAC controller |
AnnaBridge | 171:3a7713b1edbc | 542 | * configuration structure for ENET_Init(). Users may use the initialized |
AnnaBridge | 171:3a7713b1edbc | 543 | * structure unchanged in ENET_Init() or modify fields of the |
AnnaBridge | 171:3a7713b1edbc | 544 | * structure before calling ENET_Init(). |
AnnaBridge | 171:3a7713b1edbc | 545 | * This is an example. |
AnnaBridge | 171:3a7713b1edbc | 546 | @code |
AnnaBridge | 171:3a7713b1edbc | 547 | enet_config_t config; |
AnnaBridge | 171:3a7713b1edbc | 548 | ENET_GetDefaultConfig(&config); |
AnnaBridge | 171:3a7713b1edbc | 549 | @endcode |
AnnaBridge | 171:3a7713b1edbc | 550 | * @param config The ENET mac controller configuration structure pointer. |
AnnaBridge | 171:3a7713b1edbc | 551 | */ |
AnnaBridge | 171:3a7713b1edbc | 552 | void ENET_GetDefaultConfig(enet_config_t *config); |
AnnaBridge | 171:3a7713b1edbc | 553 | |
AnnaBridge | 171:3a7713b1edbc | 554 | /*! |
AnnaBridge | 171:3a7713b1edbc | 555 | * @brief Initializes the ENET module. |
AnnaBridge | 171:3a7713b1edbc | 556 | * |
AnnaBridge | 171:3a7713b1edbc | 557 | * This function ungates the module clock and initializes it with the ENET configuration. |
AnnaBridge | 171:3a7713b1edbc | 558 | * |
AnnaBridge | 171:3a7713b1edbc | 559 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 560 | * @param handle ENET handler pointer. |
AnnaBridge | 171:3a7713b1edbc | 561 | * @param config ENET Mac configuration structure pointer. |
AnnaBridge | 171:3a7713b1edbc | 562 | * The "enet_config_t" type mac configuration return from ENET_GetDefaultConfig |
AnnaBridge | 171:3a7713b1edbc | 563 | * can be used directly. It is also possible to verify the Mac configuration using other methods. |
AnnaBridge | 171:3a7713b1edbc | 564 | * @param bufferConfig ENET buffer configuration structure pointer. |
AnnaBridge | 171:3a7713b1edbc | 565 | * The buffer configuration should be prepared for ENET Initialization. |
AnnaBridge | 171:3a7713b1edbc | 566 | * @param macAddr ENET mac address of the Ethernet device. This Mac address should be |
AnnaBridge | 171:3a7713b1edbc | 567 | * provided. |
AnnaBridge | 171:3a7713b1edbc | 568 | * @param srcClock_Hz The internal module clock source for MII clock. |
AnnaBridge | 171:3a7713b1edbc | 569 | * |
AnnaBridge | 171:3a7713b1edbc | 570 | * @note ENET has two buffer descriptors legacy buffer descriptors and |
AnnaBridge | 171:3a7713b1edbc | 571 | * enhanced IEEE 1588 buffer descriptors. The legacy descriptor is used by default. To |
AnnaBridge | 171:3a7713b1edbc | 572 | * use the IEEE 1588 feature, use the enhanced IEEE 1588 buffer descriptor |
AnnaBridge | 171:3a7713b1edbc | 573 | * by defining "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" and calling ENET_Ptp1588Configure() |
AnnaBridge | 171:3a7713b1edbc | 574 | * to configure the 1588 feature and related buffers after calling ENET_Init(). |
AnnaBridge | 171:3a7713b1edbc | 575 | */ |
AnnaBridge | 171:3a7713b1edbc | 576 | void ENET_Init(ENET_Type *base, |
AnnaBridge | 171:3a7713b1edbc | 577 | enet_handle_t *handle, |
AnnaBridge | 171:3a7713b1edbc | 578 | const enet_config_t *config, |
AnnaBridge | 171:3a7713b1edbc | 579 | const enet_buffer_config_t *bufferConfig, |
AnnaBridge | 171:3a7713b1edbc | 580 | uint8_t *macAddr, |
AnnaBridge | 171:3a7713b1edbc | 581 | uint32_t srcClock_Hz); |
AnnaBridge | 171:3a7713b1edbc | 582 | /*! |
AnnaBridge | 171:3a7713b1edbc | 583 | * @brief Deinitializes the ENET module. |
AnnaBridge | 171:3a7713b1edbc | 584 | |
AnnaBridge | 171:3a7713b1edbc | 585 | * This function gates the module clock, clears ENET interrupts, and disables the ENET module. |
AnnaBridge | 171:3a7713b1edbc | 586 | * |
AnnaBridge | 171:3a7713b1edbc | 587 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 588 | */ |
AnnaBridge | 171:3a7713b1edbc | 589 | void ENET_Deinit(ENET_Type *base); |
AnnaBridge | 171:3a7713b1edbc | 590 | |
AnnaBridge | 171:3a7713b1edbc | 591 | /*! |
AnnaBridge | 171:3a7713b1edbc | 592 | * @brief Resets the ENET module. |
AnnaBridge | 171:3a7713b1edbc | 593 | * |
AnnaBridge | 171:3a7713b1edbc | 594 | * This function restores the ENET module to the reset state. |
AnnaBridge | 171:3a7713b1edbc | 595 | * Note that this function sets all registers to the |
AnnaBridge | 171:3a7713b1edbc | 596 | * reset state. As a result, the ENET module can't work after calling this function. |
AnnaBridge | 171:3a7713b1edbc | 597 | * |
AnnaBridge | 171:3a7713b1edbc | 598 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 599 | */ |
AnnaBridge | 171:3a7713b1edbc | 600 | static inline void ENET_Reset(ENET_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 601 | { |
AnnaBridge | 171:3a7713b1edbc | 602 | base->ECR |= ENET_ECR_RESET_MASK; |
AnnaBridge | 171:3a7713b1edbc | 603 | } |
AnnaBridge | 171:3a7713b1edbc | 604 | |
AnnaBridge | 171:3a7713b1edbc | 605 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 606 | |
AnnaBridge | 171:3a7713b1edbc | 607 | /*! |
AnnaBridge | 171:3a7713b1edbc | 608 | * @name MII interface operation |
AnnaBridge | 171:3a7713b1edbc | 609 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 610 | */ |
AnnaBridge | 171:3a7713b1edbc | 611 | |
AnnaBridge | 171:3a7713b1edbc | 612 | /*! |
AnnaBridge | 171:3a7713b1edbc | 613 | * @brief Sets the ENET MII speed and duplex. |
AnnaBridge | 171:3a7713b1edbc | 614 | * |
AnnaBridge | 171:3a7713b1edbc | 615 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 616 | * @param speed The speed of the RMII mode. |
AnnaBridge | 171:3a7713b1edbc | 617 | * @param duplex The duplex of the RMII mode. |
AnnaBridge | 171:3a7713b1edbc | 618 | */ |
AnnaBridge | 171:3a7713b1edbc | 619 | void ENET_SetMII(ENET_Type *base, enet_mii_speed_t speed, enet_mii_duplex_t duplex); |
AnnaBridge | 171:3a7713b1edbc | 620 | |
AnnaBridge | 171:3a7713b1edbc | 621 | /*! |
AnnaBridge | 171:3a7713b1edbc | 622 | * @brief Sets the ENET SMI(serial management interface)- MII management interface. |
AnnaBridge | 171:3a7713b1edbc | 623 | * |
AnnaBridge | 171:3a7713b1edbc | 624 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 625 | * @param srcClock_Hz This is the ENET module clock frequency. Normally it's the system clock. See clock distribution. |
AnnaBridge | 171:3a7713b1edbc | 626 | * @param isPreambleDisabled The preamble disable flag. |
AnnaBridge | 171:3a7713b1edbc | 627 | * - true Enables the preamble. |
AnnaBridge | 171:3a7713b1edbc | 628 | * - false Disables the preamble. |
AnnaBridge | 171:3a7713b1edbc | 629 | */ |
AnnaBridge | 171:3a7713b1edbc | 630 | void ENET_SetSMI(ENET_Type *base, uint32_t srcClock_Hz, bool isPreambleDisabled); |
AnnaBridge | 171:3a7713b1edbc | 631 | |
AnnaBridge | 171:3a7713b1edbc | 632 | /*! |
AnnaBridge | 171:3a7713b1edbc | 633 | * @brief Gets the ENET SMI- MII management interface configuration. |
AnnaBridge | 171:3a7713b1edbc | 634 | * |
AnnaBridge | 171:3a7713b1edbc | 635 | * This API is used to get the SMI configuration to check whether the MII management |
AnnaBridge | 171:3a7713b1edbc | 636 | * interface has been set. |
AnnaBridge | 171:3a7713b1edbc | 637 | * |
AnnaBridge | 171:3a7713b1edbc | 638 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 639 | * @return The SMI setup status true or false. |
AnnaBridge | 171:3a7713b1edbc | 640 | */ |
AnnaBridge | 171:3a7713b1edbc | 641 | static inline bool ENET_GetSMI(ENET_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 642 | { |
AnnaBridge | 171:3a7713b1edbc | 643 | return (0 != (base->MSCR & 0x7E)); |
AnnaBridge | 171:3a7713b1edbc | 644 | } |
AnnaBridge | 171:3a7713b1edbc | 645 | |
AnnaBridge | 171:3a7713b1edbc | 646 | /*! |
AnnaBridge | 171:3a7713b1edbc | 647 | * @brief Reads data from the PHY register through an SMI interface. |
AnnaBridge | 171:3a7713b1edbc | 648 | * |
AnnaBridge | 171:3a7713b1edbc | 649 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 650 | * @return The data read from PHY |
AnnaBridge | 171:3a7713b1edbc | 651 | */ |
AnnaBridge | 171:3a7713b1edbc | 652 | static inline uint32_t ENET_ReadSMIData(ENET_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 653 | { |
AnnaBridge | 171:3a7713b1edbc | 654 | return (uint32_t)((base->MMFR & ENET_MMFR_DATA_MASK) >> ENET_MMFR_DATA_SHIFT); |
AnnaBridge | 171:3a7713b1edbc | 655 | } |
AnnaBridge | 171:3a7713b1edbc | 656 | |
AnnaBridge | 171:3a7713b1edbc | 657 | /*! |
AnnaBridge | 171:3a7713b1edbc | 658 | * @brief Starts an SMI (Serial Management Interface) read command. |
AnnaBridge | 171:3a7713b1edbc | 659 | * |
AnnaBridge | 171:3a7713b1edbc | 660 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 661 | * @param phyAddr The PHY address. |
AnnaBridge | 171:3a7713b1edbc | 662 | * @param phyReg The PHY register. |
AnnaBridge | 171:3a7713b1edbc | 663 | * @param operation The read operation. |
AnnaBridge | 171:3a7713b1edbc | 664 | */ |
AnnaBridge | 171:3a7713b1edbc | 665 | void ENET_StartSMIRead(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_read_t operation); |
AnnaBridge | 171:3a7713b1edbc | 666 | |
AnnaBridge | 171:3a7713b1edbc | 667 | /*! |
AnnaBridge | 171:3a7713b1edbc | 668 | * @brief Starts an SMI write command. |
AnnaBridge | 171:3a7713b1edbc | 669 | * |
AnnaBridge | 171:3a7713b1edbc | 670 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 671 | * @param phyAddr The PHY address. |
AnnaBridge | 171:3a7713b1edbc | 672 | * @param phyReg The PHY register. |
AnnaBridge | 171:3a7713b1edbc | 673 | * @param operation The write operation. |
AnnaBridge | 171:3a7713b1edbc | 674 | * @param data The data written to PHY. |
AnnaBridge | 171:3a7713b1edbc | 675 | */ |
AnnaBridge | 171:3a7713b1edbc | 676 | void ENET_StartSMIWrite(ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_write_t operation, uint32_t data); |
AnnaBridge | 171:3a7713b1edbc | 677 | |
AnnaBridge | 171:3a7713b1edbc | 678 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 679 | |
AnnaBridge | 171:3a7713b1edbc | 680 | /*! |
AnnaBridge | 171:3a7713b1edbc | 681 | * @name MAC Address Filter |
AnnaBridge | 171:3a7713b1edbc | 682 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 683 | */ |
AnnaBridge | 171:3a7713b1edbc | 684 | |
AnnaBridge | 171:3a7713b1edbc | 685 | /*! |
AnnaBridge | 171:3a7713b1edbc | 686 | * @brief Sets the ENET module Mac address. |
AnnaBridge | 171:3a7713b1edbc | 687 | * |
AnnaBridge | 171:3a7713b1edbc | 688 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 689 | * @param macAddr The six-byte Mac address pointer. |
AnnaBridge | 171:3a7713b1edbc | 690 | * The pointer is allocated by application and input into the API. |
AnnaBridge | 171:3a7713b1edbc | 691 | */ |
AnnaBridge | 171:3a7713b1edbc | 692 | void ENET_SetMacAddr(ENET_Type *base, uint8_t *macAddr); |
AnnaBridge | 171:3a7713b1edbc | 693 | |
AnnaBridge | 171:3a7713b1edbc | 694 | /*! |
AnnaBridge | 171:3a7713b1edbc | 695 | * @brief Gets the ENET module Mac address. |
AnnaBridge | 171:3a7713b1edbc | 696 | * |
AnnaBridge | 171:3a7713b1edbc | 697 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 698 | * @param macAddr The six-byte Mac address pointer. |
AnnaBridge | 171:3a7713b1edbc | 699 | * The pointer is allocated by application and input into the API. |
AnnaBridge | 171:3a7713b1edbc | 700 | */ |
AnnaBridge | 171:3a7713b1edbc | 701 | void ENET_GetMacAddr(ENET_Type *base, uint8_t *macAddr); |
AnnaBridge | 171:3a7713b1edbc | 702 | |
AnnaBridge | 171:3a7713b1edbc | 703 | /*! |
AnnaBridge | 171:3a7713b1edbc | 704 | * @brief Adds the ENET device to a multicast group. |
AnnaBridge | 171:3a7713b1edbc | 705 | * |
AnnaBridge | 171:3a7713b1edbc | 706 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 707 | * @param address The six-byte multicast group address which is provided by application. |
AnnaBridge | 171:3a7713b1edbc | 708 | */ |
AnnaBridge | 171:3a7713b1edbc | 709 | void ENET_AddMulticastGroup(ENET_Type *base, uint8_t *address); |
AnnaBridge | 171:3a7713b1edbc | 710 | |
AnnaBridge | 171:3a7713b1edbc | 711 | /*! |
AnnaBridge | 171:3a7713b1edbc | 712 | * @brief Moves the ENET device from a multicast group. |
AnnaBridge | 171:3a7713b1edbc | 713 | * |
AnnaBridge | 171:3a7713b1edbc | 714 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 715 | * @param address The six-byte multicast group address which is provided by application. |
AnnaBridge | 171:3a7713b1edbc | 716 | */ |
AnnaBridge | 171:3a7713b1edbc | 717 | void ENET_LeaveMulticastGroup(ENET_Type *base, uint8_t *address); |
AnnaBridge | 171:3a7713b1edbc | 718 | |
AnnaBridge | 171:3a7713b1edbc | 719 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 720 | |
AnnaBridge | 171:3a7713b1edbc | 721 | /*! |
AnnaBridge | 171:3a7713b1edbc | 722 | * @name Other basic operations |
AnnaBridge | 171:3a7713b1edbc | 723 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 724 | */ |
AnnaBridge | 171:3a7713b1edbc | 725 | |
AnnaBridge | 171:3a7713b1edbc | 726 | /*! |
AnnaBridge | 171:3a7713b1edbc | 727 | * @brief Activates ENET read or receive. |
AnnaBridge | 171:3a7713b1edbc | 728 | * |
AnnaBridge | 171:3a7713b1edbc | 729 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 730 | * |
AnnaBridge | 171:3a7713b1edbc | 731 | * @note This must be called after the MAC configuration and |
AnnaBridge | 171:3a7713b1edbc | 732 | * state are ready. It must be called after the ENET_Init() and |
AnnaBridge | 171:3a7713b1edbc | 733 | * ENET_Ptp1588Configure(). This should be called when the ENET receive required. |
AnnaBridge | 171:3a7713b1edbc | 734 | */ |
AnnaBridge | 171:3a7713b1edbc | 735 | static inline void ENET_ActiveRead(ENET_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 736 | { |
AnnaBridge | 171:3a7713b1edbc | 737 | base->RDAR = ENET_RDAR_RDAR_MASK; |
AnnaBridge | 171:3a7713b1edbc | 738 | } |
AnnaBridge | 171:3a7713b1edbc | 739 | |
AnnaBridge | 171:3a7713b1edbc | 740 | /*! |
AnnaBridge | 171:3a7713b1edbc | 741 | * @brief Enables/disables the MAC to enter sleep mode. |
AnnaBridge | 171:3a7713b1edbc | 742 | * This function is used to set the MAC enter sleep mode. |
AnnaBridge | 171:3a7713b1edbc | 743 | * When entering sleep mode, the magic frame wakeup interrupt should be enabled |
AnnaBridge | 171:3a7713b1edbc | 744 | * to wake up MAC from the sleep mode and reset it to normal mode. |
AnnaBridge | 171:3a7713b1edbc | 745 | * |
AnnaBridge | 171:3a7713b1edbc | 746 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 747 | * @param enable True enable sleep mode, false disable sleep mode. |
AnnaBridge | 171:3a7713b1edbc | 748 | */ |
AnnaBridge | 171:3a7713b1edbc | 749 | static inline void ENET_EnableSleepMode(ENET_Type *base, bool enable) |
AnnaBridge | 171:3a7713b1edbc | 750 | { |
AnnaBridge | 171:3a7713b1edbc | 751 | if (enable) |
AnnaBridge | 171:3a7713b1edbc | 752 | { |
AnnaBridge | 171:3a7713b1edbc | 753 | /* When this field is set, MAC enters sleep mode. */ |
AnnaBridge | 171:3a7713b1edbc | 754 | base->ECR |= ENET_ECR_SLEEP_MASK | ENET_ECR_MAGICEN_MASK; |
AnnaBridge | 171:3a7713b1edbc | 755 | } |
AnnaBridge | 171:3a7713b1edbc | 756 | else |
AnnaBridge | 171:3a7713b1edbc | 757 | { /* MAC exits sleep mode. */ |
AnnaBridge | 171:3a7713b1edbc | 758 | base->ECR &= ~(ENET_ECR_SLEEP_MASK | ENET_ECR_MAGICEN_MASK); |
AnnaBridge | 171:3a7713b1edbc | 759 | } |
AnnaBridge | 171:3a7713b1edbc | 760 | } |
AnnaBridge | 171:3a7713b1edbc | 761 | |
AnnaBridge | 171:3a7713b1edbc | 762 | /*! |
AnnaBridge | 171:3a7713b1edbc | 763 | * @brief Gets ENET transmit and receive accelerator functions from the MAC controller. |
AnnaBridge | 171:3a7713b1edbc | 764 | * |
AnnaBridge | 171:3a7713b1edbc | 765 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 766 | * @param txAccelOption The transmit accelerator option. The "enet_tx_accelerator_t" is |
AnnaBridge | 171:3a7713b1edbc | 767 | * recommended as the mask to get the exact the accelerator option. |
AnnaBridge | 171:3a7713b1edbc | 768 | * @param rxAccelOption The receive accelerator option. The "enet_rx_accelerator_t" is |
AnnaBridge | 171:3a7713b1edbc | 769 | * recommended as the mask to get the exact the accelerator option. |
AnnaBridge | 171:3a7713b1edbc | 770 | */ |
AnnaBridge | 171:3a7713b1edbc | 771 | static inline void ENET_GetAccelFunction(ENET_Type *base, uint32_t *txAccelOption, uint32_t *rxAccelOption) |
AnnaBridge | 171:3a7713b1edbc | 772 | { |
AnnaBridge | 171:3a7713b1edbc | 773 | assert(txAccelOption); |
AnnaBridge | 171:3a7713b1edbc | 774 | assert(txAccelOption); |
AnnaBridge | 171:3a7713b1edbc | 775 | |
AnnaBridge | 171:3a7713b1edbc | 776 | *txAccelOption = base->TACC; |
AnnaBridge | 171:3a7713b1edbc | 777 | *rxAccelOption = base->RACC; |
AnnaBridge | 171:3a7713b1edbc | 778 | } |
AnnaBridge | 171:3a7713b1edbc | 779 | |
AnnaBridge | 171:3a7713b1edbc | 780 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 781 | |
AnnaBridge | 171:3a7713b1edbc | 782 | /*! |
AnnaBridge | 171:3a7713b1edbc | 783 | * @name Interrupts |
AnnaBridge | 171:3a7713b1edbc | 784 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 785 | */ |
AnnaBridge | 171:3a7713b1edbc | 786 | |
AnnaBridge | 171:3a7713b1edbc | 787 | /*! |
AnnaBridge | 171:3a7713b1edbc | 788 | * @brief Enables the ENET interrupt. |
AnnaBridge | 171:3a7713b1edbc | 789 | * |
AnnaBridge | 171:3a7713b1edbc | 790 | * This function enables the ENET interrupt according to the provided mask. The mask |
AnnaBridge | 171:3a7713b1edbc | 791 | * is a logical OR of enumeration members. See @ref enet_interrupt_enable_t. |
AnnaBridge | 171:3a7713b1edbc | 792 | * For example, to enable the TX frame interrupt and RX frame interrupt, do the following. |
AnnaBridge | 171:3a7713b1edbc | 793 | * @code |
AnnaBridge | 171:3a7713b1edbc | 794 | * ENET_EnableInterrupts(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt); |
AnnaBridge | 171:3a7713b1edbc | 795 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 796 | * |
AnnaBridge | 171:3a7713b1edbc | 797 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 798 | * @param mask ENET interrupts to enable. This is a logical OR of the |
AnnaBridge | 171:3a7713b1edbc | 799 | * enumeration :: enet_interrupt_enable_t. |
AnnaBridge | 171:3a7713b1edbc | 800 | */ |
AnnaBridge | 171:3a7713b1edbc | 801 | static inline void ENET_EnableInterrupts(ENET_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 802 | { |
AnnaBridge | 171:3a7713b1edbc | 803 | base->EIMR |= mask; |
AnnaBridge | 171:3a7713b1edbc | 804 | } |
AnnaBridge | 171:3a7713b1edbc | 805 | |
AnnaBridge | 171:3a7713b1edbc | 806 | /*! |
AnnaBridge | 171:3a7713b1edbc | 807 | * @brief Disables the ENET interrupt. |
AnnaBridge | 171:3a7713b1edbc | 808 | * |
AnnaBridge | 171:3a7713b1edbc | 809 | * This function disables the ENET interrupts according to the provided mask. The mask |
AnnaBridge | 171:3a7713b1edbc | 810 | * is a logical OR of enumeration members. See @ref enet_interrupt_enable_t. |
AnnaBridge | 171:3a7713b1edbc | 811 | * For example, to disable the TX frame interrupt and RX frame interrupt, do the following. |
AnnaBridge | 171:3a7713b1edbc | 812 | * @code |
AnnaBridge | 171:3a7713b1edbc | 813 | * ENET_DisableInterrupts(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt); |
AnnaBridge | 171:3a7713b1edbc | 814 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 815 | * |
AnnaBridge | 171:3a7713b1edbc | 816 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 817 | * @param mask ENET interrupts to disable. This is a logical OR of the |
AnnaBridge | 171:3a7713b1edbc | 818 | * enumeration :: enet_interrupt_enable_t. |
AnnaBridge | 171:3a7713b1edbc | 819 | */ |
AnnaBridge | 171:3a7713b1edbc | 820 | static inline void ENET_DisableInterrupts(ENET_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 821 | { |
AnnaBridge | 171:3a7713b1edbc | 822 | base->EIMR &= ~mask; |
AnnaBridge | 171:3a7713b1edbc | 823 | } |
AnnaBridge | 171:3a7713b1edbc | 824 | |
AnnaBridge | 171:3a7713b1edbc | 825 | /*! |
AnnaBridge | 171:3a7713b1edbc | 826 | * @brief Gets the ENET interrupt status flag. |
AnnaBridge | 171:3a7713b1edbc | 827 | * |
AnnaBridge | 171:3a7713b1edbc | 828 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 829 | * @return The event status of the interrupt source. This is the logical OR of members |
AnnaBridge | 171:3a7713b1edbc | 830 | * of the enumeration :: enet_interrupt_enable_t. |
AnnaBridge | 171:3a7713b1edbc | 831 | */ |
AnnaBridge | 171:3a7713b1edbc | 832 | static inline uint32_t ENET_GetInterruptStatus(ENET_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 833 | { |
AnnaBridge | 171:3a7713b1edbc | 834 | return base->EIR; |
AnnaBridge | 171:3a7713b1edbc | 835 | } |
AnnaBridge | 171:3a7713b1edbc | 836 | |
AnnaBridge | 171:3a7713b1edbc | 837 | /*! |
AnnaBridge | 171:3a7713b1edbc | 838 | * @brief Clears the ENET interrupt events status flag. |
AnnaBridge | 171:3a7713b1edbc | 839 | * |
AnnaBridge | 171:3a7713b1edbc | 840 | * This function clears enabled ENET interrupts according to the provided mask. The mask |
AnnaBridge | 171:3a7713b1edbc | 841 | * is a logical OR of enumeration members. See the @ref enet_interrupt_enable_t. |
AnnaBridge | 171:3a7713b1edbc | 842 | * For example, to clear the TX frame interrupt and RX frame interrupt, do the following. |
AnnaBridge | 171:3a7713b1edbc | 843 | * @code |
AnnaBridge | 171:3a7713b1edbc | 844 | * ENET_ClearInterruptStatus(ENET, kENET_TxFrameInterrupt | kENET_RxFrameInterrupt); |
AnnaBridge | 171:3a7713b1edbc | 845 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 846 | * |
AnnaBridge | 171:3a7713b1edbc | 847 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 848 | * @param mask ENET interrupt source to be cleared. |
AnnaBridge | 171:3a7713b1edbc | 849 | * This is the logical OR of members of the enumeration :: enet_interrupt_enable_t. |
AnnaBridge | 171:3a7713b1edbc | 850 | */ |
AnnaBridge | 171:3a7713b1edbc | 851 | static inline void ENET_ClearInterruptStatus(ENET_Type *base, uint32_t mask) |
AnnaBridge | 171:3a7713b1edbc | 852 | { |
AnnaBridge | 171:3a7713b1edbc | 853 | base->EIR = mask; |
AnnaBridge | 171:3a7713b1edbc | 854 | } |
AnnaBridge | 171:3a7713b1edbc | 855 | |
AnnaBridge | 171:3a7713b1edbc | 856 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 857 | |
AnnaBridge | 171:3a7713b1edbc | 858 | /*! |
AnnaBridge | 171:3a7713b1edbc | 859 | * @name Transactional operation |
AnnaBridge | 171:3a7713b1edbc | 860 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 861 | */ |
AnnaBridge | 171:3a7713b1edbc | 862 | |
AnnaBridge | 171:3a7713b1edbc | 863 | /*! |
AnnaBridge | 171:3a7713b1edbc | 864 | * @brief Sets the callback function. |
AnnaBridge | 171:3a7713b1edbc | 865 | * This API is provided for the application callback required case when ENET |
AnnaBridge | 171:3a7713b1edbc | 866 | * interrupt is enabled. This API should be called after calling ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 867 | * |
AnnaBridge | 171:3a7713b1edbc | 868 | * @param handle ENET handler pointer. Should be provided by application. |
AnnaBridge | 171:3a7713b1edbc | 869 | * @param callback The ENET callback function. |
AnnaBridge | 171:3a7713b1edbc | 870 | * @param userData The callback function parameter. |
AnnaBridge | 171:3a7713b1edbc | 871 | */ |
AnnaBridge | 171:3a7713b1edbc | 872 | void ENET_SetCallback(enet_handle_t *handle, enet_callback_t callback, void *userData); |
AnnaBridge | 171:3a7713b1edbc | 873 | |
AnnaBridge | 171:3a7713b1edbc | 874 | /*! |
AnnaBridge | 171:3a7713b1edbc | 875 | * @brief Gets the ENET the error statistics of a received frame. |
AnnaBridge | 171:3a7713b1edbc | 876 | * |
AnnaBridge | 171:3a7713b1edbc | 877 | * This API must be called after the ENET_GetRxFrameSize and before the ENET_ReadFrame(). |
AnnaBridge | 171:3a7713b1edbc | 878 | * If the ENET_GetRxFrameSize returns kStatus_ENET_RxFrameError, |
AnnaBridge | 171:3a7713b1edbc | 879 | * the ENET_GetRxErrBeforeReadFrame can be used to get the exact error statistics. |
AnnaBridge | 171:3a7713b1edbc | 880 | * This is an example. |
AnnaBridge | 171:3a7713b1edbc | 881 | * @code |
AnnaBridge | 171:3a7713b1edbc | 882 | * status = ENET_GetRxFrameSize(&g_handle, &length); |
AnnaBridge | 171:3a7713b1edbc | 883 | * if (status == kStatus_ENET_RxFrameError) |
AnnaBridge | 171:3a7713b1edbc | 884 | * { |
AnnaBridge | 171:3a7713b1edbc | 885 | * // Get the error information of the received frame. |
AnnaBridge | 171:3a7713b1edbc | 886 | * ENET_GetRxErrBeforeReadFrame(&g_handle, &eErrStatic); |
AnnaBridge | 171:3a7713b1edbc | 887 | * // update the receive buffer. |
AnnaBridge | 171:3a7713b1edbc | 888 | * ENET_ReadFrame(EXAMPLE_ENET, &g_handle, NULL, 0); |
AnnaBridge | 171:3a7713b1edbc | 889 | * } |
AnnaBridge | 171:3a7713b1edbc | 890 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 891 | * @param handle The ENET handler structure pointer. This is the same handler pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 892 | * @param eErrorStatic The error statistics structure pointer. |
AnnaBridge | 171:3a7713b1edbc | 893 | */ |
AnnaBridge | 171:3a7713b1edbc | 894 | void ENET_GetRxErrBeforeReadFrame(enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic); |
AnnaBridge | 171:3a7713b1edbc | 895 | |
AnnaBridge | 171:3a7713b1edbc | 896 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 897 | /*! |
AnnaBridge | 171:3a7713b1edbc | 898 | * @brief Gets the ENET transmit frame statistics after the data send. |
AnnaBridge | 171:3a7713b1edbc | 899 | * |
AnnaBridge | 171:3a7713b1edbc | 900 | * This interface gets the error statistics of the transmit frame. |
AnnaBridge | 171:3a7713b1edbc | 901 | * Because the error information is reported by the uDMA after the data delivery, this interface |
AnnaBridge | 171:3a7713b1edbc | 902 | * should be called after the data transmit API. It is recommended to call this function on |
AnnaBridge | 171:3a7713b1edbc | 903 | * transmit interrupt handler. After calling the ENET_SendFrame, the |
AnnaBridge | 171:3a7713b1edbc | 904 | * transmit interrupt notifies the transmit completion. |
AnnaBridge | 171:3a7713b1edbc | 905 | * |
AnnaBridge | 171:3a7713b1edbc | 906 | * @param handle The PTP handler pointer. This is the same handler pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 907 | * @param eErrorStatic The error statistics structure pointer. |
AnnaBridge | 171:3a7713b1edbc | 908 | * @return The execute status. |
AnnaBridge | 171:3a7713b1edbc | 909 | */ |
AnnaBridge | 171:3a7713b1edbc | 910 | status_t ENET_GetTxErrAfterSendFrame(enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic); |
AnnaBridge | 171:3a7713b1edbc | 911 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 912 | /*! |
AnnaBridge | 171:3a7713b1edbc | 913 | * @brief Gets the size of the read frame. |
AnnaBridge | 171:3a7713b1edbc | 914 | * This function gets a received frame size from the ENET buffer descriptors. |
AnnaBridge | 171:3a7713b1edbc | 915 | * @note The FCS of the frame is automatically removed by Mac and the size is the length without the FCS. |
AnnaBridge | 171:3a7713b1edbc | 916 | * After calling ENET_GetRxFrameSize, ENET_ReadFrame() should be called to update the |
AnnaBridge | 171:3a7713b1edbc | 917 | * receive buffers If the result is not "kStatus_ENET_RxFrameEmpty". |
AnnaBridge | 171:3a7713b1edbc | 918 | * |
AnnaBridge | 171:3a7713b1edbc | 919 | * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 920 | * @param length The length of the valid frame received. |
AnnaBridge | 171:3a7713b1edbc | 921 | * @retval kStatus_ENET_RxFrameEmpty No frame received. Should not call ENET_ReadFrame to read frame. |
AnnaBridge | 171:3a7713b1edbc | 922 | * @retval kStatus_ENET_RxFrameError Data error happens. ENET_ReadFrame should be called with NULL data |
AnnaBridge | 171:3a7713b1edbc | 923 | * and NULL length to update the receive buffers. |
AnnaBridge | 171:3a7713b1edbc | 924 | * @retval kStatus_Success Receive a frame Successfully then the ENET_ReadFrame |
AnnaBridge | 171:3a7713b1edbc | 925 | * should be called with the right data buffer and the captured data length input. |
AnnaBridge | 171:3a7713b1edbc | 926 | */ |
AnnaBridge | 171:3a7713b1edbc | 927 | status_t ENET_GetRxFrameSize(enet_handle_t *handle, uint32_t *length); |
AnnaBridge | 171:3a7713b1edbc | 928 | |
AnnaBridge | 171:3a7713b1edbc | 929 | /*! |
AnnaBridge | 171:3a7713b1edbc | 930 | * @brief Reads a frame from the ENET device. |
AnnaBridge | 171:3a7713b1edbc | 931 | * This function reads a frame (both the data and the length) from the ENET buffer descriptors. |
AnnaBridge | 171:3a7713b1edbc | 932 | * The ENET_GetRxFrameSize should be used to get the size of the prepared data buffer. |
AnnaBridge | 171:3a7713b1edbc | 933 | * This is an example. |
AnnaBridge | 171:3a7713b1edbc | 934 | * @code |
AnnaBridge | 171:3a7713b1edbc | 935 | * uint32_t length; |
AnnaBridge | 171:3a7713b1edbc | 936 | * enet_handle_t g_handle; |
AnnaBridge | 171:3a7713b1edbc | 937 | * //Get the received frame size firstly. |
AnnaBridge | 171:3a7713b1edbc | 938 | * status = ENET_GetRxFrameSize(&g_handle, &length); |
AnnaBridge | 171:3a7713b1edbc | 939 | * if (length != 0) |
AnnaBridge | 171:3a7713b1edbc | 940 | * { |
AnnaBridge | 171:3a7713b1edbc | 941 | * //Allocate memory here with the size of "length" |
AnnaBridge | 171:3a7713b1edbc | 942 | * uint8_t *data = memory allocate interface; |
AnnaBridge | 171:3a7713b1edbc | 943 | * if (!data) |
AnnaBridge | 171:3a7713b1edbc | 944 | * { |
AnnaBridge | 171:3a7713b1edbc | 945 | * ENET_ReadFrame(ENET, &g_handle, NULL, 0); |
AnnaBridge | 171:3a7713b1edbc | 946 | * //Add the console warning log. |
AnnaBridge | 171:3a7713b1edbc | 947 | * } |
AnnaBridge | 171:3a7713b1edbc | 948 | * else |
AnnaBridge | 171:3a7713b1edbc | 949 | * { |
AnnaBridge | 171:3a7713b1edbc | 950 | * status = ENET_ReadFrame(ENET, &g_handle, data, length); |
AnnaBridge | 171:3a7713b1edbc | 951 | * //Call stack input API to deliver the data to stack |
AnnaBridge | 171:3a7713b1edbc | 952 | * } |
AnnaBridge | 171:3a7713b1edbc | 953 | * } |
AnnaBridge | 171:3a7713b1edbc | 954 | * else if (status == kStatus_ENET_RxFrameError) |
AnnaBridge | 171:3a7713b1edbc | 955 | * { |
AnnaBridge | 171:3a7713b1edbc | 956 | * //Update the received buffer when a error frame is received. |
AnnaBridge | 171:3a7713b1edbc | 957 | * ENET_ReadFrame(ENET, &g_handle, NULL, 0); |
AnnaBridge | 171:3a7713b1edbc | 958 | * } |
AnnaBridge | 171:3a7713b1edbc | 959 | * @endcode |
AnnaBridge | 171:3a7713b1edbc | 960 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 961 | * @param handle The ENET handler structure. This is the same handler pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 962 | * @param data The data buffer provided by user to store the frame which memory size should be at least "length". |
AnnaBridge | 171:3a7713b1edbc | 963 | * @param length The size of the data buffer which is still the length of the received frame. |
AnnaBridge | 171:3a7713b1edbc | 964 | * @return The execute status, successful or failure. |
AnnaBridge | 171:3a7713b1edbc | 965 | */ |
AnnaBridge | 171:3a7713b1edbc | 966 | status_t ENET_ReadFrame(ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length); |
AnnaBridge | 171:3a7713b1edbc | 967 | |
AnnaBridge | 171:3a7713b1edbc | 968 | /*! |
AnnaBridge | 171:3a7713b1edbc | 969 | * @brief Transmits an ENET frame. |
AnnaBridge | 171:3a7713b1edbc | 970 | * @note The CRC is automatically appended to the data. Input the data |
AnnaBridge | 171:3a7713b1edbc | 971 | * to send without the CRC. |
AnnaBridge | 171:3a7713b1edbc | 972 | * |
AnnaBridge | 171:3a7713b1edbc | 973 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 974 | * @param handle The ENET handler pointer. This is the same handler pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 975 | * @param data The data buffer provided by user to be send. |
AnnaBridge | 171:3a7713b1edbc | 976 | * @param length The length of the data to be send. |
AnnaBridge | 171:3a7713b1edbc | 977 | * @retval kStatus_Success Send frame succeed. |
AnnaBridge | 171:3a7713b1edbc | 978 | * @retval kStatus_ENET_TxFrameBusy Transmit buffer descriptor is busy under transmission. |
AnnaBridge | 171:3a7713b1edbc | 979 | * The transmit busy happens when the data send rate is over the MAC capacity. |
AnnaBridge | 171:3a7713b1edbc | 980 | * The waiting mechanism is recommended to be added after each call return with |
AnnaBridge | 171:3a7713b1edbc | 981 | * kStatus_ENET_TxFrameBusy. |
AnnaBridge | 171:3a7713b1edbc | 982 | */ |
AnnaBridge | 171:3a7713b1edbc | 983 | status_t ENET_SendFrame(ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length); |
AnnaBridge | 171:3a7713b1edbc | 984 | |
AnnaBridge | 171:3a7713b1edbc | 985 | /*! |
AnnaBridge | 171:3a7713b1edbc | 986 | * @brief The transmit IRQ handler. |
AnnaBridge | 171:3a7713b1edbc | 987 | * |
AnnaBridge | 171:3a7713b1edbc | 988 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 989 | * @param handle The ENET handler pointer. |
AnnaBridge | 171:3a7713b1edbc | 990 | */ |
AnnaBridge | 171:3a7713b1edbc | 991 | void ENET_TransmitIRQHandler(ENET_Type *base, enet_handle_t *handle); |
AnnaBridge | 171:3a7713b1edbc | 992 | |
AnnaBridge | 171:3a7713b1edbc | 993 | /*! |
AnnaBridge | 171:3a7713b1edbc | 994 | * @brief The receive IRQ handler. |
AnnaBridge | 171:3a7713b1edbc | 995 | * |
AnnaBridge | 171:3a7713b1edbc | 996 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 997 | * @param handle The ENET handler pointer. |
AnnaBridge | 171:3a7713b1edbc | 998 | */ |
AnnaBridge | 171:3a7713b1edbc | 999 | void ENET_ReceiveIRQHandler(ENET_Type *base, enet_handle_t *handle); |
AnnaBridge | 171:3a7713b1edbc | 1000 | |
AnnaBridge | 171:3a7713b1edbc | 1001 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1002 | * @brief The error IRQ handler. |
AnnaBridge | 171:3a7713b1edbc | 1003 | * |
AnnaBridge | 171:3a7713b1edbc | 1004 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1005 | * @param handle The ENET handler pointer. |
AnnaBridge | 171:3a7713b1edbc | 1006 | */ |
AnnaBridge | 171:3a7713b1edbc | 1007 | void ENET_ErrorIRQHandler(ENET_Type *base, enet_handle_t *handle); |
AnnaBridge | 171:3a7713b1edbc | 1008 | |
AnnaBridge | 171:3a7713b1edbc | 1009 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 1010 | |
AnnaBridge | 171:3a7713b1edbc | 1011 | #ifdef ENET_ENHANCEDBUFFERDESCRIPTOR_MODE |
AnnaBridge | 171:3a7713b1edbc | 1012 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1013 | * @name ENET PTP 1588 function operation |
AnnaBridge | 171:3a7713b1edbc | 1014 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 1015 | */ |
AnnaBridge | 171:3a7713b1edbc | 1016 | |
AnnaBridge | 171:3a7713b1edbc | 1017 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1018 | * @brief Configures the ENET PTP IEEE 1588 feature with the basic configuration. |
AnnaBridge | 171:3a7713b1edbc | 1019 | * The function sets the clock for PTP 1588 timer and enables |
AnnaBridge | 171:3a7713b1edbc | 1020 | * time stamp interrupts and transmit interrupts for PTP 1588 features. |
AnnaBridge | 171:3a7713b1edbc | 1021 | * This API should be called when the 1588 feature is enabled |
AnnaBridge | 171:3a7713b1edbc | 1022 | * or the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is defined. |
AnnaBridge | 171:3a7713b1edbc | 1023 | * ENET_Init should be called before calling this API. |
AnnaBridge | 171:3a7713b1edbc | 1024 | * |
AnnaBridge | 171:3a7713b1edbc | 1025 | * @note The PTP 1588 time-stamp second increase though time-stamp interrupt handler |
AnnaBridge | 171:3a7713b1edbc | 1026 | * and the transmit time-stamp store is done through transmit interrupt handler. |
AnnaBridge | 171:3a7713b1edbc | 1027 | * As a result, the TS interrupt and TX interrupt are enabled when you call this API. |
AnnaBridge | 171:3a7713b1edbc | 1028 | * |
AnnaBridge | 171:3a7713b1edbc | 1029 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1030 | * @param handle ENET handler pointer. |
AnnaBridge | 171:3a7713b1edbc | 1031 | * @param ptpConfig The ENET PTP1588 configuration. |
AnnaBridge | 171:3a7713b1edbc | 1032 | */ |
AnnaBridge | 171:3a7713b1edbc | 1033 | void ENET_Ptp1588Configure(ENET_Type *base, enet_handle_t *handle, enet_ptp_config_t *ptpConfig); |
AnnaBridge | 171:3a7713b1edbc | 1034 | |
AnnaBridge | 171:3a7713b1edbc | 1035 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1036 | * @brief Starts the ENET PTP 1588 Timer. |
AnnaBridge | 171:3a7713b1edbc | 1037 | * This function is used to initialize the PTP timer. After the PTP starts, |
AnnaBridge | 171:3a7713b1edbc | 1038 | * the PTP timer starts running. |
AnnaBridge | 171:3a7713b1edbc | 1039 | * |
AnnaBridge | 171:3a7713b1edbc | 1040 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1041 | * @param ptpClkSrc The clock source of the PTP timer. |
AnnaBridge | 171:3a7713b1edbc | 1042 | */ |
AnnaBridge | 171:3a7713b1edbc | 1043 | void ENET_Ptp1588StartTimer(ENET_Type *base, uint32_t ptpClkSrc); |
AnnaBridge | 171:3a7713b1edbc | 1044 | |
AnnaBridge | 171:3a7713b1edbc | 1045 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1046 | * @brief Stops the ENET PTP 1588 Timer. |
AnnaBridge | 171:3a7713b1edbc | 1047 | * This function is used to stops the ENET PTP timer. |
AnnaBridge | 171:3a7713b1edbc | 1048 | * |
AnnaBridge | 171:3a7713b1edbc | 1049 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1050 | */ |
AnnaBridge | 171:3a7713b1edbc | 1051 | static inline void ENET_Ptp1588StopTimer(ENET_Type *base) |
AnnaBridge | 171:3a7713b1edbc | 1052 | { |
AnnaBridge | 171:3a7713b1edbc | 1053 | /* Disable PTP timer and reset the timer. */ |
AnnaBridge | 171:3a7713b1edbc | 1054 | base->ATCR &= ~ENET_ATCR_EN_MASK; |
AnnaBridge | 171:3a7713b1edbc | 1055 | base->ATCR |= ENET_ATCR_RESTART_MASK; |
AnnaBridge | 171:3a7713b1edbc | 1056 | } |
AnnaBridge | 171:3a7713b1edbc | 1057 | |
AnnaBridge | 171:3a7713b1edbc | 1058 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1059 | * @brief Adjusts the ENET PTP 1588 timer. |
AnnaBridge | 171:3a7713b1edbc | 1060 | * |
AnnaBridge | 171:3a7713b1edbc | 1061 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1062 | * @param corrIncrease The correction increment value. This value is added every time the correction |
AnnaBridge | 171:3a7713b1edbc | 1063 | * timer expires. A value less than the PTP timer frequency(1/ptpClkSrc) slows down the timer, |
AnnaBridge | 171:3a7713b1edbc | 1064 | * a value greater than the 1/ptpClkSrc speeds up the timer. |
AnnaBridge | 171:3a7713b1edbc | 1065 | * @param corrPeriod The PTP timer correction counter wrap-around value. This defines after how |
AnnaBridge | 171:3a7713b1edbc | 1066 | * many timer clock the correction counter should be reset and trigger a correction |
AnnaBridge | 171:3a7713b1edbc | 1067 | * increment on the timer. A value of 0 disables the correction counter and no correction occurs. |
AnnaBridge | 171:3a7713b1edbc | 1068 | */ |
AnnaBridge | 171:3a7713b1edbc | 1069 | void ENET_Ptp1588AdjustTimer(ENET_Type *base, uint32_t corrIncrease, uint32_t corrPeriod); |
AnnaBridge | 171:3a7713b1edbc | 1070 | |
AnnaBridge | 171:3a7713b1edbc | 1071 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1072 | * @brief Sets the ENET PTP 1588 timer channel mode. |
AnnaBridge | 171:3a7713b1edbc | 1073 | * |
AnnaBridge | 171:3a7713b1edbc | 1074 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1075 | * @param channel The ENET PTP timer channel number. |
AnnaBridge | 171:3a7713b1edbc | 1076 | * @param mode The PTP timer channel mode, see "enet_ptp_timer_channel_mode_t". |
AnnaBridge | 171:3a7713b1edbc | 1077 | * @param intEnable Enables or disables the interrupt. |
AnnaBridge | 171:3a7713b1edbc | 1078 | */ |
AnnaBridge | 171:3a7713b1edbc | 1079 | static inline void ENET_Ptp1588SetChannelMode(ENET_Type *base, |
AnnaBridge | 171:3a7713b1edbc | 1080 | enet_ptp_timer_channel_t channel, |
AnnaBridge | 171:3a7713b1edbc | 1081 | enet_ptp_timer_channel_mode_t mode, |
AnnaBridge | 171:3a7713b1edbc | 1082 | bool intEnable) |
AnnaBridge | 171:3a7713b1edbc | 1083 | { |
AnnaBridge | 171:3a7713b1edbc | 1084 | uint32_t tcrReg = 0; |
AnnaBridge | 171:3a7713b1edbc | 1085 | |
AnnaBridge | 171:3a7713b1edbc | 1086 | tcrReg = ENET_TCSR_TMODE(mode) | ENET_TCSR_TIE(intEnable); |
AnnaBridge | 171:3a7713b1edbc | 1087 | /* Disable channel mode first. */ |
AnnaBridge | 171:3a7713b1edbc | 1088 | base->CHANNEL[channel].TCSR = 0; |
AnnaBridge | 171:3a7713b1edbc | 1089 | base->CHANNEL[channel].TCSR = tcrReg; |
AnnaBridge | 171:3a7713b1edbc | 1090 | } |
AnnaBridge | 171:3a7713b1edbc | 1091 | |
AnnaBridge | 171:3a7713b1edbc | 1092 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1093 | * @brief Sets the ENET PTP 1588 timer channel comparison value. |
AnnaBridge | 171:3a7713b1edbc | 1094 | * |
AnnaBridge | 171:3a7713b1edbc | 1095 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1096 | * @param channel The PTP timer channel, see "enet_ptp_timer_channel_t". |
AnnaBridge | 171:3a7713b1edbc | 1097 | * @param cmpValue The compare value for the compare setting. |
AnnaBridge | 171:3a7713b1edbc | 1098 | */ |
AnnaBridge | 171:3a7713b1edbc | 1099 | static inline void ENET_Ptp1588SetChannelCmpValue(ENET_Type *base, enet_ptp_timer_channel_t channel, uint32_t cmpValue) |
AnnaBridge | 171:3a7713b1edbc | 1100 | { |
AnnaBridge | 171:3a7713b1edbc | 1101 | base->CHANNEL[channel].TCCR = cmpValue; |
AnnaBridge | 171:3a7713b1edbc | 1102 | } |
AnnaBridge | 171:3a7713b1edbc | 1103 | |
AnnaBridge | 171:3a7713b1edbc | 1104 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1105 | * @brief Gets the ENET PTP 1588 timer channel status. |
AnnaBridge | 171:3a7713b1edbc | 1106 | * |
AnnaBridge | 171:3a7713b1edbc | 1107 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1108 | * @param channel The IEEE 1588 timer channel number. |
AnnaBridge | 171:3a7713b1edbc | 1109 | * @return True or false, Compare or capture operation status |
AnnaBridge | 171:3a7713b1edbc | 1110 | */ |
AnnaBridge | 171:3a7713b1edbc | 1111 | static inline bool ENET_Ptp1588GetChannelStatus(ENET_Type *base, enet_ptp_timer_channel_t channel) |
AnnaBridge | 171:3a7713b1edbc | 1112 | { |
AnnaBridge | 171:3a7713b1edbc | 1113 | return (0 != (base->CHANNEL[channel].TCSR & ENET_TCSR_TF_MASK)); |
AnnaBridge | 171:3a7713b1edbc | 1114 | } |
AnnaBridge | 171:3a7713b1edbc | 1115 | |
AnnaBridge | 171:3a7713b1edbc | 1116 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1117 | * @brief Clears the ENET PTP 1588 timer channel status. |
AnnaBridge | 171:3a7713b1edbc | 1118 | * |
AnnaBridge | 171:3a7713b1edbc | 1119 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1120 | * @param channel The IEEE 1588 timer channel number. |
AnnaBridge | 171:3a7713b1edbc | 1121 | */ |
AnnaBridge | 171:3a7713b1edbc | 1122 | static inline void ENET_Ptp1588ClearChannelStatus(ENET_Type *base, enet_ptp_timer_channel_t channel) |
AnnaBridge | 171:3a7713b1edbc | 1123 | { |
AnnaBridge | 171:3a7713b1edbc | 1124 | base->CHANNEL[channel].TCSR |= ENET_TCSR_TF_MASK; |
AnnaBridge | 171:3a7713b1edbc | 1125 | base->TGSR = (1U << channel); |
AnnaBridge | 171:3a7713b1edbc | 1126 | } |
AnnaBridge | 171:3a7713b1edbc | 1127 | |
AnnaBridge | 171:3a7713b1edbc | 1128 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1129 | * @brief Gets the current ENET time from the PTP 1588 timer. |
AnnaBridge | 171:3a7713b1edbc | 1130 | * |
AnnaBridge | 171:3a7713b1edbc | 1131 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1132 | * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 1133 | * @param ptpTime The PTP timer structure. |
AnnaBridge | 171:3a7713b1edbc | 1134 | */ |
AnnaBridge | 171:3a7713b1edbc | 1135 | void ENET_Ptp1588GetTimer(ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime); |
AnnaBridge | 171:3a7713b1edbc | 1136 | |
AnnaBridge | 171:3a7713b1edbc | 1137 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1138 | * @brief Sets the ENET PTP 1588 timer to the assigned time. |
AnnaBridge | 171:3a7713b1edbc | 1139 | * |
AnnaBridge | 171:3a7713b1edbc | 1140 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1141 | * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 1142 | * @param ptpTime The timer to be set to the PTP timer. |
AnnaBridge | 171:3a7713b1edbc | 1143 | */ |
AnnaBridge | 171:3a7713b1edbc | 1144 | void ENET_Ptp1588SetTimer(ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime); |
AnnaBridge | 171:3a7713b1edbc | 1145 | |
AnnaBridge | 171:3a7713b1edbc | 1146 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1147 | * @brief The IEEE 1588 PTP time stamp interrupt handler. |
AnnaBridge | 171:3a7713b1edbc | 1148 | * |
AnnaBridge | 171:3a7713b1edbc | 1149 | * @param base ENET peripheral base address. |
AnnaBridge | 171:3a7713b1edbc | 1150 | * @param handle The ENET state pointer. This is the same state pointer used in the ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 1151 | */ |
AnnaBridge | 171:3a7713b1edbc | 1152 | void ENET_Ptp1588TimerIRQHandler(ENET_Type *base, enet_handle_t *handle); |
AnnaBridge | 171:3a7713b1edbc | 1153 | |
AnnaBridge | 171:3a7713b1edbc | 1154 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1155 | * @brief Gets the time stamp of the received frame. |
AnnaBridge | 171:3a7713b1edbc | 1156 | * |
AnnaBridge | 171:3a7713b1edbc | 1157 | * This function is used for PTP stack to get the timestamp captured by the ENET driver. |
AnnaBridge | 171:3a7713b1edbc | 1158 | * |
AnnaBridge | 171:3a7713b1edbc | 1159 | * @param handle The ENET handler pointer.This is the same state pointer used in |
AnnaBridge | 171:3a7713b1edbc | 1160 | * ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 1161 | * @param ptpTimeData The special PTP timestamp data for search the receive timestamp. |
AnnaBridge | 171:3a7713b1edbc | 1162 | * @retval kStatus_Success Get 1588 timestamp success. |
AnnaBridge | 171:3a7713b1edbc | 1163 | * @retval kStatus_ENET_PtpTsRingEmpty 1588 timestamp ring empty. |
AnnaBridge | 171:3a7713b1edbc | 1164 | * @retval kStatus_ENET_PtpTsRingFull 1588 timestamp ring full. |
AnnaBridge | 171:3a7713b1edbc | 1165 | */ |
AnnaBridge | 171:3a7713b1edbc | 1166 | status_t ENET_GetRxFrameTime(enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData); |
AnnaBridge | 171:3a7713b1edbc | 1167 | |
AnnaBridge | 171:3a7713b1edbc | 1168 | /*! |
AnnaBridge | 171:3a7713b1edbc | 1169 | * @brief Gets the time stamp of the transmit frame. |
AnnaBridge | 171:3a7713b1edbc | 1170 | * |
AnnaBridge | 171:3a7713b1edbc | 1171 | * This function is used for PTP stack to get the timestamp captured by the ENET driver. |
AnnaBridge | 171:3a7713b1edbc | 1172 | * |
AnnaBridge | 171:3a7713b1edbc | 1173 | * @param handle The ENET handler pointer.This is the same state pointer used in |
AnnaBridge | 171:3a7713b1edbc | 1174 | * ENET_Init. |
AnnaBridge | 171:3a7713b1edbc | 1175 | * @param ptpTimeData The special PTP timestamp data for search the receive timestamp. |
AnnaBridge | 171:3a7713b1edbc | 1176 | * @retval kStatus_Success Get 1588 timestamp success. |
AnnaBridge | 171:3a7713b1edbc | 1177 | * @retval kStatus_ENET_PtpTsRingEmpty 1588 timestamp ring empty. |
AnnaBridge | 171:3a7713b1edbc | 1178 | * @retval kStatus_ENET_PtpTsRingFull 1588 timestamp ring full. |
AnnaBridge | 171:3a7713b1edbc | 1179 | */ |
AnnaBridge | 171:3a7713b1edbc | 1180 | status_t ENET_GetTxFrameTime(enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData); |
AnnaBridge | 171:3a7713b1edbc | 1181 | #endif /* ENET_ENHANCEDBUFFERDESCRIPTOR_MODE */ |
AnnaBridge | 171:3a7713b1edbc | 1182 | /* @} */ |
AnnaBridge | 171:3a7713b1edbc | 1183 | |
AnnaBridge | 171:3a7713b1edbc | 1184 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 1185 | } |
AnnaBridge | 171:3a7713b1edbc | 1186 | #endif |
AnnaBridge | 171:3a7713b1edbc | 1187 | |
AnnaBridge | 171:3a7713b1edbc | 1188 | /*! @}*/ |
AnnaBridge | 171:3a7713b1edbc | 1189 | |
AnnaBridge | 171:3a7713b1edbc | 1190 | #endif /* _FSL_ENET_H_ */ |