Microchip® Advanced Software Framework

gmac_raw_2.c File Reference

GMAC (Ethernet MAC) driver for SAM.

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

#include "compiler.h"
#include "gmac.h"
#include "gmac_raw_2.h"
#include <string.h>
#include "conf_eth.h"

Data Structures

struct  gmac_dev_mem
 GMAC 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 gmac_dev_mem gmac_dev_mem_t
 GMAC device memory management struct. More...
 

Functions

static void circ_inc (uint16_t *headortail, uint32_t size)
 Increment head or tail. More...
 
uint8_t * gmac_dev_get_tx_buffer (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
 
uint32_t gmac_dev_get_tx_load (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
 Get current load of transmit. More...
 
void gmac_dev_init (Gmac *p_gmac, gmac_device_t *p_gmac_dev, gmac_options_t *p_opt)
 Initialize the GMAC driver. More...
 
uint32_t gmac_dev_read (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx, uint8_t *p_frame, uint32_t ul_frame_size, uint32_t *p_rcv_size)
 Frames can be read from the GMAC in multiple sections. More...
 
void gmac_dev_reset (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
 Reset TX & RX queue & statistics. More...
 
uint32_t gmac_dev_rx_buf_used (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
 Return the number of RX buffer full. More...
 
void gmac_dev_set_rx_callback (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx, gmac_dev_tx_cb_t func_rx_cb)
 Register/Clear RX callback. More...
 
uint8_t gmac_dev_set_tx_wakeup_callback (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx, gmac_dev_wakeup_cb_t func_wakeup_cb, uint8_t uc_threshold)
 Register/Clear TX wakeup callback. More...
 
uint32_t gmac_dev_tx_buf_used (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
 Return the number of TX buffer waiting for transfer. More...
 
uint32_t gmac_dev_write (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx, void *p_buffer, uint32_t ul_size, gmac_dev_tx_cb_t func_tx_cb)
 Send ulLength bytes from pcFrom. More...
 
uint32_t gmac_dev_write_nocopy (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx, uint32_t ul_size, gmac_dev_tx_cb_t func_tx_cb)
 
void gmac_handler (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx)
 GMAC Interrupt handler. More...
 
static uint8_t gmac_init_mem (gmac_device_t *p_gmac_dev, gmac_quelist_t queue_idx, gmac_dev_mem_t *p_dev_mm, gmac_dev_tx_cb_t *p_tx_cb)
 Initialize the allocated buffer lists for GMAC driver to transfer data. More...
 
static void gmac_init_queue (Gmac *p_gmac, gmac_device_t *p_gmac_dev)
 
static void gmac_reset_rx_mem (gmac_device_t *p_dev, gmac_quelist_t queue_idx)
 Disable receiver, reset registers and descriptor list. More...
 
static void gmac_reset_tx_mem (gmac_device_t *p_dev, gmac_quelist_t queue_idx)
 Disable transfer, reset registers and descriptor lists. More...
 

Variables

static gmac_rx_descriptor_t gs_rx_desc [GMAC_RX_BUFFERS]
 
static gmac_rx_descriptor_t gs_rx_desc_null
 RX descriptors lists. More...
 
static gmac_dev_tx_cb_t gs_tx_callback [GMAC_TX_BUFFERS]
 TX callback lists. More...
 
static gmac_tx_descriptor_t gs_tx_desc [GMAC_TX_BUFFERS]
 
static gmac_tx_descriptor_t gs_tx_desc_null
 TX descriptor lists. More...
 
static uint8_t gs_uc_rx_buffer [GMAC_RX_BUFFERS *GMAC_RX_UNITSIZE]
 Receive Buffer. More...
 
static uint8_t gs_uc_tx_buffer [GMAC_TX_BUFFERS *GMAC_TX_UNITSIZE]
 Send Buffer. More...