Microchip® Advanced Software Framework

emac.c File Reference

EMAC (Ethernet MAC) driver for SAM.

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

#include "compiler.h"
#include "emac.h"
#include <string.h>

Data Structures

struct  emac_dev_mem
 EMAC device memory management struct. More...
 

Macros

#define CIRC_CLEAR(head, tail)   (head = tail = 0)
 Clear circular buffer. More...
 
#define CIRC_CNT(head, tail, size)   (((head) - (tail)) % (size))
 Return count in buffer. More...
 
#define CIRC_EMPTY(head, tail)   (head == tail)
 Circular buffer is empty ? More...
 
#define CIRC_SPACE(head, tail, size)   CIRC_CNT((tail),((head)+1),(size))
 

Typedefs

typedef struct emac_dev_mem emac_dev_mem_t
 EMAC device memory management struct. More...
 

Functions

static void circ_inc (uint16_t *headortail, uint32_t size)
 Increment head or tail. 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_cb, 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...
 
void emac_handler (emac_device_t *p_emac_dev)
 EMAC Interrupt handler. More...
 
static uint8_t emac_init_mem (Emac *p_emac, emac_device_t *p_emac_dev, emac_dev_mem_t *p_dev_mm, emac_dev_tx_cb_t *p_tx_cb)
 Initialize the allocated buffer lists for EMAC driver to transfer data. 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_reset_rx_mem (emac_device_t *p_dev)
 Disable receiver, reset registers and descriptor list. More...
 
static void emac_reset_tx_mem (emac_device_t *p_dev)
 Disable transfer, reset registers and descriptor lists. More...
 
static uint8_t emac_wait_phy (Emac *p_emac, const uint32_t ul_retry)
 Wait PHY operation to be completed. More...
 

Variables

static emac_rx_descriptor_t gs_rx_desc [EMAC_RX_BUFFERS]
 RX descriptors lists. More...
 
static emac_dev_tx_cb_t gs_tx_callback [EMAC_TX_BUFFERS]
 TX callback lists. More...
 
static emac_tx_descriptor_t gs_tx_desc [EMAC_TX_BUFFERS]
 TX descriptor lists. More...
 
static uint8_t gs_uc_rx_buffer [EMAC_RX_BUFFERS *EMAC_RX_UNITSIZE]
 Receive Buffer. More...
 
static uint8_t gs_uc_tx_buffer [EMAC_TX_BUFFERS *EMAC_TX_UNITSIZE]
 Send Buffer. More...