📄 mainloop.lst
字号:
C51 COMPILER V7.00 MAINLOOP 06/16/2004 13:29:52 PAGE 1
C51 COMPILER V7.00, COMPILATION OF MODULE MAINLOOP
OBJECT MODULE PLACED IN Mainloop.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE Mainloop.c DEBUG OBJECTEXTEND
stmt level source
1 /*
2 //*************************************************************************
3 //
4 // ZLGMCU
5 // www.zlgmcu.com
6 // File Name: MAINLOOP.C
7 // Revision: V0.2(2002-04-08)
8 // Use Library: USB51S.LIB
9 // Note: USB51S.LIB不带DMA控制功能
10 //*************************************************************************
11 */
12
13 #include <stdio.h>
14 #include <string.h>
15
16 #include <reg51.h> /* special function register declarations */
17
18 #include "mainloop.h"
19 #include "isr.h"
20 #include "vi2c_c51.h"
21
22 /*
23 //*************************************************************************
24 // Public static data
25 //*************************************************************************
26 */
27
28 extern EPPFLAGS bEPPflags;
29 extern unsigned char idata GenEpBuf[];
30 extern IO_REQUEST idata ioRequest;
31 extern unsigned char ioSize, ioCount;
32 extern unsigned char idata EpBuf[];
33 extern CONTROL_XFER ControlData;
34
35 bit i;
36 unsigned char idata ComEpBuf[8];
37 rom_addr rwrom_addr,rwrom_type,rwlen;
38 unsigned char eprom_sla,operate_type,check_dat,rwcount;
39 unsigned char *eprom_sub;
40
41
42 unsigned char code i2crom_mask[]=
43 {
44 //页写掩字
45 0x00, //
46 0x07, //24c01
47 0x0f, //24c02
48 0x0f, //24c04
49 0x0f, //24c08
50 0x0f, //24c16
51 0x1f, //24c64
52 };
53
54 unsigned int code rom_size[]=
55 {
C51 COMPILER V7.00 MAINLOOP 06/16/2004 13:29:52 PAGE 2
56 //空间大小
57 0x0000, //
58 0x007f, //24c01
59 0x0100, //24c02
60 0x0200, //24c04
61 0x0400, //24c08
62 0x0800, //24c16
63 0x2000, //24c64
64 };
65
66
67 void init_timer0(void)
68 {
69 1 TMOD &= 0XF0;
70 1 TMOD |= 0X1;
71 1 TL0 = 0X0;
72 1 TH0 = 0X0;
73 1 ET0 = 1;
74 1 TR0 = 1;
75 1 PT0 = 1;
76 1 EA = 1;
77 1 }
78
79 void init_special_interrupts(void)
80 {
81 1 IT0 = 0;
82 1 EX0 = 1;
83 1 PX0 = 0;
84 1 }
85
86 void init_port()
87 {
88 1 P0 = 0xFF;
89 1 P1 = 0xFF;
90 1 P2 = 0xFF;
91 1 P3 = 0xFF;
92 1 MCU_D12CS = 0x0;
93 1 D12SUSPD = 0;
94 1 }
95
96
97 timer_isr() interrupt 1
98 {
99 1 DISABLE;
100 1 bEPPflags.bits.timer = 0;
101 1 ENABLE;
102 1 }
103
104 usb_isr() interrupt 0
105 {
106 1 DISABLE;
107 1 fn_usb_isr();
108 1 ENABLE;
109 1 }
110
111 void main(void)
112 {
113 1 init_port();
114 1 init_timer0();
115 1 init_special_interrupts();
116 1
117 1 MCU_D12CS = 0x1;
C51 COMPILER V7.00 MAINLOOP 06/16/2004 13:29:52 PAGE 3
118 1 MCU_D12CS = 0x0;
119 1 D12_SetDMA(0x0);
120 1 bEPPflags.value = 0;
121 1
122 1 /* Power on reset, lightup LEDs
123 1 disconnect and reconnect Soft-Connect */
124 1 reconnect_USB();
125 1
126 1 /* Main program loop */
127 1 while( TRUE ){
128 2 if(bEPPflags.bits.configuration)
129 2 i2crw();
130 2
131 2 usbserve();
132 2
133 2 } // Main Loop
134 1
135 1 }
136
137
138 void i2crw(void)
139 {
140 1 if (bEPPflags.bits.ep1_rxdone) {
141 2 DISABLE;
142 2 bEPPflags.bits.ep1_rxdone = 0;
143 2 ENABLE;
144 2 if (bEPPflags.bits.timer)
145 2 {
146 3 ComEpBuf[4]=GenEpBuf[0];
147 3 ComEpBuf[5]=GenEpBuf[1];
148 3 ComEpBuf[6]=GenEpBuf[2];
149 3 ComEpBuf[7]=GenEpBuf[3];
150 3 check_dat=ComEpBuf[0]^ComEpBuf[1]^ComEpBuf[2]^ComEpBuf[3]^ComEpBuf[4]^ComEpBuf[5]^ComEpBuf[6];
151 3 if (check_dat==ComEpBuf[7])
152 3 {
153 4 GenEpBuf[0]=0x55;
154 4 GenEpBuf[1]=0xaa;
155 4 bEPPflags.bits.command=1;
156 4 rwrom_type.word=(ComEpBuf[2] <<8)+ComEpBuf[1];
157 4 switch (rwrom_type.word)
158 4 {
159 5 case 0x0001: //24c01
160 5 case 0x0002: //24c02
161 5 case 0x0003: //24c04
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -