S32 SDK
enet_driver.h File Reference
#include "device_registers.h"
#include "status.h"
#include "osif.h"
#include <stdlib.h>

Go to the source code of this file.

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...
 

Functions

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...