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

📄 ethernet.h

📁 ATmega103、ATmega128做的开发板web server源码
💻 H
字号:
/******************************************************************
* ethernet.h:
* 
* Copyright (c) 2001 Atmel Corporation.
* All Rights Reserved.
*
* You are autorized to use, copy and distribute this software only at 
* a single site (the term "site" meaning a single company location). 
* This copyright notice must be included in any copy, modification 
* or portion of this software merged into another program.
* 
* This software is licenced solely for use with Atmel AVR micro 
* controller family. The software may not be modified to execute on 
* any other microcontroller architectures
*
* This software is provided "as is"; Without warranties either express
* or implied, including any warranty regarding merchantability, 
* fitness for a particular purpose or noninfringement. 
*
* In no event shall Atmel or its suppliers be liable for any special, 
* indirect,incidential or concequential damages resulting from the 
* use or inability to use this software.
*
* Revision history:
*
* January 17, 2001:   Version 1.0   Created by JB
* July 13, 2001		  Version 1.2     JB
* 					- Changed to IAR compiler V2.25
*					- Renamed flash file functions to avoid conflict with 
*					  standard file I/O names	
*					- Bug fixes in HTTP
*					- Speed optimization in TCP 
*
*
*******************************************************************/

/*macro*/
#define LO(x) ((unsigned char) ((x)&0x00ff))          //returns the lower end byte of an integer
#define HI(x) ((unsigned char) (((x)>>8)&0x00ff))     //returns the higher end byte of an integer   

#define TOPTR(x) ((unsigned int *)x) 

/*Base addresses*/
#define IOBASE    0x8300
#define MEMBASE   0xd000

#pragma location = 0x000c+IOBASE
__no_init volatile unsigned int PPdata0;
#pragma location = 0x0138+MEMBASE
__no_init volatile unsigned int ppBusST;

/*I/O registers*/
#define RxTxData0 TOPTR((0x0000+IOBASE))
#define RxTxData1 TOPTR((0x0002+IOBASE))
#define TxCMD     TOPTR((0x0004+IOBASE))
#define TxLength  TOPTR((0x0006+IOBASE))
#define ISQ       TOPTR((0x0008+IOBASE))
#define PPptr     TOPTR((0x000a+IOBASE))
//#define PPdata0   TOPTR((0x000c+IOBASE))
#define PPdata1   TOPTR((0x000e+IOBASE))

/*PacketPage Addresses*/
#define ppEISA      TOPTR((0x0000+MEMBASE))
#define ppID        TOPTR((0x0002+MEMBASE))
#define ppIObase    TOPTR((0x0020+MEMBASE))
#define ppIntNum    TOPTR((0x0022+MEMBASE))
#define ppMEMbase   TOPTR((0x002c+MEMBASE))
#define ppRxFByte   TOPTR((0x0050+MEMBASE))
#define ppRxCFG     TOPTR((0x0102+MEMBASE))
#define ppRxCTL     TOPTR((0x0104+MEMBASE))
#define ppTxCFG     TOPTR((0x0106+MEMBASE))
#define ppTxCMDr    TOPTR((0x0108+MEMBASE))
#define ppBufCFG    TOPTR((0x010a+MEMBASE))
#define ppLineCTL   TOPTR((0x0112+MEMBASE))
#define ppSelfCTL   TOPTR((0x0114+MEMBASE))
#define ppBusCTL    TOPTR((0x0116+MEMBASE))
#define ppTestCTL   TOPTR((0x0118+MEMBASE))
#define ppISQ       TOPTR((0x0120+MEMBASE))
#define ppRxEvent   TOPTR((0x0124+MEMBASE))
#define ppTxEvent   TOPTR((0x0128+MEMBASE))
#define ppBufEvent  TOPTR((0x012c+MEMBASE))
#define ppRxMISS    TOPTR((0x0130+MEMBASE))
#define ppTxCOL     TOPTR((0x0132+MEMBASE))
#define ppLineST    TOPTR((0x0134+MEMBASE))
#define ppSelfST    TOPTR((0x0136+MEMBASE))
//#define ppBusST     TOPTR((0x0138+MEMBASE))
#define ppTxCMD     TOPTR((0x0144+MEMBASE))
#define ppTxLength  TOPTR((0x0146+MEMBASE))
#define ppIA0       TOPTR((0x0158+MEMBASE))
#define ppIA1       TOPTR((0x015a+MEMBASE))
#define ppIA2       TOPTR((0x015c+MEMBASE))
#define ppRxStatus  TOPTR((0x0400+MEMBASE))
#define ppRxLength  TOPTR((0x0402+MEMBASE))
#define ppRxFrame   TOPTR((0x0404+MEMBASE))
#define ppTxFrame   TOPTR((0x0a00+MEMBASE))

/*Frame offset*/
#define ETH_TARGET_MAC        0
#define ETH_TARGET_MAC0       0
#define ETH_TARGET_MAC1       1
#define ETH_TARGET_MAC2       2
#define ETH_SENDER_MAC0       3
#define ETH_SENDER_MAC1       4
#define ETH_SENDER_MAC2       5
#define ETH_SENDER_MAC        3
#define ETH_TYPE              6

/*size of ARP table*/
#define ETH_MAC_TABLE_SIZE    20
#define ETH_HEADER_LENGTH     14

typedef struct
{
  unsigned int MAC0, MAC1, MAC2;
  unsigned int IP0,IP1;
}config_type;

/* Function prototypes*/
char sendFrame(unsigned int length, unsigned int type, unsigned int hisIP0, unsigned int hisIP1);
void initEthernet(void);
void receiveEvent(void);
char getMAC(unsigned int hisIP0, unsigned int hisIP1);
void dhcpMAC(unsigned int hisIP0, unsigned int hisIP1);

⌨️ 快捷键说明

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