MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ENET: Ethernet Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the 10/100 Mbps Ethernet (ENET)module of MCUXpresso SDK devices.

Use the ENET_GetDefaultConfig() to get the default basic configuration, Use the default configuration unchanged or changed as the input to the ENET_Init() to do basic configuration for ENET module. Call ENET_DescriptorInit() to intialization the descriptors and Call ENET_StartRxTx() to start the ENET engine after all initialization. ENET_Deinit() is used to to ENET Deinitialization.

The MII interface is the interface connected with MAC and PHY. the Serial management interface - MII management interface should be set before any access to the external PHY chip register. Call ENET_SetSMI() to initialize MII management interface. Use ENET_StartSMIRead(), ENET_StartSMIWrite(), and ENET_ReadSMIData() to read/write to PHY registers, ENET_IsSMIBusy() to check the SMI busy status. This function group sets up the MII and serial management SMI interface, gets data from the SMI interface, and starts the SMI read and write command. Use ENET_SetMII() to configure the MII before successfully getting data from the external PHY.

This group provides the ENET mac address set/get operation with ENET_SetMacAddr() and ENET_GetMacAddr(). The ENET_EnterPowerDown() and ENET_ExitPowerDown() can be used to do power management.

This group provide the DMA interrupt get and clear APIs. This can be used by application to create new IRQ handler.

This group functions are low level tx/rx descriptor operations. It is convenient to use these tx/rx APIs to do application specific rx/tx. For TX: Use ENET_IsTxDescriptorDmaOwn(), ENET_SetupTxDescriptor() to build your packet for transfer and ENET_UpdateTxDescriptorTail to update the tx tail pointer. For RX: Use ENET_GetRxDescriptor() to get the received data/length and use the ENET_UpdateRxDescriptor() to update the buffers/status.

When use the Transactional APIs, please make sure to call the ENET_CreateHandler to create the handler which are used to maintain all datas related to tx/tx process.

For ENET receive, the ENET_GetRxFrameSize() function must be called to get the received data size. Then, call the ENET_ReadFrame() function to get the received data.

For ENET transmit, call the ENET_SendFrame() function to send the data out. To save memory and avoid the memory copy in the TX process. The ENET_SendFrame() here is a zero-copy API, so make sure the input data buffers are not requeued or freed before the data are really sent out. To makesure the data buffers reclaim is rightly done. the transmit interrupt must be used. so For transactional APIs here we enabled the tx interrupt in ENET_CreateHandler(). That means the tx interrupt is automatically enabled in transctional APIs. is recommended to be called on the transmit interrupt handler.ENET_ReclaimTxDescriptor() is a transactional API to get the information from the finished transmit data buffers and reclaim the tx index. it is called by the transmit interrupt IRQ handler.

All PTP 1588 fatures are enabled by define "ENET_PTP1588FEATURE_REQUIRED" This function group configures the PTP IEEE 1588 feature, starts/stops/gets/sets/corrects the PTP IEEE 1588 timer, gets the receive/transmit frame timestamp

The ENET_GetRxFrameTime() and ENET_GetTxFrameTime() functions are called by the PTP stack to get the timestamp captured by the ENET driver.

Typical use case

ENET Initialization, receive, and transmit operations

For use the transactional APIs, receive polling Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/enet For the functional API, rx polling Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/enet

Data Structures

struct  enet_rx_bd_struct_t
 Defines the receive descriptor structure has the read-format and write-back format structure. More...
 
struct  enet_tx_bd_struct_t
 Defines the transmit descriptor structure has the read-format and write-back format structure. More...
 
struct  enet_buffer_config_t
 Defines the buffer descriptor configure structure. More...
 
struct  enet_multiqueue_config_t
 Defines the configuration when multi-queue is used. More...
 
struct  enet_config_t
 Defines the basic configuration structure for the ENET device. More...
 
struct  enet_tx_bd_ring_t
 Defines the ENET transmit buffer descriptor ring/queue structure. More...
 
struct  enet_rx_bd_ring_t
 Defines the ENET receive buffer descriptor ring/queue structure. More...
 
struct  enet_handle_t
 Defines the ENET handler structure. More...
 

Typedefs

typedef void(* enet_callback_t )(ENET_Type *base, enet_handle_t *handle, enet_event_t event, uint8_t channel, void *userData)
 ENET callback function. More...
 

Enumerations

enum  _enet_status {
  kStatus_ENET_RxFrameError = MAKE_STATUS(kStatusGroup_ENET, 0U),
  kStatus_ENET_RxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 1U),
  kStatus_ENET_RxFrameEmpty = MAKE_STATUS(kStatusGroup_ENET, 2U),
  kStatus_ENET_TxFrameBusy = MAKE_STATUS(kStatusGroup_ENET, 3U),
  kStatus_ENET_TxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 4U),
  kStatus_ENET_TxFrameOverLen = MAKE_STATUS(kStatusGroup_ENET, 5U)
}
 Defines the status return codes for transaction. More...
 
enum  enet_mii_mode_t {
  kENET_MiiMode = 0U,
  kENET_RmiiMode = 1U
}
 Defines the MII/RMII mode for data interface between the MAC and the PHY. More...
 
enum  enet_mii_speed_t {
  kENET_MiiSpeed10M = 0U,
  kENET_MiiSpeed100M = 1U
}
 Defines the 10/100 Mbps speed for the MII data interface. More...
 
enum  enet_mii_duplex_t {
  kENET_MiiHalfDuplex = 0U,
  kENET_MiiFullDuplex
}
 Defines the half or full duplex for the MII data interface. More...
 
enum  enet_mii_normal_opcode {
  kENET_MiiWriteFrame = 1U,
  kENET_MiiReadFrame = 3U
}
 Define the MII opcode for normal MDIO_CLAUSES_22 Frame. More...
 
enum  enet_dma_burstlen {
  kENET_BurstLen1 = 0x00001U,
  kENET_BurstLen2 = 0x00002U,
  kENET_BurstLen4 = 0x00004U,
  kENET_BurstLen8 = 0x00008U,
  kENET_BurstLen16 = 0x00010U,
  kENET_BurstLen32 = 0x00020U,
  kENET_BurstLen64 = 0x10008U,
  kENET_BurstLen128 = 0x10010U,
  kENET_BurstLen256 = 0x10020U
}
 Define the DMA maximum transmit burst length. More...
 
enum  enet_desc_flag {
  kENET_MiddleFlag = 0,
  kENET_FirstFlagOnly,
  kENET_LastFlagOnly,
  kENET_FirstLastFlag
}
 Define the flag for the descriptor. More...
 
enum  enet_systime_op {
  kENET_SystimeAdd = 0U,
  kENET_SystimeSubtract = 1U
}
 Define the system time adjust operation control. More...
 
enum  enet_ts_rollover_type {
  kENET_BinaryRollover = 0,
  kENET_DigitalRollover = 1
}
 Define the system time rollover control. More...
 
enum  enet_special_config_t {
  kENET_DescDoubleBuffer = 0x0001U,
  kENET_StoreAndForward = 0x0002U,
  kENET_PromiscuousEnable = 0x0004U,
  kENET_FlowControlEnable = 0x0008U,
  kENET_BroadCastRxDisable = 0x0010U,
  kENET_MulticastAllEnable = 0x0020U,
  kENET_8023AS2KPacket = 0x0040U
}
 Defines some special configuration for ENET. More...
 
enum  enet_dma_interrupt_enable_t {
  kENET_DmaTx = ENET_DMA_CH_DMA_CHX_INT_EN_TIE_MASK,
  kENET_DmaTxStop = ENET_DMA_CH_DMA_CHX_INT_EN_TSE_MASK,
  kENET_DmaTxBuffUnavail = ENET_DMA_CH_DMA_CHX_INT_EN_TBUE_MASK,
  kENET_DmaRx = ENET_DMA_CH_DMA_CHX_INT_EN_RIE_MASK,
  kENET_DmaRxBuffUnavail = ENET_DMA_CH_DMA_CHX_INT_EN_RBUE_MASK,
  kENET_DmaRxStop = ENET_DMA_CH_DMA_CHX_INT_EN_RSE_MASK,
  kENET_DmaRxWatchdogTimeout = ENET_DMA_CH_DMA_CHX_INT_EN_RWTE_MASK,
  kENET_DmaEarlyTx = ENET_DMA_CH_DMA_CHX_INT_EN_ETIE_MASK,
  kENET_DmaEarlyRx = ENET_DMA_CH_DMA_CHX_INT_EN_ERIE_MASK,
  kENET_DmaBusErr = ENET_DMA_CH_DMA_CHX_INT_EN_FBEE_MASK
}
 List of DMA interrupts supported by the ENET interrupt. More...
 
enum  enet_mac_interrupt_enable_t
 List of mac interrupts supported by the ENET interrupt. More...
 
enum  enet_event_t {
  kENET_RxIntEvent,
  kENET_TxIntEvent,
  kENET_WakeUpIntEvent,
  kENET_TimeStampIntEvent
}
 Defines the common interrupt event for callback use. More...
 
enum  enet_dma_tx_sche {
  kENET_FixPri = 0,
  kENET_WeightStrPri,
  kENET_WeightRoundRobin
}
 Define the DMA transmit arbitration for multi-queue. More...
 
enum  enet_mtl_multiqueue_txsche {
  kENET_txWeightRR = 0U,
  kENET_txStrPrio = 3U
}
 Define the MTL tx scheduling algorithm for multiple queues/rings. More...
 
enum  enet_mtl_multiqueue_rxsche {
  kENET_rxStrPrio = 0U,
  kENET_rxWeightStrPrio
}
 Define the MTL rx scheduling algorithm for multiple queues/rings. More...
 
enum  enet_mtl_rxqueuemap {
  kENET_StaticDirctMap = 0x100U,
  kENET_DynamicMap
}
 Define the MTL rx queue and DMA channel mapping. More...
 
enum  enet_ptp_event_type_t {
  kENET_PtpEventMsgType = 3U,
  kENET_PtpSrcPortIdLen = 10U,
  kENET_PtpEventPort = 319U,
  kENET_PtpGnrlPort = 320U
}
 Defines the ENET PTP message related constant. More...
 

Driver version

#define FSL_ENET_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 Defines the driver version. More...
 

Control and status region bit masks of the receive buffer descriptor.

#define ENET_RXDESCRIP_RD_BUFF1VALID_MASK   (1U << 24)
 Defines for read format. More...
 
#define ENET_RXDESCRIP_RD_BUFF2VALID_MASK   (1U << 25)
 Buffer2 address valid. More...
 
#define ENET_RXDESCRIP_RD_IOC_MASK   (1U << 30)
 Interrupt enable on complete. More...
 
#define ENET_RXDESCRIP_RD_OWN_MASK   (1U << 31)
 Own bit. More...
 
#define ENET_RXDESCRIP_WR_ERR_MASK   ((1U << 3) | (1U << 7))
 Defines for write back format. More...
 
#define ENET_RXDESCRIP_WR_PYLOAD_MASK   (0x7U)
 
#define ENET_RXDESCRIP_WR_PTPMSGTYPE_MASK   (0xF00U)
 
#define ENET_RXDESCRIP_WR_PTPTYPE_MASK   (1U << 12)
 
#define ENET_RXDESCRIP_WR_PTPVERSION_MASK   (1U << 13)
 
#define ENET_RXDESCRIP_WR_PTPTSA_MASK   (1U << 14)
 
#define ENET_RXDESCRIP_WR_PACKETLEN_MASK   (0x7FFFU)
 
#define ENET_RXDESCRIP_WR_ERRSUM_MASK   (1U << 15)
 
#define ENET_RXDESCRIP_WR_TYPE_MASK   (0x30000U)
 
#define ENET_RXDESCRIP_WR_DE_MASK   (1U << 19)
 
#define ENET_RXDESCRIP_WR_RE_MASK   (1U << 20)
 
#define ENET_RXDESCRIP_WR_OE_MASK   (1U << 21)
 
#define ENET_RXDESCRIP_WR_RS0V_MASK   (1U << 25)
 
#define ENET_RXDESCRIP_WR_RS1V_MASK   (1U << 26)
 
#define ENET_RXDESCRIP_WR_RS2V_MASK   (1U << 27)
 
#define ENET_RXDESCRIP_WR_LD_MASK   (1U << 28)
 
#define ENET_RXDESCRIP_WR_FD_MASK   (1U << 29)
 
#define ENET_RXDESCRIP_WR_CTXT_MASK   (1U << 30)
 
#define ENET_RXDESCRIP_WR_OWN_MASK   (1U << 31)
 

Control and status bit masks of the transmit buffer descriptor.

#define ENET_TXDESCRIP_RD_BL1_MASK   (0x3fffU)
 Defines for read format. More...
 
#define ENET_TXDESCRIP_RD_BL2_MASK   (ENET_TXDESCRIP_RD_BL1_MASK << 16)
 
#define ENET_TXDESCRIP_RD_BL1(n)   ((uint32_t)(n) & ENET_TXDESCRIP_RD_BL1_MASK)
 
#define ENET_TXDESCRIP_RD_BL2(n)   (((uint32_t)(n) & ENET_TXDESCRIP_RD_BL1_MASK) << 16)
 
#define ENET_TXDESCRIP_RD_TTSE_MASK   (1U << 30)
 
#define ENET_TXDESCRIP_RD_IOC_MASK   (1U << 31)
 
#define ENET_TXDESCRIP_RD_FL_MASK   (0x7FFFU)
 
#define ENET_TXDESCRIP_RD_FL(n)   ((uint32_t)(n) & ENET_TXDESCRIP_RD_FL_MASK)
 
#define ENET_TXDESCRIP_RD_CIC(n)   (((uint32_t)(n) & 0x3) << 16)
 
#define ENET_TXDESCRIP_RD_TSE_MASK   (1U << 18)
 
#define ENET_TXDESCRIP_RD_SLOT(n)   (((uint32_t)(n) & 0x0f) << 19)
 
#define ENET_TXDESCRIP_RD_SAIC(n)   (((uint32_t)(n) & 0x07) << 23)
 
#define ENET_TXDESCRIP_RD_CPC(n)   (((uint32_t)(n) & 0x03) << 26)
 
#define ENET_TXDESCRIP_RD_LDFD(n)   (((uint32_t)(n) & 0x03) << 28)
 
#define ENET_TXDESCRIP_RD_LD_MASK   (1U << 28)
 
#define ENET_TXDESCRIP_RD_FD_MASK   (1U << 29)
 
#define ENET_TXDESCRIP_RD_CTXT_MASK   (1U << 30)
 
#define ENET_TXDESCRIP_RD_OWN_MASK   (1UL << 31)
 
#define ENET_TXDESCRIP_WB_TTSS_MASK   (1UL << 17)
 Defines for write back format. More...
 

Bit mask for interrupt enable type.

#define ENET_ABNORM_INT_MASK
 
#define ENET_NORM_INT_MASK
 

Defines some Ethernet parameters.

#define ENET_FRAME_MAX_FRAMELEN   (1518U)
 Default maximum Ethernet frame size. More...
 
#define ENET_ADDR_ALIGNMENT   (0x3U)
 Recommended ethernet buffer alignment. More...
 
#define ENET_BUFF_ALIGNMENT   (4U)
 Receive buffer alignment shall be 4bytes-aligned. More...
 
#define ENET_RING_NUM_MAX   (2U)
 The Maximum number of tx/rx descriptor rings. More...
 
#define ENET_MTL_RXFIFOSIZE   (2048U)
 The rx fifo size. More...
 
#define ENET_MTL_TXFIFOSIZE   (2048U)
 The tx fifo size. More...
 
#define ENET_MACINT_ENUM_OFFSET   (16U)
 The offest for mac interrupt in enum type. More...
 

Initialization and De-initialization

void ENET_GetDefaultConfig (enet_config_t *config)
 Gets the ENET default configuration structure. More...
 
void ENET_Init (ENET_Type *base, const enet_config_t *config, uint8_t *macAddr, uint32_t refclkSrc_Hz)
 Initializes the ENET module. More...
 
void ENET_Deinit (ENET_Type *base)
 Deinitializes the ENET module. More...
 
status_t ENET_DescriptorInit (ENET_Type *base, enet_config_t *config, enet_buffer_config_t *bufferConfig)
 Initialize for all ENET descriptors. More...
 
void ENET_StartRxTx (ENET_Type *base, uint8_t txRingNum, uint8_t rxRingNum)
 Starts the ENET rx/tx. More...
 

MII interface operation

static void ENET_SetMII (ENET_Type *base, enet_mii_speed_t speed, enet_mii_duplex_t duplex)
 Sets the ENET MII speed and duplex. More...
 
void ENET_SetSMI (ENET_Type *base)
 Sets the ENET SMI(serial management interface)- MII management interface. More...
 
static bool ENET_IsSMIBusy (ENET_Type *base)
 Checks if the SMI is busy. More...
 
static uint16_t ENET_ReadSMIData (ENET_Type *base)
 Reads data from the PHY register through SMI interface. More...
 
void ENET_StartSMIRead (ENET_Type *base, uint32_t phyAddr, uint32_t phyReg)
 Starts an SMI read command. More...
 
void ENET_StartSMIWrite (ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, uint32_t data)
 Starts a SMI write command. More...
 

Other basic operation

static void ENET_SetMacAddr (ENET_Type *base, uint8_t *macAddr)
 Sets the ENET module Mac address. More...
 
void ENET_GetMacAddr (ENET_Type *base, uint8_t *macAddr)
 Gets the ENET module Mac address. More...
 
void ENET_EnterPowerDown (ENET_Type *base, uint32_t *wakeFilter)
 Set the MAC to enter into power down mode. More...
 
static void ENET_ExitPowerDown (ENET_Type *base)
 Set the MAC to exit power down mode. More...
 

Interrupts.

void ENET_EnableInterrupts (ENET_Type *base, uint32_t mask)
 Enables the ENET DMA and MAC interrupts. More...
 
void ENET_DisableInterrupts (ENET_Type *base, uint32_t mask)
 Disables the ENET DMA and MAC interrupts. More...
 
static uint32_t ENET_GetDmaInterruptStatus (ENET_Type *base, uint8_t channel)
 Gets the ENET DMA interrupt status flag. More...
 
static void ENET_ClearDmaInterruptStatus (ENET_Type *base, uint8_t channel, uint32_t mask)
 Clear the ENET DMA interrupt status flag. More...
 
static uint32_t ENET_GetMacInterruptStatus (ENET_Type *base)
 Gets the ENET MAC interrupt status flag. More...
 
void ENET_ClearMacInterruptStatus (ENET_Type *base, uint32_t mask)
 Clears the ENET mac interrupt events status flag. More...
 

Functional operation.

static bool ENET_IsTxDescriptorDmaOwn (enet_tx_bd_struct_t *txDesc)
 Get the tx descriptor DMA Own flag. More...
 
void ENET_SetupTxDescriptor (enet_tx_bd_struct_t *txDesc, void *buffer1, uint32_t bytes1, void *buffer2, uint32_t bytes2, uint32_t framelen, bool intEnable, bool tsEnable, enet_desc_flag flag, uint8_t slotNum)
 Setup a given tx descriptor. More...
 
static void ENET_UpdateTxDescriptorTail (ENET_Type *base, uint8_t channel, uint32_t txDescTailAddrAlign)
 Update the tx descriptor tail pointer. More...
 
static void ENET_UpdateRxDescriptorTail (ENET_Type *base, uint8_t channel, uint32_t rxDescTailAddrAlign)
 Update the rx descriptor tail pointer. More...
 
static uint32_t ENET_GetRxDescriptor (enet_rx_bd_struct_t *rxDesc)
 Gets the context in the ENET rx descriptor. More...
 
void ENET_UpdateRxDescriptor (enet_rx_bd_struct_t *rxDesc, void *buffer1, void *buffer2, bool intEnable, bool doubleBuffEnable)
 Updates the buffers and the own status for a given rx descriptor. More...
 

Transactional operation

void ENET_CreateHandler (ENET_Type *base, enet_handle_t *handle, enet_config_t *config, enet_buffer_config_t *bufferConfig, enet_callback_t callback, void *userData)
 Create ENET Handler. More...
 
status_t ENET_GetRxFrameSize (ENET_Type *base, enet_handle_t *handle, uint32_t *length, uint8_t channel)
 Gets the size of the read frame. More...
 
status_t ENET_ReadFrame (ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length, uint8_t channel)
 Reads a frame from the ENET device. More...
 
status_t ENET_SendFrame (ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length)
 Transmits an ENET frame. More...
 
void ENET_ReclaimTxDescriptor (ENET_Type *base, enet_handle_t *handle, uint8_t channel)
 Reclaim tx descriptors. More...
 
void ENET_PMTIRQHandler (ENET_Type *base, enet_handle_t *handle)
 The ENET PMT IRQ handler. More...
 
void ENET_IRQHandler (ENET_Type *base, enet_handle_t *handle)
 The ENET IRQ handler. More...
 

Data Structure Documentation

struct enet_rx_bd_struct_t

They both has the same size with different region definition. so we define the read-format region as the recive descriptor structure Use the read-format region mask bits in the descriptor initialization Use the write-back format region mask bits in the receive data process.

Data Fields

__IO uint32_t buff1Addr
 Buffer 1 address.
 
__IO uint32_t reserved
 Reserved.
 
__IO uint32_t buff2Addr
 Buffer 2 or next descriptor address.
 
__IO uint32_t control
 Buffer 1/2 byte counts and control.
 
struct enet_tx_bd_struct_t

They both has the same size with different region definition. so we define the read-format region as the transmit descriptor structure Use the read-format region mask bits in the descriptor initialization Use the write-back format region mask bits in the transmit data process.

Data Fields

__IO uint32_t buff1Addr
 Buffer 1 address.
 
__IO uint32_t buff2Addr
 Buffer 2 address.
 
__IO uint32_t buffLen
 Buffer 1/2 byte counts.
 
__IO uint32_t controlStat
 TDES control and status word.
 
struct enet_buffer_config_t

Notes:

  1. The receive and transmit descriptor start address pointer and tail pointer must be word-aligned.
  2. The recommended minimum tx/rx ring length is 4.
  3. The tx/rx descriptor tail address shall be the address pointer to the address just after the end of the last last descriptor. because only the descriptors between the start address and the tail address will be used by DMA.
  4. The decriptor address is the start address of all used contiguous memory. for example, the rxDescStartAddrAlign is the start address of rxRingLen contiguous descriptor memorise for rx descriptor ring 0.
  5. The "*rxBufferstartAddr" is the first element of rxRingLen (2*rxRingLen for double buffers) rx buffers. It means the *rxBufferStartAddr is the rx buffer for the first descriptor the *rxBufferStartAddr + 1 is the rx buffer for the second descriptor or the rx buffer for the second buffer in the first descriptor. so please make sure the rxBufferStartAddr is the address of a rxRingLen or 2*rxRingLen array.

Data Fields

uint8_t rxRingLen
 The length of receive buffer descriptor ring. More...
 
uint8_t txRingLen
 The length of transmit buffer descriptor ring. More...
 
enet_tx_bd_struct_ttxDescStartAddrAlign
 Aligned transmit descriptor start address. More...
 
enet_tx_bd_struct_ttxDescTailAddrAlign
 Aligned transmit descriptor tail address. More...
 
enet_rx_bd_struct_trxDescStartAddrAlign
 Aligned receive descriptor start address. More...
 
enet_rx_bd_struct_trxDescTailAddrAlign
 Aligned receive descriptor tail address. More...
 
uint32_t * rxBufferStartAddr
 Start address of the rx buffers. More...
 
uint32_t rxBuffSizeAlign
 Aligned receive data buffer size. More...
 

Field Documentation

uint8_t enet_buffer_config_t::rxRingLen
uint8_t enet_buffer_config_t::txRingLen
enet_tx_bd_struct_t* enet_buffer_config_t::txDescStartAddrAlign
enet_tx_bd_struct_t* enet_buffer_config_t::txDescTailAddrAlign
enet_rx_bd_struct_t* enet_buffer_config_t::rxDescStartAddrAlign
enet_rx_bd_struct_t* enet_buffer_config_t::rxDescTailAddrAlign
uint32_t* enet_buffer_config_t::rxBufferStartAddr
uint32_t enet_buffer_config_t::rxBuffSizeAlign
struct enet_multiqueue_config_t

Data Fields

enet_dma_tx_sche dmaTxSche
 Transmit arbitation. More...
 
enet_dma_burstlen burstLen
 Burset len for the queue 1. More...
 
uint8_t txdmaChnWeight [ENET_RING_NUM_MAX]
 Transmit channel weight. More...
 
enet_mtl_multiqueue_txsche mtltxSche
 Transmit schedule for multi-queue. More...
 
enet_mtl_multiqueue_rxsche mtlrxSche
 Receive schedule for multi-queue. More...
 
uint8_t rxqueweight [ENET_RING_NUM_MAX]
 Refer to the MTL RxQ Control register. More...
 
uint32_t txqueweight [ENET_RING_NUM_MAX]
 Refer to the MTL TxQ Quantum Weight register. More...
 
uint8_t rxqueuePrio [ENET_RING_NUM_MAX]
 Receive queue priority. More...
 
uint8_t txqueuePrio [ENET_RING_NUM_MAX]
 Refer to Transmit Queue Priority Mapping register. More...
 
enet_mtl_rxqueuemap mtlrxQuemap
 Rx queue DMA Channel mapping. More...
 

Field Documentation

enet_dma_tx_sche enet_multiqueue_config_t::dmaTxSche
enet_dma_burstlen enet_multiqueue_config_t::burstLen
uint8_t enet_multiqueue_config_t::txdmaChnWeight[ENET_RING_NUM_MAX]
enet_mtl_multiqueue_txsche enet_multiqueue_config_t::mtltxSche
enet_mtl_multiqueue_rxsche enet_multiqueue_config_t::mtlrxSche
uint8_t enet_multiqueue_config_t::rxqueweight[ENET_RING_NUM_MAX]
uint32_t enet_multiqueue_config_t::txqueweight[ENET_RING_NUM_MAX]
uint8_t enet_multiqueue_config_t::rxqueuePrio[ENET_RING_NUM_MAX]
uint8_t enet_multiqueue_config_t::txqueuePrio[ENET_RING_NUM_MAX]
enet_mtl_rxqueuemap enet_multiqueue_config_t::mtlrxQuemap
struct enet_config_t

Note:

  1. Default the signal queue is used so the "*multiqueueCfg" is set default with NULL. Set the pointer with a valid configration pointer if the multiple queues are required. If multiple queue is enabled, please make sure the buffer configuration for all are prepared also.

Data Fields

uint16_t specialControl
 The logicl or of enet_special_config_t.
 
enet_multiqueue_config_tmultiqueueCfg
 Use both tx/rx queue(dma channel) 0 and 1. More...
 
enet_mii_mode_t miiMode
 MII mode. More...
 
enet_mii_speed_t miiSpeed
 MII Speed. More...
 
enet_mii_duplex_t miiDuplex
 MII duplex. More...
 
uint16_t pauseDuration
 Used in the tx flow control frame, only valid when kENET_FlowControlEnable is set. More...
 

Field Documentation

enet_multiqueue_config_t* enet_config_t::multiqueueCfg
enet_mii_mode_t enet_config_t::miiMode
enet_mii_speed_t enet_config_t::miiSpeed
enet_mii_duplex_t enet_config_t::miiDuplex
uint16_t enet_config_t::pauseDuration
struct enet_tx_bd_ring_t

Data Fields

enet_tx_bd_struct_ttxBdBase
 Buffer descriptor base address pointer. More...
 
uint16_t txGenIdx
 tx generate index. More...
 
uint16_t txConsumIdx
 tx consum index. More...
 
volatile uint16_t txDescUsed
 tx descriptor used number. More...
 
uint16_t txRingLen
 tx ring length. More...
 

Field Documentation

enet_tx_bd_struct_t* enet_tx_bd_ring_t::txBdBase
uint16_t enet_tx_bd_ring_t::txGenIdx
uint16_t enet_tx_bd_ring_t::txConsumIdx
volatile uint16_t enet_tx_bd_ring_t::txDescUsed
uint16_t enet_tx_bd_ring_t::txRingLen
struct enet_rx_bd_ring_t

Data Fields

enet_rx_bd_struct_trxBdBase
 Buffer descriptor base address pointer. More...
 
uint16_t rxGenIdx
 The current available receive buffer descriptor pointer. More...
 
uint16_t rxRingLen
 Receive ring length. More...
 
uint32_t rxBuffSizeAlign
 Receive buffer size. More...
 

Field Documentation

enet_rx_bd_struct_t* enet_rx_bd_ring_t::rxBdBase
uint16_t enet_rx_bd_ring_t::rxGenIdx
uint16_t enet_rx_bd_ring_t::rxRingLen
uint32_t enet_rx_bd_ring_t::rxBuffSizeAlign
struct _enet_handle

Data Fields

bool multiQueEnable
 Enable multi-queue. More...
 
bool doubleBuffEnable
 The double buffer is used in the descriptor. More...
 
bool rxintEnable
 Rx interrup enabled. More...
 
enet_rx_bd_ring_t rxBdRing [ENET_RING_NUM_MAX]
 Receive buffer descriptor. More...
 
enet_tx_bd_ring_t txBdRing [ENET_RING_NUM_MAX]
 Transmit buffer descriptor. More...
 
enet_callback_t callback
 Callback function. More...
 
void * userData
 Callback function parameter. More...
 

Field Documentation

bool enet_handle_t::multiQueEnable
bool enet_handle_t::doubleBuffEnable
bool enet_handle_t::rxintEnable
enet_rx_bd_ring_t enet_handle_t::rxBdRing[ENET_RING_NUM_MAX]
enet_tx_bd_ring_t enet_handle_t::txBdRing[ENET_RING_NUM_MAX]
enet_callback_t enet_handle_t::callback
void* enet_handle_t::userData

Macro Definition Documentation

#define FSL_ENET_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Version 2.0.0.

#define ENET_RXDESCRIP_RD_BUFF1VALID_MASK   (1U << 24)

Buffer1 address valid.

#define ENET_RXDESCRIP_RD_BUFF2VALID_MASK   (1U << 25)
#define ENET_RXDESCRIP_RD_IOC_MASK   (1U << 30)
#define ENET_RXDESCRIP_RD_OWN_MASK   (1U << 31)
#define ENET_RXDESCRIP_WR_ERR_MASK   ((1U << 3) | (1U << 7))
#define ENET_TXDESCRIP_RD_BL1_MASK   (0x3fffU)
#define ENET_TXDESCRIP_WB_TTSS_MASK   (1UL << 17)
#define ENET_FRAME_MAX_FRAMELEN   (1518U)
#define ENET_ADDR_ALIGNMENT   (0x3U)
#define ENET_BUFF_ALIGNMENT   (4U)
#define ENET_RING_NUM_MAX   (2U)
#define ENET_MTL_RXFIFOSIZE   (2048U)
#define ENET_MTL_TXFIFOSIZE   (2048U)
#define ENET_MACINT_ENUM_OFFSET   (16U)

Typedef Documentation

typedef void(* enet_callback_t)(ENET_Type *base, enet_handle_t *handle, enet_event_t event, uint8_t channel, void *userData)

Enumeration Type Documentation

Enumerator
kStatus_ENET_RxFrameError 

A frame received but data error happen.

kStatus_ENET_RxFrameFail 

Failed to receive a frame.

kStatus_ENET_RxFrameEmpty 

No frame arrive.

kStatus_ENET_TxFrameBusy 

Transmit descriptors are under process.

kStatus_ENET_TxFrameFail 

Transmit frame fail.

kStatus_ENET_TxFrameOverLen 

Transmit oversize.

Enumerator
kENET_MiiMode 

MII mode for data interface.

kENET_RmiiMode 

RMII mode for data interface.

Enumerator
kENET_MiiSpeed10M 

Speed 10 Mbps.

kENET_MiiSpeed100M 

Speed 100 Mbps.

Enumerator
kENET_MiiHalfDuplex 

Half duplex mode.

kENET_MiiFullDuplex 

Full duplex mode.

Enumerator
kENET_MiiWriteFrame 

Write frame operation for a valid MII management frame.

kENET_MiiReadFrame 

Read frame operation for a valid MII management frame.

Enumerator
kENET_BurstLen1 

DMA burst length 1.

kENET_BurstLen2 

DMA burst length 2.

kENET_BurstLen4 

DMA burst length 4.

kENET_BurstLen8 

DMA burst length 8.

kENET_BurstLen16 

DMA burst length 16.

kENET_BurstLen32 

DMA burst length 32.

kENET_BurstLen64 

DMA burst length 64.

eight times enabled.

kENET_BurstLen128 

DMA burst length 128.

eight times enabled.

kENET_BurstLen256 

DMA burst length 256.

eight times enabled.

Enumerator
kENET_MiddleFlag 

It's a middle descriptor of the frame.

kENET_FirstFlagOnly 

It's the first descriptor of the frame.

kENET_LastFlagOnly 

It's the last descriptor of the frame.

kENET_FirstLastFlag 

It's the first and last descriptor of the frame.

Enumerator
kENET_SystimeAdd 

System time add to.

kENET_SystimeSubtract 

System time subtract.

Enumerator
kENET_BinaryRollover 

System time binary rollover.

kENET_DigitalRollover 

System time digital rollover.

These control flags are provided for special user requirements. Normally, these is no need to set this control flags for ENET initialization. But if you have some special requirements, set the flags to specialControl in the enet_config_t.

Note
"kENET_StoreAndForward" is recommended to be set when the ENET_PTP1588FEATURE_REQUIRED is defined or else the timestamp will be mess-up when the overflow happens.
Enumerator
kENET_DescDoubleBuffer 

The double buffer is used in the tx/rx descriptor.

kENET_StoreAndForward 

The rx/tx store and forward enable.

kENET_PromiscuousEnable 

The promiscuous enabled.

kENET_FlowControlEnable 

The flow control enabled.

kENET_BroadCastRxDisable 

The broadcast disabled.

kENET_MulticastAllEnable 

All multicast are passed.

kENET_8023AS2KPacket 

8023as support for 2K packets.

This enumeration uses one-bot encoding to allow a logical OR of multiple members.

Enumerator
kENET_DmaTx 

Tx interrupt.

kENET_DmaTxStop 

Tx stop interrupt.

kENET_DmaTxBuffUnavail 

Tx buffer unavailable.

kENET_DmaRx 

Rx interrupt.

kENET_DmaRxBuffUnavail 

Rx buffer unavailable.

kENET_DmaRxStop 

Rx stop.

kENET_DmaRxWatchdogTimeout 

Rx watchdog timeout.

kENET_DmaEarlyTx 

Early transmit.

kENET_DmaEarlyRx 

Early receive.

kENET_DmaBusErr 

Fatal bus error.

This enumeration uses one-bot encoding to allow a logical OR of multiple members.

Enumerator
kENET_RxIntEvent 

Receive interrupt event.

kENET_TxIntEvent 

Transmit interrupt event.

kENET_WakeUpIntEvent 

Wake up interrupt event.

kENET_TimeStampIntEvent 

Time stamp interrupt event.

Enumerator
kENET_FixPri 

Fixed priority.

channel 0 has lower priority than channel 1.

kENET_WeightStrPri 

Weighted(burst length) strict priority.

kENET_WeightRoundRobin 

Weighted (weight factor) round robin.

Enumerator
kENET_txWeightRR 

Tx weight round-robin.

kENET_txStrPrio 

Tx strict priority.

Enumerator
kENET_rxStrPrio 

Tx weight round-robin, rx strict priority.

kENET_rxWeightStrPrio 

Tx strict priority, rx weight strict priority.

Enumerator
kENET_StaticDirctMap 

The received fame in rx Qn(n = 0,1) direclty map to dma channel n.

kENET_DynamicMap 

The received frame in rx Qn(n = 0,1) map to the dma channel m(m = 0,1) related with the same Mac.

Enumerator
kENET_PtpEventMsgType 

PTP event message type.

kENET_PtpSrcPortIdLen 

PTP message sequence id length.

kENET_PtpEventPort 

PTP event port number.

kENET_PtpGnrlPort 

PTP general port number.

Function Documentation

void ENET_GetDefaultConfig ( enet_config_t config)

The purpose of this API is to get the default ENET configure structure for ENET_Init(). User may use the initialized structure unchanged in ENET_Init(), or modify some fields of the structure before calling ENET_Init(). Example:

Parameters
configThe ENET mac controller configuration structure pointer.
void ENET_Init ( ENET_Type *  base,
const enet_config_t config,
uint8_t *  macAddr,
uint32_t  refclkSrc_Hz 
)

This function ungates the module clock and initializes it with the ENET basic configuration.

Parameters
baseENET peripheral base address.
configENET mac configuration structure pointer. The "enet_config_t" type mac configuration return from ENET_GetDefaultConfig can be used directly. It is also possible to verify the Mac configuration using other methods.
macAddrENET mac address of Ethernet device. This MAC address should be provided.
refclkSrc_HzENET input reference clock.
void ENET_Deinit ( ENET_Type *  base)

This function gates the module clock and disables the ENET module.

Parameters
baseENET peripheral base address.
status_t ENET_DescriptorInit ( ENET_Type *  base,
enet_config_t config,
enet_buffer_config_t bufferConfig 
)
Note
This function is do all tx/rx descriptors initialization. Because this API read all interrupt registers first and then set the interrupt flag for all descriptos, if the interrupt register is set. so the descriptor initialization should be called after ENET_Init(), ENET_EnableInterrupts() and ENET_CreateHandle()(if transactional APIs are used).
Parameters
baseENET peripheral base address.
configThe configuration for ENET.
bufferConfigAll buffers configuration.
void ENET_StartRxTx ( ENET_Type *  base,
uint8_t  txRingNum,
uint8_t  rxRingNum 
)

This function enable the tx/rx and starts the rx/tx DMA. This shall be set after ENET initialization and before starting to receive the data.

Parameters
baseENET peripheral base address.
rxRingNumThe number of the used rx rings. It shall not be larger than the ENET_RING_NUM_MAX(2). If the ringNum is set with 1, the ring 0 will be used.
txRingNumThe number of the used tx rings. It shall not be larger than the ENET_RING_NUM_MAX(2). If the ringNum is set with 1, the ring 0 will be used.
Note
This must be called after all the ENET initilization. And should be called when the ENET receive/transmit is required.
static void ENET_SetMII ( ENET_Type *  base,
enet_mii_speed_t  speed,
enet_mii_duplex_t  duplex 
)
inlinestatic

This API is provided to dynamically change the speed and dulpex for MAC.

Parameters
baseENET peripheral base address.
speedThe speed of the RMII mode.
duplexThe duplex of the RMII mode.
void ENET_SetSMI ( ENET_Type *  base)
Parameters
baseENET peripheral base address.
static bool ENET_IsSMIBusy ( ENET_Type *  base)
inlinestatic
Parameters
baseENET peripheral base address.
Returns
The status of MII Busy status.
static uint16_t ENET_ReadSMIData ( ENET_Type *  base)
inlinestatic
Parameters
baseENET peripheral base address.
Returns
The data read from PHY
void ENET_StartSMIRead ( ENET_Type *  base,
uint32_t  phyAddr,
uint32_t  phyReg 
)

support both MDIO IEEE802.3 Clause 22 and clause 45.

Parameters
baseENET peripheral base address.
phyAddrThe PHY address.
phyRegThe PHY register.
void ENET_StartSMIWrite ( ENET_Type *  base,
uint32_t  phyAddr,
uint32_t  phyReg,
uint32_t  data 
)

support both MDIO IEEE802.3 Clause 22 and clause 45.

Parameters
baseENET peripheral base address.
phyAddrThe PHY address.
phyRegThe PHY register.
dataThe data written to PHY.
static void ENET_SetMacAddr ( ENET_Type *  base,
uint8_t *  macAddr 
)
inlinestatic
Parameters
baseENET peripheral base address.
macAddrThe six-byte Mac address pointer. The pointer is allocated by application and input into the API.
void ENET_GetMacAddr ( ENET_Type *  base,
uint8_t *  macAddr 
)
Parameters
baseENET peripheral base address.
macAddrThe six-byte Mac address pointer. The pointer is allocated by application and input into the API.
void ENET_EnterPowerDown ( ENET_Type *  base,
uint32_t *  wakeFilter 
)

the remote power wake up frame and magic frame can wake up the ENET from the power down mode.

Parameters
baseENET peripheral base address.
wakeFilterThe wakeFilter provided to configure the wake up frame fitlter. Set the wakeFilter to NULL is not required. But if you have the filter requirement, please make sure the wakeFilter pointer shall be eight continous 32-bits configuration.
static void ENET_ExitPowerDown ( ENET_Type *  base)
inlinestatic

Eixt from the power down mode and recover to noraml work mode.

Parameters
baseENET peripheral base address.
void ENET_EnableInterrupts ( ENET_Type *  base,
uint32_t  mask 
)

This function enables the ENET interrupt according to the provided mask. The mask is a logical OR of enet_dma_interrupt_enable_t and enet_mac_interrupt_enable_t. For example, to enable the dma and mac interrupt, do the following.

* ENET_EnableInterrupts(ENET, kENET_DmaRx | kENET_DmaTx | kENET_MacPmt);
*
Parameters
baseENET peripheral base address.
maskENET interrupts to enable. This is a logical OR of both enumeration :: enet_dma_interrupt_enable_t and enet_mac_interrupt_enable_t.
void ENET_DisableInterrupts ( ENET_Type *  base,
uint32_t  mask 
)

This function disables the ENET interrupt according to the provided mask. The mask is a logical OR of enet_dma_interrupt_enable_t and enet_mac_interrupt_enable_t. For example, to disable the dma and mac interrupt, do the following.

*
Parameters
baseENET peripheral base address.
maskENET interrupts to disables. This is a logical OR of both enumeration :: enet_dma_interrupt_enable_t and enet_mac_interrupt_enable_t.
static uint32_t ENET_GetDmaInterruptStatus ( ENET_Type *  base,
uint8_t  channel 
)
inlinestatic
Parameters
baseENET peripheral base address.
channelThe DMA Channel. Shall not be larger than ENET_RING_NUM_MAX.
Returns
The event status of the interrupt source. This is the logical OR of members of the enumeration :: enet_dma_interrupt_enable_t.
static void ENET_ClearDmaInterruptStatus ( ENET_Type *  base,
uint8_t  channel,
uint32_t  mask 
)
inlinestatic
Parameters
baseENET peripheral base address.
channelThe DMA Channel. Shall not be larger than ENET_RING_NUM_MAX.
Returns
The event status of the interrupt source. This is the logical OR of members of the enumeration :: enet_dma_interrupt_enable_t.
static uint32_t ENET_GetMacInterruptStatus ( ENET_Type *  base)
inlinestatic
Parameters
baseENET peripheral base address.
Returns
The event status of the interrupt source. Use the enum in enet_mac_interrupt_enable_t and right shift ENET_MACINT_ENUM_OFFSET to mask the returned value to get the exact interrupt status.
void ENET_ClearMacInterruptStatus ( ENET_Type *  base,
uint32_t  mask 
)

This function clears enabled ENET interrupts according to the provided mask. The mask is a logical OR of enumeration members. See the enet_mac_interrupt_enable_t. For example, to clear the TX frame interrupt and RX frame interrupt, do the following.

* ENET_ClearMacInterruptStatus(ENET, kENET_MacPmt);
*
Parameters
baseENET peripheral base address.
maskENET interrupt source to be cleared. This is the logical OR of members of the enumeration :: enet_mac_interrupt_enable_t.
static bool ENET_IsTxDescriptorDmaOwn ( enet_tx_bd_struct_t txDesc)
inlinestatic
Parameters
txDescThe given tx descriptor.
Return values
Truethe dma own tx descriptor, false application own tx descriptor.
void ENET_SetupTxDescriptor ( enet_tx_bd_struct_t txDesc,
void *  buffer1,
uint32_t  bytes1,
void *  buffer2,
uint32_t  bytes2,
uint32_t  framelen,
bool  intEnable,
bool  tsEnable,
enet_desc_flag  flag,
uint8_t  slotNum 
)

This function is a low level functional API to setup or prepare a given tx descriptor.

Parameters
txDescThe given tx descriptor.
buffer1The first buffer address in the descriptor.
bytes1The bytes in the fist buffer.
buffer2The second buffer address in the descriptor.
bytes1The bytes in the second buffer.
framelenThe length of the frame to be transmitted.
intEnableInterrupt enable flag.
tsEnableThe timestamp enable.
flagThe flag of this tx desciriptor, see "enet_desc_flag" .
slotNumThe slot num used for AV only.
Note
This must be called after all the ENET initilization. And should be called when the ENET receive/transmit is required. Transmit buffers are 'zero-copy' buffers, so the buffer must remain in memory until the packet has been fully transmitted. The buffers should be free or requeued in the transmit interrupt irq handler.
static void ENET_UpdateTxDescriptorTail ( ENET_Type *  base,
uint8_t  channel,
uint32_t  txDescTailAddrAlign 
)
inlinestatic

This function is a low level functional API to update the the tx descriptor tail. This is called after you setup a new tx descriptor to update the tail pointer to make the new descritor accessable by DMA.

Parameters
baseENET peripheral base address.
channelThe tx DMA channel.
txDescTailAddrAlignThe new tx tail pointer address.
static void ENET_UpdateRxDescriptorTail ( ENET_Type *  base,
uint8_t  channel,
uint32_t  rxDescTailAddrAlign 
)
inlinestatic

This function is a low level functional API to update the the rx descriptor tail. This is called after you setup a new rx descriptor to update the tail pointer to make the new descritor accessable by DMA and to anouse the rx poll command for DMA.

Parameters
baseENET peripheral base address.
channelThe rx DMA channel.
rxDescTailAddrAlignThe new rx tail pointer address.
static uint32_t ENET_GetRxDescriptor ( enet_rx_bd_struct_t rxDesc)
inlinestatic

This function is a low level functional API to get the the status flag from a given rx descriptor.

Parameters
rxDescThe given rx descriptor.
Return values
TheRDES3 regions for write-back format rx buffer descriptor.
Note
This must be called after all the ENET initilization. And should be called when the ENET receive/transmit is required.
void ENET_UpdateRxDescriptor ( enet_rx_bd_struct_t rxDesc,
void *  buffer1,
void *  buffer2,
bool  intEnable,
bool  doubleBuffEnable 
)

This function is a low level functional API to Updates the buffers and the own status for a given rx descriptor.

Parameters
rxDescThe given rx descriptor.
buffer1The first buffer address in the descriptor.
buffer2The second buffer address in the descriptor.
intEnableInterrupt enable flag.
doubleBuffEnableThe double buffer enable flag.
Note
This must be called after all the ENET initilization. And should be called when the ENET receive/transmit is required.
void ENET_CreateHandler ( ENET_Type *  base,
enet_handle_t *  handle,
enet_config_t config,
enet_buffer_config_t bufferConfig,
enet_callback_t  callback,
void *  userData 
)

This is a transactional API and it's provided to store all datas which are needed during the whole transactional process. This API should not be used when you use functional APIs to do data tx/rx. This is funtion will store many data/flag for transactional use, so all configure API such as ENET_Init(), ENET_DescriptorInit(), ENET_EnableInterrupts() etc.

Note
as our transactional transmit API use the zero-copy transmit buffer. so there are two thing we emphasize here:
  1. tx buffer free/requeue for application should be done in the tx interrupt handler. Please set callback: kENET_TxIntEvent with tx buffer free/requeue process APIs.
  2. the tx interrupt is forced to open.
Parameters
baseENET peripheral base address.
handleENET handler.
configENET configuration.
bufferConfigENET buffer configuration.
callbackThe callback function.
userDataThe application data.
status_t ENET_GetRxFrameSize ( ENET_Type *  base,
enet_handle_t *  handle,
uint32_t *  length,
uint8_t  channel 
)

This function gets a received frame size from the ENET buffer descriptors.

Note
The FCS of the frame is automatically removed by MAC and the size is the length without the FCS. After calling ENET_GetRxFrameSize, ENET_ReadFrame() should be called to update the receive buffers If the result is not "kStatus_ENET_RxFrameEmpty".
Parameters
handleThe ENET handler structure. This is the same handler pointer used in the ENET_Init.
lengthThe length of the valid frame received.
channelThe DMAC channel for the rx.
Return values
kStatus_ENET_RxFrameEmptyNo frame received. Should not call ENET_ReadFrame to read frame.
kStatus_ENET_RxFrameErrorData error happens. ENET_ReadFrame should be called with NULL data and NULL length to update the receive buffers.
kStatus_SuccessReceive a frame Successfully then the ENET_ReadFrame should be called with the right data buffer and the captured data length input.
status_t ENET_ReadFrame ( ENET_Type *  base,
enet_handle_t *  handle,
uint8_t *  data,
uint32_t  length,
uint8_t  channel 
)

This function reads a frame from the ENET DMA descriptors. The ENET_GetRxFrameSize should be used to get the size of the prepared data buffer. For example use rx dma channel 0:

* uint32_t length;
* enet_handle_t g_handle;
* //Get the received frame size firstly.
* status = ENET_GetRxFrameSize(&g_handle, &length, 0);
* if (length != 0)
* {
* //Allocate memory here with the size of "length"
* uint8_t *data = memory allocate interface;
* if (!data)
* {
* ENET_ReadFrame(ENET, &g_handle, NULL, 0, 0);
* //Add the console warning log.
* }
* else
* {
* status = ENET_ReadFrame(ENET, &g_handle, data, length, 0);
* //Call stack input API to deliver the data to stack
* }
* }
* else if (status == kStatus_ENET_RxFrameError)
* {
* //Update the received buffer when a error frame is received.
* ENET_ReadFrame(ENET, &g_handle, NULL, 0, 0);
* }
*
Parameters
baseENET peripheral base address.
handleThe ENET handler structure. This is the same handler pointer used in the ENET_Init.
dataThe data buffer provided by user to store the frame which memory size should be at least "length".
lengthThe size of the data buffer which is still the length of the received frame.
channelThe rx DMA channel. shall not be larger than 2.
Returns
The execute status, successful or failure.
status_t ENET_SendFrame ( ENET_Type *  base,
enet_handle_t *  handle,
uint8_t *  data,
uint32_t  length 
)
Note
The CRC is automatically appended to the data. Input the data to send without the CRC.
Parameters
baseENET peripheral base address.
handleThe ENET handler pointer. This is the same handler pointer used in the ENET_Init.
dataThe data buffer provided by user to be send.
lengthThe length of the data to be send.
Return values
kStatus_SuccessSend frame succeed.
kStatus_ENET_TxFrameBusyTransmit buffer descriptor is busy under transmission. The transmit busy happens when the data send rate is over the MAC capacity. The waiting mechanism is recommended to be added after each call return with kStatus_ENET_TxFrameBusy.
void ENET_ReclaimTxDescriptor ( ENET_Type *  base,
enet_handle_t *  handle,
uint8_t  channel 
)

This function is used to update the tx descriptor status and store the tx timestamp when the 1588 feature is enabled. This is called by the transmit interupt IRQ handler after the complete of a frame transmission.

Parameters
baseENET peripheral base address.
handleThe ENET handler pointer. This is the same handler pointer used in the ENET_Init.
channelThe tx DMA channnel.
void ENET_PMTIRQHandler ( ENET_Type *  base,
enet_handle_t *  handle 
)
Parameters
baseENET peripheral base address.
handleThe ENET handler pointer.
void ENET_IRQHandler ( ENET_Type *  base,
enet_handle_t *  handle 
)
Parameters
baseENET peripheral base address.
handleThe ENET handler pointer.