The MCUXpresso SDK provides a peripheral driver for the 10/100 Mbps Ethernet MAC (ENET) module of MCUXpresso SDK devices.
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.
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.
This group has the receive active API ENET_ActiveRead() and ENET_ActiveReadMultiRing() 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.
- For single ring
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.
- For multiple-ring supported
The ENET driver now added a series transactional APIs with postfix "MultiRing" to support the extended multiple-ring for AVB feature. There are extended multiple-ring functions for receive side: ENET_GetRxErrBeforeReadFrameMultiRing(), ENET_GetRxFrameSizeMultiRing(), and ENET_ReadFrameMultiRing(). They are the similar to the single ring receive APIs and only add the "ringId" input param to identify the different ring index. For TX side add the ENET_SendFrameMultiRing, ENET_GetTxErrAfterSendFrameMultiRing(). They are the similar to the single ring transmit APIs and only add the "ringId" input param to identify the different ring index.
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. 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 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
|
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_TxFrameOverLen = MAKE_STATUS(kStatusGroup_ENET, 3U),
kStatus_ENET_TxFrameBusy = MAKE_STATUS(kStatusGroup_ENET, 4U),
kStatus_ENET_TxFrameFail = MAKE_STATUS(kStatusGroup_ENET, 5U),
kStatus_ENET_PtpTsRingFull = MAKE_STATUS(kStatusGroup_ENET, 6U),
kStatus_ENET_PtpTsRingEmpty = MAKE_STATUS(kStatusGroup_ENET, 7U)
} |
| Defines the status return codes for transaction. More...
|
|
enum | enet_mii_mode_t {
kENET_MiiMode = 0U,
kENET_RmiiMode = 1U,
kENET_RgmiiMode = 2U
} |
| 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,
kENET_MiiSpeed1000M = 2U
} |
| 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_mii_extend_opcode {
kENET_MiiAddrWrite_C45 = 0U,
kENET_MiiWriteFrame_C45 = 1U,
kENET_MiiReadFrame_C45 = 3U
} |
| Define the MII opcode for extended MDIO_CLAUSES_45 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,
kENET_ControlSVLANEnable = 0x0400U,
kENET_ControlVLANUseSecondTag = 0x0800U
} |
| 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_RxFlush2Interrupt = ENET_EIR_RXFLUSH_2_MASK,
kENET_RxFlush1Interrupt = ENET_EIR_RXFLUSH_1_MASK,
kENET_RxFlush0Interrupt = ENET_EIR_RXFLUSH_0_MASK,
kENET_TxFrame2Interrupt = ENET_EIR_TXF2_MASK,
kENET_TxBuffer2Interrupt = ENET_EIR_TXB2_MASK,
kENET_RxFrame2Interrupt = ENET_EIR_RXF2_MASK,
kENET_RxBuffer2Interrupt = ENET_EIR_RXB2_MASK,
kENET_TxFrame1Interrupt = ENET_EIR_TXF1_MASK,
kENET_TxBuffer1Interrupt = ENET_EIR_TXB1_MASK,
kENET_RxFrame1Interrupt = ENET_EIR_RXF1_MASK,
kENET_RxBuffer1Interrupt = ENET_EIR_RXB1_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_idle_slope_t {
kENET_IdleSlope1 = 1U,
kENET_IdleSlope2 = 2U,
kENET_IdleSlope4 = 4U,
kENET_IdleSlope8 = 8U,
kENET_IdleSlope16 = 16U,
kENET_IdleSlope32 = 32U,
kENET_IdleSlope64 = 64U,
kENET_IdleSlope128 = 128U,
kENET_IdleSlope256 = 256U,
kENET_IdleSlope384 = 384U,
kENET_IdleSlope512 = 512U,
kENET_IdleSlope640 = 640U,
kENET_IdleSlope768 = 768U,
kENET_IdleSlope896 = 896U,
kENET_IdleSlope1024 = 1024U,
kENET_IdleSlope1152 = 1152U,
kENET_IdleSlope1280 = 1280U,
kENET_IdleSlope1408 = 1408U,
kENET_IdleSlope1536 = 1536U
} |
| Defines certain idle slope for bandwidth fraction. 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...
|
|
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...
|
|
enum | enet_ptp_timer_channel_t {
kENET_PtpTimerChannel1 = 0U,
kENET_PtpTimerChannel2,
kENET_PtpTimerChannel3,
kENET_PtpTimerChannel4
} |
| Defines the IEEE 1588 PTP timer channel numbers. More...
|
|
enum | enet_ptp_timer_channel_mode_t {
kENET_PtpChannelDisable = 0U,
kENET_PtpChannelRisingCapture = 1U,
kENET_PtpChannelFallingCapture = 2U,
kENET_PtpChannelBothCapture = 3U,
kENET_PtpChannelSoftCompare = 4U,
kENET_PtpChannelToggleCompare = 5U,
kENET_PtpChannelClearCompare = 6U,
kENET_PtpChannelSetCompare = 7U,
kENET_PtpChannelClearCompareSetOverflow = 10U,
kENET_PtpChannelSetCompareClearOverflow = 11U,
kENET_PtpChannelPulseLowonCompare = 14U,
kENET_PtpChannelPulseHighonCompare = 15U
} |
| Defines the capture or compare mode for IEEE 1588 PTP timer channels. 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...
|
|
void | ENET_StartSMIRead (ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_read_t operation) |
| Starts an SMI (Serial Management Interface) read command. More...
|
|
void | ENET_StartSMIWrite (ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, enet_mii_write_t operation, uint32_t data) |
| Starts an SMI write command. More...
|
|
void | ENET_StartExtC45SMIRead (ENET_Type *base, uint32_t phyAddr, uint32_t phyReg) |
| Starts the extended IEEE802.3 Clause 45 MDIO format SMI read command. More...
|
|
void | ENET_StartExtC45SMIWrite (ENET_Type *base, uint32_t phyAddr, uint32_t phyReg, uint32_t data) |
| Starts the extended IEEE802.3 Clause 45 MDIO format SMI write command. More...
|
|
static void | ENET_SetRGMIIClockDelay (ENET_Type *base, bool txEnabled, bool rxEnabled) |
| Control the usage of the delayed tx/rx RGMII clock. More...
|
|
|
void | ENET_SetCallback (enet_handle_t *handle, enet_callback_t callback, void *userData) |
| Sets the callback function. More...
|
|
void | ENET_GetRxErrBeforeReadFrame (enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic) |
| Gets the error statistics of a received frame for ENET single ring. More...
|
|
status_t | ENET_GetTxErrAfterSendFrame (enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic) |
| Gets the ENET transmit frame statistics after the data send for single ring. More...
|
|
status_t | ENET_GetRxFrameSize (enet_handle_t *handle, uint32_t *length) |
| Gets the size of the read frame for single ring. More...
|
|
status_t | ENET_ReadFrame (ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length) |
| Reads a frame from the ENET device for single ring. More...
|
|
status_t | ENET_SendFrame (ENET_Type *base, enet_handle_t *handle, const uint8_t *data, uint32_t length) |
| Transmits an ENET frame for single ring. More...
|
|
void | ENET_GetRxErrBeforeReadFrameMultiRing (enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic, uint32_t ringId) |
| Gets the error statistics of received frame for extended multi-ring. More...
|
|
status_t | ENET_SendFrameMultiRing (ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length, uint32_t ringId) |
| Transmits an ENET frame for extended multi-ring. More...
|
|
status_t | ENET_GetTxErrAfterSendFrameMultiRing (enet_handle_t *handle, enet_data_error_stats_t *eErrorStatic, uint32_t ringId) |
| Gets the ENET transmit frame statistics after the data send for extended multi-ring. More...
|
|
status_t | ENET_GetRxFrameSizeMultiRing (enet_handle_t *handle, uint32_t *length, uint32_t ringId) |
| Gets the size of the read frame for extended mutli-ring. More...
|
|
status_t | ENET_ReadFrameMultiRing (ENET_Type *base, enet_handle_t *handle, uint8_t *data, uint32_t length, uint32_t ringId) |
| Reads a frame from the ENET device for multi-ring. More...
|
|
void | ENET_TransmitIRQHandler (ENET_Type *base, enet_handle_t *handle, uint32_t ringId) |
| The transmit IRQ handler. More...
|
|
void | ENET_ReceiveIRQHandler (ENET_Type *base, enet_handle_t *handle, uint32_t ringId) |
| The receive IRQ handler. More...
|
|
void | ENET_CommonFrame1IRQHandler (ENET_Type *base) |
| the common IRQ handler for the tx/rx irq handler. More...
|
|
void | ENET_CommonFrame2IRQHandler (ENET_Type *base) |
| the common IRQ handler for the tx/rx 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_CommonFrame0IRQHandler (ENET_Type *base) |
| the common IRQ handler for the tx/rx/error etc irq handler. More...
|
|
|
void | ENET_Ptp1588Configure (ENET_Type *base, enet_handle_t *handle, enet_ptp_config_t *ptpConfig) |
| Configures the ENET PTP IEEE 1588 feature with the basic configuration. More...
|
|
void | ENET_Ptp1588StartTimer (ENET_Type *base, uint32_t ptpClkSrc) |
| Starts the ENET PTP 1588 Timer. More...
|
|
static void | ENET_Ptp1588StopTimer (ENET_Type *base) |
| Stops the ENET PTP 1588 Timer. More...
|
|
void | ENET_Ptp1588AdjustTimer (ENET_Type *base, uint32_t corrIncrease, uint32_t corrPeriod) |
| Adjusts the ENET PTP 1588 timer. More...
|
|
static void | ENET_Ptp1588SetChannelMode (ENET_Type *base, enet_ptp_timer_channel_t channel, enet_ptp_timer_channel_mode_t mode, bool intEnable) |
| Sets the ENET PTP 1588 timer channel mode. More...
|
|
static void | ENET_Ptp1588SetChannelCmpValue (ENET_Type *base, enet_ptp_timer_channel_t channel, uint32_t cmpValue) |
| Sets the ENET PTP 1588 timer channel comparison value. More...
|
|
static bool | ENET_Ptp1588GetChannelStatus (ENET_Type *base, enet_ptp_timer_channel_t channel) |
| Gets the ENET PTP 1588 timer channel status. More...
|
|
static void | ENET_Ptp1588ClearChannelStatus (ENET_Type *base, enet_ptp_timer_channel_t channel) |
| Clears the ENET PTP 1588 timer channel status. More...
|
|
void | ENET_Ptp1588GetTimer (ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime) |
| Gets the current ENET time from the PTP 1588 timer. More...
|
|
void | ENET_Ptp1588SetTimer (ENET_Type *base, enet_handle_t *handle, enet_ptp_time_t *ptpTime) |
| Sets the ENET PTP 1588 timer to the assigned time. More...
|
|
void | ENET_Ptp1588TimerIRQHandler (ENET_Type *base, enet_handle_t *handle) |
| The IEEE 1588 PTP time stamp interrupt handler. More...
|
|
status_t | ENET_GetRxFrameTime (enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData) |
| Gets the time stamp of the received frame. More...
|
|
status_t | ENET_GetTxFrameTime (enet_handle_t *handle, enet_ptp_time_data_t *ptpTimeData) |
| Gets the time stamp of the transmit frame. More...
|
|
struct enet_rx_bd_struct_t |
uint16_t enet_rx_bd_struct_t::length |
uint16_t enet_rx_bd_struct_t::control |
uint8_t* enet_rx_bd_struct_t::buffer |
uint16_t enet_rx_bd_struct_t::controlExtend0 |
uint16_t enet_rx_bd_struct_t::controlExtend1 |
uint16_t enet_rx_bd_struct_t::payloadCheckSum |
uint8_t enet_rx_bd_struct_t::headerLength |
uint8_t enet_rx_bd_struct_t::protocolTyte |
uint16_t enet_rx_bd_struct_t::controlExtend2 |
uint32_t enet_rx_bd_struct_t::timestamp |
struct enet_tx_bd_struct_t |
uint16_t enet_tx_bd_struct_t::length |
uint16_t enet_tx_bd_struct_t::control |
uint8_t* enet_tx_bd_struct_t::buffer |
uint16_t enet_tx_bd_struct_t::controlExtend0 |
uint16_t enet_tx_bd_struct_t::controlExtend1 |
int8_t* enet_tx_bd_struct_t::txLaunchTime |
uint16_t enet_tx_bd_struct_t::controlExtend2 |
uint32_t enet_tx_bd_struct_t::timestamp |
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 |
uint32_t enet_data_error_stats_t::statsRxProtocolChecksumErr |
uint32_t enet_data_error_stats_t::statsRxIpHeadChecksumErr |
uint32_t enet_data_error_stats_t::statsRxMacErr |
uint32_t enet_data_error_stats_t::statsRxPhyErr |
uint32_t enet_data_error_stats_t::statsRxCollisionErr |
uint32_t enet_data_error_stats_t::statsTxErr |
uint32_t enet_data_error_stats_t::statsTxFrameErr |
uint32_t enet_data_error_stats_t::statsTxOverFlowErr |
uint32_t enet_data_error_stats_t::statsTxLateCollisionErr |
uint32_t enet_data_error_stats_t::statsTxExcessCollisionErr |
uint32_t enet_data_error_stats_t::statsTxUnderFlowErr |
uint32_t enet_data_error_stats_t::statsTxTsErr |
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 |
uint32_t enet_buffer_config_t::rxBuffSizeAlign |
uint32_t enet_buffer_config_t::txBuffSizeAlign |
uint8_t* enet_buffer_config_t::rxBufferAlign |
uint8_t* enet_buffer_config_t::txBufferAlign |
uint64_t enet_ptp_time_t::second |
uint32_t enet_ptp_time_t::nanosecond |
struct enet_ptp_time_data_t |
uint8_t enet_ptp_time_data_t::version |
uint16_t enet_ptp_time_data_t::sequenceId |
uint8_t enet_ptp_time_data_t::messageType |
struct enet_ptp_time_data_ring_t |
uint32_t enet_ptp_time_data_ring_t::front |
uint32_t enet_ptp_time_data_ring_t::end |
uint32_t enet_ptp_time_data_ring_t::size |
uint32_t enet_ptp_config_t::ptp1588ClockSrc_Hz |
struct enet_intcoalesce_config_t |
uint8_t enet_intcoalesce_config_t::txCoalesceFrameCount[FSL_FEATURE_ENET_QUEUE] |
uint16_t enet_intcoalesce_config_t::txCoalesceTimeCount[FSL_FEATURE_ENET_QUEUE] |
uint8_t enet_intcoalesce_config_t::rxCoalesceFrameCount[FSL_FEATURE_ENET_QUEUE] |
uint16_t enet_intcoalesce_config_t::rxCoalesceTimeCount[FSL_FEATURE_ENET_QUEUE] |
This is used for to configure the extended ring 1 and ring 2.
- The classification match format is (CMP3 << 12) | (CMP2 << 8) | (CMP1 << 4) | CMP0. composed of four 3-bit compared VLAN priority field cmp0~cmp3, cm0 ~ cmp3 are used in parallel.
If CMP1,2,3 are not unused, please set them to the same value as CMP0.
- The idleSlope is used to calculate the Band Width fraction, BW fraction = 1 / (1 + 512/idleSlope). For avb configuration, the BW fraction of Class 1 and Class 2 combined must not exceed 0.75.
uint16_t enet_avb_config_t::rxClassifyMatch[FSL_FEATURE_ENET_QUEUE-1] |
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.
uint32_t enet_handle_t::rxBuffSizeAlign[FSL_FEATURE_ENET_QUEUE] |
uint32_t enet_handle_t::txBuffSizeAlign[FSL_FEATURE_ENET_QUEUE] |
uint8_t enet_handle_t::ringNum |
void* enet_handle_t::userData |
uint64_t enet_handle_t::msTimerSecond |
#define FSL_ENET_DRIVER_VERSION (MAKE_VERSION(2, 2, 3)) |
#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_IPV4_MASK 0x0001U |
#define ENET_BUFFDESCRIPTOR_RX_IPV6_MASK 0x0002U |
#define ENET_BUFFDESCRIPTOR_RX_VLAN_MASK 0x0004U |
#define ENET_BUFFDESCRIPTOR_RX_PROTOCOLCHECKSUM_MASK 0x0010U |
#define ENET_BUFFDESCRIPTOR_RX_IPHEADCHECKSUM_MASK 0x0020U |
#define ENET_BUFFDESCRIPTOR_RX_INTERRUPT_MASK 0x0080U |
#define ENET_BUFFDESCRIPTOR_RX_UNICAST_MASK 0x0100U |
#define ENET_BUFFDESCRIPTOR_RX_COLLISION_MASK 0x0200U |
#define ENET_BUFFDESCRIPTOR_RX_PHYERR_MASK 0x0400U |
#define ENET_BUFFDESCRIPTOR_RX_MACERR_MASK 0x8000U |
#define ENET_BUFFDESCRIPTOR_TX_ERR_MASK 0x8000U |
#define ENET_BUFFDESCRIPTOR_TX_UNDERFLOWERR_MASK 0x2000U |
#define ENET_BUFFDESCRIPTOR_TX_EXCCOLLISIONERR_MASK 0x1000U |
#define ENET_BUFFDESCRIPTOR_TX_FRAMEERR_MASK 0x0800U |
#define ENET_BUFFDESCRIPTOR_TX_LATECOLLISIONERR_MASK 0x0400U |
#define ENET_BUFFDESCRIPTOR_TX_OVERFLOWERR_MASK 0x0200U |
#define ENET_BUFFDESCRIPTOR_TX_TIMESTAMPERR_MASK 0x0100U |
#define ENET_BUFFDESCRIPTOR_TX_INTERRUPT_MASK 0x4000U |
#define ENET_BUFFDESCRIPTOR_TX_TIMESTAMP_MASK 0x2000U |
#define ENET_BUFFDESCRIPTOR_TX_USETXLAUNCHTIME_MASK 0x0100U |
#define ENET_BUFFDESCRIPTOR_TX_FRAMETYPE_MASK 0x00F0U |
#define ENET_BUFFDESCRIPTOR_TX_FRAMETYPE_SHIFT 4U |
#define ENET_BUFFDESCRIPTOR_RX_ERR_MASK |
Value:
#define ENET_BUFFDESCRIPTOR_RX_LENVLIOLATE_MASK
Length violation mask.
Definition: fsl_enet.h:48
#define ENET_BUFFDESCRIPTOR_RX_TRUNC_MASK
Frame is truncated mask.
Definition: fsl_enet.h:52
#define ENET_BUFFDESCRIPTOR_RX_OVERRUN_MASK
FIFO overrun mask.
Definition: fsl_enet.h:51
#define ENET_BUFFDESCRIPTOR_RX_NOOCTET_MASK
Non-octet aligned frame mask.
Definition: fsl_enet.h:49
#define ENET_BUFFDESCRIPTOR_RX_CRC_MASK
CRC error mask.
Definition: fsl_enet.h:50
#define ENET_FRAME_MAX_FRAMELEN 1518U |
#define ENET_FIFO_MIN_RX_FULL 5U |
#define ENET_RX_MIN_BUFFERSIZE 256U |
typedef void(* enet_callback_t)(ENET_Type *base, enet_handle_t *handle, uint32_t ringId, enet_event_t event, void *userData) |
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_TxFrameOverLen |
Tx frame over length.
|
kStatus_ENET_TxFrameBusy |
Tx buffer descriptors are under process.
|
kStatus_ENET_TxFrameFail |
Transmit frame fail.
|
kStatus_ENET_PtpTsRingFull |
Timestamp ring full.
|
kStatus_ENET_PtpTsRingEmpty |
Timestamp ring empty.
|
Enumerator |
---|
kENET_MiiMode |
MII mode for data interface.
|
kENET_RmiiMode |
RMII mode for data interface.
|
kENET_RgmiiMode |
RGMII 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.
|
kENET_MiiSpeed1000M |
Speed 1000M bps.
|
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.
|
Enumerator |
---|
kENET_MiiAddrWrite_C45 |
Address Write operation.
|
kENET_MiiWriteFrame_C45 |
Write frame operation for a valid MII management frame.
|
kENET_MiiReadFrame_C45 |
Read frame operation for a valid MII management frame.
|
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).
|
kENET_ControlSVLANEnable |
Enable S-VLAN.
|
kENET_ControlVLANUseSecondTag |
Enable extracting the second vlan tag for further processing.
|
This enumeration uses one-bot 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_RxFlush2Interrupt |
Rx DMA ring2 flush indication.
|
kENET_RxFlush1Interrupt |
Rx DMA ring1 flush indication.
|
kENET_RxFlush0Interrupt |
RX DMA ring0 flush indication.
|
kENET_TxFrame2Interrupt |
Tx frame interrupt for Tx ring/class 2.
|
kENET_TxBuffer2Interrupt |
Tx buffer interrupt for Tx ring/class 2.
|
kENET_RxFrame2Interrupt |
Rx frame interrupt for Rx ring/class 2.
|
kENET_RxBuffer2Interrupt |
Rx buffer interrupt for Rx ring/class 2.
|
kENET_TxFrame1Interrupt |
Tx frame interrupt for Tx ring/class 1.
|
kENET_TxBuffer1Interrupt |
Tx buffer interrupt for Tx ring/class 1.
|
kENET_RxFrame1Interrupt |
Rx frame interrupt for Rx ring/class 1.
|
kENET_RxBuffer1Interrupt |
Rx buffer interrupt for Rx ring/class 1.
|
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_IdleSlope1 |
The bandwidth fraction is about 0.002.
|
kENET_IdleSlope2 |
The bandwidth fraction is about 0.003.
|
kENET_IdleSlope4 |
The bandwidth fraction is about 0.008.
|
kENET_IdleSlope8 |
The bandwidth fraction is about 0.02.
|
kENET_IdleSlope16 |
The bandwidth fraction is about 0.03.
|
kENET_IdleSlope32 |
The bandwidth fraction is about 0.06.
|
kENET_IdleSlope64 |
The bandwidth fraction is about 0.11.
|
kENET_IdleSlope128 |
The bandwidth fraction is about 0.20.
|
kENET_IdleSlope256 |
The bandwidth fraction is about 0.33.
|
kENET_IdleSlope384 |
The bandwidth fraction is about 0.43.
|
kENET_IdleSlope512 |
The bandwidth fraction is about 0.50.
|
kENET_IdleSlope640 |
The bandwidth fraction is about 0.56.
|
kENET_IdleSlope768 |
The bandwidth fraction is about 0.60.
|
kENET_IdleSlope896 |
The bandwidth fraction is about 0.64.
|
kENET_IdleSlope1024 |
The bandwidth fraction is about 0.67.
|
kENET_IdleSlope1152 |
The bandwidth fraction is about 0.69.
|
kENET_IdleSlope1280 |
The bandwidth fraction is about 0.71.
|
kENET_IdleSlope1408 |
The bandwidth fraction is about 0.73.
|
kENET_IdleSlope1536 |
The bandwidth fraction is about 0.75.
|
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.
|
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.
|
Enumerator |
---|
kENET_PtpTimerChannel1 |
IEEE 1588 PTP timer Channel 1.
|
kENET_PtpTimerChannel2 |
IEEE 1588 PTP timer Channel 2.
|
kENET_PtpTimerChannel3 |
IEEE 1588 PTP timer Channel 3.
|
kENET_PtpTimerChannel4 |
IEEE 1588 PTP timer Channel 4.
|
Enumerator |
---|
kENET_PtpChannelDisable |
Disable timer channel.
|
kENET_PtpChannelRisingCapture |
Input capture on rising edge.
|
kENET_PtpChannelFallingCapture |
Input capture on falling edge.
|
kENET_PtpChannelBothCapture |
Input capture on both edges.
|
kENET_PtpChannelSoftCompare |
Output compare software only.
|
kENET_PtpChannelToggleCompare |
Toggle output on compare.
|
kENET_PtpChannelClearCompare |
Clear output on compare.
|
kENET_PtpChannelSetCompare |
Set output on compare.
|
kENET_PtpChannelClearCompareSetOverflow |
Clear output on compare, set output on overflow.
|
kENET_PtpChannelSetCompareClearOverflow |
Set output on compare, clear output on overflow.
|
kENET_PtpChannelPulseLowonCompare |
Pulse output low on compare for one IEEE 1588 clock cycle.
|
kENET_PtpChannelPulseHighonCompare |
Pulse output high on compare for one IEEE 1588 clock cycle.
|
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. |
void 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 |
|
) |
| |
This function ungates the module clock and initializes it with the ENET configuration.
- 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. |
- 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().
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. Normally it's the system clock. 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
void ENET_StartSMIRead |
( |
ENET_Type * |
base, |
|
|
uint32_t |
phyAddr, |
|
|
uint32_t |
phyReg, |
|
|
enet_mii_read_t |
operation |
|
) |
| |
Used for standard IEEE802.3 MDIO Clause 22 format.
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. |
phyReg | The PHY register. Range from 0 ~ 31. |
operation | The read operation. |
void ENET_StartSMIWrite |
( |
ENET_Type * |
base, |
|
|
uint32_t |
phyAddr, |
|
|
uint32_t |
phyReg, |
|
|
enet_mii_write_t |
operation, |
|
|
uint32_t |
data |
|
) |
| |
Used for standard IEEE802.3 MDIO Clause 22 format.
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. |
phyReg | The PHY register. Range from 0 ~ 31. |
operation | The write operation. |
data | The data written to PHY. |
void ENET_StartExtC45SMIRead |
( |
ENET_Type * |
base, |
|
|
uint32_t |
phyAddr, |
|
|
uint32_t |
phyReg |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. |
phyReg | The PHY register. For MDIO IEEE802.3 Clause 45, the phyReg is a 21-bits combination of the devaddr (5 bits device address) and the regAddr (16 bits phy register): phyReg = (devaddr << 16) | regAddr. |
void ENET_StartExtC45SMIWrite |
( |
ENET_Type * |
base, |
|
|
uint32_t |
phyAddr, |
|
|
uint32_t |
phyReg, |
|
|
uint32_t |
data |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
phyAddr | The PHY address. |
phyReg | The PHY register. For MDIO IEEE802.3 Clause 45, the phyReg is a 21-bits combination of the devaddr (5 bits device address) and the regAddr (16 bits phy register): phyReg = (devaddr << 16) | regAddr. |
data | The data written to PHY. |
static void ENET_SetRGMIIClockDelay |
( |
ENET_Type * |
base, |
|
|
bool |
txEnabled, |
|
|
bool |
rxEnabled |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ENET peripheral base address. |
txEnabled | Enable or disable to generate the delayed version of RGMII_TXC. |
rxEnabled | Enable or disable to use the delayed version of RGMII_RXC. |
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. |
void ENET_AVBConfigure |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
const enet_avb_config_t * |
config |
|
) |
| |
ENET AVB feature configuration, set the Receive classification match and transmit bandwidth. This API is called when the AVB feature is required.
Note: The AVB frames transmission scheme is credit-based tx scheme and it's only supported with the Enhanced buffer descriptors. so the AVB configuration should only done with Enhanced buffer descriptor. so when the AVB feature is required, please make sure the the "ENET_ENHANCEDBUFFERDESCRIPTOR_MODE" is defined.
- Parameters
-
base | ENET peripheral base address. |
handle | ENET handler pointer. |
config | The ENET AVB feature configuration structure. |
static void ENET_ActiveRead |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
This function is to active the enet read process. It is used for single descriptor ring/queue.
- Parameters
-
base | ENET peripheral base address. |
- Note
- This must be called after the MAC configuration and state are ready. It must be called after the ENET_Init() and ENET_Ptp1588Configure(). This should be called when the ENET receive required.
static void ENET_ActiveReadMultiRing |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
This function is to active the enet read process. It is used for extended multiple descriptor rings/queues.
- Parameters
-
base | ENET peripheral base address. |
- Note
- This must be called after the MAC configuration and state are ready. It must be called after the ENET_Init() and ENET_Ptp1588Configure(). This should be called when the ENET receive required.
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_SetCallback |
( |
enet_handle_t * |
handle, |
|
|
enet_callback_t |
callback, |
|
|
void * |
userData |
|
) |
| |
This API is provided for the application callback required case when ENET interrupt is enabled. This API should be called after calling ENET_Init.
- Parameters
-
handle | ENET handler pointer. Should be provided by application. |
callback | The ENET callback function. |
userData | The callback function parameter. |
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.
- Parameters
-
handle | The ENET handler structure pointer. This is the same handler pointer used in the ENET_Init. |
eErrorStatic | The error statistics structure pointer. |
This interface gets the error statistics of the transmit frame. Because the error information is reported by the uDMA after the data delivery, this interface should be called after the data transmit API. It is recommended to call this function on transmit interrupt handler. After calling the ENET_SendFrame, the transmit interrupt notifies the transmit completion.
- Parameters
-
handle | The PTP handler pointer. This is the same handler pointer used in the ENET_Init. |
eErrorStatic | The error statistics structure pointer. |
- Returns
- The execute status.
status_t ENET_GetRxFrameSize |
( |
enet_handle_t * |
handle, |
|
|
uint32_t * |
length |
|
) |
| |
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
-
handle | The ENET handler structure. This is the same handler pointer used in the ENET_Init. |
length | The length of the valid frame received. |
- 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 |
|
) |
| |
This function reads a frame (both the data and the length) from the ENET buffer descriptors. The ENET_GetRxFrameSize should be used to get the size of the prepared data buffer. This is an example:
* uint32_t length;
* enet_handle_t g_handle;
*
* if (length != 0)
* {
*
* uint8_t *data = memory allocate interface;
* if (!data)
* {
*
* }
* else
* {
*
* }
* }
* {
*
* }
*
- 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. |
- 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 |
|
) |
| |
- Note
- The CRC is automatically appended to the data. Input the data to send without the CRC.
- 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 be send. |
length | The length of the data to be send. |
- 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. |
void ENET_GetRxErrBeforeReadFrameMultiRing |
( |
enet_handle_t * |
handle, |
|
|
enet_data_error_stats_t * |
eErrorStatic, |
|
|
uint32_t |
ringId |
|
) |
| |
This API must be called after the ENET_GetRxFrameSizeMultiRing and before the ENET_ReadFrameMultiRing(). If the ENET_GetRxFrameSizeMultiRing returns kStatus_ENET_RxFrameError, the ENET_GetRxErrBeforeReadFrameMultiRing can be used to get the exact error statistics.
- 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_QUEUE - 1. |
status_t ENET_SendFrameMultiRing |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
uint8_t * |
data, |
|
|
uint32_t |
length, |
|
|
uint32_t |
ringId |
|
) |
| |
- Note
- The CRC is automatically appended to the data. Input the data to send without the CRC.
In this API, multiple-ring are mainly used for extended avb frames are supported. The transmit scheme for avb frames is the credit-based scheme, the AVB class A, AVB class B and the non-AVB frame are transmitted in ring 1, ring 2 and ring 0 independently. So application should care about the transmit ring index when use multiple-ring transmission.
- 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 be send. |
length | The length of the data to be send. |
ringId | The ring index for transmission. |
- 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_GetTxErrAfterSendFrameMultiRing |
( |
enet_handle_t * |
handle, |
|
|
enet_data_error_stats_t * |
eErrorStatic, |
|
|
uint32_t |
ringId |
|
) |
| |
This interface gets the error statistics of the transmit frame. Because the error information is reported by the uDMA after the data delivery, this interface should be called after the data transmit API and shall be called by transmit interrupt handler. After calling the ENET_SendFrame, the transmit interrupt notifies the transmit completion.
- Parameters
-
handle | The PTP handler pointer. This is the same handler pointer used in the ENET_Init. |
eErrorStatic | The error statistics structure pointer. |
ringId | The ring index. |
- Returns
- The execute status.
status_t ENET_GetRxFrameSizeMultiRing |
( |
enet_handle_t * |
handle, |
|
|
uint32_t * |
length, |
|
|
uint32_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_GetRxFrameSizeMultiRing, ENET_ReadFrameMultiRing() should be called to update the receive buffers If the result is not "kStatus_ENET_RxFrameEmpty". The usage is the same to the single ring, refer to ENET_GetRxFrameSize.
- 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_ReadFrameMultiRing to read frame. |
kStatus_ENET_RxFrameError | Data error happens. ENET_ReadFrameMultiRing 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_ReadFrameMultiRing |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
uint8_t * |
data, |
|
|
uint32_t |
length, |
|
|
uint32_t |
ringId |
|
) |
| |
This function reads a frame (both the data and the length) from the ENET buffer descriptors. The ENET_GetRxFrameSizeMultiRing should be used to get the size of the prepared data buffer. This usage is the same as the single ring, refer to ENET_ReadFrame.
- 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; |
- Returns
- The execute status, successful or failure.
void ENET_TransmitIRQHandler |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
uint32_t |
ringId |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. |
ringId | The ring id or ring number. |
void ENET_ReceiveIRQHandler |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
uint32_t |
ringId |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. |
ringId | The ring id or ring number. |
void ENET_CommonFrame1IRQHandler |
( |
ENET_Type * |
base | ) |
|
This is used for the combined tx/rx interrupt for multi-ring (frame 1).
- Parameters
-
base | ENET peripheral base address. |
void ENET_CommonFrame2IRQHandler |
( |
ENET_Type * |
base | ) |
|
This is used for the combined tx/rx interrupt for multi-ring (frame 2).
- Parameters
-
base | ENET peripheral base address. |
void ENET_ErrorIRQHandler |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET handler pointer. |
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. |
void ENET_Ptp1588Configure |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
enet_ptp_config_t * |
ptpConfig |
|
) |
| |
The function sets the clock for PTP 1588 timer and enables time stamp interrupts and transmit interrupts for PTP 1588 features. This API should be called when the 1588 feature is enabled or the ENET_ENHANCEDBUFFERDESCRIPTOR_MODE is defined. ENET_Init should be called before calling this API.
- Note
- The PTP 1588 time-stamp second increase though time-stamp interrupt handler and the transmit time-stamp store is done through transmit interrupt handler. As a result, the TS interrupt and TX interrupt are enabled when you call this API.
- Parameters
-
base | ENET peripheral base address. |
handle | ENET handler pointer. |
ptpConfig | The ENET PTP1588 configuration. |
void ENET_Ptp1588StartTimer |
( |
ENET_Type * |
base, |
|
|
uint32_t |
ptpClkSrc |
|
) |
| |
This function is used to initialize the PTP timer. After the PTP starts, the PTP timer starts running.
- Parameters
-
base | ENET peripheral base address. |
ptpClkSrc | The clock source of the PTP timer. |
static void ENET_Ptp1588StopTimer |
( |
ENET_Type * |
base | ) |
|
|
inlinestatic |
This function is used to stops the ENET PTP timer.
- Parameters
-
base | ENET peripheral base address. |
void ENET_Ptp1588AdjustTimer |
( |
ENET_Type * |
base, |
|
|
uint32_t |
corrIncrease, |
|
|
uint32_t |
corrPeriod |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
corrIncrease | The correction increment value. This value is added every time the correction timer expires. A value less than the PTP timer frequency(1/ptpClkSrc) slows down the timer, a value greater than the 1/ptpClkSrc speeds up the timer. |
corrPeriod | The PTP timer correction counter wrap-around value. This defines after how many timer clock the correction counter should be reset and trigger a correction increment on the timer. A value of 0 disables the correction counter and no correction occurs. |
- Parameters
-
base | ENET peripheral base address. |
channel | The ENET PTP timer channel number. |
mode | The PTP timer channel mode, see "enet_ptp_timer_channel_mode_t". |
intEnable | Enables or disables the interrupt. |
- Parameters
-
base | ENET peripheral base address. |
channel | The PTP timer channel, see "enet_ptp_timer_channel_t". |
cmpValue | The compare value for the compare setting. |
- Parameters
-
base | ENET peripheral base address. |
channel | The IEEE 1588 timer channel number. |
- Returns
- True or false, Compare or capture operation status
- Parameters
-
base | ENET peripheral base address. |
channel | The IEEE 1588 timer channel number. |
void ENET_Ptp1588GetTimer |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
enet_ptp_time_t * |
ptpTime |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET state pointer. This is the same state pointer used in the ENET_Init. |
ptpTime | The PTP timer structure. |
void ENET_Ptp1588SetTimer |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle, |
|
|
enet_ptp_time_t * |
ptpTime |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET state pointer. This is the same state pointer used in the ENET_Init. |
ptpTime | The timer to be set to the PTP timer. |
void ENET_Ptp1588TimerIRQHandler |
( |
ENET_Type * |
base, |
|
|
enet_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | ENET peripheral base address. |
handle | The ENET state pointer. This is the same state pointer used in the ENET_Init. |
This function is used for PTP stack to get the timestamp captured by the ENET driver.
- Parameters
-
handle | The ENET handler pointer.This is the same state pointer used in ENET_Init. |
ptpTimeData | The special PTP timestamp data for search the receive timestamp. |
- Return values
-
kStatus_Success | Get 1588 timestamp success. |
kStatus_ENET_PtpTsRingEmpty | 1588 timestamp ring empty. |
kStatus_ENET_PtpTsRingFull | 1588 timestamp ring full. |
This function is used for PTP stack to get the timestamp captured by the ENET driver.
- Parameters
-
handle | The ENET handler pointer.This is the same state pointer used in ENET_Init. |
ptpTimeData | The special PTP timestamp data for search the receive timestamp. |
- Return values
-
kStatus_Success | Get 1588 timestamp success. |
kStatus_ENET_PtpTsRingEmpty | 1588 timestamp ring empty. |
kStatus_ENET_PtpTsRingFull | 1588 timestamp ring full. |