The MCUXpresso SDK provides a peripheral driver for the 10/100 Mbps Ethernet MAC (ENET) module of MCUXpresso SDK devices.
ENET: Ethernet MAC Driver {EthernetMACDriver}
Operations of Ethernet MAC Driver
MII interface Operation
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 the MII management interface. Use ENET_StartSMIRead(), ENET_StartSMIWrite(), and ENET_ReadSMIData() to read/write to PHY registers. 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.
MAC address filter
This group sets/gets the ENET mac address and the multicast group address filter. ENET_AddMulticastGroup() should be called to add the ENET MAC to the multicast group. The IEEE 1588 feature requires receiving the PTP message.
Other Baisc control Operations
This group has the receive active API ENET_ActiveRead() for single and multiple rings. The ENET_AVBConfigure() is provided to configure the AVB features to support the AVB frames transmission. Note that due to the AVB frames transmission scheme being a credit-based TX scheme, it is only supported with the Enhanced buffer descriptors. Because of this, the AVB configuration should only be done with the Enhanced buffer descriptor. When the AVB feature is required, make sure the the "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" is defined before using this feature.
Transactional Operation
For ENET receive, the ENET_GetRxFrameSize() function needs to be called to get the received data size. Then, call the ENET_ReadFrame() function to get the received data. If the received error occurs, call the ENET_GetRxErrBeforeReadFrame() function after ENET_GetRxFrameSize() and before ENET_ReadFrame() functions to get the detailed error information.
For ENET transmit, call the ENET_SendFrame() function to send the data out. The transmit data error information is only accessible for the IEEE 1588 enhanced buffer descriptor mode. When the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is defined, the ENET_GetTxErrAfterSendFrame() can be used to get the detail transmit error information. The transmit error information can only be updated by uDMA after the data is transmitted. The ENET_GetTxErrAfterSendFrame() function is recommended to be called on the transmit interrupt handler.
If send/read frame with zero-copy mechanism is needed, there're special APIs like ENET_GetRxFrame() and ENET_StartTxFrame(). The send frame zero-copy APIs can't be used mixed with ENET_SendFrame() for the same ENET peripheral, same as read frame zero-copy APIs.
PTP IEEE 1588 Feature Operation
This function group configures the PTP IEEE 1588 feature, starts/stops/gets/sets/adjusts the PTP IEEE 1588 timer, gets the receive/transmit frame timestamp, and PTP IEEE 1588 timer channel feature setting.
The ENET_Ptp1588Configure() function needs to be called when the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is defined and the IEEE 1588 feature is required.
Typical use case
ENET Initialization, receive, and transmit operations
For the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE undefined use case, use the legacy type buffer descriptor transmit/receive the frame as follows. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/enet For the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE defined use case, add the PTP IEEE 1588 configuration to enable the PTP IEEE 1588 feature. The initialization occurs as follows. Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/enet
|
typedef void *(* | enet_rx_alloc_callback_t )(ENET_Type *base, void *userData, uint8_t ringId) |
| Defines the ENET Rx memory buffer alloc function pointer. More...
|
|
typedef void(* | enet_rx_free_callback_t )(ENET_Type *base, void *buffer, void *userData, uint8_t ringId) |
| Defines the ENET Rx memory buffer free function pointer. More...
|
|
typedef void(* | enet_callback_t )(ENET_Type *base, enet_handle_t *handle, enet_event_t event, enet_frame_info_t *frameInfo, void *userData) |
| ENET callback function. More...
|
|
typedef void(* | enet_isr_t )(ENET_Type *base, enet_handle_t *handle) |
| Define interrupt IRQ handler. More...
|
|
|
enum | {
kStatus_ENET_InitMemoryFail,
kStatus_ENET_RxFrameError = MAKE_STATUS(kStatusGroup_ENET, 1U),
kStatus_ENET_RxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 2U),
kStatus_ENET_RxFrameEmpty = MAKE_STATUS(kStatusGroup_ENET, 3U),
kStatus_ENET_RxFrameDrop = MAKE_STATUS(kStatusGroup_ENET, 4U),
kStatus_ENET_TxFrameOverLen = MAKE_STATUS(kStatusGroup_ENET, 5U),
kStatus_ENET_TxFrameBusy = MAKE_STATUS(kStatusGroup_ENET, 6U),
kStatus_ENET_TxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 7U)
} |
| Defines the status return codes for transaction. More...
|
|
enum | enet_mii_mode_t {
kENET_MiiMode = 0U,
kENET_RmiiMode = 1U
} |
| Defines the MII/RMII/RGMII 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/1000 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_write_t {
kENET_MiiWriteNoCompliant = 0U,
kENET_MiiWriteValidFrame
} |
| Define the MII opcode for normal MDIO_CLAUSES_22 Frame. More...
|
|
enum | enet_mii_read_t {
kENET_MiiReadValidFrame = 2U,
kENET_MiiReadNoCompliant = 3U
} |
| Defines the read operation for the MII management frame. More...
|
|
enum | enet_special_control_flag_t {
kENET_ControlFlowControlEnable = 0x0001U,
kENET_ControlRxPayloadCheckEnable = 0x0002U,
kENET_ControlRxPadRemoveEnable = 0x0004U,
kENET_ControlRxBroadCastRejectEnable = 0x0008U,
kENET_ControlMacAddrInsert = 0x0010U,
kENET_ControlStoreAndFwdDisable = 0x0020U,
kENET_ControlSMIPreambleDisable = 0x0040U,
kENET_ControlPromiscuousEnable = 0x0080U,
kENET_ControlMIILoopEnable = 0x0100U,
kENET_ControlVLANTagEnable = 0x0200U
} |
| Defines a special configuration for ENET MAC controller. More...
|
|
enum | enet_interrupt_enable_t {
kENET_BabrInterrupt = ENET_EIR_BABR_MASK,
kENET_BabtInterrupt = ENET_EIR_BABT_MASK,
kENET_GraceStopInterrupt = ENET_EIR_GRA_MASK,
kENET_TxFrameInterrupt = ENET_EIR_TXF_MASK,
kENET_TxBufferInterrupt = ENET_EIR_TXB_MASK,
kENET_RxFrameInterrupt = ENET_EIR_RXF_MASK,
kENET_RxBufferInterrupt = ENET_EIR_RXB_MASK,
kENET_MiiInterrupt = ENET_EIR_MII_MASK,
kENET_EBusERInterrupt = ENET_EIR_EBERR_MASK,
kENET_LateCollisionInterrupt = ENET_EIR_LC_MASK,
kENET_RetryLimitInterrupt = ENET_EIR_RL_MASK,
kENET_UnderrunInterrupt = ENET_EIR_UN_MASK,
kENET_PayloadRxInterrupt = ENET_EIR_PLR_MASK,
kENET_WakeupInterrupt = ENET_EIR_WAKEUP_MASK,
kENET_TsAvailInterrupt = ENET_EIR_TS_AVAIL_MASK,
kENET_TsTimerInterrupt = ENET_EIR_TS_TIMER_MASK
} |
| List of interrupts supported by the peripheral. More...
|
|
enum | enet_event_t {
kENET_RxEvent,
kENET_TxEvent,
kENET_ErrEvent,
kENET_WakeUpEvent,
kENET_TimeStampEvent,
kENET_TimeStampAvailEvent
} |
| Defines the common interrupt event for callback use. More...
|
|
enum | enet_tx_accelerator_t {
kENET_TxAccelIsShift16Enabled = ENET_TACC_SHIFT16_MASK,
kENET_TxAccelIpCheckEnabled = ENET_TACC_IPCHK_MASK,
kENET_TxAccelProtoCheckEnabled = ENET_TACC_PROCHK_MASK
} |
| Defines the transmit accelerator configuration. More...
|
|
enum | enet_rx_accelerator_t {
kENET_RxAccelPadRemoveEnabled = ENET_RACC_PADREM_MASK,
kENET_RxAccelIpCheckEnabled = ENET_RACC_IPDIS_MASK,
kENET_RxAccelProtoCheckEnabled = ENET_RACC_PRODIS_MASK,
kENET_RxAccelMacCheckEnabled = ENET_RACC_LINEDIS_MASK,
kENET_RxAccelisShift16Enabled = ENET_RACC_SHIFT16_MASK
} |
| Defines the receive accelerator configuration. More...
|
|
|
void | ENET_GetDefaultConfig (enet_config_t *config) |
| Gets the ENET default configuration structure. More...
|
|
status_t | ENET_Up (ENET_Type *base, enet_handle_t *handle, const enet_config_t *config, const enet_buffer_config_t *bufferConfig, uint8_t *macAddr, uint32_t srcClock_Hz) |
| Initializes the ENET module. More...
|
|
status_t | ENET_Init (ENET_Type *base, enet_handle_t *handle, const enet_config_t *config, const enet_buffer_config_t *bufferConfig, uint8_t *macAddr, uint32_t srcClock_Hz) |
| Initializes the ENET module. More...
|
|
void | ENET_Down (ENET_Type *base) |
| Stops the ENET module. More...
|
|
void | ENET_Deinit (ENET_Type *base) |
| Deinitializes the ENET module. More...
|
|
static void | ENET_Reset (ENET_Type *base) |
| Resets the ENET module. More...
|
|
|
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, uint32_t srcClock_Hz, bool isPreambleDisabled) |
| Sets the ENET SMI(serial management interface)- MII management interface. More...
|
|
static bool | ENET_GetSMI (ENET_Type *base) |
| Gets the ENET SMI- MII management interface configuration. More...
|
|
static uint32_t | ENET_ReadSMIData (ENET_Type *base) |
| Reads data from the PHY register through an SMI interface. More...
|
|
static void | ENET_StartSMIWrite (ENET_Type *base, uint8_t phyAddr, uint8_t regAddr, enet_mii_write_t operation, uint16_t data) |
| Sends the MDIO IEEE802.3 Clause 22 format write command. More...
|
|
static void | ENET_StartSMIRead (ENET_Type *base, uint8_t phyAddr, uint8_t regAddr, enet_mii_read_t operation) |
| Sends the MDIO IEEE802.3 Clause 22 format read command. More...
|
|
status_t | ENET_MDIOWrite (ENET_Type *base, uint8_t phyAddr, uint8_t regAddr, uint16_t data) |
| MDIO write with IEEE802.3 Clause 22 format. More...
|
|
status_t | ENET_MDIORead (ENET_Type *base, uint8_t phyAddr, uint8_t regAddr, uint16_t *pData) |
| MDIO read with IEEE802.3 Clause 22 format. More...
|
|
|
static void | ENET_ActiveRead (ENET_Type *base) |
| Activates frame reception for multiple rings. More...
|
|
static void | ENET_EnableSleepMode (ENET_Type *base, bool enable) |
| Enables/disables the MAC to enter sleep mode. More...
|
|
static void | ENET_GetAccelFunction (ENET_Type *base, uint32_t *txAccelOption, uint32_t *rxAccelOption) |
| Gets ENET transmit and receive accelerator functions from MAC controller. More...
|
|
|
void | ENET_GetRxErrBeforeReadFrame (enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic, uint8_t ringId) |
| Gets the error statistics of a received frame for ENET specified ring. More...
|
|
void | ENET_EnableStatistics (ENET_Type *base, bool enable) |
| Enables/disables collection of transfer statistics. More...
|
|
void | ENET_GetStatistics (ENET_Type *base, enet_transfer_stats_t *statistics) |
| Gets transfer statistics. More...
|
|
void | ENET_ResetStatistics (ENET_Type *base) |
| Resets transfer statistics. More...
|
|
status_t | ENET_GetRxFrameSize (enet_handle_t *handle, uint32_t *length, uint8_t ringId) |
| Gets the size of the read frame for specified ring. More...
|
|
status_t | ENET_ReadFrame (ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length, uint8_t ringId, uint32_t *ts) |
| Reads a frame from the ENET device. More...
|
|
status_t | ENET_SendFrame (ENET_Type *base, enet_handle_t *handle, const uint8_t *data, uint32_t length, uint8_t ringId, bool tsFlag, void *context) |
| Transmits an ENET frame for specified ring. More...
|
|
status_t | ENET_SetTxReclaim (enet_handle_t *handle, bool isEnable, uint8_t ringId) |
| Enable or disable tx descriptors reclaim mechanism. More...
|
|
void | ENET_ReclaimTxDescriptor (ENET_Type *base, enet_handle_t *handle, uint8_t ringId) |
| Reclaim tx descriptors. More...
|
|
status_t | ENET_GetRxFrame (ENET_Type *base, enet_handle_t *handle, enet_rx_frame_struct_t *rxFrame, uint8_t ringId) |
| Receives one frame in specified BD ring with zero copy. More...
|
|
status_t | ENET_StartTxFrame (ENET_Type *base, enet_handle_t *handle, enet_tx_frame_struct_t *txFrame, uint8_t ringId) |
| Sends one frame in specified BD ring with zero copy. More...
|
|
void | ENET_TransmitIRQHandler (ENET_Type *base, enet_handle_t *handle) |
| The transmit IRQ handler. More...
|
|
void | ENET_ReceiveIRQHandler (ENET_Type *base, enet_handle_t *handle) |
| The receive IRQ handler. More...
|
|
void | ENET_ErrorIRQHandler (ENET_Type *base, enet_handle_t *handle) |
| Some special IRQ handler including the error, mii, wakeup irq handler. More...
|
|
void | ENET_Ptp1588IRQHandler (ENET_Type *base) |
| the common IRQ handler for the 1588 irq handler. More...
|
|
void | ENET_CommonFrame0IRQHandler (ENET_Type *base) |
| the common IRQ handler for the tx/rx/error etc irq handler. More...
|
|
struct enet_rx_bd_struct_t |
uint16_t enet_rx_bd_struct_t::length |
uint16_t enet_rx_bd_struct_t::control |
uint32_t enet_rx_bd_struct_t::buffer |
struct enet_tx_bd_struct_t |
uint16_t enet_tx_bd_struct_t::length |
uint16_t enet_tx_bd_struct_t::control |
uint32_t enet_tx_bd_struct_t::buffer |
struct enet_data_error_stats_t |
uint32_t enet_data_error_stats_t::statsRxLenGreaterErr |
uint32_t enet_data_error_stats_t::statsRxFcsErr |
uint32_t enet_data_error_stats_t::statsRxOverRunErr |
uint32_t enet_data_error_stats_t::statsRxTruncateErr |
struct enet_rx_frame_error_t |
bool enet_rx_frame_error_t::statsRxTruncateErr |
bool enet_rx_frame_error_t::statsRxOverRunErr |
bool enet_rx_frame_error_t::statsRxFcsErr |
bool enet_rx_frame_error_t::statsRxAlignErr |
bool enet_rx_frame_error_t::statsRxLenGreaterErr |
struct enet_transfer_stats_t |
uint32_t enet_transfer_stats_t::statsRxFrameCount |
uint32_t enet_transfer_stats_t::statsRxFrameOk |
uint32_t enet_transfer_stats_t::statsRxCrcErr |
uint32_t enet_transfer_stats_t::statsRxAlignErr |
uint32_t enet_transfer_stats_t::statsRxDropInvalidSFD |
uint32_t enet_transfer_stats_t::statsRxFifoOverflowErr |
uint32_t enet_transfer_stats_t::statsTxFrameCount |
uint32_t enet_transfer_stats_t::statsTxFrameOk |
uint32_t enet_transfer_stats_t::statsTxCrcAlignErr |
uint32_t enet_transfer_stats_t::statsTxFifoUnderRunErr |
Data Fields |
void * | context |
| User specified data.
|
|
struct enet_tx_dirty_ring_t |
uint16_t enet_tx_dirty_ring_t::txGenIdx |
uint16_t enet_tx_dirty_ring_t::txConsumIdx |
uint16_t enet_tx_dirty_ring_t::txRingLen |
bool enet_tx_dirty_ring_t::isFull |
struct enet_buffer_config_t |
Note that for the internal DMA requirements, the buffers have a corresponding alignment requirements.
- The aligned receive and transmit buffer size must be evenly divisible by ENET_BUFF_ALIGNMENT. when the data buffers are in cacheable region when cache is enabled, all those size should be aligned to the maximum value of "ENET_BUFF_ALIGNMENT" and the cache line size.
- The aligned transmit and receive buffer descriptor start address must be at least 64 bit aligned. However, it's recommended to be evenly divisible by ENET_BUFF_ALIGNMENT. buffer descriptors should be put in non-cacheable region when cache is enabled.
- The aligned transmit and receive data buffer start address must be evenly divisible by ENET_BUFF_ALIGNMENT. Receive buffers should be continuous with the total size equal to "rxBdNumber * rxBuffSizeAlign". Transmit buffers should be continuous with the total size equal to "txBdNumber * txBuffSizeAlign". when the data buffers are in cacheable region when cache is enabled, all those size should be aligned to the maximum value of "ENET_BUFF_ALIGNMENT" and the cache line size.
uint16_t enet_buffer_config_t::rxBdNumber |
uint16_t enet_buffer_config_t::txBdNumber |
uint16_t enet_buffer_config_t::rxBuffSizeAlign |
uint16_t enet_buffer_config_t::txBuffSizeAlign |
uint8_t* enet_buffer_config_t::rxBufferAlign |
uint8_t* enet_buffer_config_t::txBufferAlign |
bool enet_buffer_config_t::rxMaintainEnable |
bool enet_buffer_config_t::txMaintainEnable |
Note:
- macSpecialConfig is used for a special control configuration, A logical OR of "enet_special_control_flag_t". For a special configuration for MAC, set this parameter to 0.
- txWatermark is used for a cut-through operation. It is in steps of 64 bytes: 0/1 - 64 bytes written to TX FIFO before transmission of a frame begins. 2 - 128 bytes written to TX FIFO .... 3 - 192 bytes written to TX FIFO .... The maximum of txWatermark is 0x2F - 4032 bytes written to TX FIFO .... txWatermark allows minimizing the transmit latency to set the txWatermark to 0 or 1 or for larger bus access latency 3 or larger due to contention for the system bus.
- rxFifoFullThreshold is similar to the txWatermark for cut-through operation in RX. It is in 64-bit words. The minimum is ENET_FIFO_MIN_RX_FULL and the maximum is 0xFF. If the end of the frame is stored in FIFO and the frame size if smaller than the txWatermark, the frame is still transmitted. The rule is the same for rxFifoFullThreshold in the receive direction.
- When "kENET_ControlFlowControlEnable" is set in the macSpecialConfig, ensure that the pauseDuration, rxFifoEmptyThreshold, and rxFifoStatEmptyThreshold are set for flow control enabled case.
- When "kENET_ControlStoreAndFwdDisabled" is set in the macSpecialConfig, ensure that the rxFifoFullThreshold and txFifoWatermark are set for store and forward disable.
- The rxAccelerConfig and txAccelerConfig default setting with 0 - accelerator are disabled. The "enet_tx_accelerator_t" and "enet_rx_accelerator_t" are recommended to be used to enable the transmit and receive accelerator. After the accelerators are enabled, the store and forward feature should be enabled. As a result, kENET_ControlStoreAndFwdDisabled should not be set.
- The intCoalesceCfg can be used in the rx or tx enabled cases to decrese the CPU loading.
uint32_t enet_config_t::macSpecialConfig |
A logical OR of "enet_special_control_flag_t".
uint32_t enet_config_t::interrupt |
A logical OR of "enet_interrupt_enable_t".
uint16_t enet_config_t::rxMaxFrameLen |
uint8_t enet_config_t::rxAccelerConfig |
uint8_t enet_config_t::txAccelerConfig |
uint16_t enet_config_t::pauseDuration |
uint8_t enet_config_t::rxFifoEmptyThreshold |
uint8_t enet_config_t::rxFifoFullThreshold |
uint8_t enet_config_t::txFifoWatermark |
uint8_t enet_config_t::ringNum |
default with 1 – single ring.
void* enet_config_t::userData |
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 |
uint16_t enet_rx_bd_ring_t::rxGenIdx |
uint16_t enet_rx_bd_ring_t::rxRingLen |
uint8_t enet_handle_t::ringNum |
void* enet_handle_t::userData |
#define FSL_FEATURE_ENET_QUEUE 1 /* Singal queue for previous IP. */ |
#define ENET_BUFFDESCRIPTOR_RX_EMPTY_MASK 0x8000U |
#define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER1_MASK 0x4000U |
#define ENET_BUFFDESCRIPTOR_RX_WRAP_MASK 0x2000U |
#define ENET_BUFFDESCRIPTOR_RX_SOFTOWNER2_Mask 0x1000U |
#define ENET_BUFFDESCRIPTOR_RX_LAST_MASK 0x0800U |
#define ENET_BUFFDESCRIPTOR_RX_MISS_MASK 0x0100U |
#define ENET_BUFFDESCRIPTOR_RX_BROADCAST_MASK 0x0080U |
#define ENET_BUFFDESCRIPTOR_RX_MULTICAST_MASK 0x0040U |
#define ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK 0x0020U |
#define ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK 0x0010U |
#define ENET_BUFFDESCRIPTOR_RX_CRC_MASK 0x0004U |
#define ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK 0x0002U |
#define ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK 0x0001U |
#define ENET_BUFFDESCRIPTOR_TX_READY_MASK 0x8000U |
#define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER1_MASK 0x4000U |
#define ENET_BUFFDESCRIPTOR_TX_WRAP_MASK 0x2000U |
#define ENET_BUFFDESCRIPTOR_TX_SOFTOWENER2_MASK 0x1000U |
#define ENET_BUFFDESCRIPTOR_TX_LAST_MASK 0x0800U |
#define ENET_BUFFDESCRIPTOR_TX_TRANMITCRC_MASK 0x0400U |
#define ENET_BUFFDESCRIPTOR_RX_ERR_MASK |
Value:
#define ENET_BUFFDESCRIPTOR_RX_CRC_MASK
CRC error mask.
Definition: fsl_enet.h:49
#define ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK
Length violation mask.
Definition: fsl_enet.h:47
#define ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK
Non-octet aligned frame mask.
Definition: fsl_enet.h:48
#define ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK
FIFO overrun mask.
Definition: fsl_enet.h:50
#define ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK
Frame is truncated mask.
Definition: fsl_enet.h:51
#define ENET_FRAME_MAX_FRAMELEN 1518U |
#define ENET_FRAME_VLAN_TAGLEN 4U |
#define ENET_FRAME_CRC_LEN 4U |
#define ENET_FIFO_MIN_RX_FULL 5U |
#define ENET_RX_MIN_BUFFERSIZE 256U |
#define ENET_PHY_MAXADDRESS (ENET_MMFR_PA_MASK >> ENET_MMFR_PA_SHIFT) |
#define ENET_ERR_INTERRUPT |
Value:
Babbling transmit error interrupt source.
Definition: fsl_enet.h:261
Babbling receive error interrupt source.
Definition: fsl_enet.h:260
Transmit FIFO underrun interrupt source.
Definition: fsl_enet.h:271
Late collision interrupt source.
Definition: fsl_enet.h:269
Collision Retry Limit interrupt source.
Definition: fsl_enet.h:270
Payload Receive error interrupt source.
Definition: fsl_enet.h:272
Ethernet bus error interrupt source.
Definition: fsl_enet.h:268
typedef void*(* enet_rx_alloc_callback_t)(ENET_Type *base, void *userData, uint8_t ringId) |
typedef void(* enet_rx_free_callback_t)(ENET_Type *base, void *buffer, void *userData, uint8_t ringId) |
typedef void(* enet_isr_t)(ENET_Type *base, enet_handle_t *handle) |
Enumerator |
---|
kStatus_ENET_InitMemoryFail |
Init fails since buffer memory is not enough.
|
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_RxFrameDrop |
Rx frame is dropped since no buffer memory.
|
kStatus_ENET_TxFrameOverLen |
Tx frame over length.
|
kStatus_ENET_TxFrameBusy |
Tx buffer descriptors are under process.
|
kStatus_ENET_TxFrameFail |
Transmit frame fail.
|
Enumerator |
---|
kENET_MiiMode |
MII mode for data interface.
|
kENET_RmiiMode |
RMII mode for data interface.
|
Notice: "kENET_MiiSpeed1000M" only supported when mii mode is "kENET_RgmiiMode".
Enumerator |
---|
kENET_MiiSpeed10M |
Speed 10 Mbps.
|
kENET_MiiSpeed100M |
Speed 100 Mbps.
|
Enumerator |
---|
kENET_MiiHalfDuplex |
Half duplex mode.
|
kENET_MiiFullDuplex |
Full duplex mode.
|
Enumerator |
---|
kENET_MiiWriteNoCompliant |
Write frame operation, but not MII-compliant.
|
kENET_MiiWriteValidFrame |
Write frame operation for a valid MII management frame.
|
Enumerator |
---|
kENET_MiiReadValidFrame |
Read frame operation for a valid MII management frame.
|
kENET_MiiReadNoCompliant |
Read frame operation, but not MII-compliant.
|
These control flags are provided for special user requirements. Normally, these control flags are unused for ENET initialization. For special requirements, set the flags to macSpecialConfig in the enet_config_t. The kENET_ControlStoreAndFwdDisable is used to disable the FIFO store and forward. FIFO store and forward means that the FIFO read/send is started when a complete frame is stored in TX/RX FIFO. If this flag is set, configure rxFifoFullThreshold and txFifoWatermark in the enet_config_t.
Enumerator |
---|
kENET_ControlFlowControlEnable |
Enable ENET flow control: pause frame.
|
kENET_ControlRxPayloadCheckEnable |
Enable ENET receive payload length check.
|
kENET_ControlRxPadRemoveEnable |
Padding is removed from received frames.
|
kENET_ControlRxBroadCastRejectEnable |
Enable broadcast frame reject.
|
kENET_ControlMacAddrInsert |
Enable MAC address insert.
|
kENET_ControlStoreAndFwdDisable |
Enable FIFO store and forward.
|
kENET_ControlSMIPreambleDisable |
Enable SMI preamble.
|
kENET_ControlPromiscuousEnable |
Enable promiscuous mode.
|
kENET_ControlMIILoopEnable |
Enable ENET MII loop back.
|
kENET_ControlVLANTagEnable |
Enable normal VLAN (single vlan tag).
|
This enumeration uses one-bit encoding to allow a logical OR of multiple members. Members usually map to interrupt enable bits in one or more peripheral registers.
Enumerator |
---|
kENET_BabrInterrupt |
Babbling receive error interrupt source.
|
kENET_BabtInterrupt |
Babbling transmit error interrupt source.
|
kENET_GraceStopInterrupt |
Graceful stop complete interrupt source.
|
kENET_TxFrameInterrupt |
TX FRAME interrupt source.
|
kENET_TxBufferInterrupt |
TX BUFFER interrupt source.
|
kENET_RxFrameInterrupt |
RX FRAME interrupt source.
|
kENET_RxBufferInterrupt |
RX BUFFER interrupt source.
|
kENET_MiiInterrupt |
MII interrupt source.
|
kENET_EBusERInterrupt |
Ethernet bus error interrupt source.
|
kENET_LateCollisionInterrupt |
Late collision interrupt source.
|
kENET_RetryLimitInterrupt |
Collision Retry Limit interrupt source.
|
kENET_UnderrunInterrupt |
Transmit FIFO underrun interrupt source.
|
kENET_PayloadRxInterrupt |
Payload Receive error interrupt source.
|
kENET_WakeupInterrupt |
WAKEUP interrupt source.
|
kENET_TsAvailInterrupt |
TS AVAIL interrupt source for PTP.
|
kENET_TsTimerInterrupt |
TS WRAP interrupt source for PTP.
|
Enumerator |
---|
kENET_RxEvent |
Receive event.
|
kENET_TxEvent |
Transmit event.
|
kENET_ErrEvent |
Error event: BABR/BABT/EBERR/LC/RL/UN/PLR .
|
kENET_WakeUpEvent |
Wake up from sleep mode event.
|
kENET_TimeStampEvent |
Time stamp event.
|
kENET_TimeStampAvailEvent |
Time stamp available event.
|
Enumerator |
---|
kENET_TxAccelIsShift16Enabled |
Transmit FIFO shift-16.
|
kENET_TxAccelIpCheckEnabled |
Insert IP header checksum.
|
kENET_TxAccelProtoCheckEnabled |
Insert protocol checksum.
|
Enumerator |
---|
kENET_RxAccelPadRemoveEnabled |
Padding removal for short IP frames.
|
kENET_RxAccelIpCheckEnabled |
Discard with wrong IP header checksum.
|
kENET_RxAccelProtoCheckEnabled |
Discard with wrong protocol checksum.
|
kENET_RxAccelMacCheckEnabled |
Discard with Mac layer errors.
|
kENET_RxAccelisShift16Enabled |
Receive FIFO shift-16.
|
uint32_t ENET_GetInstance |
( |
ENET_Type * |
base | ) |
|
- Parameters
-
base | ENET peripheral base address. |
- Returns
- ENET instance.
The purpose of this API is to get the default ENET MAC controller 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
-
config | The ENET mac controller configuration structure pointer. |
This function initializes the module with the ENET configuration.
- Note
- ENET has two buffer descriptors legacy buffer descriptors and enhanced IEEE 1588 buffer descriptors. The legacy descriptor is used by default. To use the IEEE 1588 feature, use the enhanced IEEE 1588 buffer descriptor by defining "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" and calling ENET_Ptp1588Configure() to configure the 1588 feature and related buffers after calling ENET_Up().
- Parameters
-
base | ENET peripheral base address. |
handle | ENET handler pointer. |
config | ENET 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. |
bufferConfig | ENET buffer configuration structure pointer. The buffer configuration should be prepared for ENET Initialization. It is the start address of "ringNum" enet_buffer_config structures. To support added multi-ring features in some soc and compatible with the previous enet driver version. For single ring supported, this bufferConfig is a buffer configure structure pointer, for multi-ring supported and used case, this bufferConfig pointer should be a buffer configure structure array pointer. |
macAddr | ENET mac address of Ethernet device. This MAC address should be provided. |
srcClock_Hz | The internal module clock source for MII clock. |
- Return values
-
kStatus_Success | Succeed to initialize the ethernet driver. |
kStatus_ENET_InitMemoryFail | Init fails since buffer memory is not enough. |
This function ungates the module clock and initializes it with the ENET configuration.
- Note
- ENET has two buffer descriptors legacy buffer descriptors and enhanced IEEE 1588 buffer descriptors. The legacy descriptor is used by default. To use the IEEE 1588 feature, use the enhanced IEEE 1588 buffer descriptor by defining "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" and calling ENET_Ptp1588Configure() to configure the 1588 feature and related buffers after calling ENET_Init().
- Parameters
-
base | ENET peripheral base address. |
handle | ENET handler pointer. |
config | ENET 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. |
bufferConfig | ENET buffer configuration structure pointer. The buffer configuration should be prepared for ENET Initialization. It is the start address of "ringNum" enet_buffer_config structures. To support added multi-ring features in some soc and compatible with the previous enet driver version. For single ring supported, this bufferConfig is a buffer configure structure pointer, for multi-ring supported and used case, this bufferConfig pointer should be a buffer configure structure array pointer. |
macAddr | ENET mac address of Ethernet device. This MAC address should be provided. |
srcClock_Hz | The internal module clock source for MII clock. |
- Return values
-
kStatus_Success | Succeed to initialize the ethernet driver. |
kStatus_ENET_InitMemoryFail | Init fails since buffer memory is not enough. |
void ENET_Down |
( |
ENET_Type * |
base | ) |
|
This function disables the ENET module.
- Parameters
-
base | ENET peripheral base address. |
void ENET_Deinit |
( |
ENET_Type * |
base | ) |
|
This function gates the module clock, clears ENET interrupts, and disables the ENET module.
- Parameters
-
base | ENET peripheral base address. |
static void ENET_Reset |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
This function restores the ENET module to reset state. Note that this function sets all registers to reset state. As a result, the ENET module can't work after calling this function.
- Parameters
-
base | ENET peripheral base address. |
This API is provided to dynamically change the speed and dulpex for MAC.
- Parameters
-
base | ENET peripheral base address. |
speed | The speed of the RMII mode. |
duplex | The duplex of the RMII mode. |
void ENET_SetSMI |
( |
ENET_Type * |
base, |
|
|
uint32_t |
srcClock_Hz, |
|
|
bool |
isPreambleDisabled |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
srcClock_Hz | This is the ENET module clock frequency. See clock distribution. |
isPreambleDisabled | The preamble disable flag.
- true Enables the preamble.
- false Disables the preamble.
|
static bool ENET_GetSMI |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
This API is used to get the SMI configuration to check whether the MII management interface has been set.
- Parameters
-
base | ENET peripheral base address. |
- Returns
- The SMI setup status true or false.
static uint32_t ENET_ReadSMIData |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | ENET peripheral base address. |
- Returns
- The data read from PHY
static void ENET_StartSMIWrite |
( |
ENET_Type * |
base, |
|
|
uint8_t |
phyAddr, |
|
|
uint8_t |
regAddr, |
|
|
enet_mii_write_t |
operation, |
|
|
uint16_t |
data |
|
) |
| |
|
inlinestatic |
After calling this function, need to check whether the transmission is over then do next MDIO operation. For ease of use, encapsulated ENET_MDIOWrite() can be called. For customized requirements, implement with combining separated APIs.
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. Range from 0 ~ 31. |
regAddr | The PHY register address. Range from 0 ~ 31. |
operation | The write operation. |
data | The data written to PHY. |
static void ENET_StartSMIRead |
( |
ENET_Type * |
base, |
|
|
uint8_t |
phyAddr, |
|
|
uint8_t |
regAddr, |
|
|
enet_mii_read_t |
operation |
|
) |
| |
|
inlinestatic |
After calling this function, need to check whether the transmission is over then do next MDIO operation. For ease of use, encapsulated ENET_MDIORead() can be called. For customized requirements, implement with combining separated APIs.
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. Range from 0 ~ 31. |
regAddr | The PHY register address. Range from 0 ~ 31. |
operation | The read operation. |
status_t ENET_MDIOWrite |
( |
ENET_Type * |
base, |
|
|
uint8_t |
phyAddr, |
|
|
uint8_t |
regAddr, |
|
|
uint16_t |
data |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. Range from 0 ~ 31. |
regAddr | The PHY register. Range from 0 ~ 31. |
data | The data written to PHY. |
- Returns
- kStatus_Success MDIO access succeeds.
-
kStatus_Timeout MDIO access timeout.
status_t ENET_MDIORead |
( |
ENET_Type * |
base, |
|
|
uint8_t |
phyAddr, |
|
|
uint8_t |
regAddr, |
|
|
uint16_t * |
pData |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. Range from 0 ~ 31. |
regAddr | The PHY register. Range from 0 ~ 31. |
pData | The data read from PHY. |
- Returns
- kStatus_Success MDIO access succeeds.
-
kStatus_Timeout MDIO access timeout.
void ENET_SetMacAddr |
( |
ENET_Type * |
base, |
|
|
uint8_t * |
macAddr |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
macAddr | The 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
-
base | ENET peripheral base address. |
macAddr | The six-byte Mac address pointer. The pointer is allocated by application and input into the API. |
void ENET_AddMulticastGroup |
( |
ENET_Type * |
base, |
|
|
uint8_t * |
address |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
address | The six-byte multicast group address which is provided by application. |
void ENET_LeaveMulticastGroup |
( |
ENET_Type * |
base, |
|
|
uint8_t * |
address |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
address | The six-byte multicast group address which is provided by application. |
static void ENET_ActiveRead |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
This function is to active the enet read process.
- Note
- This must be called after the MAC configuration and state are ready. It must be called after the ENET_Init(). This should be called when the frame reception is required.
- Parameters
-
base | ENET peripheral base address. |
static void ENET_EnableSleepMode |
( |
ENET_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
This function is used to set the MAC enter sleep mode. When entering sleep mode, the magic frame wakeup interrupt should be enabled to wake up MAC from the sleep mode and reset it to normal mode.
- Parameters
-
base | ENET peripheral base address. |
enable | True enable sleep mode, false disable sleep mode. |
static void ENET_GetAccelFunction |
( |
ENET_Type * |
base, |
|
|
uint32_t * |
txAccelOption, |
|
|
uint32_t * |
rxAccelOption |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ENET peripheral base address. |
txAccelOption | The transmit accelerator option. The "enet_tx_accelerator_t" is recommended to be used to as the mask to get the exact the accelerator option. |
rxAccelOption | The receive accelerator option. The "enet_rx_accelerator_t" is recommended to be used to as the mask to get the exact the accelerator option. |
static void ENET_EnableInterrupts |
( |
ENET_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
This function enables the ENET interrupt according to the provided mask. The mask is a logical OR of enumeration members. See enet_interrupt_enable_t. For example, to enable the TX frame interrupt and RX frame interrupt, do the following.
- Parameters
-
base | ENET peripheral base address. |
mask | ENET interrupts to enable. This is a logical OR of the enumeration enet_interrupt_enable_t. |
static void ENET_DisableInterrupts |
( |
ENET_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
This function disables the ENET interrupts according to the provided mask. The mask is a logical OR of enumeration members. See enet_interrupt_enable_t. For example, to disable the TX frame interrupt and RX frame interrupt, do the following.
- Parameters
-
base | ENET peripheral base address. |
mask | ENET interrupts to disable. This is a logical OR of the enumeration enet_interrupt_enable_t. |
static uint32_t ENET_GetInterruptStatus |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
base | ENET peripheral base address. |
- Returns
- The event status of the interrupt source. This is the logical OR of members of the enumeration enet_interrupt_enable_t.
static void ENET_ClearInterruptStatus |
( |
ENET_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
This function clears enabled ENET interrupts according to the provided mask. The mask is a logical OR of enumeration members. See the enet_interrupt_enable_t. For example, to clear the TX frame interrupt and RX frame interrupt, do the following.
- Parameters
-
base | ENET peripheral base address. |
mask | ENET interrupt source to be cleared. This is the logical OR of members of the enumeration enet_interrupt_enable_t. |
void ENET_SetRxISRHandler |
( |
ENET_Type * |
base, |
|
|
enet_isr_t |
ISRHandler |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
ISRHandler | The handler to install. |
void ENET_SetTxISRHandler |
( |
ENET_Type * |
base, |
|
|
enet_isr_t |
ISRHandler |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
ISRHandler | The handler to install. |
void ENET_SetErrISRHandler |
( |
ENET_Type * |
base, |
|
|
enet_isr_t |
ISRHandler |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
ISRHandler | The handler to install. |
void ENET_GetRxErrBeforeReadFrame |
( |
enet_handle_t * |
handle, |
|
|
enet_data_error_stats_t * |
eErrorStatic, |
|
|
uint8_t |
ringId |
|
) |
| |
This API must be called after the ENET_GetRxFrameSize and before the ENET_ReadFrame(). If the ENET_GetRxFrameSize returns kStatus_ENET_RxFrameError, the ENET_GetRxErrBeforeReadFrame can be used to get the exact error statistics. This is an example.
* {
* Comments: Get the error information of the received frame.
* Comments: update the receive buffer.
* }
*
- Parameters
-
handle | The ENET handler structure pointer. This is the same handler pointer used in the ENET_Init. |
eErrorStatic | The error statistics structure pointer. |
ringId | The ring index, range from 0 ~ (FSL_FEATURE_ENET_INSTANCE_QUEUEn(x) - 1). |
void ENET_EnableStatistics |
( |
ENET_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
Note that this function does not reset any of the already collected data, use the function ENET_ResetStatistics to clear the transfer statistics if needed.
- Parameters
-
base | ENET peripheral base address. |
enable | True enable statistics collection, false disable statistics collection. |
Copies the actual value of hardware counters into the provided structure. Calling this function does not reset the counters in hardware.
- Parameters
-
base | ENET peripheral base address. |
statistics | The statistics structure pointer. |
void ENET_ResetStatistics |
( |
ENET_Type * |
base | ) |
|
Sets the value of hardware transfer counters to zero.
- Parameters
-
base | ENET peripheral base address. |
status_t ENET_GetRxFrameSize |
( |
enet_handle_t * |
handle, |
|
|
uint32_t * |
length, |
|
|
uint8_t |
ringId |
|
) |
| |
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 receive frame and update the BD if the result is not "kStatus_ENET_RxFrameEmpty".
- Parameters
-
handle | The ENET handler structure. This is the same handler pointer used in the ENET_Init. |
length | The length of the valid frame received. |
ringId | The ring index or ring number. |
- Return values
-
kStatus_ENET_RxFrameEmpty | No frame received. Should not call ENET_ReadFrame to read frame. |
kStatus_ENET_RxFrameError | Data error happens. ENET_ReadFrame should be called with NULL data and NULL length to update the receive buffers. |
kStatus_Success | Receive 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 |
ringId, |
|
|
uint32_t * |
ts |
|
) |
| |
This function reads a frame (both the data and the length) from the ENET buffer descriptors. User can get timestamp through ts pointer if the ts is not NULL.
- Note
- It doesn't store the timestamp in the receive timestamp queue. The ENET_GetRxFrameSize should be used to get the size of the prepared data buffer. This API uses memcpy to copy data from DMA buffer to application buffer, 4 bytes aligned data buffer in 32 bits platforms provided by user may let compiler use optimization instruction to reduce time consumption. This is an example:
* uint32_t length;
* enet_handle_t g_handle;
* Comments: Get the received frame size firstly.
* if (length != 0)
* {
* Comments: Allocate memory here with the size of "length"
* uint8_t *data = memory allocate interface;
* if (!data)
* {
* Comments: Add the console warning log.
* }
* else
* {
* Comments: Call stack input API to deliver the data to stack
* }
* }
* {
* Comments: Update the received buffer when a error frame is received.
* }
*
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler structure. This is the same handler pointer used in the ENET_Init. |
data | The data buffer provided by user to store the frame which memory size should be at least "length". |
length | The size of the data buffer which is still the length of the received frame. |
ringId | The ring index or ring number. |
ts | The timestamp address to store received timestamp. |
- Returns
- The execute status, successful or failure.
status_t ENET_SendFrame |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
const uint8_t * |
data, |
|
|
uint32_t |
length, |
|
|
uint8_t |
ringId, |
|
|
bool |
tsFlag, |
|
|
void * |
context |
|
) |
| |
- Note
- The CRC is automatically appended to the data. Input the data to send without the CRC. This API uses memcpy to copy data from DMA buffer to application buffer, 4 bytes aligned data buffer in 32 bits platforms provided by user may let compiler use optimization instruction to reduce time consumption.
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. This is the same handler pointer used in the ENET_Init. |
data | The data buffer provided by user to send. |
length | The length of the data to send. |
ringId | The ring index or ring number. |
tsFlag | Timestamp enable flag. |
context | Used by user to handle some events after transmit over. |
- Return values
-
kStatus_Success | Send frame succeed. |
kStatus_ENET_TxFrameBusy | Transmit 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. |
status_t ENET_SetTxReclaim |
( |
enet_handle_t * |
handle, |
|
|
bool |
isEnable, |
|
|
uint8_t |
ringId |
|
) |
| |
- Note
- This function must be called when no pending send frame action. Set enable if you want to reclaim context or timestamp in interrupt.
- Parameters
-
handle | The ENET handler pointer. This is the same handler pointer used in the ENET_Init. |
isEnable | Enable or disable flag. |
ringId | The ring index or ring number. |
- Return values
-
kStatus_Success | Succeed to enable/disable Tx reclaim. |
kStatus_Fail | Fail to enable/disable Tx reclaim. |
void ENET_ReclaimTxDescriptor |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
uint8_t |
ringId |
|
) |
| |
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
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. This is the same handler pointer used in the ENET_Init. |
ringId | The ring index or ring number. |
status_t ENET_GetRxFrame |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
enet_rx_frame_struct_t * |
rxFrame, |
|
|
uint8_t |
ringId |
|
) |
| |
This function uses the user-defined allocation and free callbacks. Every time application gets one frame through this function, driver stores the buffer address(es) in enet_buffer_struct_t and allocate new buffer(s) for the BD(s). If there's no memory buffer in the pool, this function drops current one frame to keep the Rx frame in BD ring is as fresh as possible.
- Note
- Application must provide a memory pool including at least BD number + n buffers in order for this function to work properly, because each BD must always take one buffer while driver is running, then other extra n buffer(s) can be taken by application. Here n is the ceil(max_frame_length(set by RCR) / bd_rx_size(set by MRBR)). Application must also provide an array structure in rxFrame->rxBuffArray with n index to receive one complete frame in any case.
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. This is the same handler pointer used in the ENET_Init. |
rxFrame | The received frame information structure provided by user. |
ringId | The ring index or ring number. |
- Return values
-
kStatus_Success | Succeed to get one frame and allocate new memory for Rx buffer. |
kStatus_ENET_RxFrameEmpty | There's no Rx frame in the BD. |
kStatus_ENET_RxFrameError | There's issue in this receiving. |
kStatus_ENET_RxFrameDrop | There's no new buffer memory for BD, drop this frame. |
status_t ENET_StartTxFrame |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
enet_tx_frame_struct_t * |
txFrame, |
|
|
uint8_t |
ringId |
|
) |
| |
This function supports scattered buffer transmit, user needs to provide the buffer array.
- Note
- Tx reclaim should be enabled to ensure the Tx buffer ownership can be given back to application after Tx is over.
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. This is the same handler pointer used in the ENET_Init. |
txFrame | The Tx frame structure. |
ringId | The ring index or ring number. |
- Return values
-
kStatus_Success | Succeed to send one frame. |
kStatus_ENET_TxFrameBusy | The BD is not ready for Tx or the reclaim operation still not finishs. |
kStatus_ENET_TxFrameOverLen | The Tx frame length is over max ethernet frame length. |
void ENET_TransmitIRQHandler |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. |
void ENET_ReceiveIRQHandler |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. |
void ENET_ErrorIRQHandler |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. |
void ENET_Ptp1588IRQHandler |
( |
ENET_Type * |
base | ) |
|
This is used for the 1588 timer interrupt.
- Parameters
-
base | ENET peripheral base address. |
void ENET_CommonFrame0IRQHandler |
( |
ENET_Type * |
base | ) |
|
This is used for the combined tx/rx/error interrupt for single/mutli-ring (frame 0).
- Parameters
-
base | ENET peripheral base address. |
const clock_ip_name_t s_enetClock[] |