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:
Wed May 21 23:15:06 2014 +0100
Revision:
204:92d082577917
Parent:
149:1fb5f62b92bd
Child:
324:406fd2029f23
Synchronized with git revision 3c2119fab6f21f7d8fdce8bd96665bbaf8e5beec

Full URL: https://github.com/mbedmicro/mbed/commit/3c2119fab6f21f7d8fdce8bd96665bbaf8e5beec/

Signed-off-by: Sergio Scaglia <sergio.scaglia@arm.com>

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 204:92d082577917 348 #define TX_DESC_UPDATED_MASK (0x8000)
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 204:92d082577917 369 #define TX_DESC_UPDATED_MASK (0x0080)
mbed_official 146:f64d43ff0c18 370 #endif
mbed_official 146:f64d43ff0c18 371
mbed_official 146:f64d43ff0c18 372 /*! @brief Defines the configuration structure for the 1588 PTP timer.*/
mbed_official 146:f64d43ff0c18 373 typedef struct ENETConfigPtpTimer
mbed_official 146:f64d43ff0c18 374 {
mbed_official 146:f64d43ff0c18 375 bool isSlaveEnabled; /*!< Master or slave PTP timer*/
mbed_official 146:f64d43ff0c18 376 uint32_t clockIncease; /*!< Timer increase value each clock period*/
mbed_official 146:f64d43ff0c18 377 uint32_t period; /*!< Timer period for generate interrupt event */
mbed_official 146:f64d43ff0c18 378 } enet_config_ptp_timer_t;
mbed_official 146:f64d43ff0c18 379
mbed_official 146:f64d43ff0c18 380 /*! @brief Defines the transmit accelerator configuration.*/
mbed_official 146:f64d43ff0c18 381 typedef struct ENETConfigTxAccelerator
mbed_official 146:f64d43ff0c18 382 {
mbed_official 146:f64d43ff0c18 383 bool isIpCheckEnabled; /*!< Insert IP header checksum */
mbed_official 146:f64d43ff0c18 384 bool isProtocolCheckEnabled; /*!< Insert protocol checksum*/
mbed_official 146:f64d43ff0c18 385 bool isShift16Enabled; /*!< Tx FIFO shift-16*/
mbed_official 146:f64d43ff0c18 386 } enet_config_tx_accelerator_t;
mbed_official 146:f64d43ff0c18 387
mbed_official 146:f64d43ff0c18 388 /*! @brief Defines the receive accelerator configuration.*/
mbed_official 146:f64d43ff0c18 389 typedef struct ENETConfigRxAccelerator
mbed_official 146:f64d43ff0c18 390 {
mbed_official 146:f64d43ff0c18 391 bool isIpcheckEnabled; /*!< Discard with wrong IP header checksum */
mbed_official 146:f64d43ff0c18 392 bool isProtocolCheckEnabled; /*!< Discard with wrong protocol checksum*/
mbed_official 146:f64d43ff0c18 393 bool isMacCheckEnabled; /*!< Discard with Mac layer errors*/
mbed_official 146:f64d43ff0c18 394 bool isPadRemoveEnabled; /*!< Padding removal for short IP frames*/
mbed_official 146:f64d43ff0c18 395 bool isShift16Enabled; /*!< Rx FIFO shift-16*/
mbed_official 146:f64d43ff0c18 396 } enet_config_rx_accelerator_t;
mbed_official 146:f64d43ff0c18 397
mbed_official 146:f64d43ff0c18 398 /*! @brief Defines the transmit FIFO configuration.*/
mbed_official 146:f64d43ff0c18 399 typedef struct ENETConfigTxFifo
mbed_official 146:f64d43ff0c18 400 {
mbed_official 146:f64d43ff0c18 401 bool isStoreForwardEnabled; /*!< Transmit FIFO store and forward */
mbed_official 146:f64d43ff0c18 402 uint8_t txFifoWrite; /*!< Transmit FIFO write */
mbed_official 146:f64d43ff0c18 403 uint8_t txEmpty; /*!< Transmit FIFO section empty threshold*/
mbed_official 146:f64d43ff0c18 404 uint8_t txAlmostEmpty; /*!< Transmit FIFO section almost empty threshold*/
mbed_official 146:f64d43ff0c18 405 uint8_t txAlmostFull; /*!< Transmit FIFO section almost full threshold*/
mbed_official 146:f64d43ff0c18 406 } enet_config_tx_fifo_t;
mbed_official 146:f64d43ff0c18 407
mbed_official 146:f64d43ff0c18 408 /*! @brief Defines the receive FIFO configuration.*/
mbed_official 146:f64d43ff0c18 409 typedef struct ENETConfigRxFifo
mbed_official 146:f64d43ff0c18 410 {
mbed_official 146:f64d43ff0c18 411 uint8_t rxFull; /*!< Receive FIFO section full threshold*/
mbed_official 146:f64d43ff0c18 412 uint8_t rxAlmostFull; /*!< Receive FIFO section almost full threshold*/
mbed_official 146:f64d43ff0c18 413 uint8_t rxEmpty; /*!< Receive FIFO section empty threshold*/
mbed_official 146:f64d43ff0c18 414 uint8_t rxAlmostEmpty; /*!< Receive FIFO section almost empty threshold*/
mbed_official 146:f64d43ff0c18 415 } enet_config_rx_fifo_t;
mbed_official 146:f64d43ff0c18 416
mbed_official 146:f64d43ff0c18 417 /*******************************************************************************
mbed_official 146:f64d43ff0c18 418 * API
mbed_official 146:f64d43ff0c18 419 ******************************************************************************/
mbed_official 146:f64d43ff0c18 420
mbed_official 146:f64d43ff0c18 421 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 422 extern "C" {
mbed_official 146:f64d43ff0c18 423 #endif
mbed_official 146:f64d43ff0c18 424
mbed_official 146:f64d43ff0c18 425 /*!
mbed_official 146:f64d43ff0c18 426 * @brief Resets the ENET module.
mbed_official 146:f64d43ff0c18 427 *
mbed_official 146:f64d43ff0c18 428 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 429 */
mbed_official 146:f64d43ff0c18 430 static inline void enet_hal_reset_ethernet(uint32_t instance)
mbed_official 146:f64d43ff0c18 431 {
mbed_official 146:f64d43ff0c18 432 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 433
mbed_official 146:f64d43ff0c18 434 HW_ENET_ECR_SET(instance, BM_ENET_ECR_RESET);
mbed_official 146:f64d43ff0c18 435 }
mbed_official 146:f64d43ff0c18 436
mbed_official 146:f64d43ff0c18 437 /*!
mbed_official 146:f64d43ff0c18 438 * @brief Gets the ENET status to check whether the reset has completed.
mbed_official 146:f64d43ff0c18 439 *
mbed_official 146:f64d43ff0c18 440 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 441 * @return Current status of the reset operation
mbed_official 146:f64d43ff0c18 442 * - true if ENET reset completed.
mbed_official 146:f64d43ff0c18 443 * - false if ENET reset has not completed.
mbed_official 146:f64d43ff0c18 444 */
mbed_official 146:f64d43ff0c18 445 static inline bool enet_hal_is_reset_completed(uint32_t instance)
mbed_official 146:f64d43ff0c18 446 {
mbed_official 146:f64d43ff0c18 447 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 448
mbed_official 146:f64d43ff0c18 449 return (BR_ENET_ECR_RESET(instance) == 0);
mbed_official 146:f64d43ff0c18 450 }
mbed_official 146:f64d43ff0c18 451
mbed_official 146:f64d43ff0c18 452 /*!
mbed_official 146:f64d43ff0c18 453 * @brief Enable or disable stop mode.
mbed_official 146:f64d43ff0c18 454 *
mbed_official 146:f64d43ff0c18 455 * Enable stop mode will control device behavior in doze mode.
mbed_official 146:f64d43ff0c18 456 * In doze mode, if this filed is set then all clock of the enet assemably are
mbed_official 146:f64d43ff0c18 457 * disabled, except the RMII/MII clock.
mbed_official 146:f64d43ff0c18 458 *
mbed_official 146:f64d43ff0c18 459 * @param instance The ENET instance number.
mbed_official 146:f64d43ff0c18 460 * @param isEnabled The switch to enable/disable stop mode.
mbed_official 146:f64d43ff0c18 461 * - true to enabale the stop mode.
mbed_official 146:f64d43ff0c18 462 * - false to disable the stop mode.
mbed_official 146:f64d43ff0c18 463 */
mbed_official 146:f64d43ff0c18 464 static inline void enet_hal_enable_stop(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 465 {
mbed_official 146:f64d43ff0c18 466 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 467 BW_ENET_ECR_STOPEN(instance, isEnabled);
mbed_official 146:f64d43ff0c18 468 }
mbed_official 146:f64d43ff0c18 469 /*!
mbed_official 146:f64d43ff0c18 470 * @brief Enable or disable sleep mode.
mbed_official 146:f64d43ff0c18 471 *
mbed_official 146:f64d43ff0c18 472 * Enable sleep mode will disable normal operating mode. When enable the sleep
mbed_official 146:f64d43ff0c18 473 * mode, the magic packet detection is also enabled so that a remote agent can
mbed_official 146:f64d43ff0c18 474 * wakeup the node.
mbed_official 146:f64d43ff0c18 475 *
mbed_official 146:f64d43ff0c18 476 * @param instance The ENET instance number.
mbed_official 146:f64d43ff0c18 477 * @param isEnabled The switch to enable/disable the sleep mode.
mbed_official 146:f64d43ff0c18 478 * - true to enabale the sleep mode.
mbed_official 146:f64d43ff0c18 479 * - false to disable the sleep mode.
mbed_official 146:f64d43ff0c18 480 */
mbed_official 146:f64d43ff0c18 481 static inline void enet_hal_enable_sleep(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 482 {
mbed_official 146:f64d43ff0c18 483 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 484 BW_ENET_ECR_SLEEP(instance, isEnabled);
mbed_official 146:f64d43ff0c18 485 BW_ENET_ECR_MAGICEN(instance, isEnabled);
mbed_official 146:f64d43ff0c18 486 }
mbed_official 146:f64d43ff0c18 487
mbed_official 146:f64d43ff0c18 488 /*!
mbed_official 146:f64d43ff0c18 489 * @brief Sets the Mac address.
mbed_official 146:f64d43ff0c18 490 *
mbed_official 146:f64d43ff0c18 491 * This interface sets the six-byte Mac address of the ENET interface.
mbed_official 146:f64d43ff0c18 492 *
mbed_official 146:f64d43ff0c18 493 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 494 * @param hwAddr The mac address pointer store for six bytes Mac address
mbed_official 146:f64d43ff0c18 495 */
mbed_official 146:f64d43ff0c18 496 void enet_hal_set_mac_address(uint32_t instance, enetMacAddr hwAddr);
mbed_official 146:f64d43ff0c18 497
mbed_official 146:f64d43ff0c18 498 /*!
mbed_official 146:f64d43ff0c18 499 * @brief Sets the hardware addressing filtering to a multicast group address.
mbed_official 146:f64d43ff0c18 500 *
mbed_official 146:f64d43ff0c18 501 * This interface is used to add the ENET device to a multicast group address.
mbed_official 146:f64d43ff0c18 502 * After joining the group, Mac receives all frames with the group Mac address.
mbed_official 146:f64d43ff0c18 503 *
mbed_official 146:f64d43ff0c18 504 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 505 * @param crcValue The CRC value of the special address
mbed_official 146:f64d43ff0c18 506 * @param mode The operation for init/enable/disable the specified hardware address
mbed_official 146:f64d43ff0c18 507 */
mbed_official 146:f64d43ff0c18 508 void enet_hal_set_group_hashtable(uint32_t instance, uint32_t crcValue, enet_special_address_filter_t mode);
mbed_official 146:f64d43ff0c18 509
mbed_official 146:f64d43ff0c18 510 /*!
mbed_official 146:f64d43ff0c18 511 * @brief Sets the hardware addressing filtering to an individual address.
mbed_official 146:f64d43ff0c18 512 *
mbed_official 146:f64d43ff0c18 513 * This interface is used to add an individual address to the hardware address
mbed_official 146:f64d43ff0c18 514 * filter. Mac receives all frames with the individual address as a destination address.
mbed_official 146:f64d43ff0c18 515 *
mbed_official 146:f64d43ff0c18 516 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 517 * @param crcValue The CRC value of the special address
mbed_official 146:f64d43ff0c18 518 * @param mode The operation for init/enable/disable the specified hardware address
mbed_official 146:f64d43ff0c18 519 */
mbed_official 146:f64d43ff0c18 520 void enet_hal_set_individual_hashtable(uint32_t instance, uint32_t crcValue, enet_special_address_filter_t mode);
mbed_official 146:f64d43ff0c18 521
mbed_official 146:f64d43ff0c18 522 /*!
mbed_official 146:f64d43ff0c18 523 * @brief Enable/disable payload length check.
mbed_official 146:f64d43ff0c18 524 *
mbed_official 146:f64d43ff0c18 525 * If the length/type is less than 0x600,When enable payload length check
mbed_official 146:f64d43ff0c18 526 * the core checks the fame's payload length. If the length/type is greater
mbed_official 146:f64d43ff0c18 527 * than or equal to 0x600. The MAC interprets the field as a type and no
mbed_official 146:f64d43ff0c18 528 * payload length check is performanced.
mbed_official 146:f64d43ff0c18 529 *
mbed_official 146:f64d43ff0c18 530 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 531 * @param isEnabled The switch to enable/disable payload length check
mbed_official 146:f64d43ff0c18 532 * - True to enabale payload length check.
mbed_official 146:f64d43ff0c18 533 * - False to disable payload legnth check.
mbed_official 146:f64d43ff0c18 534 */
mbed_official 146:f64d43ff0c18 535 static inline void enet_hal_enable_payloadcheck(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 536 {
mbed_official 146:f64d43ff0c18 537 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 538 BW_ENET_RCR_NLC(instance, isEnabled);
mbed_official 146:f64d43ff0c18 539 }
mbed_official 146:f64d43ff0c18 540
mbed_official 146:f64d43ff0c18 541 /*!
mbed_official 146:f64d43ff0c18 542 * @brief Enable/disable append CRC to transmitted frames.
mbed_official 146:f64d43ff0c18 543 *
mbed_official 146:f64d43ff0c18 544 * If transmit CRC forward is enabled, the transmit buffer descriptor controls
mbed_official 146:f64d43ff0c18 545 * whether the frame has a CRC from the application. If transmit CRC forward is disabled,
mbed_official 146:f64d43ff0c18 546 * transmitter does not append any CRC to transmitted frames.
mbed_official 146:f64d43ff0c18 547 *
mbed_official 146:f64d43ff0c18 548 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 549 * @param isEnabled The switch to enable/disable transmit the receive CRC
mbed_official 146:f64d43ff0c18 550 * - True the transmitter control CRC through transmit buffer descriptor.
mbed_official 146:f64d43ff0c18 551 * - False the transmitter does not append any CRC to transmitted frames.
mbed_official 146:f64d43ff0c18 552 */
mbed_official 146:f64d43ff0c18 553 static inline void enet_hal_enable_txcrcforward(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 554 {
mbed_official 146:f64d43ff0c18 555 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 556 BW_ENET_TCR_CRCFWD(instance, !isEnabled);
mbed_official 146:f64d43ff0c18 557 }
mbed_official 146:f64d43ff0c18 558
mbed_official 146:f64d43ff0c18 559 /*!
mbed_official 146:f64d43ff0c18 560 * @brief Enable/disable forward the CRC filed of the received frame.
mbed_official 146:f64d43ff0c18 561 *
mbed_official 146:f64d43ff0c18 562 * This is used to deceide whether the CRC field of received frame is transmitted
mbed_official 146:f64d43ff0c18 563 * or stripped. Enable this feature to strip CRC field from the frame.
mbed_official 146:f64d43ff0c18 564 * If padding remove is enabled, this feature will be ignored and
mbed_official 146:f64d43ff0c18 565 * the CRC field is checked and always terminated and removed.
mbed_official 146:f64d43ff0c18 566 *
mbed_official 146:f64d43ff0c18 567 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 568 * @param isEnabled The switch to enable/disable transmit the receive CRC
mbed_official 146:f64d43ff0c18 569 * - True to transmit the received CRC.
mbed_official 146:f64d43ff0c18 570 * - False to strip the received CRC.
mbed_official 146:f64d43ff0c18 571 */
mbed_official 146:f64d43ff0c18 572 static inline void enet_hal_enable_rxcrcforward(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 573 {
mbed_official 146:f64d43ff0c18 574 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 575 BW_ENET_RCR_CRCFWD(instance, !isEnabled);
mbed_official 146:f64d43ff0c18 576 }
mbed_official 146:f64d43ff0c18 577 /*!
mbed_official 146:f64d43ff0c18 578 * @brief Enable/disable forward PAUSE frames.
mbed_official 146:f64d43ff0c18 579 *
mbed_official 146:f64d43ff0c18 580 * This is used to deceide whether PAUSE frames is forwarded or discarded.
mbed_official 146:f64d43ff0c18 581 *
mbed_official 146:f64d43ff0c18 582 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 583 * @param isEnabled The switch to enable/disable forward PAUSE frames
mbed_official 146:f64d43ff0c18 584 * - True to forward PAUSE frames.
mbed_official 146:f64d43ff0c18 585 * - False to terminate and discard PAUSE frames.
mbed_official 146:f64d43ff0c18 586 */
mbed_official 146:f64d43ff0c18 587 static inline void enet_hal_enable_pauseforward(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 588 {
mbed_official 146:f64d43ff0c18 589 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 590 BW_ENET_RCR_PAUFWD(instance, isEnabled);
mbed_official 146:f64d43ff0c18 591 }
mbed_official 146:f64d43ff0c18 592
mbed_official 146:f64d43ff0c18 593 /*!
mbed_official 146:f64d43ff0c18 594 * @brief Enable/disable frame padding remove on receive.
mbed_official 146:f64d43ff0c18 595 *
mbed_official 146:f64d43ff0c18 596 * Enable frame padding remove will remove the padding from the received frames.
mbed_official 146:f64d43ff0c18 597 *
mbed_official 146:f64d43ff0c18 598 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 599 * @param isEnabled The switch to enable/disable remove padding
mbed_official 146:f64d43ff0c18 600 * - True to remove padding from frames.
mbed_official 146:f64d43ff0c18 601 * - False to disable padding remove.
mbed_official 146:f64d43ff0c18 602 */
mbed_official 146:f64d43ff0c18 603 static inline void enet_hal_enable_padremove(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 604 {
mbed_official 146:f64d43ff0c18 605 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 606 BW_ENET_RCR_PADEN(instance, isEnabled);
mbed_official 146:f64d43ff0c18 607 }
mbed_official 146:f64d43ff0c18 608
mbed_official 146:f64d43ff0c18 609 /*!
mbed_official 146:f64d43ff0c18 610 * @brief Enable/disable flow control.
mbed_official 146:f64d43ff0c18 611 *
mbed_official 146:f64d43ff0c18 612 * If flow control is enabled, the receive detects PAUSE frames.
mbed_official 146:f64d43ff0c18 613 * Upon PAUSE frame detection, the transmitter stops transmitting
mbed_official 146:f64d43ff0c18 614 * data frames for a given duration.
mbed_official 146:f64d43ff0c18 615 *
mbed_official 146:f64d43ff0c18 616 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 617 * @param isEnabled The switch to enable/disable flow control
mbed_official 146:f64d43ff0c18 618 * - True to enable the flow control.
mbed_official 146:f64d43ff0c18 619 * - False to disable the flow control.
mbed_official 146:f64d43ff0c18 620 */
mbed_official 146:f64d43ff0c18 621 static inline void enet_hal_enable_flowcontrol(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 622 {
mbed_official 146:f64d43ff0c18 623 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 624 BW_ENET_RCR_CFEN(instance, isEnabled);
mbed_official 146:f64d43ff0c18 625 BW_ENET_RCR_FCE(instance, isEnabled);
mbed_official 146:f64d43ff0c18 626 }
mbed_official 146:f64d43ff0c18 627
mbed_official 146:f64d43ff0c18 628 /*!
mbed_official 146:f64d43ff0c18 629 * @brief Enable/disable broadcast frame reject.
mbed_official 146:f64d43ff0c18 630 *
mbed_official 146:f64d43ff0c18 631 * If broadcast frame reject is enabled, frames with destination address
mbed_official 146:f64d43ff0c18 632 * equal to 0xffff_ffff_ffff are rejected unless the promiscuous mode is open.
mbed_official 146:f64d43ff0c18 633 *
mbed_official 146:f64d43ff0c18 634 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 635 * @param isEnabled The switch to enable/disable reject broadcast frames
mbed_official 146:f64d43ff0c18 636 * - True to reject broadcast frames.
mbed_official 146:f64d43ff0c18 637 * - False to accept broadcast frames.
mbed_official 146:f64d43ff0c18 638 */
mbed_official 146:f64d43ff0c18 639 static inline void enet_hal_enable_broadcastreject(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 640 {
mbed_official 146:f64d43ff0c18 641 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 642 BW_ENET_RCR_BC_REJ(instance, isEnabled);
mbed_official 146:f64d43ff0c18 643 }
mbed_official 146:f64d43ff0c18 644
mbed_official 146:f64d43ff0c18 645 /*!
mbed_official 146:f64d43ff0c18 646 * @brief Sets PAUSE duration for a PAUSE frame.
mbed_official 146:f64d43ff0c18 647 *
mbed_official 146:f64d43ff0c18 648 * This function is used to set the pause duraion used in transmission
mbed_official 146:f64d43ff0c18 649 * of a PAUSE frame. When another node detects a PAUSE frame, that node
mbed_official 146:f64d43ff0c18 650 * pauses transmission for the pause duration.
mbed_official 146:f64d43ff0c18 651 *
mbed_official 146:f64d43ff0c18 652 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 653 * @param pauseDuration The PAUSE duration for the transmitted PAUSE frame
mbed_official 146:f64d43ff0c18 654 * the maximum pause duration is 0xFFFF.
mbed_official 146:f64d43ff0c18 655 */
mbed_official 146:f64d43ff0c18 656 static inline void enet_hal_set_pauseduration(uint32_t instance, uint32_t pauseDuration)
mbed_official 146:f64d43ff0c18 657 {
mbed_official 146:f64d43ff0c18 658 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 659 assert(pauseDuration <= BM_ENET_OPD_PAUSE_DUR);
mbed_official 146:f64d43ff0c18 660 BW_ENET_OPD_PAUSE_DUR(instance, pauseDuration);
mbed_official 146:f64d43ff0c18 661 }
mbed_official 146:f64d43ff0c18 662
mbed_official 146:f64d43ff0c18 663 /*!
mbed_official 146:f64d43ff0c18 664 * @brief Gets receive PAUSE frame status.
mbed_official 146:f64d43ff0c18 665 *
mbed_official 146:f64d43ff0c18 666 * This function is used to get the received PAUSE frame status.
mbed_official 146:f64d43ff0c18 667 *
mbed_official 146:f64d43ff0c18 668 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 669 * @return The status of the received flow control frames
mbed_official 146:f64d43ff0c18 670 * true if the flow control pause frame is received.
mbed_official 146:f64d43ff0c18 671 * false if there is no flow control frame received or the pause duration is complete.
mbed_official 146:f64d43ff0c18 672 */
mbed_official 146:f64d43ff0c18 673 static inline bool enet_hal_get_rxpause_status(uint32_t instance)
mbed_official 146:f64d43ff0c18 674 {
mbed_official 146:f64d43ff0c18 675 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 676 return BR_ENET_TCR_RFC_PAUSE(instance);
mbed_official 146:f64d43ff0c18 677 }
mbed_official 146:f64d43ff0c18 678 /*!
mbed_official 146:f64d43ff0c18 679 * @brief Enables transmit frame control PAUSE.
mbed_official 146:f64d43ff0c18 680 *
mbed_official 146:f64d43ff0c18 681 * This function enables pauses frame transmission.
mbed_official 146:f64d43ff0c18 682 * When this is set, with transmission of data frames stopped, the MAC
mbed_official 146:f64d43ff0c18 683 * transmits a MAC control PAUSE frame. NEXT, the MAC clear the
mbed_official 146:f64d43ff0c18 684 * and resumes transmitting data frames.
mbed_official 146:f64d43ff0c18 685 *
mbed_official 146:f64d43ff0c18 686 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 687 * @param isEnabled The switch to enable/disable PAUSE control frame transmission
mbed_official 146:f64d43ff0c18 688 * - True enable PAUSE control frame transmission.
mbed_official 146:f64d43ff0c18 689 * - Flase disable PAUSE control frame transmission.
mbed_official 146:f64d43ff0c18 690 */
mbed_official 146:f64d43ff0c18 691 static inline void enet_hal_enable_txpause(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 692 {
mbed_official 146:f64d43ff0c18 693 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 694 BW_ENET_TCR_TFC_PAUSE(instance, isEnabled);
mbed_official 146:f64d43ff0c18 695 }
mbed_official 146:f64d43ff0c18 696
mbed_official 146:f64d43ff0c18 697 /*!
mbed_official 146:f64d43ff0c18 698 * @brief Sets transmit PAUSE frame.
mbed_official 146:f64d43ff0c18 699 *
mbed_official 146:f64d43ff0c18 700 * This function Sets ENET transmit controller with pause duration.
mbed_official 146:f64d43ff0c18 701 * And set the transmit control to do PAUSE frame transmission
mbed_official 146:f64d43ff0c18 702 * This should be called when a PAUSE frame is dynamically wanted.
mbed_official 146:f64d43ff0c18 703 *
mbed_official 146:f64d43ff0c18 704 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 705 */
mbed_official 146:f64d43ff0c18 706 void enet_hal_set_txpause(uint32_t instance, uint32_t pauseDuration);
mbed_official 146:f64d43ff0c18 707
mbed_official 146:f64d43ff0c18 708 /*!
mbed_official 146:f64d43ff0c18 709 * @brief Sets the transmit inter-packet gap.
mbed_official 146:f64d43ff0c18 710 *
mbed_official 146:f64d43ff0c18 711 * This function indicates the IPG, in bytes, between transmitted frames.
mbed_official 146:f64d43ff0c18 712 * Valid values range from 8 to 27. If value is less than 8, the IPG is 8.
mbed_official 146:f64d43ff0c18 713 * If value is greater than 27, the IPG is 27.
mbed_official 146:f64d43ff0c18 714 *
mbed_official 146:f64d43ff0c18 715 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 716 * @param ipgValue The IPG for transmitted frames
mbed_official 146:f64d43ff0c18 717 * The default value is 12, the maximum value set to ipg is 0x1F.
mbed_official 146:f64d43ff0c18 718 *
mbed_official 146:f64d43ff0c18 719 */
mbed_official 146:f64d43ff0c18 720 static inline void enet_hal_set_txipg(uint32_t instance, uint32_t ipgValue)
mbed_official 146:f64d43ff0c18 721 {
mbed_official 146:f64d43ff0c18 722 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 723 assert(ipgValue <= BM_ENET_TIPG_IPG);
mbed_official 146:f64d43ff0c18 724 BW_ENET_TIPG_IPG(instance, ipgValue);
mbed_official 146:f64d43ff0c18 725 }
mbed_official 146:f64d43ff0c18 726
mbed_official 146:f64d43ff0c18 727 /*!
mbed_official 146:f64d43ff0c18 728 * @brief Sets the receive frame truncation length.
mbed_official 146:f64d43ff0c18 729 *
mbed_official 146:f64d43ff0c18 730 * This function indicates the value a receive frame is truncated,
mbed_official 146:f64d43ff0c18 731 * if it is greater than this value. The frame truncation length must be greater
mbed_official 146:f64d43ff0c18 732 * than or equal to the receive maximum frame length.
mbed_official 146:f64d43ff0c18 733 *
mbed_official 146:f64d43ff0c18 734 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 735 * @param length The truncation length. The maximum value is 0x3FFF
mbed_official 146:f64d43ff0c18 736 * The default truncation length is 2047(0x7FF).
mbed_official 146:f64d43ff0c18 737 *
mbed_official 146:f64d43ff0c18 738 */
mbed_official 146:f64d43ff0c18 739 static inline void enet_hal_set_truncationlen(uint32_t instance, uint32_t length)
mbed_official 146:f64d43ff0c18 740 {
mbed_official 146:f64d43ff0c18 741 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 742 assert(length <= BM_ENET_FTRL_TRUNC_FL);
mbed_official 146:f64d43ff0c18 743 BW_ENET_FTRL_TRUNC_FL(instance, length);
mbed_official 146:f64d43ff0c18 744 }
mbed_official 146:f64d43ff0c18 745
mbed_official 146:f64d43ff0c18 746 /*!
mbed_official 146:f64d43ff0c18 747 * @brief Sets the maximum receive buffer size and the maximum frame size.
mbed_official 146:f64d43ff0c18 748 *
mbed_official 146:f64d43ff0c18 749 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 750 * @param maxBufferSize The maximum receive buffer size, which should not be smaller than 256
mbed_official 146:f64d43ff0c18 751 * It should be evenly divisible by 16 and the maximum receive size should not be larger than 0x3ff0.
mbed_official 146:f64d43ff0c18 752 * @param maxFrameSize The maximum receive frame size, the reset value is 1518 or 1522 if the VLAN tags are
mbed_official 146:f64d43ff0c18 753 * supported. The length is measured starting at DA and including the CRC.
mbed_official 146:f64d43ff0c18 754 */
mbed_official 146:f64d43ff0c18 755 static inline void enet_hal_set_rx_max_size(uint32_t instance, uint32_t maxBufferSize, uint32_t maxFrameSize)
mbed_official 146:f64d43ff0c18 756 {
mbed_official 146:f64d43ff0c18 757 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 758 /* max buffer size must larger than 256 to minimize bus usage*/
mbed_official 146:f64d43ff0c18 759 assert(maxBufferSize >= 256);
mbed_official 146:f64d43ff0c18 760 assert(maxFrameSize <= (BM_ENET_RCR_MAX_FL >> BP_ENET_RCR_MAX_FL));
mbed_official 146:f64d43ff0c18 761
mbed_official 146:f64d43ff0c18 762 BW_ENET_RCR_MAX_FL(instance, maxFrameSize);
mbed_official 146:f64d43ff0c18 763 HW_ENET_MRBR_WR(instance, (maxBufferSize & BM_ENET_MRBR_R_BUF_SIZE));
mbed_official 146:f64d43ff0c18 764 }
mbed_official 146:f64d43ff0c18 765
mbed_official 146:f64d43ff0c18 766 /*!
mbed_official 146:f64d43ff0c18 767 * @brief Configures the ENET transmit FIFO.
mbed_official 146:f64d43ff0c18 768 *
mbed_official 146:f64d43ff0c18 769 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 770 * @param thresholdCfg The FIFO threshold configuration
mbed_official 146:f64d43ff0c18 771 */
mbed_official 146:f64d43ff0c18 772 void enet_hal_config_tx_fifo(uint32_t instance, enet_config_tx_fifo_t *thresholdCfg);
mbed_official 146:f64d43ff0c18 773
mbed_official 146:f64d43ff0c18 774 /*!
mbed_official 146:f64d43ff0c18 775 * @brief Configures the ENET receive FIFO.
mbed_official 146:f64d43ff0c18 776 *
mbed_official 146:f64d43ff0c18 777 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 778 * @param thresholdCfg The FIFO threshold configuration
mbed_official 146:f64d43ff0c18 779 */
mbed_official 146:f64d43ff0c18 780 void enet_hal_config_rx_fifo(uint32_t instance, enet_config_rx_fifo_t *thresholdCfg);
mbed_official 146:f64d43ff0c18 781
mbed_official 146:f64d43ff0c18 782 /*!
mbed_official 146:f64d43ff0c18 783 * @brief Sets the start address for ENET receive buffer descriptors.
mbed_official 146:f64d43ff0c18 784 *
mbed_official 146:f64d43ff0c18 785 * This interface provides the beginning of the receive
mbed_official 146:f64d43ff0c18 786 * and receive buffer descriptor queue in the external memory. The
mbed_official 146:f64d43ff0c18 787 * txbdAddr is recommended to be 128-bit aligned, must be evenly divisible by 16.
mbed_official 146:f64d43ff0c18 788 *
mbed_official 146:f64d43ff0c18 789 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 790 * @param rxBdAddr The start address of receive buffer descriptors
mbed_official 146:f64d43ff0c18 791 */
mbed_official 146:f64d43ff0c18 792 static inline void enet_hal_set_rxbd_address(uint32_t instance, uint32_t rxBdAddr)
mbed_official 146:f64d43ff0c18 793 {
mbed_official 146:f64d43ff0c18 794 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 795
mbed_official 146:f64d43ff0c18 796 HW_ENET_RDSR_WR(instance,rxBdAddr); /* Initialize receive buffer descriptor start address*/
mbed_official 146:f64d43ff0c18 797 }
mbed_official 146:f64d43ff0c18 798 /*!
mbed_official 146:f64d43ff0c18 799 * @brief Sets the start address for ENET transmit buffer descriptors.
mbed_official 146:f64d43ff0c18 800 *
mbed_official 146:f64d43ff0c18 801 * This interface provides the beginning of the receive
mbed_official 146:f64d43ff0c18 802 * and transmit buffer descriptor queue in the external memory. The
mbed_official 146:f64d43ff0c18 803 * txbdAddr is recommended to be 128-bit aligned, must be evenly divisible by 16.
mbed_official 146:f64d43ff0c18 804 *
mbed_official 146:f64d43ff0c18 805 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 806 * @param txBdAddr The start address of transmit buffer descriptors
mbed_official 146:f64d43ff0c18 807 */
mbed_official 146:f64d43ff0c18 808 static inline void enet_hal_set_txbd_address(uint32_t instance, uint32_t txBdAddr)
mbed_official 146:f64d43ff0c18 809 {
mbed_official 146:f64d43ff0c18 810 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 811
mbed_official 146:f64d43ff0c18 812 HW_ENET_TDSR_WR(instance,txBdAddr); /* Initialize transmit buffer descriptor start address*/
mbed_official 146:f64d43ff0c18 813 }
mbed_official 146:f64d43ff0c18 814
mbed_official 146:f64d43ff0c18 815 /*!
mbed_official 146:f64d43ff0c18 816 * @brief Initializes the receive buffer descriptors.
mbed_official 146:f64d43ff0c18 817 *
mbed_official 146:f64d43ff0c18 818 * To make sure the uDMA will do the right data transfer after you activate
mbed_official 146:f64d43ff0c18 819 * with wrap flag and all the buffer descriptors should be initialized with an empty bit.
mbed_official 146:f64d43ff0c18 820 *
mbed_official 146:f64d43ff0c18 821 * @param rxBds The current receive buffer descriptor
mbed_official 146:f64d43ff0c18 822 * @param buffer The data buffer on buffer descriptor
mbed_official 146:f64d43ff0c18 823 * @param isLastBd The flag to indicate the last receive buffer descriptor
mbed_official 146:f64d43ff0c18 824 */
mbed_official 146:f64d43ff0c18 825 void enet_hal_init_rxbds(void *rxBds, uint8_t *buffer, bool isLastBd);
mbed_official 146:f64d43ff0c18 826
mbed_official 146:f64d43ff0c18 827 /*!
mbed_official 146:f64d43ff0c18 828 * @brief Initializes the transmit buffer descriptors.
mbed_official 146:f64d43ff0c18 829 *
mbed_official 146:f64d43ff0c18 830 * To make sure the uDMA will do the right data transfer after you active
mbed_official 146:f64d43ff0c18 831 * with wrap flag.
mbed_official 146:f64d43ff0c18 832 *
mbed_official 146:f64d43ff0c18 833 * @param txBds The current transmit buffer descriptor.
mbed_official 146:f64d43ff0c18 834 * @param isLastBd The last transmit buffer descriptor flag.
mbed_official 146:f64d43ff0c18 835 */
mbed_official 146:f64d43ff0c18 836 void enet_hal_init_txbds(void *txBds, bool isLastBd);
mbed_official 146:f64d43ff0c18 837
mbed_official 146:f64d43ff0c18 838 /*!
mbed_official 146:f64d43ff0c18 839 * @brief Updates the receive buffer descriptors.
mbed_official 146:f64d43ff0c18 840 *
mbed_official 146:f64d43ff0c18 841 * This interface mainly clears the status region and updates the received
mbed_official 146:f64d43ff0c18 842 * buffer descriptor to ensure that the BD is correctly used.
mbed_official 146:f64d43ff0c18 843 *
mbed_official 146:f64d43ff0c18 844 * @param rxBds The current receive buffer descriptor
mbed_official 146:f64d43ff0c18 845 * @param data The data buffer address
mbed_official 146:f64d43ff0c18 846 * @param isbufferUpdate The data buffer update flag. When you want to update
mbed_official 146:f64d43ff0c18 847 * the data buffer of the buffer descriptor ensure that this flag
mbed_official 146:f64d43ff0c18 848 * is set.
mbed_official 146:f64d43ff0c18 849 */
mbed_official 146:f64d43ff0c18 850 void enet_hal_update_rxbds(void *rxBds, uint8_t *data, bool isbufferUpdate);
mbed_official 146:f64d43ff0c18 851
mbed_official 146:f64d43ff0c18 852 /*!
mbed_official 146:f64d43ff0c18 853 * @brief Initializes the transmit buffer descriptors.
mbed_official 146:f64d43ff0c18 854 *
mbed_official 146:f64d43ff0c18 855 * Ensures that the uDMA transfer data correctly after the user activates
mbed_official 146:f64d43ff0c18 856 * with the wrap flag.
mbed_official 146:f64d43ff0c18 857 *
mbed_official 146:f64d43ff0c18 858 * @param txBds The current transmit buffer descriptor
mbed_official 146:f64d43ff0c18 859 * @param isLastBd The last transmit buffer descriptor flag
mbed_official 146:f64d43ff0c18 860 */
mbed_official 146:f64d43ff0c18 861 void enet_hal_init_txbds(void *txBds, bool isLastBd);
mbed_official 146:f64d43ff0c18 862
mbed_official 146:f64d43ff0c18 863 /*!
mbed_official 146:f64d43ff0c18 864 * @brief Updates the transmit buffer descriptors.
mbed_official 146:f64d43ff0c18 865 *
mbed_official 146:f64d43ff0c18 866 * This interface mainly clears the status region and updates the transmit
mbed_official 146:f64d43ff0c18 867 * buffer descriptor to ensure tat this BD is correctly used again.
mbed_official 146:f64d43ff0c18 868 * You should set the isTxtsCfged when the transmit timestamp feature is required.
mbed_official 146:f64d43ff0c18 869 *
mbed_official 146:f64d43ff0c18 870 * @param txBds The current transmit buffer descriptor
mbed_official 146:f64d43ff0c18 871 * @param buffer The data buffer on buffer descriptor
mbed_official 146:f64d43ff0c18 872 * @param length The data length on buffer descriptor
mbed_official 146:f64d43ff0c18 873 * @param isTxtsCfged The timestamp configure flag. The timestamp is
mbed_official 146:f64d43ff0c18 874 * added to the transmit buffer descriptor when this flag is set.
mbed_official 146:f64d43ff0c18 875 */
mbed_official 146:f64d43ff0c18 876 void enet_hal_update_txbds(void *txBds,uint8_t *buffer, uint16_t length, bool isTxtsCfged);
mbed_official 146:f64d43ff0c18 877
mbed_official 146:f64d43ff0c18 878 /*!
mbed_official 146:f64d43ff0c18 879 * @brief Clears the context in the transmit buffer descriptors.
mbed_official 146:f64d43ff0c18 880 *
mbed_official 146:f64d43ff0c18 881 * Clears the data, length, control, and status region of the transmit buffer descriptor.
mbed_official 146:f64d43ff0c18 882 *
mbed_official 146:f64d43ff0c18 883 * @param curBd The current buffer descriptor
mbed_official 146:f64d43ff0c18 884 */
mbed_official 146:f64d43ff0c18 885 static inline void enet_hal_clear_txbds(void *curBd)
mbed_official 146:f64d43ff0c18 886 {
mbed_official 146:f64d43ff0c18 887 assert(curBd);
mbed_official 146:f64d43ff0c18 888
mbed_official 146:f64d43ff0c18 889 volatile enet_bd_struct_t *bdPtr = (enet_bd_struct_t *)curBd;
mbed_official 146:f64d43ff0c18 890 bdPtr->length = 0; /* Set data length*/
mbed_official 146:f64d43ff0c18 891 bdPtr->buffer = (uint8_t *)(NULL);/* Set data buffer*/
mbed_official 146:f64d43ff0c18 892 bdPtr->control &= (kEnetTxBdWrap);/* Set control */
mbed_official 146:f64d43ff0c18 893 }
mbed_official 146:f64d43ff0c18 894
mbed_official 146:f64d43ff0c18 895 /*!
mbed_official 146:f64d43ff0c18 896 * @brief Gets the control and the status region of the receive buffer descriptors.
mbed_official 146:f64d43ff0c18 897 *
mbed_official 146:f64d43ff0c18 898 * This interface can get the whole control and status region of the
mbed_official 146:f64d43ff0c18 899 * receive buffer descriptor. The enet_rx_bd_control_status_t enum type
mbed_official 146:f64d43ff0c18 900 * definition should be used if you want to get each status bit of
mbed_official 146:f64d43ff0c18 901 * the control and status region.
mbed_official 146:f64d43ff0c18 902 *
mbed_official 146:f64d43ff0c18 903 * @param curBd The current receive buffer descriptor
mbed_official 146:f64d43ff0c18 904 * @return The control and status data on buffer descriptors
mbed_official 146:f64d43ff0c18 905 */
mbed_official 146:f64d43ff0c18 906 uint16_t enet_hal_get_rxbd_control(void *curBd);
mbed_official 146:f64d43ff0c18 907
mbed_official 146:f64d43ff0c18 908 /*!
mbed_official 146:f64d43ff0c18 909 * @brief Gets the control and the status region of the transmit buffer descriptors.
mbed_official 146:f64d43ff0c18 910 *
mbed_official 146:f64d43ff0c18 911 * This interface can get the whole control and status region of the
mbed_official 146:f64d43ff0c18 912 * transmit buffer descriptor. The enet_tx_bd_control_status_t enum type
mbed_official 146:f64d43ff0c18 913 * definition should be used if you want to get each status bit of
mbed_official 146:f64d43ff0c18 914 * the control and status region.
mbed_official 146:f64d43ff0c18 915 *
mbed_official 146:f64d43ff0c18 916 * @param curBd The current transmit buffer descriptor
mbed_official 146:f64d43ff0c18 917 * @return The extended control region of transmit buffer descriptor
mbed_official 146:f64d43ff0c18 918 */
mbed_official 146:f64d43ff0c18 919 uint16_t enet_hal_get_txbd_control(void *curBd);
mbed_official 146:f64d43ff0c18 920
mbed_official 146:f64d43ff0c18 921 /*!
mbed_official 146:f64d43ff0c18 922 * @brief Gets the extended control region of the receive buffer descriptors.
mbed_official 146:f64d43ff0c18 923 *
mbed_official 146:f64d43ff0c18 924 * This interface can get the whole control and status region of the
mbed_official 146:f64d43ff0c18 925 * receive buffer descriptor. The enet_rx_bd_control_extend_t enum type
mbed_official 146:f64d43ff0c18 926 * definition should be used if you want to get each status bit of
mbed_official 146:f64d43ff0c18 927 * the control and status region.
mbed_official 146:f64d43ff0c18 928 *
mbed_official 146:f64d43ff0c18 929 * @param curBd The current receive buffer descriptor
mbed_official 146:f64d43ff0c18 930 * @param controlRegion The different control region
mbed_official 146:f64d43ff0c18 931 * @return The extended control region data of receive buffer descriptor
mbed_official 146:f64d43ff0c18 932 * - true when the control region is set
mbed_official 146:f64d43ff0c18 933 * - false when the control region is not set
mbed_official 146:f64d43ff0c18 934 */
mbed_official 146:f64d43ff0c18 935 bool enet_hal_get_rxbd_control_extend(void *curBd,enet_rx_bd_control_extend_t controlRegion);
mbed_official 146:f64d43ff0c18 936 /*!
mbed_official 146:f64d43ff0c18 937 * @brief Gets the extended control region of the transmit buffer descriptors.
mbed_official 146:f64d43ff0c18 938 *
mbed_official 146:f64d43ff0c18 939 * This interface can get the whole control and status region of the
mbed_official 146:f64d43ff0c18 940 * transmit buffer descriptor. The enet_tx_bd_control_extend_t enum type
mbed_official 146:f64d43ff0c18 941 * definition should be used if you want to get each status bit of
mbed_official 146:f64d43ff0c18 942 * the control and status region.
mbed_official 146:f64d43ff0c18 943 *
mbed_official 146:f64d43ff0c18 944 * @param curBd The current transmit buffer descriptor
mbed_official 146:f64d43ff0c18 945 * @return The extended control data
mbed_official 146:f64d43ff0c18 946 */
mbed_official 146:f64d43ff0c18 947 uint16_t enet_hal_get_txbd_control_extend(void *curBd);
mbed_official 146:f64d43ff0c18 948
mbed_official 146:f64d43ff0c18 949 /*!
mbed_official 146:f64d43ff0c18 950 * @brief Gets the data length of the buffer descriptors.
mbed_official 146:f64d43ff0c18 951 *
mbed_official 146:f64d43ff0c18 952 * @param curBd The current buffer descriptor
mbed_official 146:f64d43ff0c18 953 * @return The data length of the buffer descriptor
mbed_official 146:f64d43ff0c18 954 */
mbed_official 146:f64d43ff0c18 955 uint16_t enet_hal_get_bd_length(void *curBd);
mbed_official 146:f64d43ff0c18 956
mbed_official 146:f64d43ff0c18 957 /*!
mbed_official 146:f64d43ff0c18 958 * @brief Gets the buffer address of the buffer descriptors.
mbed_official 146:f64d43ff0c18 959 *
mbed_official 146:f64d43ff0c18 960 * @param curBd The current buffer descriptor
mbed_official 146:f64d43ff0c18 961 * @return The buffer address of the buffer descriptor
mbed_official 146:f64d43ff0c18 962 */
mbed_official 146:f64d43ff0c18 963 uint8_t* enet_hal_get_bd_buffer(void *curBd);
mbed_official 146:f64d43ff0c18 964
mbed_official 146:f64d43ff0c18 965 /*!
mbed_official 146:f64d43ff0c18 966 * @brief Gets the timestamp of the buffer descriptors.
mbed_official 146:f64d43ff0c18 967 *
mbed_official 146:f64d43ff0c18 968 * @param curBd The current buffer descriptor
mbed_official 146:f64d43ff0c18 969 * @return The time stamp of the frame in the buffer descriptor.
mbed_official 146:f64d43ff0c18 970 * Notice that the frame timestamp is only set in the last
mbed_official 146:f64d43ff0c18 971 * buffer descriptor of the frame.
mbed_official 146:f64d43ff0c18 972 */
mbed_official 146:f64d43ff0c18 973 uint32_t enet_hal_get_bd_timestamp(void *curBd);
mbed_official 146:f64d43ff0c18 974
mbed_official 146:f64d43ff0c18 975 /*!
mbed_official 146:f64d43ff0c18 976 * @brief Activates the receive buffer descriptor.
mbed_official 146:f64d43ff0c18 977 *
mbed_official 146:f64d43ff0c18 978 * The buffer descriptor activation
mbed_official 146:f64d43ff0c18 979 * should be done after the ENET module is enabled. Otherwise, the activation fails.
mbed_official 146:f64d43ff0c18 980 *
mbed_official 146:f64d43ff0c18 981 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 982 */
mbed_official 146:f64d43ff0c18 983 static inline void enet_hal_active_rxbd(uint32_t instance)
mbed_official 146:f64d43ff0c18 984 {
mbed_official 146:f64d43ff0c18 985 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 986
mbed_official 146:f64d43ff0c18 987 HW_ENET_RDAR_SET(instance, BM_ENET_RDAR_RDAR);
mbed_official 146:f64d43ff0c18 988 }
mbed_official 146:f64d43ff0c18 989
mbed_official 146:f64d43ff0c18 990 /*!
mbed_official 146:f64d43ff0c18 991 * @brief Activates the transmit buffer descriptor.
mbed_official 146:f64d43ff0c18 992 *
mbed_official 146:f64d43ff0c18 993 * The buffer descriptor activation should be done after the ENET module is
mbed_official 146:f64d43ff0c18 994 * enabled. Otherwise, the activation fails.
mbed_official 146:f64d43ff0c18 995 *
mbed_official 146:f64d43ff0c18 996 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 997 */
mbed_official 146:f64d43ff0c18 998 static inline void enet_hal_active_txbd(uint32_t instance)
mbed_official 146:f64d43ff0c18 999 {
mbed_official 146:f64d43ff0c18 1000 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1001
mbed_official 146:f64d43ff0c18 1002 HW_ENET_TDAR_SET(instance, BM_ENET_TDAR_TDAR);
mbed_official 146:f64d43ff0c18 1003 }
mbed_official 146:f64d43ff0c18 1004
mbed_official 146:f64d43ff0c18 1005 /*!
mbed_official 146:f64d43ff0c18 1006 * @brief Configures the (R)MII of ENET.
mbed_official 146:f64d43ff0c18 1007 *
mbed_official 146:f64d43ff0c18 1008 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1009 * @param mode The RMII or MII mode
mbed_official 146:f64d43ff0c18 1010 * @param speed The speed of RMII
mbed_official 146:f64d43ff0c18 1011 * @param duplex The full or half duplex mode
mbed_official 146:f64d43ff0c18 1012 * @param isRxOnTxDisabled The Receive on transmit disable flag
mbed_official 146:f64d43ff0c18 1013 * @param isLoopEnabled The loop enable flag
mbed_official 146:f64d43ff0c18 1014 */
mbed_official 146:f64d43ff0c18 1015 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 1016
mbed_official 146:f64d43ff0c18 1017 /*!
mbed_official 146:f64d43ff0c18 1018 * @brief Configures the MII of ENET.
mbed_official 146:f64d43ff0c18 1019 *
mbed_official 146:f64d43ff0c18 1020 * Sets the MII interface between Mac and PHY. The miiSpeed is
mbed_official 146:f64d43ff0c18 1021 * a value that controls the frequency of the MDC, relative to the internal module clock(InterClockSrc).
mbed_official 146:f64d43ff0c18 1022 * A value of zero in this parameter turns the MDC off and leaves it in the low voltage state.
mbed_official 146:f64d43ff0c18 1023 * Any non-zero value results in the MDC frequency MDC = InterClockSrc/((miiSpeed + 1)*2).
mbed_official 146:f64d43ff0c18 1024 * So miiSpeed = InterClockSrc/(2*MDC) - 1.
mbed_official 146:f64d43ff0c18 1025 * The Maximum MDC clock is 2.5MHZ(maximum). We should round up and plus one to simlplify:
mbed_official 146:f64d43ff0c18 1026 * miiSpeed = InterClockSrc/(2*2.5MHZ).
mbed_official 146:f64d43ff0c18 1027 *
mbed_official 146:f64d43ff0c18 1028 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1029 * @param miiSpeed The MII speed and it is ranged from 0~0x3F
mbed_official 146:f64d43ff0c18 1030 * @param time The holdon clock cycles for MDIO output
mbed_official 146:f64d43ff0c18 1031 * @param isPreambleDisabled The preamble disabled flag
mbed_official 146:f64d43ff0c18 1032 */
mbed_official 146:f64d43ff0c18 1033 static inline void enet_hal_config_mii(uint32_t instance, uint32_t miiSpeed,
mbed_official 146:f64d43ff0c18 1034 enet_mdio_holdon_clkcycle_t clkCycle, bool isPreambleDisabled)
mbed_official 146:f64d43ff0c18 1035 {
mbed_official 146:f64d43ff0c18 1036 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1037
mbed_official 146:f64d43ff0c18 1038 BW_ENET_MSCR_MII_SPEED(instance, miiSpeed); /* MII speed set*/
mbed_official 146:f64d43ff0c18 1039 BW_ENET_MSCR_DIS_PRE(instance, isPreambleDisabled); /* Preamble is disabled*/
mbed_official 146:f64d43ff0c18 1040 BW_ENET_MSCR_HOLDTIME(instance, clkCycle); /* hold on clock cycles for MDIO output*/
mbed_official 146:f64d43ff0c18 1041
mbed_official 146:f64d43ff0c18 1042 }
mbed_official 146:f64d43ff0c18 1043
mbed_official 146:f64d43ff0c18 1044 /*!
mbed_official 146:f64d43ff0c18 1045 * @brief Gets the MII configuration status.
mbed_official 146:f64d43ff0c18 1046 *
mbed_official 146:f64d43ff0c18 1047 * This interface is usually called to check the MII interface before
mbed_official 146:f64d43ff0c18 1048 * the Mac writes or reads the PHY registers.
mbed_official 146:f64d43ff0c18 1049 *
mbed_official 146:f64d43ff0c18 1050 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1051 * @return The MII configuration status
mbed_official 146:f64d43ff0c18 1052 * - true if the MII has been configured.
mbed_official 146:f64d43ff0c18 1053 * - false if the MII has not been configured.
mbed_official 146:f64d43ff0c18 1054 */
mbed_official 146:f64d43ff0c18 1055 static inline bool enet_hal_is_mii_enabled(uint32_t instance)
mbed_official 146:f64d43ff0c18 1056 {
mbed_official 146:f64d43ff0c18 1057 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1058
mbed_official 146:f64d43ff0c18 1059 return (HW_ENET_MSCR_RD(instance) & 0x7E)!= 0;
mbed_official 146:f64d43ff0c18 1060 }
mbed_official 146:f64d43ff0c18 1061
mbed_official 146:f64d43ff0c18 1062 /*!
mbed_official 146:f64d43ff0c18 1063 * @brief Reads data from PHY.
mbed_official 146:f64d43ff0c18 1064 *
mbed_official 146:f64d43ff0c18 1065 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1066 * @return The data read from PHY
mbed_official 146:f64d43ff0c18 1067 */
mbed_official 146:f64d43ff0c18 1068 static inline uint32_t enet_hal_get_mii_data(uint32_t instance)
mbed_official 146:f64d43ff0c18 1069 {
mbed_official 146:f64d43ff0c18 1070 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1071
mbed_official 146:f64d43ff0c18 1072 return (uint32_t)BR_ENET_MMFR_DATA(instance);
mbed_official 146:f64d43ff0c18 1073 }
mbed_official 146:f64d43ff0c18 1074
mbed_official 146:f64d43ff0c18 1075 /*!
mbed_official 146:f64d43ff0c18 1076 * @brief Sets the MII command.
mbed_official 146:f64d43ff0c18 1077 *
mbed_official 146:f64d43ff0c18 1078 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1079 * @param phyAddr The PHY address
mbed_official 146:f64d43ff0c18 1080 * @param phyReg The PHY register
mbed_official 146:f64d43ff0c18 1081 * @param operation The read or write operation
mbed_official 146:f64d43ff0c18 1082 * @param data The data written to PHY
mbed_official 146:f64d43ff0c18 1083 */
mbed_official 146:f64d43ff0c18 1084 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 1085
mbed_official 146:f64d43ff0c18 1086 /*!
mbed_official 146:f64d43ff0c18 1087 * @brief Enables/Disables the ENET module.
mbed_official 146:f64d43ff0c18 1088 *
mbed_official 146:f64d43ff0c18 1089 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1090 * @param isEnhanced The enhanced 1588 feature switch
mbed_official 146:f64d43ff0c18 1091 * @param isEnabled The ENET module enable switch
mbed_official 146:f64d43ff0c18 1092 */
mbed_official 146:f64d43ff0c18 1093 void enet_hal_config_ethernet(uint32_t instance, bool isEnhanced, bool isEnabled);
mbed_official 146:f64d43ff0c18 1094
mbed_official 146:f64d43ff0c18 1095 /*!
mbed_official 146:f64d43ff0c18 1096 * @brief Enables/Disables the ENET interrupt.
mbed_official 146:f64d43ff0c18 1097 *
mbed_official 146:f64d43ff0c18 1098 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1099 * @param source The interrupt sources. enet_interrupt_request_t enum types
mbed_official 146:f64d43ff0c18 1100 * is recommended as the interrupt source.
mbed_official 146:f64d43ff0c18 1101 * @param isEnabled The interrupt enable switch
mbed_official 146:f64d43ff0c18 1102 */
mbed_official 146:f64d43ff0c18 1103 void enet_hal_config_interrupt(uint32_t instance, uint32_t source, bool isEnabled);
mbed_official 146:f64d43ff0c18 1104
mbed_official 146:f64d43ff0c18 1105 /*!
mbed_official 146:f64d43ff0c18 1106 * @brief Clears ENET interrupt events.
mbed_official 146:f64d43ff0c18 1107 *
mbed_official 146:f64d43ff0c18 1108 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1109 * @param source The interrupt source to be cleared. enet_interrupt_request_t
mbed_official 146:f64d43ff0c18 1110 * enum types is recommended as the interrupt source.
mbed_official 146:f64d43ff0c18 1111 */
mbed_official 146:f64d43ff0c18 1112 static inline void enet_hal_clear_interrupt(uint32_t instance, uint32_t source)
mbed_official 146:f64d43ff0c18 1113 {
mbed_official 146:f64d43ff0c18 1114 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1115
mbed_official 146:f64d43ff0c18 1116 HW_ENET_EIR_WR(instance,source);
mbed_official 146:f64d43ff0c18 1117 }
mbed_official 146:f64d43ff0c18 1118
mbed_official 146:f64d43ff0c18 1119 /*!
mbed_official 146:f64d43ff0c18 1120 * @brief Gets the ENET interrupt status.
mbed_official 146:f64d43ff0c18 1121 *
mbed_official 146:f64d43ff0c18 1122 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1123 * @param source The interrupt sources. enet_interrupt_request_t
mbed_official 146:f64d43ff0c18 1124 * enum types is recommended as the interrupt source.
mbed_official 146:f64d43ff0c18 1125 * @return The event status of the interrupt source
mbed_official 146:f64d43ff0c18 1126 * - true if the interrupt event happened.
mbed_official 146:f64d43ff0c18 1127 * - false if the interrupt event has not happened.
mbed_official 146:f64d43ff0c18 1128 */
mbed_official 146:f64d43ff0c18 1129 static inline bool enet_hal_get_interrupt_status(uint32_t instance, uint32_t source)
mbed_official 146:f64d43ff0c18 1130 {
mbed_official 146:f64d43ff0c18 1131 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1132
mbed_official 146:f64d43ff0c18 1133 return ((HW_ENET_EIR_RD(instance) & source) != 0);
mbed_official 146:f64d43ff0c18 1134 }
mbed_official 146:f64d43ff0c18 1135
mbed_official 146:f64d43ff0c18 1136 /*
mbed_official 146:f64d43ff0c18 1137 * @brief Enables/disables the ENET promiscuous mode.
mbed_official 146:f64d43ff0c18 1138 *
mbed_official 146:f64d43ff0c18 1139 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1140 * @param isEnabled The enable switch
mbed_official 146:f64d43ff0c18 1141 */
mbed_official 146:f64d43ff0c18 1142 static inline void enet_hal_config_promiscuous(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 1143 {
mbed_official 146:f64d43ff0c18 1144 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1145
mbed_official 146:f64d43ff0c18 1146 BW_ENET_RCR_PROM(instance,isEnabled);
mbed_official 146:f64d43ff0c18 1147 }
mbed_official 146:f64d43ff0c18 1148
mbed_official 146:f64d43ff0c18 1149 /*!
mbed_official 146:f64d43ff0c18 1150 * @brief Enables/disables the clear MIB counter.
mbed_official 146:f64d43ff0c18 1151 *
mbed_official 146:f64d43ff0c18 1152 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1153 * @param isEnabled The enable switch
mbed_official 146:f64d43ff0c18 1154 */
mbed_official 146:f64d43ff0c18 1155 static inline void enet_hal_clear_mib(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 1156 {
mbed_official 146:f64d43ff0c18 1157 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1158
mbed_official 146:f64d43ff0c18 1159 BW_ENET_MIBC_MIB_CLEAR(instance, isEnabled);
mbed_official 146:f64d43ff0c18 1160
mbed_official 146:f64d43ff0c18 1161 }
mbed_official 146:f64d43ff0c18 1162
mbed_official 146:f64d43ff0c18 1163 /*!
mbed_official 146:f64d43ff0c18 1164 * @brief Sets the enable/disable of the MIB block.
mbed_official 146:f64d43ff0c18 1165 *
mbed_official 146:f64d43ff0c18 1166 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1167 * @param isEnabled The enable flag
mbed_official 146:f64d43ff0c18 1168 * - True to enabale MIB block.
mbed_official 146:f64d43ff0c18 1169 * - False to disable MIB block.
mbed_official 146:f64d43ff0c18 1170 */
mbed_official 146:f64d43ff0c18 1171 static inline void enet_hal_enable_mib(uint32_t instance, bool isEnabled)
mbed_official 146:f64d43ff0c18 1172 {
mbed_official 146:f64d43ff0c18 1173 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1174
mbed_official 146:f64d43ff0c18 1175 BW_ENET_MIBC_MIB_DIS(instance,!isEnabled);
mbed_official 146:f64d43ff0c18 1176
mbed_official 146:f64d43ff0c18 1177 }
mbed_official 146:f64d43ff0c18 1178
mbed_official 146:f64d43ff0c18 1179 /*!
mbed_official 146:f64d43ff0c18 1180 * @brief Gets the MIB idle status.
mbed_official 146:f64d43ff0c18 1181 *
mbed_official 146:f64d43ff0c18 1182 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1183 * @return true if in MIB idle and MIB is not updating else false.
mbed_official 146:f64d43ff0c18 1184 */
mbed_official 146:f64d43ff0c18 1185 static inline bool enet_hal_get_mib_status(uint32_t instance)
mbed_official 146:f64d43ff0c18 1186 {
mbed_official 146:f64d43ff0c18 1187 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1188
mbed_official 146:f64d43ff0c18 1189 return BR_ENET_MIBC_MIB_IDLE(instance);
mbed_official 146:f64d43ff0c18 1190 }
mbed_official 146:f64d43ff0c18 1191
mbed_official 146:f64d43ff0c18 1192 /*!
mbed_official 146:f64d43ff0c18 1193 * @brief Sets the transmit accelerator.
mbed_official 146:f64d43ff0c18 1194 *
mbed_official 146:f64d43ff0c18 1195 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1196 * @param txCfgPtr The transmit accelerator configuration
mbed_official 146:f64d43ff0c18 1197 */
mbed_official 146:f64d43ff0c18 1198 void enet_hal_config_tx_accelerator(uint32_t instance, enet_config_tx_accelerator_t *txCfgPtr);
mbed_official 146:f64d43ff0c18 1199
mbed_official 146:f64d43ff0c18 1200 /*!
mbed_official 146:f64d43ff0c18 1201 * @brief Sets the receive accelerator.
mbed_official 146:f64d43ff0c18 1202 *
mbed_official 146:f64d43ff0c18 1203 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1204 * @param rxCfgPtr The receive accelerator configuration
mbed_official 146:f64d43ff0c18 1205 */
mbed_official 146:f64d43ff0c18 1206 void enet_hal_config_rx_accelerator(uint32_t instance, enet_config_rx_accelerator_t *rxCfgPtr);
mbed_official 146:f64d43ff0c18 1207
mbed_official 146:f64d43ff0c18 1208 /*!
mbed_official 146:f64d43ff0c18 1209 * @brief Initializes the 1588 timer.
mbed_official 146:f64d43ff0c18 1210 *
mbed_official 146:f64d43ff0c18 1211 * This interface initializes the 1588 context structure.
mbed_official 146:f64d43ff0c18 1212 * Initialize 1588 parameters according to the user configuration structure.
mbed_official 146:f64d43ff0c18 1213 *
mbed_official 146:f64d43ff0c18 1214 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1215 * @param ptpCfg The 1588 timer configuration
mbed_official 146:f64d43ff0c18 1216 */
mbed_official 146:f64d43ff0c18 1217 void enet_hal_init_ptp_timer(uint32_t instance, enet_config_ptp_timer_t *ptpCfgPtr);
mbed_official 146:f64d43ff0c18 1218
mbed_official 146:f64d43ff0c18 1219 /*!
mbed_official 146:f64d43ff0c18 1220 * @brief Enables or disables the 1588 timer.
mbed_official 146:f64d43ff0c18 1221 *
mbed_official 146:f64d43ff0c18 1222 * Enable the PTP timer will starts the timer. Disable the timer will stop timer
mbed_official 146:f64d43ff0c18 1223 * at the current value.
mbed_official 146:f64d43ff0c18 1224 *
mbed_official 146:f64d43ff0c18 1225 * @param instance The ENET instance number.
mbed_official 146:f64d43ff0c18 1226 * @param isEnabled The 1588 timer Enable switch
mbed_official 146:f64d43ff0c18 1227 * - True enbaled the 1588 PTP timer.
mbed_official 146:f64d43ff0c18 1228 * - False disable or stop the 1588 PTP timer.
mbed_official 146:f64d43ff0c18 1229 */
mbed_official 146:f64d43ff0c18 1230 static inline void enet_hal_enable_ptp_timer(uint32_t instance, uint32_t isEnabled)
mbed_official 146:f64d43ff0c18 1231 {
mbed_official 146:f64d43ff0c18 1232 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1233
mbed_official 146:f64d43ff0c18 1234 BW_ENET_ATCR_EN(instance,isEnabled);
mbed_official 146:f64d43ff0c18 1235 }
mbed_official 146:f64d43ff0c18 1236
mbed_official 146:f64d43ff0c18 1237 /*!
mbed_official 146:f64d43ff0c18 1238 * @brief Restarts the 1588 timer.
mbed_official 146:f64d43ff0c18 1239 *
mbed_official 146:f64d43ff0c18 1240 * Restarting the PTP timer clears all PTP-timer counters to zero.
mbed_official 146:f64d43ff0c18 1241 *
mbed_official 146:f64d43ff0c18 1242 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1243 */
mbed_official 146:f64d43ff0c18 1244 static inline void enet_hal_restart_ptp_timer(uint32_t instance)
mbed_official 146:f64d43ff0c18 1245 {
mbed_official 146:f64d43ff0c18 1246 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1247
mbed_official 146:f64d43ff0c18 1248 BW_ENET_ATCR_RESTART(instance,1);
mbed_official 146:f64d43ff0c18 1249 }
mbed_official 146:f64d43ff0c18 1250
mbed_official 146:f64d43ff0c18 1251 /*!
mbed_official 146:f64d43ff0c18 1252 * @brief Adjusts the 1588 timer.
mbed_official 146:f64d43ff0c18 1253 *
mbed_official 146:f64d43ff0c18 1254 * Adjust the 1588 timer according to the increase and correction period of the configured correction.
mbed_official 146:f64d43ff0c18 1255 *
mbed_official 146:f64d43ff0c18 1256 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1257 * @param inceaseCorrection The increase correction for 1588 timer
mbed_official 146:f64d43ff0c18 1258 * @param periodCorrection The period correction for 1588 timer
mbed_official 146:f64d43ff0c18 1259 */
mbed_official 146:f64d43ff0c18 1260 static inline void enet_hal_adjust_ptp_timer(uint32_t instance, uint32_t increaseCorrection, uint32_t periodCorrection)
mbed_official 146:f64d43ff0c18 1261 {
mbed_official 146:f64d43ff0c18 1262 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1263
mbed_official 146:f64d43ff0c18 1264 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 1265 /* set correction for ptp timer period*/
mbed_official 146:f64d43ff0c18 1266 HW_ENET_ATCOR_SET(instance, (BM_ENET_ATCOR_COR & periodCorrection));
mbed_official 146:f64d43ff0c18 1267 }
mbed_official 146:f64d43ff0c18 1268
mbed_official 146:f64d43ff0c18 1269 /*!
mbed_official 146:f64d43ff0c18 1270 * @brief Initializes the 1588 timer channel.
mbed_official 146:f64d43ff0c18 1271 *
mbed_official 146:f64d43ff0c18 1272 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1273 * @Param channel The 1588 timer channel number
mbed_official 146:f64d43ff0c18 1274 * @param mode Compare or capture mode for the 1588 timer channel
mbed_official 146:f64d43ff0c18 1275 */
mbed_official 146:f64d43ff0c18 1276 static inline void enet_hal_init_timer_channel(uint32_t instance, uint32_t channel, enet_timer_channel_mode_t mode)
mbed_official 146:f64d43ff0c18 1277 {
mbed_official 146:f64d43ff0c18 1278 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1279 assert(channel < HW_ENET_TCSRn_COUNT);
mbed_official 146:f64d43ff0c18 1280 HW_ENET_TCSRn_SET(instance, channel,
mbed_official 146:f64d43ff0c18 1281 (BM_ENET_TCSRn_TMODE &(mode << BP_ENET_TCSRn_TMODE)));
mbed_official 146:f64d43ff0c18 1282 HW_ENET_TCSRn_SET(instance, channel, BM_ENET_TCSRn_TIE);
mbed_official 146:f64d43ff0c18 1283 }
mbed_official 146:f64d43ff0c18 1284
mbed_official 146:f64d43ff0c18 1285 /*!
mbed_official 146:f64d43ff0c18 1286 * @brief Sets the compare value for the 1588 timer channel.
mbed_official 146:f64d43ff0c18 1287 *
mbed_official 146:f64d43ff0c18 1288 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1289 * @Param channel The 1588 timer channel number
mbed_official 146:f64d43ff0c18 1290 * @param compareValue Compare value for 1588 timer channel
mbed_official 146:f64d43ff0c18 1291 */
mbed_official 146:f64d43ff0c18 1292 static inline void enet_hal_set_timer_channel_compare(uint32_t instance, uint32_t channel, uint32_t compareValue)
mbed_official 146:f64d43ff0c18 1293 {
mbed_official 146:f64d43ff0c18 1294 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1295 assert(channel < HW_ENET_TCSRn_COUNT);
mbed_official 146:f64d43ff0c18 1296 HW_ENET_TCCRn_WR(instance,channel, compareValue);
mbed_official 146:f64d43ff0c18 1297 }
mbed_official 146:f64d43ff0c18 1298
mbed_official 146:f64d43ff0c18 1299 /*!
mbed_official 146:f64d43ff0c18 1300 * @brief Gets the 1588 timer channel status.
mbed_official 146:f64d43ff0c18 1301 *
mbed_official 146:f64d43ff0c18 1302 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1303 * @param channel The 1588 timer channel number
mbed_official 146:f64d43ff0c18 1304 * @return Compare or capture operation status
mbed_official 146:f64d43ff0c18 1305 * - True if the compare or capture has occurred.
mbed_official 146:f64d43ff0c18 1306 * - False if the compare or capture has not occurred.
mbed_official 146:f64d43ff0c18 1307 */
mbed_official 146:f64d43ff0c18 1308 static inline bool enet_hal_get_timer_channel_status(uint32_t instance, uint32_t channel)
mbed_official 146:f64d43ff0c18 1309 {
mbed_official 146:f64d43ff0c18 1310 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1311 assert(channel < HW_ENET_TCSRn_COUNT);
mbed_official 146:f64d43ff0c18 1312
mbed_official 146:f64d43ff0c18 1313 return BR_ENET_TCSRn_TF(instance,channel);
mbed_official 146:f64d43ff0c18 1314 }
mbed_official 146:f64d43ff0c18 1315
mbed_official 146:f64d43ff0c18 1316 /*!
mbed_official 146:f64d43ff0c18 1317 * @brief Clears the 1588 timer channel flag.
mbed_official 146:f64d43ff0c18 1318 *
mbed_official 146:f64d43ff0c18 1319 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1320 * @param channel The 1588 timer channel number
mbed_official 146:f64d43ff0c18 1321 */
mbed_official 146:f64d43ff0c18 1322 static inline void enet_hal_clear_timer_channel_flag(uint32_t instance, uint32_t channel)
mbed_official 146:f64d43ff0c18 1323 {
mbed_official 146:f64d43ff0c18 1324 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1325 assert(channel < HW_ENET_TCSRn_COUNT);
mbed_official 146:f64d43ff0c18 1326 HW_ENET_TCSRn_SET(instance, channel, BM_ENET_TCSRn_TF);/* clear interrupt flag*/
mbed_official 146:f64d43ff0c18 1327 HW_ENET_TGSR_WR(instance,(1U << channel)); /* clear channel flag*/
mbed_official 146:f64d43ff0c18 1328 }
mbed_official 146:f64d43ff0c18 1329
mbed_official 146:f64d43ff0c18 1330 /*!
mbed_official 146:f64d43ff0c18 1331 * @brief Sets the capture command to the 1588 timer.
mbed_official 146:f64d43ff0c18 1332 *
mbed_official 146:f64d43ff0c18 1333 * This is used before reading the current time register.
mbed_official 146:f64d43ff0c18 1334 * After set timer capture, please wait for about 1us before read
mbed_official 146:f64d43ff0c18 1335 * the captured timer.
mbed_official 146:f64d43ff0c18 1336 *
mbed_official 146:f64d43ff0c18 1337 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1338 */
mbed_official 146:f64d43ff0c18 1339 static inline void enet_hal_set_timer_capture(uint32_t instance)
mbed_official 146:f64d43ff0c18 1340 {
mbed_official 146:f64d43ff0c18 1341 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1342
mbed_official 146:f64d43ff0c18 1343 HW_ENET_ATCR_SET(instance, BM_ENET_ATCR_CAPTURE);
mbed_official 146:f64d43ff0c18 1344 }
mbed_official 146:f64d43ff0c18 1345
mbed_official 146:f64d43ff0c18 1346 /*!
mbed_official 146:f64d43ff0c18 1347 * @brief Sets the 1588 timer.
mbed_official 146:f64d43ff0c18 1348 *
mbed_official 146:f64d43ff0c18 1349 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1350 * @param nanSecond The nanosecond set to 1588 timer
mbed_official 146:f64d43ff0c18 1351 */
mbed_official 146:f64d43ff0c18 1352 static inline void enet_hal_set_current_time(uint32_t instance, uint32_t nanSecond)
mbed_official 146:f64d43ff0c18 1353 {
mbed_official 146:f64d43ff0c18 1354 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1355
mbed_official 146:f64d43ff0c18 1356 HW_ENET_ATVR_WR(instance,nanSecond);
mbed_official 146:f64d43ff0c18 1357 }
mbed_official 146:f64d43ff0c18 1358
mbed_official 146:f64d43ff0c18 1359 /*!
mbed_official 146:f64d43ff0c18 1360 * @brief Gets the time from the 1588 timer.
mbed_official 146:f64d43ff0c18 1361 *
mbed_official 146:f64d43ff0c18 1362 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1363 * @return the current time from 1588 timer
mbed_official 146:f64d43ff0c18 1364 */
mbed_official 146:f64d43ff0c18 1365 static inline uint32_t enet_hal_get_current_time(uint32_t instance)
mbed_official 146:f64d43ff0c18 1366 {
mbed_official 146:f64d43ff0c18 1367 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1368
mbed_official 146:f64d43ff0c18 1369 return HW_ENET_ATVR_RD(instance);
mbed_official 146:f64d43ff0c18 1370 }
mbed_official 146:f64d43ff0c18 1371
mbed_official 146:f64d43ff0c18 1372 /*!
mbed_official 146:f64d43ff0c18 1373 * @brief Gets the transmit timestamp.
mbed_official 146:f64d43ff0c18 1374 *
mbed_official 146:f64d43ff0c18 1375 * @param instance The ENET instance number
mbed_official 146:f64d43ff0c18 1376 * @return The timestamp of the last transmitted frame
mbed_official 146:f64d43ff0c18 1377 */
mbed_official 146:f64d43ff0c18 1378 static inline uint32_t enet_hal_get_tx_timestamp(uint32_t instance)
mbed_official 146:f64d43ff0c18 1379 {
mbed_official 146:f64d43ff0c18 1380 assert(instance < HW_ENET_INSTANCE_COUNT);
mbed_official 146:f64d43ff0c18 1381
mbed_official 146:f64d43ff0c18 1382 return HW_ENET_ATSTMP_RD(instance);
mbed_official 146:f64d43ff0c18 1383 }
mbed_official 146:f64d43ff0c18 1384
mbed_official 146:f64d43ff0c18 1385 /*!
mbed_official 146:f64d43ff0c18 1386 * @brief Gets the transmit buffer descriptor timestamp flag.
mbed_official 146:f64d43ff0c18 1387 *
mbed_official 146:f64d43ff0c18 1388 * @param curBd The ENET transmit buffer descriptor
mbed_official 146:f64d43ff0c18 1389 * @return true if timestamp region is set else false.
mbed_official 146:f64d43ff0c18 1390 */
mbed_official 146:f64d43ff0c18 1391 bool enet_hal_get_txbd_timestamp_flag(void *curBd);
mbed_official 146:f64d43ff0c18 1392
mbed_official 146:f64d43ff0c18 1393 /*!
mbed_official 146:f64d43ff0c18 1394 * @brief Gets the buffer descriptor timestamp.
mbed_official 146:f64d43ff0c18 1395 *
mbed_official 146:f64d43ff0c18 1396 * @param null
mbed_official 146:f64d43ff0c18 1397 * @return The the size of the buffer descriptor
mbed_official 146:f64d43ff0c18 1398 */
mbed_official 146:f64d43ff0c18 1399 static inline uint32_t enet_hal_get_bd_size(void)
mbed_official 146:f64d43ff0c18 1400 {
mbed_official 146:f64d43ff0c18 1401 return sizeof(enet_bd_struct_t);
mbed_official 146:f64d43ff0c18 1402 }
mbed_official 146:f64d43ff0c18 1403
mbed_official 146:f64d43ff0c18 1404 /* @} */
mbed_official 146:f64d43ff0c18 1405
mbed_official 146:f64d43ff0c18 1406 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 1407 }
mbed_official 146:f64d43ff0c18 1408 #endif
mbed_official 146:f64d43ff0c18 1409
mbed_official 146:f64d43ff0c18 1410 /*! @}*/
mbed_official 146:f64d43ff0c18 1411 #endif /*!< __FSL_ENET_HAL_H__*/
mbed_official 146:f64d43ff0c18 1412
mbed_official 146:f64d43ff0c18 1413 /*******************************************************************************
mbed_official 146:f64d43ff0c18 1414 * EOF
mbed_official 146:f64d43ff0c18 1415 ******************************************************************************/
mbed_official 146:f64d43ff0c18 1416