mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Apr 03 11:45:06 2014 +0100
Revision:
149:1fb5f62b92bd
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK_MCUS/TARGET_KSDK_CODE/hal/enet/fsl_enet_hal.h@146:f64d43ff0c18
Child:
204:92d082577917
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

Full URL: https://github.com/mbedmicro/mbed/commit/220c0bb39ceee40016e1e86350c058963d01ed42/

Who changed what in which revision?

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