⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zlg_avalon_rtl8019.h

📁 周立功 SOPC嵌入式系统实验教程 网卡芯片驱动及其应用
💻 H
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzhou ZHIYUAN ELECTRONIC CO.,LTD.
**                                      Research centre
**                         http://www.zyinside.com, http://www.zlgmcu.com
**
**---------------------------------------File Info-----------------------------------------------------
** File name:			zlg_avalon_rtl8019.h
** Latest modified Date:  2005-12-07
** Latest Version:		    1.0
** Descriptions:		LWIP ethernet interface for the RTL8019as on the ZLG NiosII board
**
**------------------------------------------------------------------------------------------------------
** Created by:			Jing.Zhang
** Created date:		2005-12-07
** Version:				  1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/
#ifndef __ZLG_AVALON_RTL8019_H__
#define __ZLG_AVALON_RTL8019_H__

#ifdef LWIP
#include <stdlib.h>
#include <stdio.h>
#include "alt_types.h"
#include "zlg_avalon_rtl8019_regs.h"
#include "system.h"
#include "lwip/netif.h"
#include "arch/sys_arch.h"
#include "alt_lwip_dev.h"
#include "sys/alt_warning.h"
#include "altera_avalon_pio_regs.h"

#ifndef  FALSE
#define  FALSE                     0
#endif

#ifndef  TRUE
#define  TRUE                      1
#endif

#ifdef __GLOBAL_DEF__
#define __EXT__   
#else
#define __EXT__ extern
#endif

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/********************************************************************************************************
**                    Accessor Marco  for RTL8019 operation
********************************************************************************************************/
/* Software reset RTL8019        */
#define RTL8019_SRST(base)        do{ \
	                                   IOWR((base), 0x1f, 0x00);\
	                                   usleep(1000);\
	                                  }while(0)
	                                  
/* Hardware reset RTL8019        */
#define RTL8019_HRST(pio_base)    do{\
	                                   IOWR_ALTERA_AVALON_PIO_DATA((pio_base), 0);\
	                                   usleep(100);\
	                                   IOWR_ALTERA_AVALON_PIO_DATA((pio_base), 1);\
	                                   usleep(2000);\
	                                   IOWR_ALTERA_AVALON_PIO_DATA((pio_base), 0);\
	                                   usleep(100);\
	                                  }while(0)
	                                  


/* Select the page of register. Read-Modify-Write */	                                                                 
static ALT_INLINE void ALT_ALWAYS_INLINE SelectPage(alt_u32 base, alt_u8 page_num)
{
	  alt_u8 tmp;
	  tmp = GET_CR_REG(base)&0x3b;  //Keep TXP bit cleared
	  tmp |= page_num<<6;
	  SET_CR_REG(base,tmp);
}


/********************************************************************************************************
**                    Public functions declared here
********************************************************************************************************/
err_t zlg_avalon_rtl8019_init(struct netif *netif); 
void zlg_avalon_rtl8019_rx();


/********************************************************************************************************
**                RTL8019 Network interface class declaration
********************************************************************************************************/

typedef struct 
{
  alt_lwip_dev_list   lwip_dev_list;
  alt_u32             base_addr;    /* base_addr of zlg_avalon_rtl8019                   */
  alt_u32             irq;          /* irq number of zlg_avalon_rtl8019                  */
  alt_u32             bus_width;
  sys_sem_t           semaphore;    /* Semaphore for low_level_input and low_level_ouput */
  sys_sem_t           arp_semaphore;/* Semaphore for ARP                 */ 
  alt_u32             tx_packet_no; /* Number of packet allocated for Tx */
  alt_u32             rst_pio_base;
  alt_u32             irq_pio_base; 
}zlg_avalon_rtl8019_if;

/********************************************************************************************************
**               Create a RTL8019 device instance
********************************************************************************************************/
#define ZLG_AVALON_RTL8019_INSTANCE(name, dev) \
zlg_avalon_rtl8019_if dev = \
{\
  {\
    ALT_LLIST_ENTRY,\
    {\
      0,\
      name##_NAME,\
      zlg_avalon_rtl8019_init, \
      zlg_avalon_rtl8019_rx,\
    },\
  },\
  name##_BASE, \
  name##_INT_IRQ,\
  16,\
  0,\
  0,\
  0,\
  name##_RST_BASE, \
  name##_INT_BASE \
}

#define ZLG_AVALON_RTL8019_INIT(name, dev) alt_lwip_dev_reg(dev)
                                        

#ifdef __cplusplus
}
#endif /* __cplusplus */

#else
#warning excluding drivers for the rtl8019 as you do not have the LWIP software component selected
#define ZLG_AVALON_RTL8019_INSTANCE(name, dev) extern int alt_no_storage
#define ZLG_AVALON_RTL8019_INIT(name, dev) while(0)     
#endif /* LWIP */

#endif /* __ZLG_AVALON_RTL8019_H__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -