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

📄 etherdev.h

📁 STC51系列的源码
💻 H
字号:
/********************************************************************************/
/* filename: ethernet.h                                                         */
/* version : v1.00                                                              */
/* created : hw-chen                                                            */
/* descript: 与RTL8019相关的数据信息                                            */
/*           RTL8019AS芯片工作在跳线模式,基地址为0x300,所以SA6,SA7,SA10~SA19   */
/*           均接地,SA8接高,SA9连接到A11,所以A11必须为高电平                    */
/*           SA0~SA4与扩展的地址线A6~A10连接,HC138扩展的CS2=0x9000            */
/*------------------------------------------------------------------------------*/
/*                 A11 | A10 |  A9 |  A8 |  A7 |  A6 |  A5 | A4 |               */
/*---------------------+-----+-----+-----+-----+-----+--------------------------*/
/*                 SA9 | SA4 | SA3 | SA2 | SA1 | SA0 |                          */
/*---------------------+-----+-----+-----+-----+-----+--------------------------*/
/*                  1  |  X  |  X  |  X  |  X  |  X  |   0 |  0 |               */
/*  DEV_NET_COMMAND 1  |  0  |  0  |  0  |  0  |  0  |   0 |  0 |               */
/*  DEV_NET_PORT    1  |  1  |  0  |  0  |  0  |  0  |   0 |  0 |               */
/*  DEV_NET_RESET   1  |  1  |  1  |  0  |  0  |  0  |   0 |  0 |               */
/********************************************************************************/
#ifndef  __ETHERNET_H__
#define  __ETHERNET_H__

#define  ETH_A11         0x800
#define  ETH_OFFSET      0x6

#define  DEV_NET_COMMAND c51_hc138_cs2[(ETH_A11+(0x00<<ETH_OFFSET))]     //R/W   NE2000 Registers CR
#define  DEV_NET_PORT    c51_hc138_cs2[(ETH_A11+(0x10<<ETH_OFFSET))]     //R/W   Remote DMA Port
#define  DEV_NET_RESET   c51_hc138_cs2[(ETH_A11+(0x18<<ETH_OFFSET))]     //R/W   Reset Port

/********************************************************************************/
/* Page0 register */
/********************************************************************************/
#define  DEV_NET_CLDA0   c51_hc138_cs2[(ETH_A11+(0x01<<ETH_OFFSET))]     //R      0x1
#define  DEV_NET_PSTART  c51_hc138_cs2[(ETH_A11+(0x01<<ETH_OFFSET))]     //W
#define  DEV_NET_CLDA1   c51_hc138_cs2[(ETH_A11+(0x02<<ETH_OFFSET))]     //R      0x2
#define  DEV_NET_PSTOP   c51_hc138_cs2[(ETH_A11+(0x02<<ETH_OFFSET))]     //W
#define  DEV_NET_BNRY    c51_hc138_cs2[(ETH_A11+(0x03<<ETH_OFFSET))]     //C/W    0x3
#define  DEV_NET_TSR     c51_hc138_cs2[(ETH_A11+(0x04<<ETH_OFFSET))]     //R      0x4
#define  DEV_NET_TPSR    c51_hc138_cs2[(ETH_A11+(0x04<<ETH_OFFSET))]     //W
#define  DEV_NET_NCR     c51_hc138_cs2[(ETH_A11+(0x05<<ETH_OFFSET))]     //R      0x5
#define  DEV_NET_TBCR0   c51_hc138_cs2[(ETH_A11+(0x05<<ETH_OFFSET))]     //W
#define  DEV_NET_FIFO    c51_hc138_cs2[(ETH_A11+(0x06<<ETH_OFFSET))]     //R      0x6
#define  DEV_NET_TBCR1   c51_hc138_cs2[(ETH_A11+(0x06<<ETH_OFFSET))]     //W
#define  DEV_NET_ISR     c51_hc138_cs2[(ETH_A11+(0x07<<ETH_OFFSET))]     //R/W    0x7
#define  DEV_NET_CRDA0   c51_hc138_cs2[(ETH_A11+(0x08<<ETH_OFFSET))]     //R      0x8
#define  DEV_NET_RSAR0   c51_hc138_cs2[(ETH_A11+(0x08<<ETH_OFFSET))]     //W
#define  DEV_NET_CRDA1   c51_hc138_cs2[(ETH_A11+(0x09<<ETH_OFFSET))]     //R      0x9
#define  DEV_NET_RSAR1   c51_hc138_cs2[(ETH_A11+(0x09<<ETH_OFFSET))]     //W
#define  DEV_NET_ID0     c51_hc138_cs2[(ETH_A11+(0x0A<<ETH_OFFSET))]     //R      0xA
#define  DEV_NET_RBCR0   c51_hc138_cs2[(ETH_A11+(0x0A<<ETH_OFFSET))]     //W
#define  DEV_NET_ID1     c51_hc138_cs2[(ETH_A11+(0x0B<<ETH_OFFSET))]     //R      0xB
#define  DEV_NET_RBCR1   c51_hc138_cs2[(ETH_A11+(0x0B<<ETH_OFFSET))]     //W
#define  DEV_NET_RSR     c51_hc138_cs2[(ETH_A11+(0x0C<<ETH_OFFSET))]     //R      0xC
#define  DEV_NET_RCR     c51_hc138_cs2[(ETH_A11+(0x0C<<ETH_OFFSET))]     //W
#define  DEV_NET_CNTR0   c51_hc138_cs2[(ETH_A11+(0x0D<<ETH_OFFSET))]     //R      0xD
#define  DEV_NET_TCR     c51_hc138_cs2[(ETH_A11+(0x0D<<ETH_OFFSET))]     //W
#define  DEV_NET_CNTR1   c51_hc138_cs2[(ETH_A11+(0x0E<<ETH_OFFSET))]     //R      0xE
#define  DEV_NET_DCR     c51_hc138_cs2[(ETH_A11+(0x0E<<ETH_OFFSET))]     //W
#define  DEV_NET_CNTR2   c51_hc138_cs2[(ETH_A11+(0x0F<<ETH_OFFSET))]     //R      0xF
#define  DEV_NET_IMR     c51_hc138_cs2[(ETH_A11+(0x0F<<ETH_OFFSET))]     //W

/********************************************************************************/
/* Page1 register */
/********************************************************************************/
#define  DEV_NET_PAR0    c51_hc138_cs2[(ETH_A11+(0x01<<ETH_OFFSET))]    //R/W     0x1
#define  DEV_NET_PAR1    c51_hc138_cs2[(ETH_A11+(0x02<<ETH_OFFSET))]    //R/W     0x2
#define  DEV_NET_PAR2    c51_hc138_cs2[(ETH_A11+(0x03<<ETH_OFFSET))]    //R/W     0x3
#define  DEV_NET_PAR3    c51_hc138_cs2[(ETH_A11+(0x04<<ETH_OFFSET))]    //R/W     0x4
#define  DEV_NET_PAR4    c51_hc138_cs2[(ETH_A11+(0x05<<ETH_OFFSET))]    //R/W     0x5
#define  DEV_NET_PAR5    c51_hc138_cs2[(ETH_A11+(0x06<<ETH_OFFSET))]    //R/W     0x6
#define  DEV_NET_CURR    c51_hc138_cs2[(ETH_A11+(0x07<<ETH_OFFSET))]    //R/W     0x7
#define  DEV_NET_MAR0    c51_hc138_cs2[(ETH_A11+(0x08<<ETH_OFFSET))]    //R/W     0x8
#define  DEV_NET_MAR1    c51_hc138_cs2[(ETH_A11+(0x09<<ETH_OFFSET))]    //R/W     0x9
#define  DEV_NET_MAR2    c51_hc138_cs2[(ETH_A11+(0x0A<<ETH_OFFSET))]    //R/W     0xA
#define  DEV_NET_MAR3    c51_hc138_cs2[(ETH_A11+(0x0B<<ETH_OFFSET))]    //R/W     0xB
#define  DEV_NET_MAR4    c51_hc138_cs2[(ETH_A11+(0x0C<<ETH_OFFSET))]    //R/W     0xC
#define  DEV_NET_MAR5    c51_hc138_cs2[(ETH_A11+(0x0D<<ETH_OFFSET))]    //R/W     0xD
#define  DEV_NET_MAR6    c51_hc138_cs2[(ETH_A11+(0x0E<<ETH_OFFSET))]    //R/W     0xE
#define  DEV_NET_MAR7    c51_hc138_cs2[(ETH_A11+(0x0F<<ETH_OFFSET))]    //R/W     0xF
                             
/********************************************************************************/
/* Page2 register */
/********************************************************************************/
#define  DEV_NET_PSTART  c51_hc138_cs2[(ETH_A11+(0x01<<ETH_OFFSET))]    //R
#define  DEV_NET_PSTOP   c51_hc138_cs2[(ETH_A11+(0x02<<ETH_OFFSET))]    //R
#define  DEV_NET_TPSR    c51_hc138_cs2[(ETH_A11+(0x04<<ETH_OFFSET))]    //R
#define  DEV_NET_RCR     c51_hc138_cs2[(ETH_A11+(0x0C<<ETH_OFFSET))]    //R
#define  DEV_NET_TCR     c51_hc138_cs2[(ETH_A11+(0x0D<<ETH_OFFSET))]    //R
#define  DEV_NET_DCR     c51_hc138_cs2[(ETH_A11+(0x0E<<ETH_OFFSET))]    //R
#define  DEV_NET_IMR     c51_hc138_cs2[(ETH_A11+(0x0F<<ETH_OFFSET))]    //R

/********************************************************************************/
/* Page3 register */
/********************************************************************************/
#define  DEV_NET_CFG3    c51_hc138_cs2[(ETH_A11+(0x06<<ETH_OFFSET))]   //R/W  LED

/********************************************************************************/
/* 其他相关数据 */
/********************************************************************************/
#define NET_PAGE0           0x00    //* Select  page0,using the two high-order bits
#define NET_PAGE1           0x40    //* Select  page1
#define NET_PAGE2           0x80    //* Select  page2
#define NET_PAGE3           0xC0    //* Select  page3
#define NET_NODMA           0x20    //* Abort/Complete remote DMA
#define NET_STOP            0x01    //* Stop command
#define NET_START           0x02    //* Start command
#define NET_TXP			    0x04    //* trasmmite packet flag
#define NET_REM_READ	    0x08    //* commands
#define NET_REM_WRITE	    0x10
#define NET_SEND_PKT	    0x18

/********************************************************************************/
/* 其他相关数据 */
/********************************************************************************/
#define RSR_MULTI_BROAD_PKT	0x20	//* current receive packet is multi or broadcast packet
#define RSR_RECV_NO_ERR     0x01

#define TX_START_PAGE       0x40    //* the start pages address of the send buffer ring
#define RX_START_PAGE       0x4C    //* the start pages address of the receive buffer ring
#define RX_STOP_PAGE        0x60    //* 接收缓冲区的尾部,在8位模式不能超过0x60

void rtl8019_initialize(void);
unsigned int etherdev_send(void);
unsigned int etherdev_read(void);
void rtl8019_reset(void);

#endif

⌨️ 快捷键说明

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