S32 SDK
enet_driver.c File Reference
#include "enet_driver.h"
#include "enet_hw_access.h"
#include "clock_manager.h"
#include "interrupt_manager.h"

Go to the source code of this file.

Macros

#define ENET_ROUNDED_UP_DIV(a, b)    ((a) + (b) - 1) / (b)
 
#define ENET_NS_IN_SECOND   (1000000000U)
 
#define ENET_ALL_INTERRUPTS_MASK   (0xFFFFFFFFU)
 
#define ENET_BYTE_0_IN_ADDR_SHIFT   (24U)
 
#define ENET_BYTE_1_IN_ADDR_SHIFT   (16U)
 
#define ENET_BYTE_2_IN_ADDR_SHIFT   (8U)
 
#define ENET_BYTE_3_IN_ADDR_SHIFT   (0U)
 
#define ENET_BYTE_4_IN_ADDR_SHIFT   (8U)
 
#define ENET_BYTE_5_IN_ADDR_SHIFT   (0U)
 
#define ENET_BYTE_MASK   (0xFFU)
 

Functions

static uint32_t ENET_DRV_ComputeCRC32 (uint8_t *mac)
 
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...
 
status_t ENET_DRV_ReadFrame (uint8_t instance, enet_buffer_t *buff)
 Reads a received Ethernet frame. 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...
 
void ENET_DRV_ProvideRxBuff (uint8_t instance, enet_buffer_t *buff)
 Provides a receive buffer to be used by the driver for reception. More...
 
void ENET_DRV_EnableMDIO (uint8_t instance, bool miiPreambleDisabled)
 Enables the MDIO interface. 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...
 
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...
 
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...
 
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...
 

Variables

enet_state_tg_enetState [ENET_INSTANCE_COUNT] = {NULL}
 Pointers to ENET internal driver state for each instance. More...
 
static const IRQn_Type s_enetTxIrqId [] = FEATURE_ENET_TX_IRQS
 ENET transmit IRQ number for each instance. More...
 
static const IRQn_Type s_enetRxIrqId [] = FEATURE_ENET_RX_IRQS
 ENET receive IRQ number for each instance. More...
 
static const IRQn_Type s_enetErrIrqId [] = FEATURE_ENET_ERR_IRQS
 ENET error IRQ number for each instance. More...
 
static const clock_names_t s_enetClkNames [] = FEATURE_ENET_CLOCK_NAMES
 Table to save ENET clock indexes in clock configuration. More...
 

Macro Definition Documentation

#define ENET_ALL_INTERRUPTS_MASK   (0xFFFFFFFFU)

Definition at line 30 of file enet_driver.c.

#define ENET_BYTE_0_IN_ADDR_SHIFT   (24U)

Definition at line 32 of file enet_driver.c.

#define ENET_BYTE_1_IN_ADDR_SHIFT   (16U)

Definition at line 33 of file enet_driver.c.

#define ENET_BYTE_2_IN_ADDR_SHIFT   (8U)

Definition at line 34 of file enet_driver.c.

#define ENET_BYTE_3_IN_ADDR_SHIFT   (0U)

Definition at line 35 of file enet_driver.c.

#define ENET_BYTE_4_IN_ADDR_SHIFT   (8U)

Definition at line 36 of file enet_driver.c.

#define ENET_BYTE_5_IN_ADDR_SHIFT   (0U)

Definition at line 37 of file enet_driver.c.

#define ENET_BYTE_MASK   (0xFFU)

Definition at line 39 of file enet_driver.c.

#define ENET_NS_IN_SECOND   (1000000000U)

Definition at line 28 of file enet_driver.c.

#define ENET_ROUNDED_UP_DIV (   a,
 
)    ((a) + (b) - 1) / (b)

Definition at line 27 of file enet_driver.c.

Function Documentation

static uint32_t ENET_DRV_ComputeCRC32 ( uint8_t *  mac)
static

Definition at line 78 of file enet_driver.c.

Variable Documentation

enet_state_t* g_enetState[ENET_INSTANCE_COUNT] = {NULL}

Pointers to ENET internal driver state for each instance.

Definition at line 46 of file enet_driver.c.

const clock_names_t s_enetClkNames[] = FEATURE_ENET_CLOCK_NAMES
static

Table to save ENET clock indexes in clock configuration.

Definition at line 60 of file enet_driver.c.

const IRQn_Type s_enetErrIrqId[] = FEATURE_ENET_ERR_IRQS
static

ENET error IRQ number for each instance.

Definition at line 53 of file enet_driver.c.

const IRQn_Type s_enetRxIrqId[] = FEATURE_ENET_RX_IRQS
static

ENET receive IRQ number for each instance.

Definition at line 51 of file enet_driver.c.

const IRQn_Type s_enetTxIrqId[] = FEATURE_ENET_TX_IRQS
static

ENET transmit IRQ number for each instance.

Definition at line 49 of file enet_driver.c.