version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon Apr 07 18:28:36 2014 +0100
Revision:
82:6473597d706e
Child:
85:024bf7f99721
Release 82 of the mbed library

Main changes:

- support for K64F
- Revisited Nordic code structure
- Test infrastructure improvements
- various bug fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 82:6473597d706e 1 /*
bogdanm 82:6473597d706e 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
bogdanm 82:6473597d706e 3 * All rights reserved.
bogdanm 82:6473597d706e 4 *
bogdanm 82:6473597d706e 5 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 82:6473597d706e 6 * are permitted provided that the following conditions are met:
bogdanm 82:6473597d706e 7 *
bogdanm 82:6473597d706e 8 * o Redistributions of source code must retain the above copyright notice, this list
bogdanm 82:6473597d706e 9 * of conditions and the following disclaimer.
bogdanm 82:6473597d706e 10 *
bogdanm 82:6473597d706e 11 * o Redistributions in binary form must reproduce the above copyright notice, this
bogdanm 82:6473597d706e 12 * list of conditions and the following disclaimer in the documentation and/or
bogdanm 82:6473597d706e 13 * other materials provided with the distribution.
bogdanm 82:6473597d706e 14 *
bogdanm 82:6473597d706e 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
bogdanm 82:6473597d706e 16 * contributors may be used to endorse or promote products derived from this
bogdanm 82:6473597d706e 17 * software without specific prior written permission.
bogdanm 82:6473597d706e 18 *
bogdanm 82:6473597d706e 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
bogdanm 82:6473597d706e 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
bogdanm 82:6473597d706e 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 82:6473597d706e 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
bogdanm 82:6473597d706e 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
bogdanm 82:6473597d706e 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
bogdanm 82:6473597d706e 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
bogdanm 82:6473597d706e 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
bogdanm 82:6473597d706e 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
bogdanm 82:6473597d706e 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 82:6473597d706e 29 */
bogdanm 82:6473597d706e 30
bogdanm 82:6473597d706e 31 #ifndef __FSL_ENET_HAL_H__
bogdanm 82:6473597d706e 32 #define __FSL_ENET_HAL_H__
bogdanm 82:6473597d706e 33
bogdanm 82:6473597d706e 34 #include <stdint.h>
bogdanm 82:6473597d706e 35 #include <stdbool.h>
bogdanm 82:6473597d706e 36 #include "fsl_device_registers.h"
bogdanm 82:6473597d706e 37 #include "fsl_enet_features.h"
bogdanm 82:6473597d706e 38 #include <assert.h>
bogdanm 82:6473597d706e 39
bogdanm 82:6473597d706e 40 /*!
bogdanm 82:6473597d706e 41 * @addtogroup enet_hal
bogdanm 82:6473597d706e 42 * @{
bogdanm 82:6473597d706e 43 */
bogdanm 82:6473597d706e 44
bogdanm 82:6473597d706e 45 /*******************************************************************************
bogdanm 82:6473597d706e 46 * Definitions
bogdanm 82:6473597d706e 47 ******************************************************************************/
bogdanm 82:6473597d706e 48 /*! @brief Defines the system endian type.*/
bogdanm 82:6473597d706e 49 #define SYSTEM_LITTLE_ENDIAN (1)
bogdanm 82:6473597d706e 50
bogdanm 82:6473597d706e 51 /*! @brief Define macro to do the endianness swap*/
bogdanm 82:6473597d706e 52 #define BSWAP_16(x) (uint16_t)((uint16_t)(((uint16_t)(x) & (uint16_t)0xFF00) >> 0x8) | (uint16_t)(((uint16_t)(x) & (uint16_t)0xFF) << 0x8))
bogdanm 82:6473597d706e 53 #define BSWAP_32(x) (uint32_t)((((uint32_t)(x) & 0x00FFU) << 24) | (((uint32_t)(x) & 0x00FF00U) << 8) | (((uint32_t)(x) & 0xFF0000U) >> 8) | (((uint32_t)(x) & 0xFF000000U) >> 24))
bogdanm 82:6473597d706e 54 #if SYSTEM_LITTLE_ENDIAN && FSL_FEATURE_ENET_DMA_BIG_ENDIAN_ONLY
bogdanm 82:6473597d706e 55 #define HTONS(n) BSWAP_16(n)
bogdanm 82:6473597d706e 56 #define HTONL(n) BSWAP_32(n)
bogdanm 82:6473597d706e 57 #define NTOHS(n) BSWAP_16(n)
bogdanm 82:6473597d706e 58 #define NTOHL(n) BSWAP_32(n)
bogdanm 82:6473597d706e 59 #else
bogdanm 82:6473597d706e 60 #define HTONS(n) (n)
bogdanm 82:6473597d706e 61 #define HTONL(n) (n)
bogdanm 82:6473597d706e 62 #define NTOHS(n) (n)
bogdanm 82:6473597d706e 63 #define NTOHL(n) (n)
bogdanm 82:6473597d706e 64 #endif
bogdanm 82:6473597d706e 65
bogdanm 82:6473597d706e 66 /*! @brief Defines the Status return codes.*/
bogdanm 82:6473597d706e 67 typedef enum _enet_status
bogdanm 82:6473597d706e 68 {
bogdanm 82:6473597d706e 69 kStatus_ENET_Success = 0,
bogdanm 82:6473597d706e 70 kStatus_ENET_InvalidInput, /*!< Invalid ENET input parameter */
bogdanm 82:6473597d706e 71 kStatus_ENET_MemoryAllocateFail, /*!< Memory allocate failure*/
bogdanm 82:6473597d706e 72 kStatus_ENET_GetClockFreqFail, /*!< Get clock frequency failure*/
bogdanm 82:6473597d706e 73 kStatus_ENET_Initialized, /*!< ENET device already initialized*/
bogdanm 82:6473597d706e 74 kStatus_ENET_Layer2QueueNull, /*!< NULL L2 PTP buffer queue pointer*/
bogdanm 82:6473597d706e 75 kStatus_ENET_Layer2OverLarge, /*!< Layer2 packet length over large*/
bogdanm 82:6473597d706e 76 kStatus_ENET_Layer2BufferFull, /*!< Layer2 packet buffer full*/
bogdanm 82:6473597d706e 77 kStatus_ENET_PtpringBufferFull, /*!< PTP ring buffer full*/
bogdanm 82:6473597d706e 78 kStatus_ENET_PtpringBufferEmpty, /*!< PTP ring buffer empty*/
bogdanm 82:6473597d706e 79 kStatus_ENET_Miiuninitialized, /*!< MII uninitialized*/
bogdanm 82:6473597d706e 80 kStatus_ENET_RxbdInvalid, /*!< Receive buffer descriptor invalid*/
bogdanm 82:6473597d706e 81 kStatus_ENET_RxbdEmpty, /*!< Receive buffer descriptor empty*/
bogdanm 82:6473597d706e 82 kStatus_ENET_RxbdTrunc, /*!< Receive buffer descriptor truncate*/
bogdanm 82:6473597d706e 83 kStatus_ENET_RxbdError, /*!< Receive buffer descriptor error*/
bogdanm 82:6473597d706e 84 kStatus_ENET_RxBdFull, /*!< Receive buffer descriptor full*/
bogdanm 82:6473597d706e 85 kStatus_ENET_SmallBdSize, /*!< Small receive buffer size*/
bogdanm 82:6473597d706e 86 kStatus_ENET_LargeBufferFull, /*!< Receive large buffer full*/
bogdanm 82:6473597d706e 87 kStatus_ENET_TxbdFull, /*!< Transmit buffer descriptor full*/
bogdanm 82:6473597d706e 88 kStatus_ENET_TxbdNull, /*!< Transmit buffer descriptor Null*/
bogdanm 82:6473597d706e 89 kStatus_ENET_TxBufferNull, /*!< Transmit data buffer Null*/
bogdanm 82:6473597d706e 90 kStatus_ENET_NoRxBufferLeft, /*!< No more receive buffer left*/
bogdanm 82:6473597d706e 91 kStatus_ENET_UnknownCommand, /*!< Invalid ENET PTP IOCTL command*/
bogdanm 82:6473597d706e 92 kStatus_ENET_TimeOut, /*!< ENET Timeout*/
bogdanm 82:6473597d706e 93 kStatus_ENET_MulticastPointerNull, /*!< Null multicast group pointer*/
bogdanm 82:6473597d706e 94 kStatus_ENET_AlreadyAddedMulticast /*!< Have Already added to multicast group*/
bogdanm 82:6473597d706e 95 } enet_status_t;
bogdanm 82:6473597d706e 96
bogdanm 82:6473597d706e 97
bogdanm 82:6473597d706e 98 #if FSL_FEATURE_ENET_DMA_BIG_ENDIAN_ONLY && SYSTEM_LITTLE_ENDIAN
bogdanm 82:6473597d706e 99 /*! @brief Defines the control and status regions of the receive buffer descriptor.*/
bogdanm 82:6473597d706e 100 typedef enum _enet_rx_bd_control_status
bogdanm 82:6473597d706e 101 {
bogdanm 82:6473597d706e 102 kEnetRxBdBroadCast = 0x8000, /*!< Broadcast */
bogdanm 82:6473597d706e 103 kEnetRxBdMultiCast = 0x4000, /*!< Multicast*/
bogdanm 82:6473597d706e 104 kEnetRxBdLengthViolation = 0x2000, /*!< Receive length violation*/
bogdanm 82:6473597d706e 105 kEnetRxBdNoOctet = 0x1000, /*!< Receive non-octet aligned frame*/
bogdanm 82:6473597d706e 106 kEnetRxBdCrc = 0x0400, /*!< Receive CRC error*/
bogdanm 82:6473597d706e 107 kEnetRxBdOverRun = 0x0200, /*!< Receive FIFO overrun*/
bogdanm 82:6473597d706e 108 kEnetRxBdTrunc = 0x0100, /*!< Frame is truncated */
bogdanm 82:6473597d706e 109 kEnetRxBdEmpty = 0x0080, /*!< Empty bit*/
bogdanm 82:6473597d706e 110 kEnetRxBdRxSoftOwner1 = 0x0040, /*!< Receive software owner*/
bogdanm 82:6473597d706e 111 kEnetRxBdWrap = 0x0020, /*!< Update buffer descriptor*/
bogdanm 82:6473597d706e 112 kEnetRxBdRxSoftOwner2 = 0x0010, /*!< Receive software owner*/
bogdanm 82:6473597d706e 113 kEnetRxBdLast = 0x0008, /*!< Last BD in the frame*/
bogdanm 82:6473597d706e 114 kEnetRxBdMiss = 0x0001 /*!< Receive for promiscuous mode*/
bogdanm 82:6473597d706e 115 } enet_rx_bd_control_status_t;
bogdanm 82:6473597d706e 116
bogdanm 82:6473597d706e 117 /*! @brief Defines the control extended regions of the receive buffer descriptor.*/
bogdanm 82:6473597d706e 118 typedef enum _enet_rx_bd_control_extend
bogdanm 82:6473597d706e 119 {
bogdanm 82:6473597d706e 120 kEnetRxBdUnicast = 0x0001, /*!< Unicast frame*/
bogdanm 82:6473597d706e 121 kEnetRxBdCollision = 0x0002, /*!< BD collision*/
bogdanm 82:6473597d706e 122 kEnetRxBdPhyErr = 0x0004, /*!< PHY error*/
bogdanm 82:6473597d706e 123 kEnetRxBdMacErr = 0x0080, /*!< Mac error*/
bogdanm 82:6473597d706e 124 kEnetRxBdIpv4 = 0x0100, /*!< Ipv4 frame*/
bogdanm 82:6473597d706e 125 kEnetRxBdIpv6 = 0x0200, /*!< Ipv6 frame*/
bogdanm 82:6473597d706e 126 kEnetRxBdVlan = 0x0400, /*!< VLAN*/
bogdanm 82:6473597d706e 127 kEnetRxBdProtocolChecksumErr = 0x1000, /*!< Protocol checksum error*/
bogdanm 82:6473597d706e 128 kEnetRxBdIpHeaderChecksumErr = 0x2000, /*!< IP header checksum error*/
bogdanm 82:6473597d706e 129 kEnetRxBdIntrrupt = 0x8000 /*!< BD interrupt*/
bogdanm 82:6473597d706e 130 } enet_rx_bd_control_extend_t;
bogdanm 82:6473597d706e 131
bogdanm 82:6473597d706e 132 /*! @brief Defines the control status region of the transmit buffer descriptor.*/
bogdanm 82:6473597d706e 133 typedef enum _enet_tx_bd_control_status
bogdanm 82:6473597d706e 134 {
bogdanm 82:6473597d706e 135 kEnetTxBdReady = 0x0080, /*!< Ready bit*/
bogdanm 82:6473597d706e 136 kEnetTxBdTxSoftOwner1 = 0x0040, /*!< Transmit software owner*/
bogdanm 82:6473597d706e 137 kEnetTxBdWrap = 0x0020, /*!< Wrap buffer descriptor*/
bogdanm 82:6473597d706e 138 kEnetTxBdTxSoftOwner2 = 0x0010, /*!< Transmit software owner*/
bogdanm 82:6473597d706e 139 kEnetTxBdLast = 0x0008, /*!< Last BD in the frame*/
bogdanm 82:6473597d706e 140 kEnetTxBdTransmitCrc = 0x0004 /*!< Receive for transmit CRC*/
bogdanm 82:6473597d706e 141 } enet_tx_bd_control_status_t;
bogdanm 82:6473597d706e 142
bogdanm 82:6473597d706e 143 /*! @brief Defines the control extended region of the transmit buffer descriptor.*/
bogdanm 82:6473597d706e 144 typedef enum _enet_tx_bd_control_extend
bogdanm 82:6473597d706e 145 {
bogdanm 82:6473597d706e 146 kEnetTxBdTxErr = 0x0080, /*!< Transmit error*/
bogdanm 82:6473597d706e 147 kEnetTxBdTxUnderFlowErr = 0x0020, /*!< Underflow error*/
bogdanm 82:6473597d706e 148 kEnetTxBdExcessCollisionErr = 0x0010, /*!< Excess collision error*/
bogdanm 82:6473597d706e 149 kEnetTxBdTxFrameErr = 0x0008, /*!< Frame error*/
bogdanm 82:6473597d706e 150 kEnetTxBdLatecollisionErr = 0x0004, /*!< Late collision error*/
bogdanm 82:6473597d706e 151 kEnetTxBdOverFlowErr = 0x0002, /*!< Overflow error*/
bogdanm 82:6473597d706e 152 kEnetTxTimestampErr = 0x0001 /*!< Timestamp error*/
bogdanm 82:6473597d706e 153 } enet_tx_bd_control_extend_t;
bogdanm 82:6473597d706e 154
bogdanm 82:6473597d706e 155 /*! @brief Defines the control extended2 region of the transmit buffer descriptor.*/
bogdanm 82:6473597d706e 156 typedef enum _enet_tx_bd_control_extend2
bogdanm 82:6473597d706e 157 {
bogdanm 82:6473597d706e 158 kEnetTxBdTxInterrupt = 0x0040, /*!< Transmit interrupt*/
bogdanm 82:6473597d706e 159 kEnetTxBdTimeStamp = 0x0020 /*!< Transmit timestamp flag */
bogdanm 82:6473597d706e 160 } enet_tx_bd_control_extend2_t;
bogdanm 82:6473597d706e 161 #else
bogdanm 82:6473597d706e 162 /*! @brief Defines the control and status region of the receive buffer descriptor.*/
bogdanm 82:6473597d706e 163 typedef enum _enet_rx_bd_control_status
bogdanm 82:6473597d706e 164 {
bogdanm 82:6473597d706e 165 kEnetRxBdEmpty = 0x8000, /*!< Empty bit*/
bogdanm 82:6473597d706e 166 kEnetRxBdRxSoftOwner1 = 0x4000, /*!< Receive software owner*/
bogdanm 82:6473597d706e 167 kEnetRxBdWrap = 0x2000, /*!< Update buffer descriptor*/
bogdanm 82:6473597d706e 168 kEnetRxBdRxSoftOwner2 = 0x1000, /*!< Receive software owner*/
bogdanm 82:6473597d706e 169 kEnetRxBdLast = 0x0800, /*!< Last BD in the frame*/
bogdanm 82:6473597d706e 170 kEnetRxBdMiss = 0x0100, /*!< Receive for promiscuous mode*/
bogdanm 82:6473597d706e 171 kEnetRxBdBroadCast = 0x0080, /*!< Broadcast */
bogdanm 82:6473597d706e 172 kEnetRxBdMultiCast = 0x0040, /*!< Multicast*/
bogdanm 82:6473597d706e 173 kEnetRxBdLengthViolation = 0x0020, /*!< Receive length violation*/
bogdanm 82:6473597d706e 174 kEnetRxBdNoOctet = 0x0010, /*!< Receive non-octet aligned frame*/
bogdanm 82:6473597d706e 175 kEnetRxBdCrc = 0x0004, /*!< Receive CRC error*/
bogdanm 82:6473597d706e 176 kEnetRxBdOverRun = 0x0002, /*!< Receive FIFO overrun*/
bogdanm 82:6473597d706e 177 kEnetRxBdTrunc = 0x0001 /*!< Frame is truncated */
bogdanm 82:6473597d706e 178 } enet_rx_bd_control_status_t;
bogdanm 82:6473597d706e 179
bogdanm 82:6473597d706e 180 /*! @brief Defines the control extended region of the receive buffer descriptor.*/
bogdanm 82:6473597d706e 181 typedef enum _enet_rx_bd_control_extend
bogdanm 82:6473597d706e 182 {
bogdanm 82:6473597d706e 183 kEnetRxBdIpv4 = 0x0001, /*!< Ipv4 frame*/
bogdanm 82:6473597d706e 184 kEnetRxBdIpv6 = 0x0002, /*!< Ipv6 frame*/
bogdanm 82:6473597d706e 185 kEnetRxBdVlan = 0x0004, /*!< VLAN*/
bogdanm 82:6473597d706e 186 kEnetRxBdProtocolChecksumErr = 0x0010, /*!< Protocol checksum error*/
bogdanm 82:6473597d706e 187 kEnetRxBdIpHeaderChecksumErr = 0x0020, /*!< IP header checksum error*/
bogdanm 82:6473597d706e 188 kEnetRxBdIntrrupt = 0x0080, /*!< BD interrupt*/
bogdanm 82:6473597d706e 189 kEnetRxBdUnicast = 0x0100, /*!< Unicast frame*/
bogdanm 82:6473597d706e 190 kEnetRxBdCollision = 0x0200, /*!< BD collision*/
bogdanm 82:6473597d706e 191 kEnetRxBdPhyErr = 0x0400, /*!< PHY error*/
bogdanm 82:6473597d706e 192 kEnetRxBdMacErr = 0x8000 /*!< Mac error */
bogdanm 82:6473597d706e 193 } enet_rx_bd_control_extend_t;
bogdanm 82:6473597d706e 194
bogdanm 82:6473597d706e 195 /*! @brief Defines the control status of the transmit buffer descriptor.*/
bogdanm 82:6473597d706e 196 typedef enum _enet_tx_bd_control_status
bogdanm 82:6473597d706e 197 {
bogdanm 82:6473597d706e 198 kEnetTxBdReady = 0x8000, /*!< Ready bit*/
bogdanm 82:6473597d706e 199 kEnetTxBdTxSoftOwner1 = 0x4000, /*!< Transmit software owner*/
bogdanm 82:6473597d706e 200 kEnetTxBdWrap = 0x2000, /*!< Wrap buffer descriptor*/
bogdanm 82:6473597d706e 201 kEnetTxBdTxSoftOwner2 = 0x1000, /*!< Transmit software owner*/
bogdanm 82:6473597d706e 202 kEnetTxBdLast = 0x0800, /*!< Last BD in the frame*/
bogdanm 82:6473597d706e 203 kEnetTxBdTransmitCrc = 0x0400 /*!< Receive for transmit CRC */
bogdanm 82:6473597d706e 204 } enet_tx_bd_control_status_t;
bogdanm 82:6473597d706e 205
bogdanm 82:6473597d706e 206 /*! @brief Defines the control extended of the transmit buffer descriptor.*/
bogdanm 82:6473597d706e 207 typedef enum _enet_tx_bd_control_extend
bogdanm 82:6473597d706e 208 {
bogdanm 82:6473597d706e 209 kEnetTxBdTxErr = 0x8000, /*!< Transmit error*/
bogdanm 82:6473597d706e 210 kEnetTxBdTxUnderFlowErr = 0x2000, /*!< Underflow error*/
bogdanm 82:6473597d706e 211 kEnetTxBdExcessCollisionErr = 0x1000, /*!< Excess collision error*/
bogdanm 82:6473597d706e 212 kEnetTxBdTxFrameErr = 0x0800, /*!< Frame error*/
bogdanm 82:6473597d706e 213 kEnetTxBdLatecollisionErr = 0x0400, /*!< Late collision error*/
bogdanm 82:6473597d706e 214 kEnetTxBdOverFlowErr = 0x0200, /*!< Overflow error*/
bogdanm 82:6473597d706e 215 kEnetTxTimestampErr = 0x0100 /*!< Timestamp error*/
bogdanm 82:6473597d706e 216 } enet_tx_bd_control_extend_t;
bogdanm 82:6473597d706e 217
bogdanm 82:6473597d706e 218 /*! @brief Defines the control extended2 of the transmit buffer descriptor.*/
bogdanm 82:6473597d706e 219 typedef enum _enet_tx_bd_control_extend2
bogdanm 82:6473597d706e 220 {
bogdanm 82:6473597d706e 221 kEnetTxBdTxInterrupt = 0x4000, /*!< Transmit interrupt*/
bogdanm 82:6473597d706e 222 kEnetTxBdTimeStamp = 0x2000 /*!< Transmit timestamp flag */
bogdanm 82:6473597d706e 223 } enet_tx_bd_control_extend2_t;
bogdanm 82:6473597d706e 224 #endif
bogdanm 82:6473597d706e 225
bogdanm 82:6473597d706e 226 /*! @brief Defines the macro to the different ENET constant value.*/
bogdanm 82:6473597d706e 227 typedef enum _enet_constant_parameter
bogdanm 82:6473597d706e 228 {
bogdanm 82:6473597d706e 229 kEnetMacAddrLen = 6, /*!< ENET mac address length*/
bogdanm 82:6473597d706e 230 kEnetHashValMask = 0x1f, /*!< ENET hash value mask*/
bogdanm 82:6473597d706e 231 kEnetRxBdCtlJudge1 = 0x0080,/*!< ENET receive buffer descriptor control judge value1*/
bogdanm 82:6473597d706e 232 kEnetRxBdCtlJudge2 = 0x8000 /*!< ENET receive buffer descriptor control judge value2*/
bogdanm 82:6473597d706e 233 } enet_constant_parameter_t;
bogdanm 82:6473597d706e 234
bogdanm 82:6473597d706e 235 /*! @brief Defines the RMII or MII mode for data interface between the MAC and the PHY.*/
bogdanm 82:6473597d706e 236 typedef enum _enet_config_rmii
bogdanm 82:6473597d706e 237 {
bogdanm 82:6473597d706e 238 kEnetCfgMii = 0, /*!< MII mode for data interface*/
bogdanm 82:6473597d706e 239 kEnetCfgRmii = 1 /*!< RMII mode for data interface*/
bogdanm 82:6473597d706e 240 } enet_config_rmii_t;
bogdanm 82:6473597d706e 241
bogdanm 82:6473597d706e 242 /*! @brief Defines the 10 Mbps or 100 Mbps speed mode for the data transfer.*/
bogdanm 82:6473597d706e 243 typedef enum _enet_config_speed
bogdanm 82:6473597d706e 244 {
bogdanm 82:6473597d706e 245 kEnetCfgSpeed100M = 0, /*!< Speed 100 M mode*/
bogdanm 82:6473597d706e 246 kEnetCfgSpeed10M = 1 /*!< Speed 10 M mode*/
bogdanm 82:6473597d706e 247 } enet_config_speed_t;
bogdanm 82:6473597d706e 248
bogdanm 82:6473597d706e 249 /*! @brief Defines the half or full duplex mode for the data transfer.*/
bogdanm 82:6473597d706e 250 typedef enum _enet_config_duplex
bogdanm 82:6473597d706e 251 {
bogdanm 82:6473597d706e 252 kEnetCfgHalfDuplex = 0, /*!< Half duplex mode*/
bogdanm 82:6473597d706e 253 kEnetCfgFullDuplex = 1 /*!< Full duplex mode*/
bogdanm 82:6473597d706e 254 } enet_config_duplex_t;
bogdanm 82:6473597d706e 255
bogdanm 82:6473597d706e 256 /*! @brief Defines the write/read operation for the MII.*/
bogdanm 82:6473597d706e 257 typedef enum _enet_mii_operation
bogdanm 82:6473597d706e 258 {
bogdanm 82:6473597d706e 259 kEnetWriteNoCompliant = 0, /*!< Write frame operation, but not MII compliant.*/
bogdanm 82:6473597d706e 260 kEnetWriteValidFrame = 1, /*!< Write frame operation for a valid MII management frame*/
bogdanm 82:6473597d706e 261 kEnetReadValidFrame = 2, /*!< Read frame operation for a valid MII management frame.*/
bogdanm 82:6473597d706e 262 kEnetReadNoCompliant = 3 /*!< Read frame operation, but not MII compliant*/
bogdanm 82:6473597d706e 263 }enet_mii_operation_t;
bogdanm 82:6473597d706e 264
bogdanm 82:6473597d706e 265 /*! @brief Define holdon time on MDIO output*/
bogdanm 82:6473597d706e 266 typedef enum _enet_mdio_holdon_clkcycle
bogdanm 82:6473597d706e 267 {
bogdanm 82:6473597d706e 268 kEnetMdioHoldOneClkCycle = 0, /*!< MDIO output hold on one clock cycle*/
bogdanm 82:6473597d706e 269 kEnetMdioHoldTwoClkCycle = 1, /*!< MDIO output hold on two clock cycles*/
bogdanm 82:6473597d706e 270 kEnetMdioHoldThreeClkCycle = 2, /*!< MDIO output hold on three clock cycles*/
bogdanm 82:6473597d706e 271 kEnetMdioHoldFourClkCycle = 3, /*!< MDIO output hold on four clock cycles*/
bogdanm 82:6473597d706e 272 kEnetMdioHoldFiveClkCycle = 4, /*!< MDIO output hold on five clock cycles*/
bogdanm 82:6473597d706e 273 kEnetMdioHoldSixClkCycle = 5, /*!< MDIO output hold on six clock cycles*/
bogdanm 82:6473597d706e 274 kEnetMdioHoldSevenClkCycle = 6, /*!< MDIO output hold seven two clock cycles*/
bogdanm 82:6473597d706e 275 kEnetMdioHoldEightClkCycle = 7, /*!< MDIO output hold on eight clock cycles*/
bogdanm 82:6473597d706e 276 }enet_mdio_holdon_clkcycle_t;
bogdanm 82:6473597d706e 277
bogdanm 82:6473597d706e 278 /*! @brief Defines the initialization, enables or disables the operation for a special address filter */
bogdanm 82:6473597d706e 279 typedef enum _enet_special_address_filter
bogdanm 82:6473597d706e 280 {
bogdanm 82:6473597d706e 281 kEnetSpecialAddressInit= 0, /*!< Initializes the special address filter.*/
bogdanm 82:6473597d706e 282 kEnetSpecialAddressEnable = 1, /*!< Enables the special address filter.*/
bogdanm 82:6473597d706e 283 kEnetSpecialAddressDisable = 2 /*!< Disables the special address filter.*/
bogdanm 82:6473597d706e 284 } enet_special_address_filter_t;
bogdanm 82:6473597d706e 285
bogdanm 82:6473597d706e 286 /*! @brief Defines the capture or compare mode for 1588 timer channels.*/
bogdanm 82:6473597d706e 287 typedef enum _enet_timer_channel_mode
bogdanm 82:6473597d706e 288 {
bogdanm 82:6473597d706e 289 kEnetChannelDisable = 0, /*!< Disable timer channel*/
bogdanm 82:6473597d706e 290 kEnetChannelRisingCapture = 1, /*!< Input capture on rising edge*/
bogdanm 82:6473597d706e 291 kEnetChannelFallingCapture = 2, /*!< Input capture on falling edge*/
bogdanm 82:6473597d706e 292 kEnetChannelBothCapture = 3, /*!< Input capture on both edges*/
bogdanm 82:6473597d706e 293 kEnetChannelSoftCompare = 4, /*!< Output compare software only*/
bogdanm 82:6473597d706e 294 kEnetChannelToggleCompare = 5, /*!< Toggle output on compare*/
bogdanm 82:6473597d706e 295 kEnetChannelClearCompare = 6, /*!< Clear output on compare*/
bogdanm 82:6473597d706e 296 kEnetChannelSetCompare = 7, /*!< Set output on compare*/
bogdanm 82:6473597d706e 297 kEnetChannelClearCompareSetOverflow = 10, /*!< Clear output on compare, set output on overflow*/
bogdanm 82:6473597d706e 298 kEnetChannelSetCompareClearOverflow = 11, /*!< Set output on compare, clear output on overflow*/
bogdanm 82:6473597d706e 299 kEnetChannelPulseLowonCompare = 14, /*!< Pulse output low on compare for one 1588 clock cycle*/
bogdanm 82:6473597d706e 300 kEnetChannelPulseHighonCompare = 15 /*!< Pulse output high on compare for one 1588 clock cycle*/
bogdanm 82:6473597d706e 301 } enet_timer_channel_mode_t;
bogdanm 82:6473597d706e 302
bogdanm 82:6473597d706e 303 /*! @brief Defines the RXFRAME/RXBYTE/TXFRAME/TXBYTE/MII/TSTIMER/TSAVAIL interrupt source for ENET.*/
bogdanm 82:6473597d706e 304 typedef enum _enet_interrupt_request
bogdanm 82:6473597d706e 305 {
bogdanm 82:6473597d706e 306 kEnetBabrInterrupt = 0x40000000, /*!< BABR interrupt source*/
bogdanm 82:6473597d706e 307 kEnetBabtInterrupt = 0x20000000, /*!< BABT interrupt source*/
bogdanm 82:6473597d706e 308 kEnetGraInterrupt = 0x10000000, /*!< GRA interrupt source*/
bogdanm 82:6473597d706e 309 kEnetTxFrameInterrupt = 0x8000000, /*!< TXFRAME interrupt source */
bogdanm 82:6473597d706e 310 kEnetTxByteInterrupt = 0x4000000, /*!< TXBYTE interrupt source*/
bogdanm 82:6473597d706e 311 kEnetRxFrameInterrupt = 0x2000000, /*!< RXFRAME interrupt source */
bogdanm 82:6473597d706e 312 kEnetRxByteInterrupt = 0x1000000, /*!< RXBYTE interrupt source */
bogdanm 82:6473597d706e 313 kEnetMiiInterrupt = 0x0800000, /*!< MII interrupt source*/
bogdanm 82:6473597d706e 314 kEnetEBERInterrupt = 0x0400000, /*!< EBERR interrupt source*/
bogdanm 82:6473597d706e 315 kEnetLcInterrupt = 0x0200000, /*!< LC interrupt source*/
bogdanm 82:6473597d706e 316 kEnetRlInterrupt = 0x0100000, /*!< RL interrupt source*/
bogdanm 82:6473597d706e 317 kEnetUnInterrupt = 0x0080000, /*!< UN interrupt source*/
bogdanm 82:6473597d706e 318 kEnetPlrInterrupt = 0x0040000, /*!< PLR interrupt source*/
bogdanm 82:6473597d706e 319 kEnetWakeupInterrupt = 0x0020000, /*!< WAKEUP interrupt source*/
bogdanm 82:6473597d706e 320 kEnetTsAvailInterrupt = 0x0010000, /*!< TS AVAIL interrupt source*/
bogdanm 82:6473597d706e 321 kEnetTsTimerInterrupt = 0x0008000, /*!< TS WRAP interrupt source*/
bogdanm 82:6473597d706e 322 kEnetAllInterrupt = 0x7FFFFFFF /*!< All interrupt*/
bogdanm 82:6473597d706e 323 } enet_interrupt_request_t;
bogdanm 82:6473597d706e 324
bogdanm 82:6473597d706e 325 /*! @brief Defines the six-byte Mac address type.*/
bogdanm 82:6473597d706e 326 typedef uint8_t enetMacAddr[kEnetMacAddrLen];
bogdanm 82:6473597d706e 327
bogdanm 82:6473597d706e 328 #if (!FSL_FEATURE_ENET_DMA_BIG_ENDIAN_ONLY) && SYSTEM_LITTLE_ENDIAN
bogdanm 82:6473597d706e 329 /*! @brief Defines the buffer descriptor structure for the little-Endian system and endianness configurable IP.*/
bogdanm 82:6473597d706e 330 typedef struct ENETBdStruct
bogdanm 82:6473597d706e 331 {
bogdanm 82:6473597d706e 332 uint16_t length; /*!< Buffer descriptor data length*/
bogdanm 82:6473597d706e 333 uint16_t control; /*!< Buffer descriptor control*/
bogdanm 82:6473597d706e 334 uint8_t *buffer; /*!< Data buffer pointer*/
bogdanm 82:6473597d706e 335 uint16_t controlExtend0; /*!< Extend buffer descriptor control0*/
bogdanm 82:6473597d706e 336 uint16_t controlExtend1; /*!< Extend buffer descriptor control1*/
bogdanm 82:6473597d706e 337 uint16_t payloadCheckSum; /*!< Internal payload checksum*/
bogdanm 82:6473597d706e 338 uint8_t headerLength; /*!< Header length*/
bogdanm 82:6473597d706e 339 uint8_t protocalTyte; /*!< Protocol type*/
bogdanm 82:6473597d706e 340 uint16_t reserved0;
bogdanm 82:6473597d706e 341 uint16_t controlExtend2; /*!< Extend buffer descriptor control2*/
bogdanm 82:6473597d706e 342 uint32_t timestamp; /*!< Timestamp */
bogdanm 82:6473597d706e 343 uint16_t reserved1;
bogdanm 82:6473597d706e 344 uint16_t reserved2;
bogdanm 82:6473597d706e 345 uint16_t reserved3;
bogdanm 82:6473597d706e 346 uint16_t reserved4;
bogdanm 82:6473597d706e 347 } enet_bd_struct_t;
bogdanm 82:6473597d706e 348
bogdanm 82:6473597d706e 349 #else
bogdanm 82:6473597d706e 350 /*! @brief Defines the buffer descriptors structure for the Big-Endian system.*/
bogdanm 82:6473597d706e 351 typedef struct ENETBdStruct
bogdanm 82:6473597d706e 352 {
bogdanm 82:6473597d706e 353 uint16_t control; /*!< Buffer descriptor control */
bogdanm 82:6473597d706e 354 uint16_t length; /*!< Buffer descriptor data length*/
bogdanm 82:6473597d706e 355 uint8_t *buffer; /*!< Data buffer pointer*/
bogdanm 82:6473597d706e 356 uint16_t controlExtend1; /*!< Extend buffer descriptor control1*/
bogdanm 82:6473597d706e 357 uint16_t controlExtend0; /*!< Extend buffer descriptor control0*/
bogdanm 82:6473597d706e 358 uint8_t headerLength; /*!< Header length*/
bogdanm 82:6473597d706e 359 uint8_t protocalTyte; /*!< Protocol type*/
bogdanm 82:6473597d706e 360 uint16_t payloadCheckSum; /*!< Internal payload checksum*/
bogdanm 82:6473597d706e 361 uint16_t controlExtend2; /*!< Extend buffer descriptor control2*/
bogdanm 82:6473597d706e 362 uint16_t reserved0;
bogdanm 82:6473597d706e 363 uint32_t timestamp; /*!< Timestamp pointer*/
bogdanm 82:6473597d706e 364 uint16_t reserved1;
bogdanm 82:6473597d706e 365 uint16_t reserved2;
bogdanm 82:6473597d706e 366 uint16_t reserved3;
bogdanm 82:6473597d706e 367 uint16_t reserved4;
bogdanm 82:6473597d706e 368 } enet_bd_struct_t;
bogdanm 82:6473597d706e 369 #endif
bogdanm 82:6473597d706e 370
bogdanm 82:6473597d706e 371 /*! @brief Defines the configuration structure for the 1588 PTP timer.*/
bogdanm 82:6473597d706e 372 typedef struct ENETConfigPtpTimer
bogdanm 82:6473597d706e 373 {
bogdanm 82:6473597d706e 374 bool isSlaveEnabled; /*!< Master or slave PTP timer*/
bogdanm 82:6473597d706e 375 uint32_t clockIncease; /*!< Timer increase value each clock period*/
bogdanm 82:6473597d706e 376 uint32_t period; /*!< Timer period for generate interrupt event */
bogdanm 82:6473597d706e 377 } enet_config_ptp_timer_t;
bogdanm 82:6473597d706e 378
bogdanm 82:6473597d706e 379 /*! @brief Defines the transmit accelerator configuration.*/
bogdanm 82:6473597d706e 380 typedef struct ENETConfigTxAccelerator
bogdanm 82:6473597d706e 381 {
bogdanm 82:6473597d706e 382 bool isIpCheckEnabled; /*!< Insert IP header checksum */
bogdanm 82:6473597d706e 383 bool isProtocolCheckEnabled; /*!< Insert protocol checksum*/
bogdanm 82:6473597d706e 384 bool isShift16Enabled; /*!< Tx FIFO shift-16*/
bogdanm 82:6473597d706e 385 } enet_config_tx_accelerator_t;
bogdanm 82:6473597d706e 386
bogdanm 82:6473597d706e 387 /*! @brief Defines the receive accelerator configuration.*/
bogdanm 82:6473597d706e 388 typedef struct ENETConfigRxAccelerator
bogdanm 82:6473597d706e 389 {
bogdanm 82:6473597d706e 390 bool isIpcheckEnabled; /*!< Discard with wrong IP header checksum */
bogdanm 82:6473597d706e 391 bool isProtocolCheckEnabled; /*!< Discard with wrong protocol checksum*/
bogdanm 82:6473597d706e 392 bool isMacCheckEnabled; /*!< Discard with Mac layer errors*/
bogdanm 82:6473597d706e 393 bool isPadRemoveEnabled; /*!< Padding removal for short IP frames*/
bogdanm 82:6473597d706e 394 bool isShift16Enabled; /*!< Rx FIFO shift-16*/
bogdanm 82:6473597d706e 395 } enet_config_rx_accelerator_t;
bogdanm 82:6473597d706e 396
bogdanm 82:6473597d706e 397 /*! @brief Defines the transmit FIFO configuration.*/
bogdanm 82:6473597d706e 398 typedef struct ENETConfigTxFifo
bogdanm 82:6473597d706e 399 {
bogdanm 82:6473597d706e 400 bool isStoreForwardEnabled; /*!< Transmit FIFO store and forward */
bogdanm 82:6473597d706e 401 uint8_t txFifoWrite; /*!< Transmit FIFO write */
bogdanm 82:6473597d706e 402 uint8_t txEmpty; /*!< Transmit FIFO section empty threshold*/
bogdanm 82:6473597d706e 403 uint8_t txAlmostEmpty; /*!< Transmit FIFO section almost empty threshold*/
bogdanm 82:6473597d706e 404 uint8_t txAlmostFull; /*!< Transmit FIFO section almost full threshold*/
bogdanm 82:6473597d706e 405 } enet_config_tx_fifo_t;
bogdanm 82:6473597d706e 406
bogdanm 82:6473597d706e 407 /*! @brief Defines the receive FIFO configuration.*/
bogdanm 82:6473597d706e 408 typedef struct ENETConfigRxFifo
bogdanm 82:6473597d706e 409 {
bogdanm 82:6473597d706e 410 uint8_t rxFull; /*!< Receive FIFO section full threshold*/
bogdanm 82:6473597d706e 411 uint8_t rxAlmostFull; /*!< Receive FIFO section almost full threshold*/
bogdanm 82:6473597d706e 412 uint8_t rxEmpty; /*!< Receive FIFO section empty threshold*/
bogdanm 82:6473597d706e 413 uint8_t rxAlmostEmpty; /*!< Receive FIFO section almost empty threshold*/
bogdanm 82:6473597d706e 414 } enet_config_rx_fifo_t;
bogdanm 82:6473597d706e 415
bogdanm 82:6473597d706e 416 /*******************************************************************************
bogdanm 82:6473597d706e 417 * API
bogdanm 82:6473597d706e 418 ******************************************************************************/
bogdanm 82:6473597d706e 419
bogdanm 82:6473597d706e 420 #if defined(__cplusplus)
bogdanm 82:6473597d706e 421 extern "C" {
bogdanm 82:6473597d706e 422 #endif
bogdanm 82:6473597d706e 423
bogdanm 82:6473597d706e 424 /*!
bogdanm 82:6473597d706e 425 * @brief Resets the ENET module.
bogdanm 82:6473597d706e 426 *
bogdanm 82:6473597d706e 427 * @param instance The ENET instance number
bogdanm 82:6473597d706e 428 */
bogdanm 82:6473597d706e 429 static inline void enet_hal_reset_ethernet(uint32_t instance)
bogdanm 82:6473597d706e 430 {
bogdanm 82:6473597d706e 431 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 432
bogdanm 82:6473597d706e 433 HW_ENET_ECR_SET(instance, BM_ENET_ECR_RESET);
bogdanm 82:6473597d706e 434 }
bogdanm 82:6473597d706e 435
bogdanm 82:6473597d706e 436 /*!
bogdanm 82:6473597d706e 437 * @brief Gets the ENET status to check whether the reset has completed.
bogdanm 82:6473597d706e 438 *
bogdanm 82:6473597d706e 439 * @param instance The ENET instance number
bogdanm 82:6473597d706e 440 * @return Current status of the reset operation
bogdanm 82:6473597d706e 441 * - true if ENET reset completed.
bogdanm 82:6473597d706e 442 * - false if ENET reset has not completed.
bogdanm 82:6473597d706e 443 */
bogdanm 82:6473597d706e 444 static inline bool enet_hal_is_reset_completed(uint32_t instance)
bogdanm 82:6473597d706e 445 {
bogdanm 82:6473597d706e 446 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 447
bogdanm 82:6473597d706e 448 return (BR_ENET_ECR_RESET(instance) == 0);
bogdanm 82:6473597d706e 449 }
bogdanm 82:6473597d706e 450
bogdanm 82:6473597d706e 451 /*!
bogdanm 82:6473597d706e 452 * @brief Enable or disable stop mode.
bogdanm 82:6473597d706e 453 *
bogdanm 82:6473597d706e 454 * Enable stop mode will control device behavior in doze mode.
bogdanm 82:6473597d706e 455 * In doze mode, if this filed is set then all clock of the enet assemably are
bogdanm 82:6473597d706e 456 * disabled, except the RMII/MII clock.
bogdanm 82:6473597d706e 457 *
bogdanm 82:6473597d706e 458 * @param instance The ENET instance number.
bogdanm 82:6473597d706e 459 * @param isEnabled The switch to enable/disable stop mode.
bogdanm 82:6473597d706e 460 * - true to enabale the stop mode.
bogdanm 82:6473597d706e 461 * - false to disable the stop mode.
bogdanm 82:6473597d706e 462 */
bogdanm 82:6473597d706e 463 static inline void enet_hal_enable_stop(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 464 {
bogdanm 82:6473597d706e 465 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 466 BW_ENET_ECR_STOPEN(instance, isEnabled);
bogdanm 82:6473597d706e 467 }
bogdanm 82:6473597d706e 468 /*!
bogdanm 82:6473597d706e 469 * @brief Enable or disable sleep mode.
bogdanm 82:6473597d706e 470 *
bogdanm 82:6473597d706e 471 * Enable sleep mode will disable normal operating mode. When enable the sleep
bogdanm 82:6473597d706e 472 * mode, the magic packet detection is also enabled so that a remote agent can
bogdanm 82:6473597d706e 473 * wakeup the node.
bogdanm 82:6473597d706e 474 *
bogdanm 82:6473597d706e 475 * @param instance The ENET instance number.
bogdanm 82:6473597d706e 476 * @param isEnabled The switch to enable/disable the sleep mode.
bogdanm 82:6473597d706e 477 * - true to enabale the sleep mode.
bogdanm 82:6473597d706e 478 * - false to disable the sleep mode.
bogdanm 82:6473597d706e 479 */
bogdanm 82:6473597d706e 480 static inline void enet_hal_enable_sleep(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 481 {
bogdanm 82:6473597d706e 482 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 483 BW_ENET_ECR_SLEEP(instance, isEnabled);
bogdanm 82:6473597d706e 484 BW_ENET_ECR_MAGICEN(instance, isEnabled);
bogdanm 82:6473597d706e 485 }
bogdanm 82:6473597d706e 486
bogdanm 82:6473597d706e 487 /*!
bogdanm 82:6473597d706e 488 * @brief Sets the Mac address.
bogdanm 82:6473597d706e 489 *
bogdanm 82:6473597d706e 490 * This interface sets the six-byte Mac address of the ENET interface.
bogdanm 82:6473597d706e 491 *
bogdanm 82:6473597d706e 492 * @param instance The ENET instance number
bogdanm 82:6473597d706e 493 * @param hwAddr The mac address pointer store for six bytes Mac address
bogdanm 82:6473597d706e 494 */
bogdanm 82:6473597d706e 495 void enet_hal_set_mac_address(uint32_t instance, enetMacAddr hwAddr);
bogdanm 82:6473597d706e 496
bogdanm 82:6473597d706e 497 /*!
bogdanm 82:6473597d706e 498 * @brief Sets the hardware addressing filtering to a multicast group address.
bogdanm 82:6473597d706e 499 *
bogdanm 82:6473597d706e 500 * This interface is used to add the ENET device to a multicast group address.
bogdanm 82:6473597d706e 501 * After joining the group, Mac receives all frames with the group Mac address.
bogdanm 82:6473597d706e 502 *
bogdanm 82:6473597d706e 503 * @param instance The ENET instance number
bogdanm 82:6473597d706e 504 * @param crcValue The CRC value of the special address
bogdanm 82:6473597d706e 505 * @param mode The operation for init/enable/disable the specified hardware address
bogdanm 82:6473597d706e 506 */
bogdanm 82:6473597d706e 507 void enet_hal_set_group_hashtable(uint32_t instance, uint32_t crcValue, enet_special_address_filter_t mode);
bogdanm 82:6473597d706e 508
bogdanm 82:6473597d706e 509 /*!
bogdanm 82:6473597d706e 510 * @brief Sets the hardware addressing filtering to an individual address.
bogdanm 82:6473597d706e 511 *
bogdanm 82:6473597d706e 512 * This interface is used to add an individual address to the hardware address
bogdanm 82:6473597d706e 513 * filter. Mac receives all frames with the individual address as a destination address.
bogdanm 82:6473597d706e 514 *
bogdanm 82:6473597d706e 515 * @param instance The ENET instance number
bogdanm 82:6473597d706e 516 * @param crcValue The CRC value of the special address
bogdanm 82:6473597d706e 517 * @param mode The operation for init/enable/disable the specified hardware address
bogdanm 82:6473597d706e 518 */
bogdanm 82:6473597d706e 519 void enet_hal_set_individual_hashtable(uint32_t instance, uint32_t crcValue, enet_special_address_filter_t mode);
bogdanm 82:6473597d706e 520
bogdanm 82:6473597d706e 521 /*!
bogdanm 82:6473597d706e 522 * @brief Enable/disable payload length check.
bogdanm 82:6473597d706e 523 *
bogdanm 82:6473597d706e 524 * If the length/type is less than 0x600,When enable payload length check
bogdanm 82:6473597d706e 525 * the core checks the fame's payload length. If the length/type is greater
bogdanm 82:6473597d706e 526 * than or equal to 0x600. The MAC interprets the field as a type and no
bogdanm 82:6473597d706e 527 * payload length check is performanced.
bogdanm 82:6473597d706e 528 *
bogdanm 82:6473597d706e 529 * @param instance The ENET instance number
bogdanm 82:6473597d706e 530 * @param isEnabled The switch to enable/disable payload length check
bogdanm 82:6473597d706e 531 * - True to enabale payload length check.
bogdanm 82:6473597d706e 532 * - False to disable payload legnth check.
bogdanm 82:6473597d706e 533 */
bogdanm 82:6473597d706e 534 static inline void enet_hal_enable_payloadcheck(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 535 {
bogdanm 82:6473597d706e 536 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 537 BW_ENET_RCR_NLC(instance, isEnabled);
bogdanm 82:6473597d706e 538 }
bogdanm 82:6473597d706e 539
bogdanm 82:6473597d706e 540 /*!
bogdanm 82:6473597d706e 541 * @brief Enable/disable append CRC to transmitted frames.
bogdanm 82:6473597d706e 542 *
bogdanm 82:6473597d706e 543 * If transmit CRC forward is enabled, the transmit buffer descriptor controls
bogdanm 82:6473597d706e 544 * whether the frame has a CRC from the application. If transmit CRC forward is disabled,
bogdanm 82:6473597d706e 545 * transmitter does not append any CRC to transmitted frames.
bogdanm 82:6473597d706e 546 *
bogdanm 82:6473597d706e 547 * @param instance The ENET instance number
bogdanm 82:6473597d706e 548 * @param isEnabled The switch to enable/disable transmit the receive CRC
bogdanm 82:6473597d706e 549 * - True the transmitter control CRC through transmit buffer descriptor.
bogdanm 82:6473597d706e 550 * - False the transmitter does not append any CRC to transmitted frames.
bogdanm 82:6473597d706e 551 */
bogdanm 82:6473597d706e 552 static inline void enet_hal_enable_txcrcforward(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 553 {
bogdanm 82:6473597d706e 554 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 555 BW_ENET_TCR_CRCFWD(instance, !isEnabled);
bogdanm 82:6473597d706e 556 }
bogdanm 82:6473597d706e 557
bogdanm 82:6473597d706e 558 /*!
bogdanm 82:6473597d706e 559 * @brief Enable/disable forward the CRC filed of the received frame.
bogdanm 82:6473597d706e 560 *
bogdanm 82:6473597d706e 561 * This is used to deceide whether the CRC field of received frame is transmitted
bogdanm 82:6473597d706e 562 * or stripped. Enable this feature to strip CRC field from the frame.
bogdanm 82:6473597d706e 563 * If padding remove is enabled, this feature will be ignored and
bogdanm 82:6473597d706e 564 * the CRC field is checked and always terminated and removed.
bogdanm 82:6473597d706e 565 *
bogdanm 82:6473597d706e 566 * @param instance The ENET instance number
bogdanm 82:6473597d706e 567 * @param isEnabled The switch to enable/disable transmit the receive CRC
bogdanm 82:6473597d706e 568 * - True to transmit the received CRC.
bogdanm 82:6473597d706e 569 * - False to strip the received CRC.
bogdanm 82:6473597d706e 570 */
bogdanm 82:6473597d706e 571 static inline void enet_hal_enable_rxcrcforward(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 572 {
bogdanm 82:6473597d706e 573 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 574 BW_ENET_RCR_CRCFWD(instance, !isEnabled);
bogdanm 82:6473597d706e 575 }
bogdanm 82:6473597d706e 576 /*!
bogdanm 82:6473597d706e 577 * @brief Enable/disable forward PAUSE frames.
bogdanm 82:6473597d706e 578 *
bogdanm 82:6473597d706e 579 * This is used to deceide whether PAUSE frames is forwarded or discarded.
bogdanm 82:6473597d706e 580 *
bogdanm 82:6473597d706e 581 * @param instance The ENET instance number
bogdanm 82:6473597d706e 582 * @param isEnabled The switch to enable/disable forward PAUSE frames
bogdanm 82:6473597d706e 583 * - True to forward PAUSE frames.
bogdanm 82:6473597d706e 584 * - False to terminate and discard PAUSE frames.
bogdanm 82:6473597d706e 585 */
bogdanm 82:6473597d706e 586 static inline void enet_hal_enable_pauseforward(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 587 {
bogdanm 82:6473597d706e 588 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 589 BW_ENET_RCR_PAUFWD(instance, isEnabled);
bogdanm 82:6473597d706e 590 }
bogdanm 82:6473597d706e 591
bogdanm 82:6473597d706e 592 /*!
bogdanm 82:6473597d706e 593 * @brief Enable/disable frame padding remove on receive.
bogdanm 82:6473597d706e 594 *
bogdanm 82:6473597d706e 595 * Enable frame padding remove will remove the padding from the received frames.
bogdanm 82:6473597d706e 596 *
bogdanm 82:6473597d706e 597 * @param instance The ENET instance number
bogdanm 82:6473597d706e 598 * @param isEnabled The switch to enable/disable remove padding
bogdanm 82:6473597d706e 599 * - True to remove padding from frames.
bogdanm 82:6473597d706e 600 * - False to disable padding remove.
bogdanm 82:6473597d706e 601 */
bogdanm 82:6473597d706e 602 static inline void enet_hal_enable_padremove(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 603 {
bogdanm 82:6473597d706e 604 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 605 BW_ENET_RCR_PADEN(instance, isEnabled);
bogdanm 82:6473597d706e 606 }
bogdanm 82:6473597d706e 607
bogdanm 82:6473597d706e 608 /*!
bogdanm 82:6473597d706e 609 * @brief Enable/disable flow control.
bogdanm 82:6473597d706e 610 *
bogdanm 82:6473597d706e 611 * If flow control is enabled, the receive detects PAUSE frames.
bogdanm 82:6473597d706e 612 * Upon PAUSE frame detection, the transmitter stops transmitting
bogdanm 82:6473597d706e 613 * data frames for a given duration.
bogdanm 82:6473597d706e 614 *
bogdanm 82:6473597d706e 615 * @param instance The ENET instance number
bogdanm 82:6473597d706e 616 * @param isEnabled The switch to enable/disable flow control
bogdanm 82:6473597d706e 617 * - True to enable the flow control.
bogdanm 82:6473597d706e 618 * - False to disable the flow control.
bogdanm 82:6473597d706e 619 */
bogdanm 82:6473597d706e 620 static inline void enet_hal_enable_flowcontrol(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 621 {
bogdanm 82:6473597d706e 622 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 623 BW_ENET_RCR_CFEN(instance, isEnabled);
bogdanm 82:6473597d706e 624 BW_ENET_RCR_FCE(instance, isEnabled);
bogdanm 82:6473597d706e 625 }
bogdanm 82:6473597d706e 626
bogdanm 82:6473597d706e 627 /*!
bogdanm 82:6473597d706e 628 * @brief Enable/disable broadcast frame reject.
bogdanm 82:6473597d706e 629 *
bogdanm 82:6473597d706e 630 * If broadcast frame reject is enabled, frames with destination address
bogdanm 82:6473597d706e 631 * equal to 0xffff_ffff_ffff are rejected unless the promiscuous mode is open.
bogdanm 82:6473597d706e 632 *
bogdanm 82:6473597d706e 633 * @param instance The ENET instance number
bogdanm 82:6473597d706e 634 * @param isEnabled The switch to enable/disable reject broadcast frames
bogdanm 82:6473597d706e 635 * - True to reject broadcast frames.
bogdanm 82:6473597d706e 636 * - False to accept broadcast frames.
bogdanm 82:6473597d706e 637 */
bogdanm 82:6473597d706e 638 static inline void enet_hal_enable_broadcastreject(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 639 {
bogdanm 82:6473597d706e 640 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 641 BW_ENET_RCR_BC_REJ(instance, isEnabled);
bogdanm 82:6473597d706e 642 }
bogdanm 82:6473597d706e 643
bogdanm 82:6473597d706e 644 /*!
bogdanm 82:6473597d706e 645 * @brief Sets PAUSE duration for a PAUSE frame.
bogdanm 82:6473597d706e 646 *
bogdanm 82:6473597d706e 647 * This function is used to set the pause duraion used in transmission
bogdanm 82:6473597d706e 648 * of a PAUSE frame. When another node detects a PAUSE frame, that node
bogdanm 82:6473597d706e 649 * pauses transmission for the pause duration.
bogdanm 82:6473597d706e 650 *
bogdanm 82:6473597d706e 651 * @param instance The ENET instance number
bogdanm 82:6473597d706e 652 * @param pauseDuration The PAUSE duration for the transmitted PAUSE frame
bogdanm 82:6473597d706e 653 * the maximum pause duration is 0xFFFF.
bogdanm 82:6473597d706e 654 */
bogdanm 82:6473597d706e 655 static inline void enet_hal_set_pauseduration(uint32_t instance, uint32_t pauseDuration)
bogdanm 82:6473597d706e 656 {
bogdanm 82:6473597d706e 657 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 658 assert(pauseDuration <= BM_ENET_OPD_PAUSE_DUR);
bogdanm 82:6473597d706e 659 BW_ENET_OPD_PAUSE_DUR(instance, pauseDuration);
bogdanm 82:6473597d706e 660 }
bogdanm 82:6473597d706e 661
bogdanm 82:6473597d706e 662 /*!
bogdanm 82:6473597d706e 663 * @brief Gets receive PAUSE frame status.
bogdanm 82:6473597d706e 664 *
bogdanm 82:6473597d706e 665 * This function is used to get the received PAUSE frame status.
bogdanm 82:6473597d706e 666 *
bogdanm 82:6473597d706e 667 * @param instance The ENET instance number
bogdanm 82:6473597d706e 668 * @return The status of the received flow control frames
bogdanm 82:6473597d706e 669 * true if the flow control pause frame is received.
bogdanm 82:6473597d706e 670 * false if there is no flow control frame received or the pause duration is complete.
bogdanm 82:6473597d706e 671 */
bogdanm 82:6473597d706e 672 static inline bool enet_hal_get_rxpause_status(uint32_t instance)
bogdanm 82:6473597d706e 673 {
bogdanm 82:6473597d706e 674 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 675 return BR_ENET_TCR_RFC_PAUSE(instance);
bogdanm 82:6473597d706e 676 }
bogdanm 82:6473597d706e 677 /*!
bogdanm 82:6473597d706e 678 * @brief Enables transmit frame control PAUSE.
bogdanm 82:6473597d706e 679 *
bogdanm 82:6473597d706e 680 * This function enables pauses frame transmission.
bogdanm 82:6473597d706e 681 * When this is set, with transmission of data frames stopped, the MAC
bogdanm 82:6473597d706e 682 * transmits a MAC control PAUSE frame. NEXT, the MAC clear the
bogdanm 82:6473597d706e 683 * and resumes transmitting data frames.
bogdanm 82:6473597d706e 684 *
bogdanm 82:6473597d706e 685 * @param instance The ENET instance number
bogdanm 82:6473597d706e 686 * @param isEnabled The switch to enable/disable PAUSE control frame transmission
bogdanm 82:6473597d706e 687 * - True enable PAUSE control frame transmission.
bogdanm 82:6473597d706e 688 * - Flase disable PAUSE control frame transmission.
bogdanm 82:6473597d706e 689 */
bogdanm 82:6473597d706e 690 static inline void enet_hal_enable_txpause(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 691 {
bogdanm 82:6473597d706e 692 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 693 BW_ENET_TCR_TFC_PAUSE(instance, isEnabled);
bogdanm 82:6473597d706e 694 }
bogdanm 82:6473597d706e 695
bogdanm 82:6473597d706e 696 /*!
bogdanm 82:6473597d706e 697 * @brief Sets transmit PAUSE frame.
bogdanm 82:6473597d706e 698 *
bogdanm 82:6473597d706e 699 * This function Sets ENET transmit controller with pause duration.
bogdanm 82:6473597d706e 700 * And set the transmit control to do PAUSE frame transmission
bogdanm 82:6473597d706e 701 * This should be called when a PAUSE frame is dynamically wanted.
bogdanm 82:6473597d706e 702 *
bogdanm 82:6473597d706e 703 * @param instance The ENET instance number
bogdanm 82:6473597d706e 704 */
bogdanm 82:6473597d706e 705 void enet_hal_set_txpause(uint32_t instance, uint32_t pauseDuration);
bogdanm 82:6473597d706e 706
bogdanm 82:6473597d706e 707 /*!
bogdanm 82:6473597d706e 708 * @brief Sets the transmit inter-packet gap.
bogdanm 82:6473597d706e 709 *
bogdanm 82:6473597d706e 710 * This function indicates the IPG, in bytes, between transmitted frames.
bogdanm 82:6473597d706e 711 * Valid values range from 8 to 27. If value is less than 8, the IPG is 8.
bogdanm 82:6473597d706e 712 * If value is greater than 27, the IPG is 27.
bogdanm 82:6473597d706e 713 *
bogdanm 82:6473597d706e 714 * @param instance The ENET instance number
bogdanm 82:6473597d706e 715 * @param ipgValue The IPG for transmitted frames
bogdanm 82:6473597d706e 716 * The default value is 12, the maximum value set to ipg is 0x1F.
bogdanm 82:6473597d706e 717 *
bogdanm 82:6473597d706e 718 */
bogdanm 82:6473597d706e 719 static inline void enet_hal_set_txipg(uint32_t instance, uint32_t ipgValue)
bogdanm 82:6473597d706e 720 {
bogdanm 82:6473597d706e 721 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 722 assert(ipgValue <= BM_ENET_TIPG_IPG);
bogdanm 82:6473597d706e 723 BW_ENET_TIPG_IPG(instance, ipgValue);
bogdanm 82:6473597d706e 724 }
bogdanm 82:6473597d706e 725
bogdanm 82:6473597d706e 726 /*!
bogdanm 82:6473597d706e 727 * @brief Sets the receive frame truncation length.
bogdanm 82:6473597d706e 728 *
bogdanm 82:6473597d706e 729 * This function indicates the value a receive frame is truncated,
bogdanm 82:6473597d706e 730 * if it is greater than this value. The frame truncation length must be greater
bogdanm 82:6473597d706e 731 * than or equal to the receive maximum frame length.
bogdanm 82:6473597d706e 732 *
bogdanm 82:6473597d706e 733 * @param instance The ENET instance number
bogdanm 82:6473597d706e 734 * @param length The truncation length. The maximum value is 0x3FFF
bogdanm 82:6473597d706e 735 * The default truncation length is 2047(0x7FF).
bogdanm 82:6473597d706e 736 *
bogdanm 82:6473597d706e 737 */
bogdanm 82:6473597d706e 738 static inline void enet_hal_set_truncationlen(uint32_t instance, uint32_t length)
bogdanm 82:6473597d706e 739 {
bogdanm 82:6473597d706e 740 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 741 assert(length <= BM_ENET_FTRL_TRUNC_FL);
bogdanm 82:6473597d706e 742 BW_ENET_FTRL_TRUNC_FL(instance, length);
bogdanm 82:6473597d706e 743 }
bogdanm 82:6473597d706e 744
bogdanm 82:6473597d706e 745 /*!
bogdanm 82:6473597d706e 746 * @brief Sets the maximum receive buffer size and the maximum frame size.
bogdanm 82:6473597d706e 747 *
bogdanm 82:6473597d706e 748 * @param instance The ENET instance number
bogdanm 82:6473597d706e 749 * @param maxBufferSize The maximum receive buffer size, which should not be smaller than 256
bogdanm 82:6473597d706e 750 * It should be evenly divisible by 16 and the maximum receive size should not be larger than 0x3ff0.
bogdanm 82:6473597d706e 751 * @param maxFrameSize The maximum receive frame size, the reset value is 1518 or 1522 if the VLAN tags are
bogdanm 82:6473597d706e 752 * supported. The length is measured starting at DA and including the CRC.
bogdanm 82:6473597d706e 753 */
bogdanm 82:6473597d706e 754 static inline void enet_hal_set_rx_max_size(uint32_t instance, uint32_t maxBufferSize, uint32_t maxFrameSize)
bogdanm 82:6473597d706e 755 {
bogdanm 82:6473597d706e 756 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 757 /* max buffer size must larger than 256 to minimize bus usage*/
bogdanm 82:6473597d706e 758 assert(maxBufferSize >= 256);
bogdanm 82:6473597d706e 759 assert(maxFrameSize <= (BM_ENET_RCR_MAX_FL >> BP_ENET_RCR_MAX_FL));
bogdanm 82:6473597d706e 760
bogdanm 82:6473597d706e 761 BW_ENET_RCR_MAX_FL(instance, maxFrameSize);
bogdanm 82:6473597d706e 762 HW_ENET_MRBR_WR(instance, (maxBufferSize & BM_ENET_MRBR_R_BUF_SIZE));
bogdanm 82:6473597d706e 763 }
bogdanm 82:6473597d706e 764
bogdanm 82:6473597d706e 765 /*!
bogdanm 82:6473597d706e 766 * @brief Configures the ENET transmit FIFO.
bogdanm 82:6473597d706e 767 *
bogdanm 82:6473597d706e 768 * @param instance The ENET instance number
bogdanm 82:6473597d706e 769 * @param thresholdCfg The FIFO threshold configuration
bogdanm 82:6473597d706e 770 */
bogdanm 82:6473597d706e 771 void enet_hal_config_tx_fifo(uint32_t instance, enet_config_tx_fifo_t *thresholdCfg);
bogdanm 82:6473597d706e 772
bogdanm 82:6473597d706e 773 /*!
bogdanm 82:6473597d706e 774 * @brief Configures the ENET receive FIFO.
bogdanm 82:6473597d706e 775 *
bogdanm 82:6473597d706e 776 * @param instance The ENET instance number
bogdanm 82:6473597d706e 777 * @param thresholdCfg The FIFO threshold configuration
bogdanm 82:6473597d706e 778 */
bogdanm 82:6473597d706e 779 void enet_hal_config_rx_fifo(uint32_t instance, enet_config_rx_fifo_t *thresholdCfg);
bogdanm 82:6473597d706e 780
bogdanm 82:6473597d706e 781 /*!
bogdanm 82:6473597d706e 782 * @brief Sets the start address for ENET receive buffer descriptors.
bogdanm 82:6473597d706e 783 *
bogdanm 82:6473597d706e 784 * This interface provides the beginning of the receive
bogdanm 82:6473597d706e 785 * and receive buffer descriptor queue in the external memory. The
bogdanm 82:6473597d706e 786 * txbdAddr is recommended to be 128-bit aligned, must be evenly divisible by 16.
bogdanm 82:6473597d706e 787 *
bogdanm 82:6473597d706e 788 * @param instance The ENET instance number
bogdanm 82:6473597d706e 789 * @param rxBdAddr The start address of receive buffer descriptors
bogdanm 82:6473597d706e 790 */
bogdanm 82:6473597d706e 791 static inline void enet_hal_set_rxbd_address(uint32_t instance, uint32_t rxBdAddr)
bogdanm 82:6473597d706e 792 {
bogdanm 82:6473597d706e 793 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 794
bogdanm 82:6473597d706e 795 HW_ENET_RDSR_WR(instance,rxBdAddr); /* Initialize receive buffer descriptor start address*/
bogdanm 82:6473597d706e 796 }
bogdanm 82:6473597d706e 797 /*!
bogdanm 82:6473597d706e 798 * @brief Sets the start address for ENET transmit buffer descriptors.
bogdanm 82:6473597d706e 799 *
bogdanm 82:6473597d706e 800 * This interface provides the beginning of the receive
bogdanm 82:6473597d706e 801 * and transmit buffer descriptor queue in the external memory. The
bogdanm 82:6473597d706e 802 * txbdAddr is recommended to be 128-bit aligned, must be evenly divisible by 16.
bogdanm 82:6473597d706e 803 *
bogdanm 82:6473597d706e 804 * @param instance The ENET instance number
bogdanm 82:6473597d706e 805 * @param txBdAddr The start address of transmit buffer descriptors
bogdanm 82:6473597d706e 806 */
bogdanm 82:6473597d706e 807 static inline void enet_hal_set_txbd_address(uint32_t instance, uint32_t txBdAddr)
bogdanm 82:6473597d706e 808 {
bogdanm 82:6473597d706e 809 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 810
bogdanm 82:6473597d706e 811 HW_ENET_TDSR_WR(instance,txBdAddr); /* Initialize transmit buffer descriptor start address*/
bogdanm 82:6473597d706e 812 }
bogdanm 82:6473597d706e 813
bogdanm 82:6473597d706e 814 /*!
bogdanm 82:6473597d706e 815 * @brief Initializes the receive buffer descriptors.
bogdanm 82:6473597d706e 816 *
bogdanm 82:6473597d706e 817 * To make sure the uDMA will do the right data transfer after you activate
bogdanm 82:6473597d706e 818 * with wrap flag and all the buffer descriptors should be initialized with an empty bit.
bogdanm 82:6473597d706e 819 *
bogdanm 82:6473597d706e 820 * @param rxBds The current receive buffer descriptor
bogdanm 82:6473597d706e 821 * @param buffer The data buffer on buffer descriptor
bogdanm 82:6473597d706e 822 * @param isLastBd The flag to indicate the last receive buffer descriptor
bogdanm 82:6473597d706e 823 */
bogdanm 82:6473597d706e 824 void enet_hal_init_rxbds(void *rxBds, uint8_t *buffer, bool isLastBd);
bogdanm 82:6473597d706e 825
bogdanm 82:6473597d706e 826 /*!
bogdanm 82:6473597d706e 827 * @brief Initializes the transmit buffer descriptors.
bogdanm 82:6473597d706e 828 *
bogdanm 82:6473597d706e 829 * To make sure the uDMA will do the right data transfer after you active
bogdanm 82:6473597d706e 830 * with wrap flag.
bogdanm 82:6473597d706e 831 *
bogdanm 82:6473597d706e 832 * @param txBds The current transmit buffer descriptor.
bogdanm 82:6473597d706e 833 * @param isLastBd The last transmit buffer descriptor flag.
bogdanm 82:6473597d706e 834 */
bogdanm 82:6473597d706e 835 void enet_hal_init_txbds(void *txBds, bool isLastBd);
bogdanm 82:6473597d706e 836
bogdanm 82:6473597d706e 837 /*!
bogdanm 82:6473597d706e 838 * @brief Updates the receive buffer descriptors.
bogdanm 82:6473597d706e 839 *
bogdanm 82:6473597d706e 840 * This interface mainly clears the status region and updates the received
bogdanm 82:6473597d706e 841 * buffer descriptor to ensure that the BD is correctly used.
bogdanm 82:6473597d706e 842 *
bogdanm 82:6473597d706e 843 * @param rxBds The current receive buffer descriptor
bogdanm 82:6473597d706e 844 * @param data The data buffer address
bogdanm 82:6473597d706e 845 * @param isbufferUpdate The data buffer update flag. When you want to update
bogdanm 82:6473597d706e 846 * the data buffer of the buffer descriptor ensure that this flag
bogdanm 82:6473597d706e 847 * is set.
bogdanm 82:6473597d706e 848 */
bogdanm 82:6473597d706e 849 void enet_hal_update_rxbds(void *rxBds, uint8_t *data, bool isbufferUpdate);
bogdanm 82:6473597d706e 850
bogdanm 82:6473597d706e 851 /*!
bogdanm 82:6473597d706e 852 * @brief Initializes the transmit buffer descriptors.
bogdanm 82:6473597d706e 853 *
bogdanm 82:6473597d706e 854 * Ensures that the uDMA transfer data correctly after the user activates
bogdanm 82:6473597d706e 855 * with the wrap flag.
bogdanm 82:6473597d706e 856 *
bogdanm 82:6473597d706e 857 * @param txBds The current transmit buffer descriptor
bogdanm 82:6473597d706e 858 * @param isLastBd The last transmit buffer descriptor flag
bogdanm 82:6473597d706e 859 */
bogdanm 82:6473597d706e 860 void enet_hal_init_txbds(void *txBds, bool isLastBd);
bogdanm 82:6473597d706e 861
bogdanm 82:6473597d706e 862 /*!
bogdanm 82:6473597d706e 863 * @brief Updates the transmit buffer descriptors.
bogdanm 82:6473597d706e 864 *
bogdanm 82:6473597d706e 865 * This interface mainly clears the status region and updates the transmit
bogdanm 82:6473597d706e 866 * buffer descriptor to ensure tat this BD is correctly used again.
bogdanm 82:6473597d706e 867 * You should set the isTxtsCfged when the transmit timestamp feature is required.
bogdanm 82:6473597d706e 868 *
bogdanm 82:6473597d706e 869 * @param txBds The current transmit buffer descriptor
bogdanm 82:6473597d706e 870 * @param buffer The data buffer on buffer descriptor
bogdanm 82:6473597d706e 871 * @param length The data length on buffer descriptor
bogdanm 82:6473597d706e 872 * @param isTxtsCfged The timestamp configure flag. The timestamp is
bogdanm 82:6473597d706e 873 * added to the transmit buffer descriptor when this flag is set.
bogdanm 82:6473597d706e 874 */
bogdanm 82:6473597d706e 875 void enet_hal_update_txbds(void *txBds,uint8_t *buffer, uint16_t length, bool isTxtsCfged);
bogdanm 82:6473597d706e 876
bogdanm 82:6473597d706e 877 /*!
bogdanm 82:6473597d706e 878 * @brief Clears the context in the transmit buffer descriptors.
bogdanm 82:6473597d706e 879 *
bogdanm 82:6473597d706e 880 * Clears the data, length, control, and status region of the transmit buffer descriptor.
bogdanm 82:6473597d706e 881 *
bogdanm 82:6473597d706e 882 * @param curBd The current buffer descriptor
bogdanm 82:6473597d706e 883 */
bogdanm 82:6473597d706e 884 static inline void enet_hal_clear_txbds(void *curBd)
bogdanm 82:6473597d706e 885 {
bogdanm 82:6473597d706e 886 assert(curBd);
bogdanm 82:6473597d706e 887
bogdanm 82:6473597d706e 888 volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd;
bogdanm 82:6473597d706e 889 bdPtr->length = 0; /* Set data length*/
bogdanm 82:6473597d706e 890 bdPtr->buffer = (uint8_t *)(NULL);/* Set data buffer*/
bogdanm 82:6473597d706e 891 bdPtr->control &= (kEnetTxBdWrap);/* Set control */
bogdanm 82:6473597d706e 892 }
bogdanm 82:6473597d706e 893
bogdanm 82:6473597d706e 894 /*!
bogdanm 82:6473597d706e 895 * @brief Gets the control and the status region of the receive buffer descriptors.
bogdanm 82:6473597d706e 896 *
bogdanm 82:6473597d706e 897 * This interface can get the whole control and status region of the
bogdanm 82:6473597d706e 898 * receive buffer descriptor. The enet_rx_bd_control_status_t enum type
bogdanm 82:6473597d706e 899 * definition should be used if you want to get each status bit of
bogdanm 82:6473597d706e 900 * the control and status region.
bogdanm 82:6473597d706e 901 *
bogdanm 82:6473597d706e 902 * @param curBd The current receive buffer descriptor
bogdanm 82:6473597d706e 903 * @return The control and status data on buffer descriptors
bogdanm 82:6473597d706e 904 */
bogdanm 82:6473597d706e 905 uint16_t enet_hal_get_rxbd_control(void *curBd);
bogdanm 82:6473597d706e 906
bogdanm 82:6473597d706e 907 /*!
bogdanm 82:6473597d706e 908 * @brief Gets the control and the status region of the transmit buffer descriptors.
bogdanm 82:6473597d706e 909 *
bogdanm 82:6473597d706e 910 * This interface can get the whole control and status region of the
bogdanm 82:6473597d706e 911 * transmit buffer descriptor. The enet_tx_bd_control_status_t enum type
bogdanm 82:6473597d706e 912 * definition should be used if you want to get each status bit of
bogdanm 82:6473597d706e 913 * the control and status region.
bogdanm 82:6473597d706e 914 *
bogdanm 82:6473597d706e 915 * @param curBd The current transmit buffer descriptor
bogdanm 82:6473597d706e 916 * @return The extended control region of transmit buffer descriptor
bogdanm 82:6473597d706e 917 */
bogdanm 82:6473597d706e 918 uint16_t enet_hal_get_txbd_control(void *curBd);
bogdanm 82:6473597d706e 919
bogdanm 82:6473597d706e 920 /*!
bogdanm 82:6473597d706e 921 * @brief Gets the extended control region of the receive buffer descriptors.
bogdanm 82:6473597d706e 922 *
bogdanm 82:6473597d706e 923 * This interface can get the whole control and status region of the
bogdanm 82:6473597d706e 924 * receive buffer descriptor. The enet_rx_bd_control_extend_t enum type
bogdanm 82:6473597d706e 925 * definition should be used if you want to get each status bit of
bogdanm 82:6473597d706e 926 * the control and status region.
bogdanm 82:6473597d706e 927 *
bogdanm 82:6473597d706e 928 * @param curBd The current receive buffer descriptor
bogdanm 82:6473597d706e 929 * @param controlRegion The different control region
bogdanm 82:6473597d706e 930 * @return The extended control region data of receive buffer descriptor
bogdanm 82:6473597d706e 931 * - true when the control region is set
bogdanm 82:6473597d706e 932 * - false when the control region is not set
bogdanm 82:6473597d706e 933 */
bogdanm 82:6473597d706e 934 bool enet_hal_get_rxbd_control_extend(void *curBd,enet_rx_bd_control_extend_t controlRegion);
bogdanm 82:6473597d706e 935 /*!
bogdanm 82:6473597d706e 936 * @brief Gets the extended control region of the transmit buffer descriptors.
bogdanm 82:6473597d706e 937 *
bogdanm 82:6473597d706e 938 * This interface can get the whole control and status region of the
bogdanm 82:6473597d706e 939 * transmit buffer descriptor. The enet_tx_bd_control_extend_t enum type
bogdanm 82:6473597d706e 940 * definition should be used if you want to get each status bit of
bogdanm 82:6473597d706e 941 * the control and status region.
bogdanm 82:6473597d706e 942 *
bogdanm 82:6473597d706e 943 * @param curBd The current transmit buffer descriptor
bogdanm 82:6473597d706e 944 * @return The extended control data
bogdanm 82:6473597d706e 945 */
bogdanm 82:6473597d706e 946 uint16_t enet_hal_get_txbd_control_extend(void *curBd);
bogdanm 82:6473597d706e 947
bogdanm 82:6473597d706e 948 /*!
bogdanm 82:6473597d706e 949 * @brief Gets the data length of the buffer descriptors.
bogdanm 82:6473597d706e 950 *
bogdanm 82:6473597d706e 951 * @param curBd The current buffer descriptor
bogdanm 82:6473597d706e 952 * @return The data length of the buffer descriptor
bogdanm 82:6473597d706e 953 */
bogdanm 82:6473597d706e 954 uint16_t enet_hal_get_bd_length(void *curBd);
bogdanm 82:6473597d706e 955
bogdanm 82:6473597d706e 956 /*!
bogdanm 82:6473597d706e 957 * @brief Gets the buffer address of the buffer descriptors.
bogdanm 82:6473597d706e 958 *
bogdanm 82:6473597d706e 959 * @param curBd The current buffer descriptor
bogdanm 82:6473597d706e 960 * @return The buffer address of the buffer descriptor
bogdanm 82:6473597d706e 961 */
bogdanm 82:6473597d706e 962 uint8_t* enet_hal_get_bd_buffer(void *curBd);
bogdanm 82:6473597d706e 963
bogdanm 82:6473597d706e 964 /*!
bogdanm 82:6473597d706e 965 * @brief Gets the timestamp of the buffer descriptors.
bogdanm 82:6473597d706e 966 *
bogdanm 82:6473597d706e 967 * @param curBd The current buffer descriptor
bogdanm 82:6473597d706e 968 * @return The time stamp of the frame in the buffer descriptor.
bogdanm 82:6473597d706e 969 * Notice that the frame timestamp is only set in the last
bogdanm 82:6473597d706e 970 * buffer descriptor of the frame.
bogdanm 82:6473597d706e 971 */
bogdanm 82:6473597d706e 972 uint32_t enet_hal_get_bd_timestamp(void *curBd);
bogdanm 82:6473597d706e 973
bogdanm 82:6473597d706e 974 /*!
bogdanm 82:6473597d706e 975 * @brief Activates the receive buffer descriptor.
bogdanm 82:6473597d706e 976 *
bogdanm 82:6473597d706e 977 * The buffer descriptor activation
bogdanm 82:6473597d706e 978 * should be done after the ENET module is enabled. Otherwise, the activation fails.
bogdanm 82:6473597d706e 979 *
bogdanm 82:6473597d706e 980 * @param instance The ENET instance number
bogdanm 82:6473597d706e 981 */
bogdanm 82:6473597d706e 982 static inline void enet_hal_active_rxbd(uint32_t instance)
bogdanm 82:6473597d706e 983 {
bogdanm 82:6473597d706e 984 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 985
bogdanm 82:6473597d706e 986 HW_ENET_RDAR_SET(instance, BM_ENET_RDAR_RDAR);
bogdanm 82:6473597d706e 987 }
bogdanm 82:6473597d706e 988
bogdanm 82:6473597d706e 989 /*!
bogdanm 82:6473597d706e 990 * @brief Activates the transmit buffer descriptor.
bogdanm 82:6473597d706e 991 *
bogdanm 82:6473597d706e 992 * The buffer descriptor activation should be done after the ENET module is
bogdanm 82:6473597d706e 993 * enabled. Otherwise, the activation fails.
bogdanm 82:6473597d706e 994 *
bogdanm 82:6473597d706e 995 * @param instance The ENET instance number
bogdanm 82:6473597d706e 996 */
bogdanm 82:6473597d706e 997 static inline void enet_hal_active_txbd(uint32_t instance)
bogdanm 82:6473597d706e 998 {
bogdanm 82:6473597d706e 999 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1000
bogdanm 82:6473597d706e 1001 HW_ENET_TDAR_SET(instance, BM_ENET_TDAR_TDAR);
bogdanm 82:6473597d706e 1002 }
bogdanm 82:6473597d706e 1003
bogdanm 82:6473597d706e 1004 /*!
bogdanm 82:6473597d706e 1005 * @brief Configures the (R)MII of ENET.
bogdanm 82:6473597d706e 1006 *
bogdanm 82:6473597d706e 1007 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1008 * @param mode The RMII or MII mode
bogdanm 82:6473597d706e 1009 * @param speed The speed of RMII
bogdanm 82:6473597d706e 1010 * @param duplex The full or half duplex mode
bogdanm 82:6473597d706e 1011 * @param isRxOnTxDisabled The Receive on transmit disable flag
bogdanm 82:6473597d706e 1012 * @param isLoopEnabled The loop enable flag
bogdanm 82:6473597d706e 1013 */
bogdanm 82:6473597d706e 1014 void enet_hal_config_rmii(uint32_t instance, enet_config_rmii_t mode, enet_config_speed_t speed, enet_config_duplex_t duplex, bool isRxOnTxDisabled, bool isLoopEnabled);
bogdanm 82:6473597d706e 1015
bogdanm 82:6473597d706e 1016 /*!
bogdanm 82:6473597d706e 1017 * @brief Configures the MII of ENET.
bogdanm 82:6473597d706e 1018 *
bogdanm 82:6473597d706e 1019 * Sets the MII interface between Mac and PHY. The miiSpeed is
bogdanm 82:6473597d706e 1020 * a value that controls the frequency of the MDC, relative to the internal module clock(InterClockSrc).
bogdanm 82:6473597d706e 1021 * A value of zero in this parameter turns the MDC off and leaves it in the low voltage state.
bogdanm 82:6473597d706e 1022 * Any non-zero value results in the MDC frequency MDC = InterClockSrc/((miiSpeed + 1)*2).
bogdanm 82:6473597d706e 1023 * So miiSpeed = InterClockSrc/(2*MDC) - 1.
bogdanm 82:6473597d706e 1024 * The Maximum MDC clock is 2.5MHZ(maximum). We should round up and plus one to simlplify:
bogdanm 82:6473597d706e 1025 * miiSpeed = InterClockSrc/(2*2.5MHZ).
bogdanm 82:6473597d706e 1026 *
bogdanm 82:6473597d706e 1027 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1028 * @param miiSpeed The MII speed and it is ranged from 0~0x3F
bogdanm 82:6473597d706e 1029 * @param time The holdon clock cycles for MDIO output
bogdanm 82:6473597d706e 1030 * @param isPreambleDisabled The preamble disabled flag
bogdanm 82:6473597d706e 1031 */
bogdanm 82:6473597d706e 1032 static inline void enet_hal_config_mii(uint32_t instance, uint32_t miiSpeed,
bogdanm 82:6473597d706e 1033 enet_mdio_holdon_clkcycle_t clkCycle, bool isPreambleDisabled)
bogdanm 82:6473597d706e 1034 {
bogdanm 82:6473597d706e 1035 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1036
bogdanm 82:6473597d706e 1037 BW_ENET_MSCR_MII_SPEED(instance, miiSpeed); /* MII speed set*/
bogdanm 82:6473597d706e 1038 BW_ENET_MSCR_DIS_PRE(instance, isPreambleDisabled); /* Preamble is disabled*/
bogdanm 82:6473597d706e 1039 BW_ENET_MSCR_HOLDTIME(instance, clkCycle); /* hold on clock cycles for MDIO output*/
bogdanm 82:6473597d706e 1040
bogdanm 82:6473597d706e 1041 }
bogdanm 82:6473597d706e 1042
bogdanm 82:6473597d706e 1043 /*!
bogdanm 82:6473597d706e 1044 * @brief Gets the MII configuration status.
bogdanm 82:6473597d706e 1045 *
bogdanm 82:6473597d706e 1046 * This interface is usually called to check the MII interface before
bogdanm 82:6473597d706e 1047 * the Mac writes or reads the PHY registers.
bogdanm 82:6473597d706e 1048 *
bogdanm 82:6473597d706e 1049 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1050 * @return The MII configuration status
bogdanm 82:6473597d706e 1051 * - true if the MII has been configured.
bogdanm 82:6473597d706e 1052 * - false if the MII has not been configured.
bogdanm 82:6473597d706e 1053 */
bogdanm 82:6473597d706e 1054 static inline bool enet_hal_is_mii_enabled(uint32_t instance)
bogdanm 82:6473597d706e 1055 {
bogdanm 82:6473597d706e 1056 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1057
bogdanm 82:6473597d706e 1058 return (HW_ENET_MSCR_RD(instance) & 0x7E)!= 0;
bogdanm 82:6473597d706e 1059 }
bogdanm 82:6473597d706e 1060
bogdanm 82:6473597d706e 1061 /*!
bogdanm 82:6473597d706e 1062 * @brief Reads data from PHY.
bogdanm 82:6473597d706e 1063 *
bogdanm 82:6473597d706e 1064 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1065 * @return The data read from PHY
bogdanm 82:6473597d706e 1066 */
bogdanm 82:6473597d706e 1067 static inline uint32_t enet_hal_get_mii_data(uint32_t instance)
bogdanm 82:6473597d706e 1068 {
bogdanm 82:6473597d706e 1069 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1070
bogdanm 82:6473597d706e 1071 return (uint32_t)BR_ENET_MMFR_DATA(instance);
bogdanm 82:6473597d706e 1072 }
bogdanm 82:6473597d706e 1073
bogdanm 82:6473597d706e 1074 /*!
bogdanm 82:6473597d706e 1075 * @brief Sets the MII command.
bogdanm 82:6473597d706e 1076 *
bogdanm 82:6473597d706e 1077 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1078 * @param phyAddr The PHY address
bogdanm 82:6473597d706e 1079 * @param phyReg The PHY register
bogdanm 82:6473597d706e 1080 * @param operation The read or write operation
bogdanm 82:6473597d706e 1081 * @param data The data written to PHY
bogdanm 82:6473597d706e 1082 */
bogdanm 82:6473597d706e 1083 void enet_hal_set_mii_command(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, enet_mii_operation_t operation, uint32_t data);
bogdanm 82:6473597d706e 1084
bogdanm 82:6473597d706e 1085 /*!
bogdanm 82:6473597d706e 1086 * @brief Enables/Disables the ENET module.
bogdanm 82:6473597d706e 1087 *
bogdanm 82:6473597d706e 1088 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1089 * @param isEnhanced The enhanced 1588 feature switch
bogdanm 82:6473597d706e 1090 * @param isEnabled The ENET module enable switch
bogdanm 82:6473597d706e 1091 */
bogdanm 82:6473597d706e 1092 void enet_hal_config_ethernet(uint32_t instance, bool isEnhanced, bool isEnabled);
bogdanm 82:6473597d706e 1093
bogdanm 82:6473597d706e 1094 /*!
bogdanm 82:6473597d706e 1095 * @brief Enables/Disables the ENET interrupt.
bogdanm 82:6473597d706e 1096 *
bogdanm 82:6473597d706e 1097 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1098 * @param source The interrupt sources. enet_interrupt_request_t enum types
bogdanm 82:6473597d706e 1099 * is recommended as the interrupt source.
bogdanm 82:6473597d706e 1100 * @param isEnabled The interrupt enable switch
bogdanm 82:6473597d706e 1101 */
bogdanm 82:6473597d706e 1102 void enet_hal_config_interrupt(uint32_t instance, uint32_t source, bool isEnabled);
bogdanm 82:6473597d706e 1103
bogdanm 82:6473597d706e 1104 /*!
bogdanm 82:6473597d706e 1105 * @brief Clears ENET interrupt events.
bogdanm 82:6473597d706e 1106 *
bogdanm 82:6473597d706e 1107 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1108 * @param source The interrupt source to be cleared. enet_interrupt_request_t
bogdanm 82:6473597d706e 1109 * enum types is recommended as the interrupt source.
bogdanm 82:6473597d706e 1110 */
bogdanm 82:6473597d706e 1111 static inline void enet_hal_clear_interrupt(uint32_t instance, uint32_t source)
bogdanm 82:6473597d706e 1112 {
bogdanm 82:6473597d706e 1113 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1114
bogdanm 82:6473597d706e 1115 HW_ENET_EIR_WR(instance,source);
bogdanm 82:6473597d706e 1116 }
bogdanm 82:6473597d706e 1117
bogdanm 82:6473597d706e 1118 /*!
bogdanm 82:6473597d706e 1119 * @brief Gets the ENET interrupt status.
bogdanm 82:6473597d706e 1120 *
bogdanm 82:6473597d706e 1121 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1122 * @param source The interrupt sources. enet_interrupt_request_t
bogdanm 82:6473597d706e 1123 * enum types is recommended as the interrupt source.
bogdanm 82:6473597d706e 1124 * @return The event status of the interrupt source
bogdanm 82:6473597d706e 1125 * - true if the interrupt event happened.
bogdanm 82:6473597d706e 1126 * - false if the interrupt event has not happened.
bogdanm 82:6473597d706e 1127 */
bogdanm 82:6473597d706e 1128 static inline bool enet_hal_get_interrupt_status(uint32_t instance, uint32_t source)
bogdanm 82:6473597d706e 1129 {
bogdanm 82:6473597d706e 1130 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1131
bogdanm 82:6473597d706e 1132 return ((HW_ENET_EIR_RD(instance) & source) != 0);
bogdanm 82:6473597d706e 1133 }
bogdanm 82:6473597d706e 1134
bogdanm 82:6473597d706e 1135 /*
bogdanm 82:6473597d706e 1136 * @brief Enables/disables the ENET promiscuous mode.
bogdanm 82:6473597d706e 1137 *
bogdanm 82:6473597d706e 1138 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1139 * @param isEnabled The enable switch
bogdanm 82:6473597d706e 1140 */
bogdanm 82:6473597d706e 1141 static inline void enet_hal_config_promiscuous(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 1142 {
bogdanm 82:6473597d706e 1143 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1144
bogdanm 82:6473597d706e 1145 BW_ENET_RCR_PROM(instance,isEnabled);
bogdanm 82:6473597d706e 1146 }
bogdanm 82:6473597d706e 1147
bogdanm 82:6473597d706e 1148 /*!
bogdanm 82:6473597d706e 1149 * @brief Enables/disables the clear MIB counter.
bogdanm 82:6473597d706e 1150 *
bogdanm 82:6473597d706e 1151 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1152 * @param isEnabled The enable switch
bogdanm 82:6473597d706e 1153 */
bogdanm 82:6473597d706e 1154 static inline void enet_hal_clear_mib(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 1155 {
bogdanm 82:6473597d706e 1156 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1157
bogdanm 82:6473597d706e 1158 BW_ENET_MIBC_MIB_CLEAR(instance, isEnabled);
bogdanm 82:6473597d706e 1159
bogdanm 82:6473597d706e 1160 }
bogdanm 82:6473597d706e 1161
bogdanm 82:6473597d706e 1162 /*!
bogdanm 82:6473597d706e 1163 * @brief Sets the enable/disable of the MIB block.
bogdanm 82:6473597d706e 1164 *
bogdanm 82:6473597d706e 1165 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1166 * @param isEnabled The enable flag
bogdanm 82:6473597d706e 1167 * - True to enabale MIB block.
bogdanm 82:6473597d706e 1168 * - False to disable MIB block.
bogdanm 82:6473597d706e 1169 */
bogdanm 82:6473597d706e 1170 static inline void enet_hal_enable_mib(uint32_t instance, bool isEnabled)
bogdanm 82:6473597d706e 1171 {
bogdanm 82:6473597d706e 1172 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1173
bogdanm 82:6473597d706e 1174 BW_ENET_MIBC_MIB_DIS(instance,!isEnabled);
bogdanm 82:6473597d706e 1175
bogdanm 82:6473597d706e 1176 }
bogdanm 82:6473597d706e 1177
bogdanm 82:6473597d706e 1178 /*!
bogdanm 82:6473597d706e 1179 * @brief Gets the MIB idle status.
bogdanm 82:6473597d706e 1180 *
bogdanm 82:6473597d706e 1181 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1182 * @return true if in MIB idle and MIB is not updating else false.
bogdanm 82:6473597d706e 1183 */
bogdanm 82:6473597d706e 1184 static inline bool enet_hal_get_mib_status(uint32_t instance)
bogdanm 82:6473597d706e 1185 {
bogdanm 82:6473597d706e 1186 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1187
bogdanm 82:6473597d706e 1188 return BR_ENET_MIBC_MIB_IDLE(instance);
bogdanm 82:6473597d706e 1189 }
bogdanm 82:6473597d706e 1190
bogdanm 82:6473597d706e 1191 /*!
bogdanm 82:6473597d706e 1192 * @brief Sets the transmit accelerator.
bogdanm 82:6473597d706e 1193 *
bogdanm 82:6473597d706e 1194 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1195 * @param txCfgPtr The transmit accelerator configuration
bogdanm 82:6473597d706e 1196 */
bogdanm 82:6473597d706e 1197 void enet_hal_config_tx_accelerator(uint32_t instance, enet_config_tx_accelerator_t *txCfgPtr);
bogdanm 82:6473597d706e 1198
bogdanm 82:6473597d706e 1199 /*!
bogdanm 82:6473597d706e 1200 * @brief Sets the receive accelerator.
bogdanm 82:6473597d706e 1201 *
bogdanm 82:6473597d706e 1202 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1203 * @param rxCfgPtr The receive accelerator configuration
bogdanm 82:6473597d706e 1204 */
bogdanm 82:6473597d706e 1205 void enet_hal_config_rx_accelerator(uint32_t instance, enet_config_rx_accelerator_t *rxCfgPtr);
bogdanm 82:6473597d706e 1206
bogdanm 82:6473597d706e 1207 /*!
bogdanm 82:6473597d706e 1208 * @brief Initializes the 1588 timer.
bogdanm 82:6473597d706e 1209 *
bogdanm 82:6473597d706e 1210 * This interface initializes the 1588 context structure.
bogdanm 82:6473597d706e 1211 * Initialize 1588 parameters according to the user configuration structure.
bogdanm 82:6473597d706e 1212 *
bogdanm 82:6473597d706e 1213 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1214 * @param ptpCfg The 1588 timer configuration
bogdanm 82:6473597d706e 1215 */
bogdanm 82:6473597d706e 1216 void enet_hal_init_ptp_timer(uint32_t instance, enet_config_ptp_timer_t *ptpCfgPtr);
bogdanm 82:6473597d706e 1217
bogdanm 82:6473597d706e 1218 /*!
bogdanm 82:6473597d706e 1219 * @brief Enables or disables the 1588 timer.
bogdanm 82:6473597d706e 1220 *
bogdanm 82:6473597d706e 1221 * Enable the PTP timer will starts the timer. Disable the timer will stop timer
bogdanm 82:6473597d706e 1222 * at the current value.
bogdanm 82:6473597d706e 1223 *
bogdanm 82:6473597d706e 1224 * @param instance The ENET instance number.
bogdanm 82:6473597d706e 1225 * @param isEnabled The 1588 timer Enable switch
bogdanm 82:6473597d706e 1226 * - True enbaled the 1588 PTP timer.
bogdanm 82:6473597d706e 1227 * - False disable or stop the 1588 PTP timer.
bogdanm 82:6473597d706e 1228 */
bogdanm 82:6473597d706e 1229 static inline void enet_hal_enable_ptp_timer(uint32_t instance, uint32_t isEnabled)
bogdanm 82:6473597d706e 1230 {
bogdanm 82:6473597d706e 1231 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1232
bogdanm 82:6473597d706e 1233 BW_ENET_ATCR_EN(instance,isEnabled);
bogdanm 82:6473597d706e 1234 }
bogdanm 82:6473597d706e 1235
bogdanm 82:6473597d706e 1236 /*!
bogdanm 82:6473597d706e 1237 * @brief Restarts the 1588 timer.
bogdanm 82:6473597d706e 1238 *
bogdanm 82:6473597d706e 1239 * Restarting the PTP timer clears all PTP-timer counters to zero.
bogdanm 82:6473597d706e 1240 *
bogdanm 82:6473597d706e 1241 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1242 */
bogdanm 82:6473597d706e 1243 static inline void enet_hal_restart_ptp_timer(uint32_t instance)
bogdanm 82:6473597d706e 1244 {
bogdanm 82:6473597d706e 1245 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1246
bogdanm 82:6473597d706e 1247 BW_ENET_ATCR_RESTART(instance,1);
bogdanm 82:6473597d706e 1248 }
bogdanm 82:6473597d706e 1249
bogdanm 82:6473597d706e 1250 /*!
bogdanm 82:6473597d706e 1251 * @brief Adjusts the 1588 timer.
bogdanm 82:6473597d706e 1252 *
bogdanm 82:6473597d706e 1253 * Adjust the 1588 timer according to the increase and correction period of the configured correction.
bogdanm 82:6473597d706e 1254 *
bogdanm 82:6473597d706e 1255 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1256 * @param inceaseCorrection The increase correction for 1588 timer
bogdanm 82:6473597d706e 1257 * @param periodCorrection The period correction for 1588 timer
bogdanm 82:6473597d706e 1258 */
bogdanm 82:6473597d706e 1259 static inline void enet_hal_adjust_ptp_timer(uint32_t instance, uint32_t increaseCorrection, uint32_t periodCorrection)
bogdanm 82:6473597d706e 1260 {
bogdanm 82:6473597d706e 1261 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1262
bogdanm 82:6473597d706e 1263 HW_ENET_ATINC_SET(instance,((increaseCorrection << ENET_ATINC_INC_CORR_SHIFT) & ENET_ATINC_INC_CORR_MASK)); /* set correction for ptp timer increase*/
bogdanm 82:6473597d706e 1264 /* set correction for ptp timer period*/
bogdanm 82:6473597d706e 1265 HW_ENET_ATCOR_SET(instance, (BM_ENET_ATCOR_COR & periodCorrection));
bogdanm 82:6473597d706e 1266 }
bogdanm 82:6473597d706e 1267
bogdanm 82:6473597d706e 1268 /*!
bogdanm 82:6473597d706e 1269 * @brief Initializes the 1588 timer channel.
bogdanm 82:6473597d706e 1270 *
bogdanm 82:6473597d706e 1271 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1272 * @Param channel The 1588 timer channel number
bogdanm 82:6473597d706e 1273 * @param mode Compare or capture mode for the 1588 timer channel
bogdanm 82:6473597d706e 1274 */
bogdanm 82:6473597d706e 1275 static inline void enet_hal_init_timer_channel(uint32_t instance, uint32_t channel, enet_timer_channel_mode_t mode)
bogdanm 82:6473597d706e 1276 {
bogdanm 82:6473597d706e 1277 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1278 assert(channel < HW_ENET_TCSRn_COUNT);
bogdanm 82:6473597d706e 1279 HW_ENET_TCSRn_SET(instance, channel,
bogdanm 82:6473597d706e 1280 (BM_ENET_TCSRn_TMODE &(mode << BP_ENET_TCSRn_TMODE)));
bogdanm 82:6473597d706e 1281 HW_ENET_TCSRn_SET(instance, channel, BM_ENET_TCSRn_TIE);
bogdanm 82:6473597d706e 1282 }
bogdanm 82:6473597d706e 1283
bogdanm 82:6473597d706e 1284 /*!
bogdanm 82:6473597d706e 1285 * @brief Sets the compare value for the 1588 timer channel.
bogdanm 82:6473597d706e 1286 *
bogdanm 82:6473597d706e 1287 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1288 * @Param channel The 1588 timer channel number
bogdanm 82:6473597d706e 1289 * @param compareValue Compare value for 1588 timer channel
bogdanm 82:6473597d706e 1290 */
bogdanm 82:6473597d706e 1291 static inline void enet_hal_set_timer_channel_compare(uint32_t instance, uint32_t channel, uint32_t compareValue)
bogdanm 82:6473597d706e 1292 {
bogdanm 82:6473597d706e 1293 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1294 assert(channel < HW_ENET_TCSRn_COUNT);
bogdanm 82:6473597d706e 1295 HW_ENET_TCCRn_WR(instance,channel, compareValue);
bogdanm 82:6473597d706e 1296 }
bogdanm 82:6473597d706e 1297
bogdanm 82:6473597d706e 1298 /*!
bogdanm 82:6473597d706e 1299 * @brief Gets the 1588 timer channel status.
bogdanm 82:6473597d706e 1300 *
bogdanm 82:6473597d706e 1301 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1302 * @param channel The 1588 timer channel number
bogdanm 82:6473597d706e 1303 * @return Compare or capture operation status
bogdanm 82:6473597d706e 1304 * - True if the compare or capture has occurred.
bogdanm 82:6473597d706e 1305 * - False if the compare or capture has not occurred.
bogdanm 82:6473597d706e 1306 */
bogdanm 82:6473597d706e 1307 static inline bool enet_hal_get_timer_channel_status(uint32_t instance, uint32_t channel)
bogdanm 82:6473597d706e 1308 {
bogdanm 82:6473597d706e 1309 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1310 assert(channel < HW_ENET_TCSRn_COUNT);
bogdanm 82:6473597d706e 1311
bogdanm 82:6473597d706e 1312 return BR_ENET_TCSRn_TF(instance,channel);
bogdanm 82:6473597d706e 1313 }
bogdanm 82:6473597d706e 1314
bogdanm 82:6473597d706e 1315 /*!
bogdanm 82:6473597d706e 1316 * @brief Clears the 1588 timer channel flag.
bogdanm 82:6473597d706e 1317 *
bogdanm 82:6473597d706e 1318 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1319 * @param channel The 1588 timer channel number
bogdanm 82:6473597d706e 1320 */
bogdanm 82:6473597d706e 1321 static inline void enet_hal_clear_timer_channel_flag(uint32_t instance, uint32_t channel)
bogdanm 82:6473597d706e 1322 {
bogdanm 82:6473597d706e 1323 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1324 assert(channel < HW_ENET_TCSRn_COUNT);
bogdanm 82:6473597d706e 1325 HW_ENET_TCSRn_SET(instance, channel, BM_ENET_TCSRn_TF);/* clear interrupt flag*/
bogdanm 82:6473597d706e 1326 HW_ENET_TGSR_WR(instance,(1U << channel)); /* clear channel flag*/
bogdanm 82:6473597d706e 1327 }
bogdanm 82:6473597d706e 1328
bogdanm 82:6473597d706e 1329 /*!
bogdanm 82:6473597d706e 1330 * @brief Sets the capture command to the 1588 timer.
bogdanm 82:6473597d706e 1331 *
bogdanm 82:6473597d706e 1332 * This is used before reading the current time register.
bogdanm 82:6473597d706e 1333 * After set timer capture, please wait for about 1us before read
bogdanm 82:6473597d706e 1334 * the captured timer.
bogdanm 82:6473597d706e 1335 *
bogdanm 82:6473597d706e 1336 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1337 */
bogdanm 82:6473597d706e 1338 static inline void enet_hal_set_timer_capture(uint32_t instance)
bogdanm 82:6473597d706e 1339 {
bogdanm 82:6473597d706e 1340 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1341
bogdanm 82:6473597d706e 1342 HW_ENET_ATCR_SET(instance, BM_ENET_ATCR_CAPTURE);
bogdanm 82:6473597d706e 1343 }
bogdanm 82:6473597d706e 1344
bogdanm 82:6473597d706e 1345 /*!
bogdanm 82:6473597d706e 1346 * @brief Sets the 1588 timer.
bogdanm 82:6473597d706e 1347 *
bogdanm 82:6473597d706e 1348 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1349 * @param nanSecond The nanosecond set to 1588 timer
bogdanm 82:6473597d706e 1350 */
bogdanm 82:6473597d706e 1351 static inline void enet_hal_set_current_time(uint32_t instance, uint32_t nanSecond)
bogdanm 82:6473597d706e 1352 {
bogdanm 82:6473597d706e 1353 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1354
bogdanm 82:6473597d706e 1355 HW_ENET_ATVR_WR(instance,nanSecond);
bogdanm 82:6473597d706e 1356 }
bogdanm 82:6473597d706e 1357
bogdanm 82:6473597d706e 1358 /*!
bogdanm 82:6473597d706e 1359 * @brief Gets the time from the 1588 timer.
bogdanm 82:6473597d706e 1360 *
bogdanm 82:6473597d706e 1361 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1362 * @return the current time from 1588 timer
bogdanm 82:6473597d706e 1363 */
bogdanm 82:6473597d706e 1364 static inline uint32_t enet_hal_get_current_time(uint32_t instance)
bogdanm 82:6473597d706e 1365 {
bogdanm 82:6473597d706e 1366 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1367
bogdanm 82:6473597d706e 1368 return HW_ENET_ATVR_RD(instance);
bogdanm 82:6473597d706e 1369 }
bogdanm 82:6473597d706e 1370
bogdanm 82:6473597d706e 1371 /*!
bogdanm 82:6473597d706e 1372 * @brief Gets the transmit timestamp.
bogdanm 82:6473597d706e 1373 *
bogdanm 82:6473597d706e 1374 * @param instance The ENET instance number
bogdanm 82:6473597d706e 1375 * @return The timestamp of the last transmitted frame
bogdanm 82:6473597d706e 1376 */
bogdanm 82:6473597d706e 1377 static inline uint32_t enet_hal_get_tx_timestamp(uint32_t instance)
bogdanm 82:6473597d706e 1378 {
bogdanm 82:6473597d706e 1379 assert(instance < HW_ENET_INSTANCE_COUNT);
bogdanm 82:6473597d706e 1380
bogdanm 82:6473597d706e 1381 return HW_ENET_ATSTMP_RD(instance);
bogdanm 82:6473597d706e 1382 }
bogdanm 82:6473597d706e 1383
bogdanm 82:6473597d706e 1384 /*!
bogdanm 82:6473597d706e 1385 * @brief Gets the transmit buffer descriptor timestamp flag.
bogdanm 82:6473597d706e 1386 *
bogdanm 82:6473597d706e 1387 * @param curBd The ENET transmit buffer descriptor
bogdanm 82:6473597d706e 1388 * @return true if timestamp region is set else false.
bogdanm 82:6473597d706e 1389 */
bogdanm 82:6473597d706e 1390 bool enet_hal_get_txbd_timestamp_flag(void *curBd);
bogdanm 82:6473597d706e 1391
bogdanm 82:6473597d706e 1392 /*!
bogdanm 82:6473597d706e 1393 * @brief Gets the buffer descriptor timestamp.
bogdanm 82:6473597d706e 1394 *
bogdanm 82:6473597d706e 1395 * @param null
bogdanm 82:6473597d706e 1396 * @return The the size of the buffer descriptor
bogdanm 82:6473597d706e 1397 */
bogdanm 82:6473597d706e 1398 static inline uint32_t enet_hal_get_bd_size(void)
bogdanm 82:6473597d706e 1399 {
bogdanm 82:6473597d706e 1400 return sizeof(enet_bd_struct_t);
bogdanm 82:6473597d706e 1401 }
bogdanm 82:6473597d706e 1402
bogdanm 82:6473597d706e 1403 /* @} */
bogdanm 82:6473597d706e 1404
bogdanm 82:6473597d706e 1405 #if defined(__cplusplus)
bogdanm 82:6473597d706e 1406 }
bogdanm 82:6473597d706e 1407 #endif
bogdanm 82:6473597d706e 1408
bogdanm 82:6473597d706e 1409 /*! @}*/
bogdanm 82:6473597d706e 1410 #endif /*!< __FSL_ENET_HAL_H__*/
bogdanm 82:6473597d706e 1411
bogdanm 82:6473597d706e 1412 /*******************************************************************************
bogdanm 82:6473597d706e 1413 * EOF
bogdanm 82:6473597d706e 1414 ******************************************************************************/
bogdanm 82:6473597d706e 1415