📄 isr.lst
字号:
C51 COMPILER V6.12 ISR 06/06/2004 10:26:11 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE ISR
OBJECT MODULE PLACED IN .\ISR.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\ISR.C LARGE DEBUG OBJECTEXTEND
stmt level source
1 //////isr.c
2 #include "common.h"
3 #include "isr.h"
4 #include "d12ci.h"
5 #include "mainloop.h"
6 #include "chap_9.h"
7 #include "usb100.h"
8 #include "disp.h"
9
10 extern EPPFLAGS bEPPflags;
11 extern CONTROL_XFER ControlData;
12
13 extern uchar EpBuf[64];
14 extern uchar GenEpBuf[64];
15
16 void fn_usb_isr()
17 {
18 1 // static uchar count;//
19 1 uint i_st;
20 1 bEPPflags.bits.in_isr = 1;
21 1 i_st = D12_ReadInterruptRegister();
22 1 // if(count>0x39)//
23 1 // count = 0x30;//
24 1 // dispinfo(2,"int:");
25 1 // writedispdata(count++);//
26 1 // disphex(i_st);
27 1 // dispinfo(0," ");
28 1 if(i_st!=0)
29 1 {
30 2 if(i_st&D12_INT_BUSRESET)
31 2 bEPPflags.bits.bus_reset = 1;
32 2 if(i_st&D12_INT_EOT)
33 2 dma_eot();
34 2 if(i_st&D12_INT_SUSPENDCHANGE)
35 2 bEPPflags.bits.suspend = 1;
36 2 if(i_st&D12_INT_ENDP0IN)
37 2 ep0_txdone();
38 2 if(i_st&D12_INT_ENDP0OUT)
39 2 ep0_rxdone();
40 2 if(i_st&D12_INT_ENDP1IN)
41 2 ep1_txdone();
42 2 if(i_st&D12_INT_ENDP1OUT)
43 2 ep1_rxdone();
44 2 if(i_st&D12_INT_ENDP2IN)
45 2 main_txdone();
46 2 if(i_st&D12_INT_ENDP2OUT)
47 2 main_rxdone();
48 2 }
49 1 bEPPflags.bits.in_isr = 0;
50 1 }
51
52 void dma_eot()
53 {
54 1 ////not use DMA
55 1 }
C51 COMPILER V6.12 ISR 06/06/2004 10:26:11 PAGE 2
56 void ep0_rxdone()
57 {
58 1 uchar ep_last,i;
59 1 // dispinfo(0,"ep0rx");
60 1 ep_last = D12_ReadLastTransactionStatus(0);
61 1 if(ep_last&D12_SETUPPACKET)
62 1 {
63 2 ControlData.wLength = 0;
64 2 ControlData.wCount = 0;
65 2 if( D12_ReadEndpoint(0, sizeof(ControlData.DeviceRequest),
66 2 (unsigned char *)(&(ControlData.DeviceRequest))) != sizeof(DEVICE_REQUEST) ) {
67 3 D12_SetEndpointStatus(0, 1);
68 3 D12_SetEndpointStatus(1, 1);
69 3 bEPPflags.bits.control_state = USB_IDLE;
70 3 return;
71 3 }
72 2 ControlData.DeviceRequest.wValue = SWAP(ControlData.DeviceRequest.wValue);
73 2 ControlData.DeviceRequest.wIndex = SWAP(ControlData.DeviceRequest.wIndex);
74 2 ControlData.DeviceRequest.wLength = SWAP(ControlData.DeviceRequest.wLength);
75 2 D12_AcknowledgeEnppoint(0);
76 2 D12_AcknowledgeEnppoint(1);
77 2 ControlData.wLength = ControlData.DeviceRequest.wLength;
78 2 ControlData.wCount = 0;
79 2 if(ControlData.DeviceRequest.bmRequestType&USB_ENDPOINT_DIRECTION_MASK)
80 2 {
81 3 bEPPflags.bits.setup_packet = 1;
82 3 bEPPflags.bits.control_state = USB_TRANSMIT;
83 3 }
84 2 else{
85 3 if(ControlData.DeviceRequest.wLength==0)
86 3 {
87 4 bEPPflags.bits.setup_packet = 1;
88 4 bEPPflags.bits.control_state = USB_IDLE;
89 4 }
90 3 else{
91 4 if(ControlData.DeviceRequest.wLength>MAX_CONTROLDATA_SIZE)
92 4 {
93 5 bEPPflags.bits.control_state = USB_IDLE;
94 5 D12_SetEndpointStatus(0,1);
95 5 D12_SetEndpointStatus(1,1);
96 5 }
97 4 else{
98 5 bEPPflags.bits.control_state = USB_RECEIVE;
99 5 }
100 4 }//set command with data
101 3 }//else set command
102 2 }//if setup packet
103 1 else if(bEPPflags.bits.control_state == USB_RECEIVE)
104 1 {
105 2 i = D12_ReadEndpoint(0,EP0_PACKET_SIZE, ControlData.dataBuffer+ControlData.wCount);
106 2 ControlData.wCount += i;
107 2 if(i != EP0_PACKET_SIZE||ControlData.wCount>=ControlData.wLength)
108 2 {
109 3 bEPPflags.bits.setup_packet = 1;
110 3 bEPPflags.bits.control_state = USB_IDLE;
111 3 }
112 2 }
113 1 else {
114 2 bEPPflags.bits.control_state = USB_IDLE;
115 2 }
116 1 }
117
C51 COMPILER V6.12 ISR 06/06/2004 10:26:11 PAGE 3
118 void ep0_txdone(void)
119 {
120 1 short i = ControlData.wLength - ControlData.wCount;
121 1 // dispinfo(0,"ep0tx");
122 1 disphex(D12_ReadLastTransactionStatus(1));
123 1 if(bEPPflags.bits.control_state!=USB_TRANSMIT)
124 1 return;
125 1 if(i>=EP0_PACKET_SIZE)
126 1 {
127 2 D12_WriteEndpoint(1,EP0_PACKET_SIZE,ControlData.pData + ControlData.wCount);
128 2 ControlData.wCount += EP0_PACKET_SIZE;
129 2 bEPPflags.bits.control_state = USB_TRANSMIT;
130 2 }
131 1 else if(i != 0)
132 1 {
133 2 D12_WriteEndpoint(1,i,ControlData.pData + ControlData.wCount);
134 2 ControlData.wCount += i;
135 2 bEPPflags.bits.control_state = USB_IDLE;
136 2 }
137 1 else if(i==0)
138 1 {
139 2 D12_WriteEndpoint(1,0,0);
140 2 bEPPflags.bits.control_state = USB_IDLE;
141 2 }
142 1 }
143 void ep1_txdone()
144 {
145 1 // dispinfo(0,"ep1tx");
146 1 D12_ReadLastTransactionStatus(3);
147 1 }
148 void ep1_rxdone()
149 {
150 1 uchar len;
151 1 // dispinfo(0,"ep1tx");
152 1 D12_ReadLastTransactionStatus(2);
153 1 len = D12_ReadEndpoint(2,sizeof(GenEpBuf),GenEpBuf);
154 1 if(len !=0)
155 1 bEPPflags.bits.ep1_rxdone = 1;
156 1 }
157 void main_txdone()
158 {
159 1 // dispinfo(0,"maintx");
160 1 D12_ReadLastTransactionStatus(5);
161 1 }
162 void main_rxdone()
163 {
164 1 uchar len,epstatus;
165 1 // dispinfo(0,"mainrx");
166 1 D12_ReadLastTransactionStatus(4);
167 1 epstatus = D12_ReadEndpointStatus(4);
168 1 epstatus &= 0x60;
169 1 len = D12_ReadEndpoint(4,64,EpBuf);
170 1 if(epstatus == 0x60)
171 1 len = D12_ReadEndpoint(4,64,EpBuf);
172 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 772 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 6
PDATA SIZE = ---- ----
C51 COMPILER V6.12 ISR 06/06/2004 10:26:11 PAGE 4
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -