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

📄 nic.s

📁 uIP是免费的TCP/IP协议栈,我们将它移植到我们的AVR以太网开发板中
💻 S
字号:
	.module nic.c
	.area text(rom, con, rel)
	.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\nic.c
	.dbfunc e nic_init _nic_init fV
	.even
_nic_init::
	.dbline -1
	.dbline 25
; /*****************************************************************************
; *  Module Name:       NIC Driver Interface for uIP-AVR Port
; *  
; *  Created By:        Louis Beaudoin (www.embedded-creations.com)
; *
; *  Original Release:  November 16, 2003 
; *
; *  Module Description:  
; *  Provides three functions to interface with a NIC driver
; *  These functions can be called directly from the main uIP control loop
; *  to send packets from uip_buf and uip_appbuf, and store incoming packets to
; *  uip_buf
; *
; *
; *****************************************************************************/
; 
; #include "nic.h"
; 
; 
; #define IP_TCP_HEADER_LENGTH 40
; #define TOTAL_HEADER_LENGTH (IP_TCP_HEADER_LENGTH+ETHERNET_HEADER_LENGTH)
; 
; 
; void nic_init(void)
; {
	.dbline 26
; 	NICInit();
	xcall _rtl8019Init
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e nic_send _nic_send fV
	.even
_nic_send::
	.dbline -1
	.dbline 31
; }
; 
; 
; void nic_send(void)
; {
	.dbline 32
; 	NICBeginPacketSend(uip_len);
	lds R16,_uip_len
	lds R17,_uip_len+1
	xcall _rtl8019BeginPacketSend
	.dbline 35
; 	
; 	// send packet, using data in uip_appdata if over the IP+TCP header size
; 	if( uip_len <= TOTAL_HEADER_LENGTH )
	ldi R24,54
	ldi R25,0
	lds R2,_uip_len
	lds R3,_uip_len+1
	cp R24,R2
	cpc R25,R3
	brlo L9
	.dbline 36
; 	{
	.dbline 37
;       NICSendPacketData(uip_buf, uip_len);
	lds R18,_uip_len
	lds R19,_uip_len+1
	ldi R16,<_uip_buf
	ldi R17,>_uip_buf
	xcall _rtl8019SendPacketData
	.dbline 38
; 	}
	xjmp L10
L9:
	.dbline 40
; 	else
; 	{
	.dbline 41
;       uip_len -= TOTAL_HEADER_LENGTH;
	lds R24,_uip_len
	lds R25,_uip_len+1
	sbiw R24,54
	sts _uip_len+1,R25
	sts _uip_len,R24
	.dbline 42
;       NICSendPacketData(uip_buf, TOTAL_HEADER_LENGTH);
	ldi R18,54
	ldi R19,0
	ldi R16,<_uip_buf
	ldi R17,>_uip_buf
	xcall _rtl8019SendPacketData
	.dbline 43
; 	  NICSendPacketData((unsigned char *)uip_appdata, uip_len);
	lds R18,_uip_len
	lds R19,_uip_len+1
	lds R16,_uip_appdata
	lds R17,_uip_appdata+1
	xcall _rtl8019SendPacketData
	.dbline 44
; 	}
L10:
	.dbline 46
; 
; 	NICEndPacketSend();
	xcall _rtl8019EndPacketSend
	.dbline -2
L8:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e nic_poll _nic_poll fi
;   packetLength -> R10,R11
	.even
_nic_poll::
	xcall push_gset3x
	.dbline -1
	.dbline 56
; }
; 
; 
; 
; #if UIP_BUFSIZE > 255
; unsigned int nic_poll(void)
; #else 
; unsigned char nic_poll(void)
; #endif /* UIP_BUFSIZE > 255 */
; {
	.dbline 59
; 	unsigned int packetLength;
; 	
; 	packetLength = NICBeginPacketRetreive();
	xcall _rtl8019BeginPacketRetreive
	movw R10,R16
	.dbline 62
; 
; 	// if there's no packet or an error - exit without ending the operation
; 	if( !packetLength )
	cpi R16,0
	cpc R16,R17
	brne L12
X0:
	.dbline 63
; 	  return 0;
	clr R16
	clr R17
	xjmp L11
L12:
	.dbline 66
; 
; 	// drop anything too big for the buffer
; 	if( packetLength > UIP_BUFSIZE )
	ldi R24,1500
	ldi R25,5
	cp R24,R10
	cpc R25,R11
	brsh L14
	.dbline 67
; 	{
	.dbline 68
; 	  NICEndPacketRetreive();
	xcall _rtl8019EndPacketRetreive
	.dbline 69
;       return 0;
	clr R16
	clr R17
	xjmp L11
L14:
	.dbline 73
; 	}
; 	
; 	// copy the packet data into the uIP packet buffer
; 	NICRetreivePacketData( uip_buf, packetLength );
	movw R18,R10
	ldi R16,<_uip_buf
	ldi R17,>_uip_buf
	xcall _rtl8019RetreivePacketData
	.dbline 74
; 	NICEndPacketRetreive();
	xcall _rtl8019EndPacketRetreive
	.dbline 77
; 		
; #if UIP_BUFSIZE > 255
; 	return packetLength;
	movw R16,R10
	.dbline -2
L11:
	xcall pop_gset3x
	.dbline 0 ; func end
	ret
	.dbsym r packetLength 10 i
	.dbend

⌨️ 快捷键说明

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