📄 defs.inc.icd
字号:
RA0 equ 0
RA1 equ 1
RA2 equ 2
RA3 equ 3
RA4 equ 4
RA5 equ 5
RB0 equ 0
RB1 equ 1
RB2 equ 2
RB3 equ 3
RB4 equ 4
RB5 equ 5
RB6 equ 6
RB7 equ 7
RC0 equ 0
RC1 equ 1
RC2 equ 2
RC3 equ 3
RC4 equ 4
RC5 equ 5
RC6 equ 6
RC7 equ 7
RD0 equ 0
RD1 equ 1
RD2 equ 2
RD3 equ 3
RD4 equ 4
RD5 equ 5
RD6 equ 6
RD7 equ 7
RE0 equ 0
RE1 equ 1
RE2 equ 2
;e_data equ 0x7c
;-----------------------------------------------------------------------------------
HTTP_PORT equ 80 ; HTTP Port Number (Default=80)
LCD_PORT equ 0 ; LCD Controller Port Number(0=Not Used)
PARALLEL_PORT equ 10001 ; Parriel Port Number(0=Not Used)
SERIAL_PORT equ 10002 ; Serial Port Number(0=Not Used)
BOOTPC_PORT equ 68 ; BOOTP Port(Client)
BOOTPS_PORT equ 67 ; BOOTP Port(Server)
BAUD_RATE equ 129 ;10 ; Reset时RS232的波特率
; 129=9600bps
; 10=115200bps
PARALLEL_PACKET_SIZE equ 8 ; 并口数据包大小
SERIAL_PACKET_SIZE equ (2+6+4+2+1+1) ; 串口数据包大小
; type:mac:ip:port:baud:flow
CH_BACKSPACE equ 8 ; BackSpace的ASCII码
SOCKETS equ 4 ; Socket总数(不可变更)
;-----------------------------------------------------------------------------------
org H'2100' ; Initialize EEPROM Data
de 192,168,0,200 ; IP地址(0.0.0.0=DHCP)
de 255,255,255,0 ; Netmask
de 0,0,0,0 ; GateWay
de 1,2,0,0 ; Farmware Version x,x,x,x
de HTTP_PORT / 256,HTTP_PORT & 0xff ; HTTP Port
de LCD_PORT / 256,LCD_PORT & 0xff ; LCD Port
de PARALLEL_PORT / 256,PARALLEL_PORT & 0xff ; PARALLEL Port
de SERIAL_PORT / 256,SERIAL_PORT & 0xff ; SERIAL Port
de 0
;-----------------------------------------------------------------------------------
;
; Protocol号等
;
COM_PROTO equ 08h ; HIGH BYTE(共通)
IP_PROTO equ 00h ; LOW BYTE (0800h means IP packet)
ARP_PROTO equ 06h ; LOW BYTE (0806h means ARP packet)
TCP_PROTO equ 6
UDP_PROTO equ 17
ICMP_PROTO equ 1
;
; RTL8019AS关联设定项目
;
PAGE_BEGIN equ 40h ; 内存起始地址
PAGE_START equ 46h ; 收信缓冲区开始地址
PAGE_STOP equ 80h ; 收信缓冲区结束地址
DATA_SIZE equ 18
;
; Ethernet关联设定项目
;
NE_SIZE equ 4 ; RTL8019ステータスエリアサイズ
PACKET_SIZE equ 6+6+2 ; Ethernetヘッダサイズ
ARP_SIZE equ 28 ; ARPパケットサイズ
IP_SIZE equ 20 ; IP(基本)ヘッダサイズ
UDP_SIZE equ 8 ; UDPヘッダサイズ
TCP_SIZE equ 20 ; TCP(基本)ヘッダサイズ
DHCP_SIZE equ 308
;
; TCP/IP Start
;
LISTEN equ 00h ; 等待
SYN_RCVD equ 80h ; SYN,发送ACK后等待ACK
ESTAB equ 81h ; 通信确立
CLOSE_WAIT equ 82h
LAST_ACK equ 83h
FIN_WAIT_1 equ 84h
FIN_WAIT_2 equ 85h
CLOSING equ 86h
TIME_WAIT equ 87h
; Socket构造体
;------------------------------------------
; org 0
;so_job ds 2
;so_ip ds 4
;so_port ds 2
;so_seq_no ds 4
;so_ack_no ds 4
;------------------------------------------
;-----------------------------------------------------------------------------------
; I/O Port设定
;-----------------------------------------------------------------------------------
SA equ PORTC ; NE2000地址总线
#define SA0 PORTC,0
#define SA1 PORTC,1
#define SA2 PORTC,2
#define SA3 PORTC,3
#define SA4 PORTC,4
SD equ PORTD
#define SD0 PORTD,0
#define SD1 PORTD,1
#define SD2 PORTD,2
#define SD3 PORTD,3
#define SD4 PORTD,4
#define SD5 PORTD,5
#define SD6 PORTD,6
#define SD7 PORTD,7
#define RDY PORTC,5
;RDY equ PORTC,5 ; ~IOCHRDY
CNT equ PORTE
#define READ PORTE,0 ; RTL8019AS ~RD
#define WRITE PORTE,1 ; RTL8019AS ~WR
;
; LCD用I/O设定
;
;#define D7 PORTB,7 ; LCD
;#define D6 PORTB,6
;#define D5 PORTB,5
;#define D4 PORTB,4
#define E PORTB,3 ; LCD Enable
#define RS PORTB,2 ; LCD RS Pin
CBLOCK 0x20
; LCD用変数
wait_cn
wait_cn2
d4
d8
cd:0
tmp
use
;-----------------------------------------------------------------------------------
gcn1
sum:2 ; check sum for TCP,...
bytes ; current ptr for calculate above
ptr
cn_l
cn_h
remote_adr:2 ; Remote
remote_len:2
curr ; Current page address
val:4
val_m ; for DECIMAL
val_cn:0
proto ; Protcol Number
state ; TCP Flag
;-----------------------------------------------------------------------------------
;
; IP Protocol
;
ip_header:0
ip_ver_len ; VERSION:4,DATA SIZE:5
ip_tos ; service type
ip_length:2 ; データ長
ip_ident:2
ip_flagment:2
ip_ttl ; 生存期
ip_proto ; Protocol 1:ICMP,6:TCP,17:UDP
ip_sum:2 ; Header Checksum
ip_src:4
ip_dest:4
;-----------------------------------------------------------------------------------
; TCP Protocol
;
tcp_header:0
tcp_src_port:2
tcp_tar_port:2
tcp_seq_no:4
tcp_ack_no:4
tcp_header_size
tcp_flags
tcp_window:2
tcp_sum:2
tcp_:2
common
ENDC
#define TCP_URG tcp_flags,5
#define TCP_ACK tcp_flags,4
#define TCP_PSH tcp_flags,3
#define TCP_RST tcp_flags,2
#define TCP_SYN tcp_flags,1
#define TCP_FIN tcp_flags,0
;-----------------------------------------------------------------------------------
; UDP Protocol
;
udp_header equ tcp_header
udp_src_port equ tcp_header+0
udp_tar_port equ tcp_header+2
udp_length equ tcp_header+4
udp_sum equ tcp_header+6
udp_data equ tcp_header+8
;-----------------------------------------------------------------------------------
; ARP Protocol
;
arp_header equ ip_header
arp_hard_type equ ip_header+0
arp_prot_type equ ip_header+2
arp_hard_len equ ip_header+4
arp_prot_len equ ip_header+5
arp_ope equ ip_header+6
arp_src_mac equ ip_header+8
arp_src_ip equ ip_header+14
arp_dest_mac equ ip_header+18
arp_dest_ip equ ip_header+24
; = ip_header+28
;-----------------------------------------------------------------------------------
; ICMP Protocol
;
icmp_header equ tcp_header
icmp_type equ tcp_header+0
icmp_code equ tcp_header+1
icmp_sum equ tcp_header+2
icmp_mes equ tcp_header+4
;-----------------------------------------------------------------------------------
; DHCP Protocol
;
dhcp_header equ udp_data
dhcp_ope equ udp_data+0
dhcp_type equ udp_data+1
dhcp_phylen equ udp_data+2
dhcp_hop equ udp_data+3
dhcp_trans equ udp_data+4
dhcp_sec equ udp_data+8
dhcp_dummy equ udp_data+10
dhcp_client_ip equ udp_data+12
dhcp_user_ip equ udp_data+16
dhcp_server_ip equ udp_data+20
dhcp_router_ip equ udp_data+24
;-----------------------------------------------------------------------------------
; 环境设定用变量
;
; ■PAGE 1
; org 0a0h
CBLOCK 0xa0
this_ip:4 ; 自己的IP地址
mymac:6 ; 自己的MAC地址
seq_no:4 ; 自己的序列号
ident:2
timer
timer_cn
dhcp_done
http_port:2 ; 将EEPROM中的Port号拷贝在这里
lcd_port:2
para_port:2
serial_port:2
fifo_poi ; Routing Used Get Pointer
fifo_buff ; 中断使用的SET Pointer
fifo_cn ; 收信Byte数
fifo_top:30 ; 缓冲区
fifo_bottom:0
fifo_line
fifo_line_cn
;-----------------------------------------------------------------------------------
; Ethernet Header
;
ne_header:0 ; NE2000 Status
ne_stat ; 收信状态(RSR)
ne_next ; Next Boundary
ne_cn_l ; Data Size(L)
ne_cn_h ; Data Size(H)
eth_header:0 ; Ethernet Header
eth_dest:6 ; Dest MAC Address
eth_src:6 ; Source MAC Address
eth_type:2 ; Packet Type
null:0
ENDC
bs_ptr equ ne_header
bs_ptr2 equ ne_header+1
save_line equ ne_header+2
save_cn equ ne_header+3
;-----------------------------------------------------------------------------------
; 10进制变换区
;-----------------------------------------------------------------------------------
; ■PAGE 2
; org 110h
CBLOCK 0x110
; ds 16 ; 2进制→10进制变换用
dummy:16
decimal_top:0
ENDC
;-----------------------------------------------------------------------------------
; RS232送信数据
;-----------------------------------------------------------------------------------
; ■PAGE 3
org 190h
CBLOCK 0x190
on_ether:6 ; 收信方的Ethernet地址
on_ip:4 ; 收信方的IP地址
on_port:2 ; 收信方的端口号
on_rate ; 设置的波特率
on_flow ; 0=NONE, 1=HARDWARE
transmitted ; 发送完的Byte数
ENDC
; org 1a0h
CBLOCK 0x1A0
skb:16 ; 16*SOCKETS
dummy2
ENDC
;-----------------------------------------------------------------------------------
; ■共通变量
;
org 71h ; COMMON MEMORY PAGE
CBLOCK 0x71
w_save
pclath_save
status_save
fsr_save
save_fsr
; END
mul10:0
getmes_wk:2
com_cn
byte_cn:0
com_fsr
ind
dest:2
mdata ; a data for transmit to ethernet chip
wk:2
;common
ENDC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -