Microchip® Advanced Software Framework

emac.h File Reference

EMAC (Ethernet MAC) driver for SAM.

Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"
#include "conf_eth.h"

Data Structures

struct  emac_device
 EMAC driver structure. More...
 
struct  emac_options
 Input parameters when initializing the emac module mode. More...
 
union  emac_rx_descriptor::emac_rx_addr
 
struct  emac_rx_descriptor::emac_rx_addr::emac_rx_addr_bm
 
struct  emac_rx_descriptor
 Receive buffer descriptor struct. More...
 
union  emac_rx_descriptor::emac_rx_status
 
struct  emac_rx_descriptor::emac_rx_status::emac_rx_status_bm
 
struct  emac_tx_descriptor
 Transmit buffer descriptor struct. More...
 
union  emac_tx_descriptor::emac_tx_status
 
struct  emac_tx_descriptor::emac_tx_status::emac_tx_status_bm
 

Macros

#define EMAC_ADDR_LENGTH   (6)
 EMAC address length. More...
 
#define EMAC_CLOCK_SPEED_160MHZ   (160*1000*1000)
 EMAC clock speed. More...
 
#define EMAC_CLOCK_SPEED_20MHZ   (20*1000*1000)
 
#define EMAC_CLOCK_SPEED_40MHZ   (40*1000*1000)
 
#define EMAC_CLOCK_SPEED_80MHZ   (80*1000*1000)
 
#define EMAC_FRAME_LENTGH_MAX   1536
 The MAC can support frame lengths up to 1536 bytes. More...
 
#define EMAC_MAN_CODE_VALUE   (10)
 EMAC maintain code default value. More...
 
#define EMAC_MAN_READ_ONLY   (1)
 EMAC maintain read only. More...
 
#define EMAC_MAN_RW_TYPE   (2)
 EMAC maintain read/write. More...
 
#define EMAC_MAN_SOF_VALUE   (1)
 EMAC maintain start of frame default value. More...
 
#define EMAC_RX_UNITSIZE   128
 Fixed size for RX buffer. More...
 
#define EMAC_RXD_ADDR1   (1ul << 26)
 Address 1 match. More...
 
#define EMAC_RXD_ADDR2   (1ul << 25)
 Address 2 match. More...
 
#define EMAC_RXD_ADDR3   (1ul << 24)
 Address 3 match. More...
 
#define EMAC_RXD_ADDR4   (1ul << 23)
 Address 4 match. More...
 
#define EMAC_RXD_ADDR_MASK   0xFFFFFFFC
 The buffer addresses written into the descriptors must be aligned, so the last few bits are zero. More...
 
#define EMAC_RXD_BROADCAST   (1ul << 31)
 Broadcast detected. More...
 
#define EMAC_RXD_CFI   (1ul << 16)
 Concatenation Format Indicator only if bit 21 is set. More...
 
#define EMAC_RXD_EOF   (1ul << 15)
 End of frame. More...
 
#define EMAC_RXD_EXTADDR   (1ul << 28)
 External address match. More...
 
#define EMAC_RXD_LEN_MASK   (0xFFF)
 Length of frame including FCS (if selected) More...
 
#define EMAC_RXD_LENJUMBO_MASK   (0x3FFF)
 Jumbo frame length. More...
 
#define EMAC_RXD_MULTIHASH   (1ul << 30)
 Multicast hash match. More...
 
#define EMAC_RXD_OFFSET_MASK
 Receive buffer offset. More...
 
#define EMAC_RXD_OWNERSHIP   (1ul << 0)
 Ownership bit. More...
 
#define EMAC_RXD_PRIORITY   (1ul << 20)
 Priority tag detected. More...
 
#define EMAC_RXD_PRIORITY_MASK   (3ul << 17)
 VLAN priority. More...
 
#define EMAC_RXD_SOF   (1ul << 14)
 Start of frame. More...
 
#define EMAC_RXD_TYPE   (1ul << 22)
 Type ID match. More...
 
#define EMAC_RXD_UNIHASH   (1ul << 29)
 Unicast hash match. More...
 
#define EMAC_RXD_VLAN   (1ul << 21)
 VLAN tag detected. More...
 
#define EMAC_RXD_WRAP   (1ul << 1)
 Wrap bit. More...
 
#define EMAC_TX_UNITSIZE   1518
 Size for ETH frame length. More...
 
#define EMAC_TXD_ERROR   (1ul << 29)
 Retry limit exceeded, error. More...
 
#define EMAC_TXD_EXHAUSTED   (1ul << 27)
 Buffer exhausted. More...
 
#define EMAC_TXD_LAST   (1ul << 15)
 Last buffer in frame. More...
 
#define EMAC_TXD_LEN_MASK   (0x7FF)
 Length of buffer. More...
 
#define EMAC_TXD_NOCRC   (1ul << 16)
 No CRC. More...
 
#define EMAC_TXD_UNDERRUN   (1ul << 28)
 Transmit underrun. More...
 
#define EMAC_TXD_USED   (1ul << 31)
 Frame is transmitted. More...
 
#define EMAC_TXD_WRAP   (1ul << 30)
 Last descriptor. More...
 

Typedefs

typedef void(* emac_dev_tx_cb_t )(uint32_t ul_status)
 RX callback. More...
 
typedef void(* emac_dev_wakeup_cb_t )(void)
 Wakeup callback. More...
 
typedef struct emac_device emac_device_t
 EMAC driver structure. More...
 
typedef struct emac_options emac_options_t
 Input parameters when initializing the emac module mode. More...
 
typedef struct emac_rx_descriptor emac_rx_descriptor_t
 Receive buffer descriptor struct. More...
 
typedef struct emac_tx_descriptor emac_tx_descriptor_t
 Transmit buffer descriptor struct. More...
 

Enumerations

enum  emac_status_t {
  EMAC_OK = 0,
  EMAC_TIMEOUT = 1,
  EMAC_TX_BUSY,
  EMAC_RX_NULL,
  EMAC_SIZE_TOO_SMALL,
  EMAC_PARAM,
  EMAC_INVALID = 0xFF
}
 Return codes for EMAC APIs. More...
 

Functions

static void emac_clear_rx_status (Emac *p_emac, uint32_t ul_status)
 Clear receive status. More...
 
static void emac_clear_statistics (Emac *p_emac)
 Clear all statistics registers. More...
 
static void emac_clear_tx_status (Emac *p_emac, uint32_t ul_status)
 Clear transmit status. More...
 
uint32_t emac_dev_get_tx_load (emac_device_t *p_emac_dev)
 Get current load of transmit. More...
 
void emac_dev_init (Emac *p_emac, emac_device_t *p_emac_dev, emac_options_t *p_opt)
 Initialize the EMAC driver. More...
 
uint32_t emac_dev_read (emac_device_t *p_emac_dev, uint8_t *p_frame, uint32_t ul_frame_size, uint32_t *p_rcv_size)
 Frames can be read from the EMAC in multiple sections. More...
 
void emac_dev_reset (emac_device_t *p_emac_dev)
 Reset TX & RX queue & statistics. More...
 
void emac_dev_set_rx_callback (emac_device_t *p_emac_dev, emac_dev_tx_cb_t func_rx_cb)
 Register/Clear RX callback. More...
 
uint8_t emac_dev_set_tx_wakeup_callback (emac_device_t *p_emac_dev, emac_dev_wakeup_cb_t func_wakeup, uint8_t uc_threshold)
 Register/Clear TX wakeup callback. More...
 
uint32_t emac_dev_write (emac_device_t *p_emac_dev, void *p_buffer, uint32_t ul_size, emac_dev_tx_cb_t func_tx_cb)
 Send ulLength bytes from pcFrom. More...
 
static void emac_disable_broadcast (Emac *p_emac, uint8_t uc_enable)
 Disable/Enable broadcast receiving. More...
 
static void emac_disable_interrupt (Emac *p_emac, uint32_t ul_source)
 Disable interrupt(s). More...
 
static void emac_enable_back_pressure (Emac *p_emac, uint8_t uc_enable)
 In half-duplex mode, forces collisions on all received frames. More...
 
static void emac_enable_big_frame (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable big frames (over 1518, up to 1536). More...
 
static void emac_enable_copy_all (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable Copy(Receive) All Valid Frames. More...
 
static void emac_enable_discard_fcs (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable discarding FCS field of received frames. More...
 
static void emac_enable_efrhd (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable frames to be received in half-duplex mode while transmitting. More...
 
static void emac_enable_full_duplex (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable Full-Duplex mode. More...
 
static void emac_enable_ignore_rx_fcs (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable ignore RX FCS. More...
 
static void emac_enable_interrupt (Emac *p_emac, uint32_t ul_source)
 Enable interrupt(s). More...
 
static void emac_enable_jumbo_frames (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable jumbo frames (up to 10240 bytes). More...
 
static void emac_enable_management (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable EMAC management. More...
 
static void emac_enable_multicast_hash (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable multicast hash. More...
 
static void emac_enable_pause_frame (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable pause (when a valid pause frame is received). More...
 
static void emac_enable_receive (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable EMAC receive. More...
 
static void emac_enable_retry_test (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable retry test. More...
 
static void emac_enable_rmii (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable RMII. More...
 
static void emac_enable_rx_length_check (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable receive length field checking. More...
 
static void emac_enable_statistics_write (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable statistics registers writing. More...
 
static void emac_enable_transceiver_clock (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable transceiver input clock. More...
 
static void emac_enable_transmit (Emac *p_emac, uint8_t uc_enable)
 Enable/Disable EMAC transmit. More...
 
static uint32_t emac_get_configure (Emac *p_emac)
 Get network configuration. More...
 
static uint32_t emac_get_interrupt_mask (Emac *p_emac)
 Return interrupt mask. More...
 
static uint32_t emac_get_interrupt_status (Emac *p_emac)
 Return interrupt status. More...
 
static uint8_t emac_get_MDIO (Emac *p_emac)
 Get MDIO IN pin status. More...
 
static uint32_t emac_get_network_control (Emac *p_emac)
 Get network control value. More...
 
static uint16_t emac_get_phy_data (Emac *p_emac)
 Get PHY maintenance data returned. More...
 
static uint32_t emac_get_rx_queue (Emac *p_emac)
 Get Rx Queue Address. More...
 
static uint32_t emac_get_rx_status (Emac *p_emac)
 Return receive status. More...
 
static uint32_t emac_get_status (Emac *p_emac)
 Get Network Status. More...
 
static uint32_t emac_get_tx_queue (Emac *p_emac)
 Get Tx Queue. More...
 
static uint32_t emac_get_tx_status (Emac *p_emac)
 Return transmit status. More...
 
static uint16_t emac_get_type_id (Emac *p_emac)
 Get type ID. More...
 
static void emac_halt_transmission (Emac *p_emac)
 Halt transmission. More...
 
void emac_handler (emac_device_t *p_emac_dev)
 EMAC Interrupt handler. More...
 
static void emac_increase_statistics (Emac *p_emac)
 Increase all statistics registers. More...
 
static uint8_t emac_is_phy_idle (Emac *p_emac)
 Check if PHY is idle. More...
 
static void emac_maintain_phy (Emac *p_emac, uint8_t uc_phy_addr, uint8_t uc_reg_addr, uint8_t uc_rw, uint16_t us_data)
 Execute PHY maintenance command. More...
 
static void emac_network_control (Emac *p_emac, uint32_t ul_ncr)
 Write network control value. More...
 
uint8_t emac_phy_read (Emac *p_emac, uint8_t uc_phy_address, uint8_t uc_address, uint32_t *p_value)
 Read the PHY register. More...
 
uint8_t emac_phy_write (Emac *p_emac, uint8_t uc_phy_address, uint8_t uc_address, uint32_t ul_value)
 Write the PHY register. More...
 
static void emac_set_address (Emac *p_emac, uint8_t uc_index, uint8_t *p_mac_addr)
 Set MAC Address. More...
 
static void emac_set_address32 (Emac *p_emac, uint8_t uc_index, uint32_t ul_mac_top, uint32_t ul_mac_bottom)
 Set MAC Address via 2 dword. More...
 
static void emac_set_address64 (Emac *p_emac, uint8_t uc_index, uint64_t ull_mac)
 Set MAC Address via int64. More...
 
static uint8_t emac_set_clock (Emac *p_emac, uint32_t ul_mck)
 Set MDC clock divider. More...
 
static void emac_set_configure (Emac *p_emac, uint32_t ul_cfg)
 Set up network configuration register. More...
 
static void emac_set_hash (Emac *p_emac, uint32_t ul_hash_top, uint32_t ul_hash_bottom)
 Set Hash. More...
 
static void emac_set_hash64 (Emac *p_emac, uint64_t ull_hash)
 Set 64 bits Hash. More...
 
static void emac_set_pause_time (Emac *p_emac, uint16_t us_pause_time)
 Set pause time. More...
 
static void emac_set_rx_buffer_offset (Emac *p_emac, uint8_t uc_offset)
 Set receive buffer offset to 0 ~ 3. More...
 
static void emac_set_rx_queue (Emac *p_emac, uint32_t ul_addr)
 Set Rx Queue. More...
 
static void emac_set_speed (Emac *p_emac, uint8_t uc_speed)
 Set speed. More...
 
static void emac_set_tx_queue (Emac *p_emac, uint32_t ul_addr)
 Set Tx Queue. More...
 
static void emac_set_type_id (Emac *p_emac, uint16_t us_type_id)
 Set type ID. More...
 
static void emac_start_transmission (Emac *p_emac)
 Start transmission. More...
 

#define EMAC_ADDR_LENGTH   (6)

EMAC address length.

#define EMAC_CLOCK_SPEED_160MHZ   (160*1000*1000)

EMAC clock speed.

Referenced by emac_set_clock().

#define EMAC_CLOCK_SPEED_20MHZ   (20*1000*1000)

Referenced by emac_set_clock().

#define EMAC_CLOCK_SPEED_40MHZ   (40*1000*1000)

Referenced by emac_set_clock().

#define EMAC_CLOCK_SPEED_80MHZ   (80*1000*1000)

Referenced by emac_set_clock().

#define EMAC_FRAME_LENTGH_MAX   1536

The MAC can support frame lengths up to 1536 bytes.

#define EMAC_MAN_CODE_VALUE   (10)

EMAC maintain code default value.

Referenced by emac_maintain_phy().

#define EMAC_MAN_READ_ONLY   (1)

EMAC maintain read only.

Referenced by emac_maintain_phy().

#define EMAC_MAN_RW_TYPE   (2)

EMAC maintain read/write.

Referenced by emac_maintain_phy().

#define EMAC_MAN_SOF_VALUE   (1)

EMAC maintain start of frame default value.

Referenced by emac_maintain_phy().

#define EMAC_RX_UNITSIZE   128

Fixed size for RX buffer.

Referenced by emac_dev_read(), and emac_reset_rx_mem().

#define EMAC_RXD_ADDR1   (1ul << 26)

Address 1 match.

#define EMAC_RXD_ADDR2   (1ul << 25)

Address 2 match.

#define EMAC_RXD_ADDR3   (1ul << 24)

Address 3 match.

#define EMAC_RXD_ADDR4   (1ul << 23)

Address 4 match.

#define EMAC_RXD_ADDR_MASK   0xFFFFFFFC

The buffer addresses written into the descriptors must be aligned, so the last few bits are zero.

These bits have special meaning for the EMAC peripheral and cannot be used as part of the address.

Referenced by emac_dev_read(), and emac_reset_rx_mem().

#define EMAC_RXD_BROADCAST   (1ul << 31)

Broadcast detected.

#define EMAC_RXD_CFI   (1ul << 16)

Concatenation Format Indicator only if bit 21 is set.

#define EMAC_RXD_EOF   (1ul << 15)

End of frame.

Referenced by emac_dev_read().

#define EMAC_RXD_EXTADDR   (1ul << 28)

External address match.

#define EMAC_RXD_LEN_MASK   (0xFFF)

Length of frame including FCS (if selected)

Referenced by emac_dev_read().

#define EMAC_RXD_LENJUMBO_MASK   (0x3FFF)

Jumbo frame length.

#define EMAC_RXD_MULTIHASH   (1ul << 30)

Multicast hash match.

#define EMAC_RXD_OFFSET_MASK

Receive buffer offset.

#define EMAC_RXD_OWNERSHIP   (1ul << 0)

Ownership bit.

Referenced by emac_dev_read().

#define EMAC_RXD_PRIORITY   (1ul << 20)

Priority tag detected.

#define EMAC_RXD_PRIORITY_MASK   (3ul << 17)

VLAN priority.

#define EMAC_RXD_SOF   (1ul << 14)

Start of frame.

Referenced by emac_dev_read().

#define EMAC_RXD_TYPE   (1ul << 22)

Type ID match.

#define EMAC_RXD_UNIHASH   (1ul << 29)

Unicast hash match.

#define EMAC_RXD_VLAN   (1ul << 21)

VLAN tag detected.

#define EMAC_RXD_WRAP   (1ul << 1)

Wrap bit.

Referenced by emac_reset_rx_mem().

#define EMAC_TX_UNITSIZE   1518

Size for ETH frame length.

Referenced by emac_dev_write(), and emac_reset_tx_mem().

#define EMAC_TXD_ERROR   (1ul << 29)

Retry limit exceeded, error.

#define EMAC_TXD_EXHAUSTED   (1ul << 27)

Buffer exhausted.

#define EMAC_TXD_LAST   (1ul << 15)

Last buffer in frame.

Referenced by emac_dev_write().

#define EMAC_TXD_LEN_MASK   (0x7FF)

Length of buffer.

Referenced by emac_dev_write().

#define EMAC_TXD_NOCRC   (1ul << 16)

No CRC.

#define EMAC_TXD_UNDERRUN   (1ul << 28)

Transmit underrun.

#define EMAC_TXD_USED   (1ul << 31)

Frame is transmitted.

Referenced by emac_handler(), and emac_reset_tx_mem().

#define EMAC_TXD_WRAP   (1ul << 30)

Last descriptor.

Referenced by emac_dev_write(), and emac_reset_tx_mem().

typedef void(* emac_dev_tx_cb_t)(uint32_t ul_status)

RX callback.

typedef void(* emac_dev_wakeup_cb_t)(void)

Wakeup callback.

typedef struct emac_device emac_device_t

EMAC driver structure.

typedef struct emac_options emac_options_t

Input parameters when initializing the emac module mode.

Receive buffer descriptor struct.

Transmit buffer descriptor struct.

Return codes for EMAC APIs.

Enumerator
EMAC_OK 
EMAC_TIMEOUT 

Operation OK.

EMAC_TX_BUSY 

EMAC operation timeout.

EMAC_RX_NULL 

TX in progress.

EMAC_SIZE_TOO_SMALL 

No data received.

EMAC_PARAM 

Buffer size not enough.

EMAC_INVALID 

Parameter error, TX packet invalid or RX size too small.

static void emac_clear_rx_status ( Emac *  p_emac,
uint32_t  ul_status 
)
inlinestatic

Clear receive status.

Parameters
p_emacPointer to the EMAC instance.
ul_statusReceive status.

Referenced by emac_dev_init(), and emac_handler().

static void emac_clear_statistics ( Emac *  p_emac)
inlinestatic

Clear all statistics registers.

Parameters
p_emacPointer to the EMAC instance.

Referenced by emac_dev_init().

static void emac_clear_tx_status ( Emac *  p_emac,
uint32_t  ul_status 
)
inlinestatic

Clear transmit status.

Parameters
p_emacPointer to the EMAC instance.
ul_statusTransmit status.

Referenced by emac_dev_init(), and emac_handler().

static void emac_disable_broadcast ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Disable/Enable broadcast receiving.

Parameters
p_emacPointer to the EMAC instance.
uc_enable1 to disable the broadcast, else to enable it.

Referenced by emac_dev_init().

static void emac_disable_interrupt ( Emac *  p_emac,
uint32_t  ul_source 
)
inlinestatic

Disable interrupt(s).

Parameters
p_emacPointer to the EMAC instance.
ul_sourceInterrupt source(s) to be disabled.

Referenced by emac_dev_init(), and emac_dev_set_rx_callback().

static void emac_enable_back_pressure ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

In half-duplex mode, forces collisions on all received frames.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the back pressure, else to enable it.
static void emac_enable_big_frame ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable big frames (over 1518, up to 1536).

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable big frames else to enable it.
static void emac_enable_copy_all ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable Copy(Receive) All Valid Frames.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable copying all valid frames, else to enable it.

Referenced by emac_dev_init().

static void emac_enable_discard_fcs ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable discarding FCS field of received frames.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable discarding FCS field of received frames, else to enable it.
static void emac_enable_efrhd ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable frames to be received in half-duplex mode while transmitting.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the received in half-duplex mode, else to enable it.
static void emac_enable_full_duplex ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable Full-Duplex mode.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the Full-Duplex mode, else to enable it.

Referenced by ethernet_phy_auto_negotiate(), and ethernet_phy_set_link().

static void emac_enable_ignore_rx_fcs ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable ignore RX FCS.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable ignore RX FCS, else to enable it.
static void emac_enable_interrupt ( Emac *  p_emac,
uint32_t  ul_source 
)
inlinestatic

Enable interrupt(s).

Parameters
p_emacPointer to the EMAC instance.
ul_sourceInterrupt source(s) to be enabled.

Referenced by emac_dev_set_rx_callback(), and emac_init_mem().

static void emac_enable_jumbo_frames ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable jumbo frames (up to 10240 bytes).

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the jumbo frames, else to enable it.
static void emac_enable_management ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable EMAC management.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable EMAC management, else to enable it.

Referenced by ethernet_phy_auto_negotiate(), ethernet_phy_find_valid(), ethernet_phy_reset(), and ethernet_phy_set_link().

static void emac_enable_multicast_hash ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable multicast hash.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the multicast hash, else to enable it.
static void emac_enable_pause_frame ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable pause (when a valid pause frame is received).

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable pause frame, else to enable it.
static void emac_enable_receive ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable EMAC receive.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable EMAC receiver, else to enable it.

Referenced by emac_init_mem(), and emac_reset_rx_mem().

static void emac_enable_retry_test ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable retry test.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the EMAC receiver, else to enable it.
static void emac_enable_rmii ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable RMII.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the RMII mode, else to enable it.

Referenced by ethernet_phy_auto_negotiate().

static void emac_enable_rx_length_check ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable receive length field checking.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable receive length field checking, else to enable it.
static void emac_enable_statistics_write ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable statistics registers writing.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable the statistics registers writing, else to enable it.

Referenced by emac_init_mem().

static void emac_enable_transceiver_clock ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable transceiver input clock.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable transceiver input clock, else to enable it.

Referenced by ethernet_phy_auto_negotiate().

static void emac_enable_transmit ( Emac *  p_emac,
uint8_t  uc_enable 
)
inlinestatic

Enable/Disable EMAC transmit.

Parameters
p_emacPointer to the EMAC instance.
uc_enable0 to disable EMAC transmit, else to enable it.

Referenced by emac_handler(), emac_init_mem(), and emac_reset_tx_mem().

static uint32_t emac_get_configure ( Emac *  p_emac)
inlinestatic

Get network configuration.

Parameters
p_emacPointer to the EMAC instance.
Returns
Network configuration.

Referenced by emac_dev_init().

static uint32_t emac_get_interrupt_mask ( Emac *  p_emac)
inlinestatic

Return interrupt mask.

Parameters
p_emacPointer to the EMAC instance.
Returns
Interrupt mask.

Referenced by emac_handler().

static uint32_t emac_get_interrupt_status ( Emac *  p_emac)
inlinestatic

Return interrupt status.

Parameters
p_emacPointer to the EMAC instance.
Returns
Interrupt status.

Referenced by emac_dev_init(), and emac_handler().

static uint8_t emac_get_MDIO ( Emac *  p_emac)
inlinestatic

Get MDIO IN pin status.

Parameters
p_emacPointer to the EMAC instance.
Returns
MDIO IN pin status.
static uint32_t emac_get_network_control ( Emac *  p_emac)
inlinestatic

Get network control value.

Parameters
p_emacPointer to the EMAC instance.
static uint16_t emac_get_phy_data ( Emac *  p_emac)
inlinestatic

Get PHY maintenance data returned.

Parameters
p_emacPointer to the EMAC instance.
Returns
Get PHY data.

Referenced by emac_phy_read().

static uint32_t emac_get_rx_queue ( Emac *  p_emac)
inlinestatic

Get Rx Queue Address.

Parameters
p_emacPointer to the EMAC instance.
Returns
Rx queue address.
static uint32_t emac_get_rx_status ( Emac *  p_emac)
inlinestatic

Return receive status.

Parameters
p_emacPointer to the EMAC instance.

Referenced by emac_handler().

static uint32_t emac_get_status ( Emac *  p_emac)
inlinestatic

Get Network Status.

Parameters
p_emacPointer to the EMAC instance.
Returns
Network status.
static uint32_t emac_get_tx_queue ( Emac *  p_emac)
inlinestatic

Get Tx Queue.

Parameters
p_emacPointer to the EMAC instance.
Returns
Rx queue address.
static uint32_t emac_get_tx_status ( Emac *  p_emac)
inlinestatic

Return transmit status.

Parameters
p_emacPointer to the EMAC instance.
Returns
Transmit status.

Referenced by emac_handler().

static uint16_t emac_get_type_id ( Emac *  p_emac)
inlinestatic

Get type ID.

Parameters
p_emacPointer to the EMAC instance.
Returns
Type ID.
static void emac_halt_transmission ( Emac *  p_emac)
inlinestatic

Halt transmission.

Parameters
p_emacPointer to the EMAC instance.
static void emac_increase_statistics ( Emac *  p_emac)
inlinestatic

Increase all statistics registers.

Parameters
p_emacPointer to the EMAC instance.
static uint8_t emac_is_phy_idle ( Emac *  p_emac)
inlinestatic

Check if PHY is idle.

Parameters
p_emacPointer to the EMAC instance.
Returns
1 if PHY is idle.

Referenced by emac_wait_phy().

static void emac_maintain_phy ( Emac *  p_emac,
uint8_t  uc_phy_addr,
uint8_t  uc_reg_addr,
uint8_t  uc_rw,
uint16_t  us_data 
)
inlinestatic

Execute PHY maintenance command.

Parameters
p_emacPointer to the EMAC instance.
uc_phy_addrPHY address.
uc_reg_addrRegister address.
uc_rw1 to Read, 0 to write.
us_dataData to be performed, write only.

References EMAC_MAN_CODE_VALUE, EMAC_MAN_READ_ONLY, EMAC_MAN_RW_TYPE, and EMAC_MAN_SOF_VALUE.

Referenced by emac_phy_read(), and emac_phy_write().

static void emac_network_control ( Emac *  p_emac,
uint32_t  ul_ncr 
)
inlinestatic

Write network control value.

Parameters
p_emacPointer to the EMAC instance.
ul_ncrNetwork control value.

Referenced by emac_dev_init(), and emac_dev_reset().

static void emac_set_address ( Emac *  p_emac,
uint8_t  uc_index,
uint8_t *  p_mac_addr 
)
inlinestatic

Set MAC Address.

Parameters
p_emacPointer to the EMAC instance.
uc_indexEMAC specific address register index.
p_mac_addrEMAC address.

Referenced by emac_dev_init().

static void emac_set_address32 ( Emac *  p_emac,
uint8_t  uc_index,
uint32_t  ul_mac_top,
uint32_t  ul_mac_bottom 
)
inlinestatic

Set MAC Address via 2 dword.

Parameters
p_emacPointer to the EMAC instance.
uc_indexEMAC specific address register index.
ul_mac_topEMAC top address.
ul_mac_bottomEMAC bottom address.
static void emac_set_address64 ( Emac *  p_emac,
uint8_t  uc_index,
uint64_t  ull_mac 
)
inlinestatic

Set MAC Address via int64.

Parameters
p_emacPointer to the EMAC instance.
uc_indexEMAC specific address register index.
ull_mac64-bit EMAC address.
static uint8_t emac_set_clock ( Emac *  p_emac,
uint32_t  ul_mck 
)
inlinestatic

Set MDC clock divider.

Parameters
p_emacPointer to the EMAC instance.
ul_mckEMAC MCK.
Returns
EMAC_OK if successfully.

References EMAC_CLOCK_SPEED_160MHZ, EMAC_CLOCK_SPEED_20MHZ, EMAC_CLOCK_SPEED_40MHZ, EMAC_CLOCK_SPEED_80MHZ, EMAC_INVALID, and EMAC_OK.

Referenced by ethernet_phy_init().

static void emac_set_configure ( Emac *  p_emac,
uint32_t  ul_cfg 
)
inlinestatic

Set up network configuration register.

Parameters
p_emacPointer to the EMAC instance.
ul_cfgNetwork configuration value.

Referenced by emac_dev_init().

static void emac_set_hash ( Emac *  p_emac,
uint32_t  ul_hash_top,
uint32_t  ul_hash_bottom 
)
inlinestatic

Set Hash.

Parameters
p_emacPointer to the EMAC instance.
ul_hash_topHash top.
ul_hash_bottomHash bottom.
static void emac_set_hash64 ( Emac *  p_emac,
uint64_t  ull_hash 
)
inlinestatic

Set 64 bits Hash.

Parameters
p_emacPointer to the EMAC instance.
ull_hash64 bits hash value.
static void emac_set_pause_time ( Emac *  p_emac,
uint16_t  us_pause_time 
)
inlinestatic

Set pause time.

Parameters
p_emacPointer to the EMAC instance.
us_pause_timePause time.
static void emac_set_rx_buffer_offset ( Emac *  p_emac,
uint8_t  uc_offset 
)
inlinestatic

Set receive buffer offset to 0 ~ 3.

Parameters
p_emacPointer to the EMAC instance.
static void emac_set_rx_queue ( Emac *  p_emac,
uint32_t  ul_addr 
)
inlinestatic

Set Rx Queue.

Parameters
p_emacPointer to the EMAC instance.
ul_addrRx queue address.

Referenced by emac_reset_rx_mem().

static void emac_set_speed ( Emac *  p_emac,
uint8_t  uc_speed 
)
inlinestatic

Set speed.

Parameters
p_emacPointer to the EMAC instance.
uc_speed1 to indicate 100Mbps, 0 to 10Mbps.

Referenced by ethernet_phy_auto_negotiate(), and ethernet_phy_set_link().

static void emac_set_tx_queue ( Emac *  p_emac,
uint32_t  ul_addr 
)
inlinestatic

Set Tx Queue.

Parameters
p_emacPointer to the EMAC instance.
ul_addrTx queue address.

Referenced by emac_reset_tx_mem().

static void emac_set_type_id ( Emac *  p_emac,
uint16_t  us_type_id 
)
inlinestatic

Set type ID.

Parameters
p_emacPointer to the EMAC instance.
us_type_idType to be set.
static void emac_start_transmission ( Emac *  p_emac)
inlinestatic

Start transmission.

Parameters
p_emacPointer to the EMAC instance.

Referenced by emac_dev_write().