S32 SDK

Detailed Description

How to use the ENET driver in your application

In order to use the ENET driver in your application, the ENET_DRV_Init() function should be called prior to using the rest of the API. The parameters of this function specify:

The configuration of the module is specified through the enet_config_t structure and contains:

The buffers configuration is specified through the enet_buffer_config_t structure and contains:

In order to de-initialize the driver, the ENET_DRV_Deinit() function shall be used. This function will disable the ENET interrupts and the module, so calling other ENET driver functions after de-initializing the driver will have undefined behavior. In order to use the driver again, ENET_DRV_Init() should be called.

Examples:

Initializing the module

#define INST_ETHERNET1 (0U)
#define ENET_RXBD_NUM0 (1U)
#define ENET_TXBD_NUM0 (1U)
enet_state_t ethernet1_State;
enet_config_t ethernet1_InitConfig0 =
{
.maxFrameLen = 1518U,
.miiMode = ENET_MII_MODE,
.miiSpeed = ENET_MII_SPEED_100M,
.miiDuplex = ENET_MII_FULL_DUPLEX,
.rxAccelerConfig = 0,
.rxConfig = 0,
.callback = rx_callback
};
ALIGNED(FEATURE_ENET_BUFFDESCR_ALIGNMENT) enet_buffer_descriptor_t ethernet1_rxBuffDescrip0[ENET_RXBD_NUM0];
ALIGNED(FEATURE_ENET_BUFFDESCR_ALIGNMENT) enet_buffer_descriptor_t ethernet1_txBuffDescrip0[ENET_TXBD_NUM0];
ALIGNED(FEATURE_ENET_BUFF_ALIGNMENT) uint8_t ethernet1_rxDataBuff0[ENET_RXBD_NUM0 * ENET_BUFF_ALIGN(1518U)];
enet_buffer_config_t ethernet1_buffConfig0 =
{
ENET_RXBD_NUM0,
ENET_TXBD_NUM0,
&ethernet1_rxBuffDescrip0[0],
&ethernet1_txBuffDescrip0[0],
&ethernet1_rxDataBuff0[0]
};
uint8_t g_macAddr[6] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66};
ENET_DRV_Init(INST_ETHERNET1, &ethernet1_State, &ethernet1_InitConfig0, &ethernet1_buffConfig0, g_macAddr);
/* ... */
ENET_DRV_Deinit(INST_ETHERNET1);

Sending a frame

uint8_t data[8] = {0, 1, 2, 3, 4, 5, 6, 7};
buff.data = data;
buff.length = 8;
ENET_DRV_SendFrame(INST_ETHERNET1, &buff);

Receiving a frame - polling method

status_t status;
for (;;)
{
status = ENET_DRV_ReadFrame(INST_ETHERNET1, buff);
if (status == STATUS_SUCCESS)
{
/* Process buff */
/* buff is no longer needed, provide it to the driver in order to be
used by the reception mechanism */
}
}

Receiving a frame - interrupt method

void rx_callback(uint8_t instance, enet_event_t event)
{
if (event == ENET_RX_EVENT)
{
status = ENET_DRV_ReadFrame(INST_ETHERNET1, buff);
if (status == STATUS_SUCCESS)
{
/* Process buff */
/* buff is no longer needed, provide it to the driver in order to be
used by the reception mechanism */
}
}
}
int main(void)
{
/* ... */
/* The ethernet1_InitConfig0 shall enable the receive interrupts and shall specify the callback - see the
configuration example above */
ENET_DRV_Init(INST_ETHERNET1, &ethernet1_State, &ethernet1_InitConfig0, &ethernet1_buffConfig0, g_macAddr);
/* ... */
}

Data Structures

struct  enet_buffer_t
 Send/Receive buffer information for the user Implements : enet_buffer_t_Class. More...
 
struct  enet_buffer_config_t
 Defines the ENET buffer descriptors ring configuration structure Implements : enet_buffer_config_t_Class. More...
 
struct  enet_config_t
 Defines the ENET module configuration structure Implements : enet_config_t_Class. More...
 
struct  enet_state_t
 Internal driver state structure Implements : enet_state_t_Class. More...
 

Macros

#define ENET_FRAME_MAX_FRAMELEN   1518U
 Defines the maximum Ethernet frame size. More...
 
#define ENET_MIN_BUFFERSIZE   64U
 ENET minimum buffer size. More...
 
#define ENET_BUFF_ALIGN(x)    (((uint32_t)(x) + (FEATURE_ENET_BUFF_ALIGNMENT - 1)) & ~(FEATURE_ENET_BUFF_ALIGNMENT - 1))
 Definitions used for aligning the data buffers. More...
 
#define ENET_BUFF_IS_ALIGNED(x)   (((uint32_t)(x) & ~(FEATURE_ENET_BUFF_ALIGNMENT - 1)) != 0)
 
#define ENET_BUFFDESCR_ALIGN(x)    (((uint32_t)(x) + (FEATURE_ENET_BUFFDESCR_ALIGNMENT - 1)) & ~(FEATURE_ENET_BUFFDESCR_ALIGNMENT - 1))
 Definitions used for aligning the buffer descriptors. More...
 
#define ENET_BUFFDESCR_IS_ALIGNED(x)   (((uint32_t)(x) & ~(FEATURE_ENET_BUFFDESCR_ALIGNMENT - 1)) != 0)
 

Typedefs

typedef void(* enet_callback_t) (uint8_t instance, enet_event_t event)
 Callback function invoked when one of the events in "enet_event_t" is encountered Implements : enet_callback_t_Class. More...
 

Enumerations

enum  enet_mii_mode_t { ENET_MII_MODE = 0U, ENET_RMII_MODE }
 Media Independent Interface mode selection Implements : enet_mii_mode_t_Class. More...
 
enum  enet_mii_speed_t { ENET_MII_SPEED_10M = 0U, ENET_MII_SPEED_100M }
 Media Independent Interface speed selection Implements : enet_mii_speed_t_Class. More...
 
enum  enet_mii_duplex_t { ENET_MII_HALF_DUPLEX = 0U, ENET_MII_FULL_DUPLEX }
 Media Independent Interface full-/half-duplex selection Implements : enet_mii_duplex_t_Class. More...
 
enum  enet_rx_special_config_t {
  ENET_RX_CONFIG_ENABLE_PAYLOAD_LEN_CHECK = 0x0001U, ENET_RX_CONFIG_STRIP_CRC_FIELD = 0x0002U, ENET_RX_CONFIG_FORWARD_PAUSE_FRAMES = 0x0004U, ENET_RX_CONFIG_REMOVE_PADDING = 0x0008U,
  ENET_RX_CONFIG_ENABLE_FLOW_CONTROL = 0x0010U, ENET_RX_CONFIG_REJECT_BROADCAST_FRAMES = 0x0020U, ENET_RX_CONFIG_ENABLE_PROMISCUOUS_MODE = 0x0040U, ENET_RX_CONFIG_ENABLE_MII_LOOPBACK = 0x0080U
}
 Special receive control configurations Implements : enet_rx_special_config_t_Class. More...
 
enum  enet_tx_special_config_t { ENET_TX_CONFIG_DISABLE_CRC_APPEND = 0x0001U, ENET_TX_CONFIG_ENABLE_MAC_ADDR_INSERTION = 0x0002U }
 Special transmit control configurations Implements : enet_tx_special_config_t_Class. More...
 
enum  enet_interrupt_enable_t {
  ENET_BABR_INTERRUPT = ENET_EIR_BABR_MASK, ENET_BABT_INTERRUPT = ENET_EIR_BABT_MASK, ENET_GRACE_STOP_INTERRUPT = ENET_EIR_GRA_MASK, ENET_TX_FRAME_INTERRUPT = ENET_EIR_TXF_MASK,
  ENET_TX_BUFFER_INTERRUPT = ENET_EIR_TXB_MASK, ENET_RX_FRAME_INTERRUPT = ENET_EIR_RXF_MASK, ENET_RX_BUFFER_INTERRUPT = ENET_EIR_RXB_MASK, ENET_MII_INTERRUPT = ENET_EIR_MII_MASK,
  ENET_EBERR_INTERRUPT = ENET_EIR_EBERR_MASK, ENET_LATE_COLLISION_INTERRUPT = ENET_EIR_LC_MASK, ENET_RETRY_LIMIT_INTERRUPT = ENET_EIR_RL_MASK, ENET_UNDERRUN_INTERRUPT = ENET_EIR_UN_MASK,
  ENET_PAYLOAD_RX_INTERRUPT = ENET_EIR_PLR_MASK, ENET_WAKEUP_INTERRUPT = ENET_EIR_WAKEUP_MASK, ENET_TS_AVAIL_INTERRUPT = ENET_EIR_TS_AVAIL_MASK, ENET_TS_TIMER_INTERRUPT = ENET_EIR_TS_TIMER_MASK
}
 Interrupt sources Implements : enet_interrupt_enable_t_Class. More...
 
enum  enet_tx_accelerator_t { ENET_TX_ACCEL_ENABLE_SHIFT16 = ENET_TACC_SHIFT16_MASK, ENET_TX_ACCEL_INSERT_IP_CHECKSUM = ENET_TACC_IPCHK_MASK, ENET_TX_ACCEL_INSERT_PROTO_CHECKSUM = ENET_TACC_PROCHK_MASK }
 Transmit accelerator configurations Implements : enet_tx_accelerator_t_Class. More...
 
enum  enet_rx_accelerator_t {
  ENET_RX_ACCEL_REMOVE_PAD = ENET_RACC_PADREM_MASK, ENET_RX_ACCEL_ENABLE_IP_CHECK = ENET_RACC_IPDIS_MASK, ENET_RX_ACCEL_ENABLE_PROTO_CHECK = ENET_RACC_PRODIS_MASK, ENET_RX_ACCEL_ENABLE_MAC_CHECK = ENET_RACC_LINEDIS_MASK,
  ENET_RX_ACCEL_ENABLE_SHIFT16 = ENET_RACC_SHIFT16_MASK
}
 Receive accelerator configurations Implements : enet_rx_accelerator_t_Class. More...
 
enum  enet_event_t { ENET_RX_EVENT, ENET_TX_EVENT, ENET_ERR_EVENT, ENET_WAKE_UP_EVENT }
 Send/Receive internal buffer descriptor Implements : enet_buffer_descriptor_t_Class. More...
 
enum  enet_counter_t {
  ENET_CTR_RMON_T_DROP = 0U, ENET_CTR_RMON_T_PACKETS, ENET_CTR_RMON_T_BC_PKT, ENET_CTR_RMON_T_MC_PKT,
  ENET_CTR_RMON_T_CRC_ALIGN, ENET_CTR_RMON_T_UNDERSIZE, ENET_CTR_RMON_T_OVERSIZE, ENET_CTR_RMON_T_FRAG,
  ENET_CTR_RMON_T_JAB, ENET_CTR_RMON_T_COL, ENET_CTR_RMON_T_P64, ENET_CTR_RMON_T_P65TO127,
  ENET_CTR_RMON_T_P128TO255, ENET_CTR_RMON_T_P256TO511, ENET_CTR_RMON_T_P512TO1023, ENET_CTR_RMON_T_P1024TO2047,
  ENET_CTR_RMON_T_P_GTE2048, ENET_CTR_RMON_T_OCTETS, ENET_CTR_IEEE_T_DROP, ENET_CTR_IEEE_T_FRAME_OK,
  ENET_CTR_IEEE_T_1COL, ENET_CTR_IEEE_T_MCOL, ENET_CTR_IEEE_T_DEF, ENET_CTR_IEEE_T_LCOL,
  ENET_CTR_IEEE_T_EXCOL, ENET_CTR_IEEE_T_MACERR, ENET_CTR_IEEE_T_CSERR, ENET_CTR_IEEE_T_SQE,
  ENET_CTR_IEEE_T_FDXFC, ENET_CTR_IEEE_T_OCTETS_OK = 29U, ENET_CTR_RMON_R_PACKETS = 33U, ENET_CTR_RMON_R_BC_PKT,
  ENET_CTR_RMON_R_MC_PKT, ENET_CTR_RMON_R_CRC_ALIGN, ENET_CTR_RMON_R_UNDERSIZE, ENET_CTR_RMON_R_OVERSIZE,
  ENET_CTR_RMON_R_FRAG, ENET_CTR_RMON_R_JAB, ENET_CTR_RMON_R_RESVD_0, ENET_CTR_RMON_R_P64,
  ENET_CTR_RMON_R_P65TO127, ENET_CTR_RMON_R_P128TO255, ENET_CTR_RMON_R_P256TO511, ENET_CTR_RMON_R_P512TO1023,
  ENET_CTR_RMON_R_P1024TO2047, ENET_CTR_RMON_R_P_GTE2048, ENET_CTR_RMON_R_OCTETS, ENET_CTR_IEEE_R_DROP,
  ENET_CTR_IEEE_R_FRAME_OK, ENET_CTR_IEEE_R_CRC, ENET_CTR_IEEE_R_ALIGN, ENET_CTR_IEEE_R_MACERR,
  ENET_CTR_IEEE_R_FDXFC, ENET_CTR_IEEE_R_OCTETS_OK
}
 Statistics counters enumeration Implements : enet_counter_t_Class. More...
 

Initialization and De-initialization

void ENET_DRV_GetDefaultConfig (enet_config_t *config)
 Gets the default configuration structure. More...
 
void ENET_DRV_Init (uint8_t instance, enet_state_t *state, const enet_config_t *config, const enet_buffer_config_t *bufferConfig, uint8_t *macAddr)
 Initializes the ENET module. More...
 
void ENET_DRV_Deinit (uint8_t instance)
 Deinitializes the ENET module. More...
 

Transmission and reception operations

status_t ENET_DRV_ReadFrame (uint8_t instance, enet_buffer_t *buff)
 Reads a received Ethernet frame. More...
 
void ENET_DRV_ProvideRxBuff (uint8_t instance, enet_buffer_t *buff)
 Provides a receive buffer to be used by the driver for reception. More...
 
status_t ENET_DRV_SendFrame (uint8_t instance, enet_buffer_t *buff)
 Sends an Ethernet frame. More...
 
status_t ENET_DRV_GetTransmitStatus (uint8_t instance, enet_buffer_t *buff)
 Checks if the transmission of a buffer is complete. More...
 

MDIO configuration and operation

void ENET_DRV_EnableMDIO (uint8_t instance, bool miiPreambleDisabled)
 Enables the MDIO interface. More...
 
status_t ENET_DRV_MDIORead (uint8_t instance, uint8_t phyAddr, uint8_t phyReg, uint16_t *data, uint32_t timeoutMs)
 Reads the selected register of the PHY. More...
 
status_t ENET_DRV_MDIOWrite (uint8_t instance, uint8_t phyAddr, uint8_t phyReg, uint16_t data, uint32_t timeoutMs)
 Writes the selected register of the PHY. More...
 

MAC Address configuration

void ENET_DRV_SetMacAddr (uint8_t instance, uint8_t *macAddr)
 Configures the physical address of the MAC. More...
 
void ENET_DRV_GetMacAddr (uint8_t instance, uint8_t *macAddr)
 Gets the physical address of the MAC. More...
 
void ENET_DRV_SetUnicastForward (uint8_t instance, uint8_t *macAddr, bool enable)
 Enables/Disables forwarding of unicast traffic having a specific MAC address as destination. More...
 
void ENET_DRV_SetMulticastForward (uint8_t instance, uint8_t *macAddr, bool enable)
 Enables/Disables forwarding of multicast traffic having a specific MAC address as destination. More...
 
void ENET_DRV_SetMulticastForwardAll (uint8_t instance, bool enable)
 Enables/Disables forwarding of the multicast traffic, irrespective of the destination MAC address. More...
 

Other basic operations

void ENET_DRV_SetSleepMode (uint8_t instance, bool enable)
 Sets the MAC in sleep mode or normal mode. More...
 
void ENET_DRV_ConfigCounters (uint8_t instance, bool enable)
 Enables/Disables the MIB counters. More...
 
uint32_t ENET_DRV_GetCounter (uint8_t instance, enet_counter_t counter)
 Gets statistics from the specified counter. More...
 

Macro Definition Documentation

#define ENET_BUFF_ALIGN (   x)    (((uint32_t)(x) + (FEATURE_ENET_BUFF_ALIGNMENT - 1)) & ~(FEATURE_ENET_BUFF_ALIGNMENT - 1))

Definitions used for aligning the data buffers.

Definition at line 45 of file enet_driver.h.

#define ENET_BUFF_IS_ALIGNED (   x)    (((uint32_t)(x) & ~(FEATURE_ENET_BUFF_ALIGNMENT - 1)) != 0)

Definition at line 46 of file enet_driver.h.

#define ENET_BUFFDESCR_ALIGN (   x)    (((uint32_t)(x) + (FEATURE_ENET_BUFFDESCR_ALIGNMENT - 1)) & ~(FEATURE_ENET_BUFFDESCR_ALIGNMENT - 1))

Definitions used for aligning the buffer descriptors.

Definition at line 49 of file enet_driver.h.

#define ENET_BUFFDESCR_IS_ALIGNED (   x)    (((uint32_t)(x) & ~(FEATURE_ENET_BUFFDESCR_ALIGNMENT - 1)) != 0)

Definition at line 50 of file enet_driver.h.

#define ENET_FRAME_MAX_FRAMELEN   1518U

Defines the maximum Ethernet frame size.

Definition at line 40 of file enet_driver.h.

#define ENET_MIN_BUFFERSIZE   64U

ENET minimum buffer size.

Definition at line 42 of file enet_driver.h.

Typedef Documentation

typedef void(* enet_callback_t) (uint8_t instance, enet_event_t event)

Callback function invoked when one of the events in "enet_event_t" is encountered Implements : enet_callback_t_Class.

Definition at line 221 of file enet_driver.h.

Enumeration Type Documentation

Statistics counters enumeration Implements : enet_counter_t_Class.

Enumerator
ENET_CTR_RMON_T_DROP 
ENET_CTR_RMON_T_PACKETS 
ENET_CTR_RMON_T_BC_PKT 
ENET_CTR_RMON_T_MC_PKT 
ENET_CTR_RMON_T_CRC_ALIGN 
ENET_CTR_RMON_T_UNDERSIZE 
ENET_CTR_RMON_T_OVERSIZE 
ENET_CTR_RMON_T_FRAG 
ENET_CTR_RMON_T_JAB 
ENET_CTR_RMON_T_COL 
ENET_CTR_RMON_T_P64 
ENET_CTR_RMON_T_P65TO127 
ENET_CTR_RMON_T_P128TO255 
ENET_CTR_RMON_T_P256TO511 
ENET_CTR_RMON_T_P512TO1023 
ENET_CTR_RMON_T_P1024TO2047 
ENET_CTR_RMON_T_P_GTE2048 
ENET_CTR_RMON_T_OCTETS 
ENET_CTR_IEEE_T_DROP 
ENET_CTR_IEEE_T_FRAME_OK 
ENET_CTR_IEEE_T_1COL 
ENET_CTR_IEEE_T_MCOL 
ENET_CTR_IEEE_T_DEF 
ENET_CTR_IEEE_T_LCOL 
ENET_CTR_IEEE_T_EXCOL 
ENET_CTR_IEEE_T_MACERR 
ENET_CTR_IEEE_T_CSERR 
ENET_CTR_IEEE_T_SQE 
ENET_CTR_IEEE_T_FDXFC 
ENET_CTR_IEEE_T_OCTETS_OK 
ENET_CTR_RMON_R_PACKETS 
ENET_CTR_RMON_R_BC_PKT 
ENET_CTR_RMON_R_MC_PKT 
ENET_CTR_RMON_R_CRC_ALIGN 
ENET_CTR_RMON_R_UNDERSIZE 
ENET_CTR_RMON_R_OVERSIZE 
ENET_CTR_RMON_R_FRAG 
ENET_CTR_RMON_R_JAB 
ENET_CTR_RMON_R_RESVD_0 
ENET_CTR_RMON_R_P64 
ENET_CTR_RMON_R_P65TO127 
ENET_CTR_RMON_R_P128TO255 
ENET_CTR_RMON_R_P256TO511 
ENET_CTR_RMON_R_P512TO1023 
ENET_CTR_RMON_R_P1024TO2047 
ENET_CTR_RMON_R_P_GTE2048 
ENET_CTR_RMON_R_OCTETS 
ENET_CTR_IEEE_R_DROP 
ENET_CTR_IEEE_R_FRAME_OK 
ENET_CTR_IEEE_R_CRC 
ENET_CTR_IEEE_R_ALIGN 
ENET_CTR_IEEE_R_MACERR 
ENET_CTR_IEEE_R_FDXFC 
ENET_CTR_IEEE_R_OCTETS_OK 

Definition at line 277 of file enet_driver.h.

Send/Receive internal buffer descriptor Implements : enet_buffer_descriptor_t_Class.

Event specifier for the callback function Implements : enet_event_t_Class

Enumerator
ENET_RX_EVENT 
ENET_TX_EVENT 
ENET_ERR_EVENT 
ENET_WAKE_UP_EVENT 

Definition at line 209 of file enet_driver.h.

Interrupt sources Implements : enet_interrupt_enable_t_Class.

Enumerator
ENET_BABR_INTERRUPT 
ENET_BABT_INTERRUPT 
ENET_GRACE_STOP_INTERRUPT 
ENET_TX_FRAME_INTERRUPT 
ENET_TX_BUFFER_INTERRUPT 
ENET_RX_FRAME_INTERRUPT 
ENET_RX_BUFFER_INTERRUPT 
ENET_MII_INTERRUPT 
ENET_EBERR_INTERRUPT 
ENET_LATE_COLLISION_INTERRUPT 
ENET_RETRY_LIMIT_INTERRUPT 
ENET_UNDERRUN_INTERRUPT 
ENET_PAYLOAD_RX_INTERRUPT 
ENET_WAKEUP_INTERRUPT 
ENET_TS_AVAIL_INTERRUPT 
ENET_TS_TIMER_INTERRUPT 

Definition at line 112 of file enet_driver.h.

Media Independent Interface full-/half-duplex selection Implements : enet_mii_duplex_t_Class.

Enumerator
ENET_MII_HALF_DUPLEX 

Half-duplex mode.

ENET_MII_FULL_DUPLEX 

Full-duplex mode.

Definition at line 76 of file enet_driver.h.

Media Independent Interface mode selection Implements : enet_mii_mode_t_Class.

Enumerator
ENET_MII_MODE 

MII mode for data interface.

ENET_RMII_MODE 

RMII mode for data interface.

Definition at line 56 of file enet_driver.h.

Media Independent Interface speed selection Implements : enet_mii_speed_t_Class.

Enumerator
ENET_MII_SPEED_10M 

Speed 10 Mbps.

ENET_MII_SPEED_100M 

Speed 100 Mbps.

Definition at line 66 of file enet_driver.h.

Receive accelerator configurations Implements : enet_rx_accelerator_t_Class.

Enumerator
ENET_RX_ACCEL_REMOVE_PAD 
ENET_RX_ACCEL_ENABLE_IP_CHECK 
ENET_RX_ACCEL_ENABLE_PROTO_CHECK 
ENET_RX_ACCEL_ENABLE_MAC_CHECK 
ENET_RX_ACCEL_ENABLE_SHIFT16 

Definition at line 164 of file enet_driver.h.

Special receive control configurations Implements : enet_rx_special_config_t_Class.

Enumerator
ENET_RX_CONFIG_ENABLE_PAYLOAD_LEN_CHECK 
ENET_RX_CONFIG_STRIP_CRC_FIELD 
ENET_RX_CONFIG_FORWARD_PAUSE_FRAMES 
ENET_RX_CONFIG_REMOVE_PADDING 
ENET_RX_CONFIG_ENABLE_FLOW_CONTROL 
ENET_RX_CONFIG_REJECT_BROADCAST_FRAMES 
ENET_RX_CONFIG_ENABLE_PROMISCUOUS_MODE 
ENET_RX_CONFIG_ENABLE_MII_LOOPBACK 

Definition at line 86 of file enet_driver.h.

Transmit accelerator configurations Implements : enet_tx_accelerator_t_Class.

Enumerator
ENET_TX_ACCEL_ENABLE_SHIFT16 
ENET_TX_ACCEL_INSERT_IP_CHECKSUM 
ENET_TX_ACCEL_INSERT_PROTO_CHECKSUM 

Definition at line 153 of file enet_driver.h.

Special transmit control configurations Implements : enet_tx_special_config_t_Class.

Enumerator
ENET_TX_CONFIG_DISABLE_CRC_APPEND 
ENET_TX_CONFIG_ENABLE_MAC_ADDR_INSERTION 

Definition at line 102 of file enet_driver.h.

Function Documentation

void ENET_DRV_ConfigCounters ( uint8_t  instance,
bool  enable 
)

Enables/Disables the MIB counters.

Note: When enabling the counters, their values are reset.

Parameters
[in]instanceInstance number
[in]enableEnable/Disable MIB counters

Definition at line 737 of file enet_driver.c.

void ENET_DRV_Deinit ( uint8_t  instance)

Deinitializes the ENET module.

This function disables the interrupts and then disables the ENET module.

Parameters
[in]instanceInstance number

Definition at line 225 of file enet_driver.c.

void ENET_DRV_EnableMDIO ( uint8_t  instance,
bool  miiPreambleDisabled 
)

Enables the MDIO interface.

Parameters
[in]instanceInstance number
[in]miiPreambleDisabledEnables/disables prepending a preamble to the MII management frame.

Definition at line 444 of file enet_driver.c.

uint32_t ENET_DRV_GetCounter ( uint8_t  instance,
enet_counter_t  counter 
)

Gets statistics from the specified counter.

Parameters
[in]instanceInstance number
[in]counterThe counter to be read
Returns
The value of the requested counter

Definition at line 768 of file enet_driver.c.

void ENET_DRV_GetDefaultConfig ( enet_config_t config)

Gets the default configuration structure.

This function gets the default configuration structure, with the following settings:

  • no interrupt enabled
  • maximum receive frame length equal to the maximum Ethernet frame length
  • no special receive/transmit control configuration
  • no acceleration function enabled
  • RMII mode, full-duplex, 100Mbps for MAC and PHY data interface
  • no callback installed
Parameters
[out]configThe configuration structure

Definition at line 113 of file enet_driver.c.

void ENET_DRV_GetMacAddr ( uint8_t  instance,
uint8_t *  macAddr 
)

Gets the physical address of the MAC.

Parameters
[in]instanceInstance number
[out]macAddrThe physical address of the MAC

Definition at line 589 of file enet_driver.c.

status_t ENET_DRV_GetTransmitStatus ( uint8_t  instance,
enet_buffer_t buff 
)

Checks if the transmission of a buffer is complete.

This function checks if the transmission of the given buffer is complete.

Parameters
[in]instanceInstance number
[in]buffThe transmit buffer for which the status shall be checked
Returns
STATUS_BUSY if the frame is still enqueued for transmission, STATUS_SUCCESS otherwise.

Definition at line 358 of file enet_driver.c.

void ENET_DRV_Init ( uint8_t  instance,
enet_state_t state,
const enet_config_t config,
const enet_buffer_config_t bufferConfig,
uint8_t *  macAddr 
)

Initializes the ENET module.

This function initializes and enables the ENET module, configuring receive and transmit control settings, the receive and transmit descriptors rings, and the MAC physical address.

Parameters
[in]instanceInstance number
[in]statePointer to the state structure which will be used for holding the internal state of the driver.
[in]configThe module configuration structure
[in]bufferConfigThe buffer descriptors configuration structure
[in]macAddrThe physical address of the MAC

Definition at line 147 of file enet_driver.c.

status_t ENET_DRV_MDIORead ( uint8_t  instance,
uint8_t  phyAddr,
uint8_t  phyReg,
uint16_t *  data,
uint32_t  timeoutMs 
)

Reads the selected register of the PHY.

Parameters
[in]instanceInstance number
[in]phyAddrPHY device address
[in]phyRegPHY register address
[out]dataData read from the PHY
[in]timeoutMsTimeout for the read operation (in milliseconds)

Definition at line 515 of file enet_driver.c.

status_t ENET_DRV_MDIOWrite ( uint8_t  instance,
uint8_t  phyAddr,
uint8_t  phyReg,
uint16_t  data,
uint32_t  timeoutMs 
)

Writes the selected register of the PHY.

Parameters
[in]instanceInstance number
[in]phyAddrPHY device address
[in]phyRegPHY register address
[in]dataData to be written in the specified register of the PHY
[in]timeoutMsTimeout for the write operation (in milliseconds)

Definition at line 473 of file enet_driver.c.

void ENET_DRV_ProvideRxBuff ( uint8_t  instance,
enet_buffer_t buff 
)

Provides a receive buffer to be used by the driver for reception.

This function provides a buffer which can further be used by the reception mechanism in order to store the received data.

Note: The application can either provide a buffer previously obtained in a ENET_DRV_ReadFrame call (when it is no longer needed after being fully processed), or allocate a new buffer, pointing to a memory area having the required alignment (see FEATURE_ENET_BUFF_ALIGNMENT). The former approach is recommended as it has a simpler usage model and re-uses the same initial memory range for the entire driver lifetime operation. The later approach could provide more flexibility, but since it involves constant memory free/alloc operations it is only recommended with an efficient pool-based memory allocator.

Important: The driver does not ensure synchronization between different threads trying to provide a buffer at the same time. This synchronization shall be implemented by the application.

Important: The application is responsible for providing one Rx buffer for every frame it receives, otherwise the reception ring can fill-up, affecting further reception.

Usage example:

stat = ENET_DRV_ReadFrame(INST_ETHERNET1, &rxBuff);

if (stat == STATUS_SUCCESS) { process_buffer(&rxBuff); ENET_DRV_ProvideRxBuff(INST_ETHERNET1, &rxBuff); }

Parameters
[in]instanceInstance number
[in]buffThe buffer to be added to the reception ring

Definition at line 400 of file enet_driver.c.

status_t ENET_DRV_ReadFrame ( uint8_t  instance,
enet_buffer_t buff 
)

Reads a received Ethernet frame.

This function reads the first received Ethernet frame in the Rx queue. The buffer received as parameter will be updated by the driver and the .data field will point to a memory area containing the frame data.

Note: Once the application finished processing the buffer, it could be reused by the driver for further receptions by invoking ENET_DRV_ProvideRxBuff.

Important: The driver does not ensure synchronization between different threads trying to read a frame at the same time. This synchronization shall be implemented by the application.

Parameters
[in]instanceInstance number
[out]buffThe buffer containing the frame
Returns
STATUS_SUCCESS if a frame was successfully read, STATUS_ENET_RX_QUEUE_EMPTY if there is no available frame in the queue.

Definition at line 261 of file enet_driver.c.

status_t ENET_DRV_SendFrame ( uint8_t  instance,
enet_buffer_t buff 
)

Sends an Ethernet frame.

This function sends an Ethernet frame, contained in the buffer received as parameter.

Note: Since the transmission of the frame is not complete when this function returns, the application must not change/alter/re-use the provided buffer until after a call to ENET_DRV_GetTransmitStatus for the same buffer returns STATUS_SUCCESS.

Important: The driver does not ensure synchronization between different threads trying to send a frame at the same time. This synchronization shall be implemented by the application.

Parameters
[in]instanceInstance number
[in]buffThe buffer containing the frame
Returns
STATUS_SUCCESS if the frame was successfully enqueued for transmission, STATUS_ENET_TX_QUEUE_FULL if there is no available space for the frame in the queue.

Definition at line 306 of file enet_driver.c.

void ENET_DRV_SetMacAddr ( uint8_t  instance,
uint8_t *  macAddr 
)

Configures the physical address of the MAC.

Parameters
[in]instanceInstance number
[in]macAddrThe MAC address to be configured

Definition at line 558 of file enet_driver.c.

void ENET_DRV_SetMulticastForward ( uint8_t  instance,
uint8_t *  macAddr,
bool  enable 
)

Enables/Disables forwarding of multicast traffic having a specific MAC address as destination.

Parameters
[in]instanceInstance number
[in]macAddrThe physical address
[in]enableIf true, the application will receive all the multicast traffic having as destination address the provided MAC address; if false, stop forwarding this kind of traffic

Definition at line 652 of file enet_driver.c.

void ENET_DRV_SetMulticastForwardAll ( uint8_t  instance,
bool  enable 
)

Enables/Disables forwarding of the multicast traffic, irrespective of the destination MAC address.

Parameters
[in]instanceInstance number
[in]enableIf true, the application will receive all the multicast traffic; if false, stop forwarding this kind of traffic

Definition at line 683 of file enet_driver.c.

void ENET_DRV_SetSleepMode ( uint8_t  instance,
bool  enable 
)

Sets the MAC in sleep mode or normal mode.

Parameters
[in]instanceInstance number
[in]enableIf true, set MAC in sleep mode; if false, set MAC in normal mode

Definition at line 711 of file enet_driver.c.

void ENET_DRV_SetUnicastForward ( uint8_t  instance,
uint8_t *  macAddr,
bool  enable 
)

Enables/Disables forwarding of unicast traffic having a specific MAC address as destination.

Parameters
[in]instanceInstance number
[in]macAddrThe physical address
[in]enableIf true, the application will receive all the unicast traffic having as destination address the provided MAC address; if false, stop forwarding this kind of traffic

Definition at line 621 of file enet_driver.c.