📄 isr.lst
字号:
63
64 #ifndef __C51__
void interrupt (*OldTimerIsr)();
void interrupt (*OldUsbIsr)();
unsigned long ClockIsr = 0;
extern unsigned long dmaBuffer;
extern unsigned long ioBuffer; // V2.1
extern unsigned short ioSize, ioCount; // V2.1
#endif
73
74 #ifdef __C51__
75 timer_isr() interrupt 1
76 {
77 1 DISABLE;
78 1 ClockTicks++;
79 1 bEPPflags.bits.timer = 1;
80 1 ENABLE;
81 1 }
82 #else
void interrupt timer_isr(void)
{
DISABLE;
ClockTicks++;
bEPPflags.bits.timer = 1;
(*OldTimerIsr)();
ENABLE;
}
#endif
95
96
97 #ifdef __C51__
98 usb_isr() interrupt 0
99 {
100 1 DISABLE;
101 1 fn_usb_isr();
102 1 ENABLE;
103 1 }
104 #else
void interrupt usb_isr(void)
{
ClockIsr = ClockTicks;
D12Eval_outportb(0x0, 0x80);
fn_usb_isr();
outportb(0x20, 0x20);
D12Eval_outportb(0x80, 0x80);
}
#endif
118
119 void fn_usb_isr()
120 {
121 1 unsigned int i_st;
122 1
123 1 bEPPflags.bits.in_isr = 1;
124 1
C51 COMPILER V8.02 ISR 07/27/2007 11:10:49 PAGE 16
125 1 i_st = D12_ReadInterruptRegister();
126 1
127 1 if(i_st != 0) {
128 2 if(i_st & D12_INT_BUSRESET) {
129 3 bus_reset();
130 3 bEPPflags.bits.bus_reset = 1;
131 3 }
132 2 else {
133 3 if(i_st & D12_INT_EOT)
134 3 dma_eot();
135 3
136 3 if(i_st & D12_INT_SUSPENDCHANGE)
137 3 bEPPflags.bits.suspend = 1;
138 3
139 3 if(i_st & D12_INT_ENDP0IN)
140 3 ep0_txdone();
141 3 if(i_st & D12_INT_ENDP0OUT)
142 3 ep0_rxdone();
143 3 if(i_st & D12_INT_ENDP1IN)
144 3 ep1_txdone();
145 3 if(i_st & D12_INT_ENDP1OUT)
146 3 ep1_rxdone();
147 3 if(i_st & D12_INT_ENDP2IN)
148 3 main_txdone();
149 3 if(i_st & D12_INT_ENDP2OUT)
150 3 main_rxdone();
151 3 }
152 2 }
153 1
154 1 bEPPflags.bits.in_isr = 0;
155 1 }
156
157 void bus_reset(void)
158 {
159 1 }
160
161 void ep0_rxdone(void)
162 {
163 1 unsigned char ep_last, i;
164 1
165 1 ep_last = D12_ReadLastTransactionStatus(0); // Clear interrupt flag
166 1
167 1 if (ep_last & D12_SETUPPACKET) {
168 2
169 2 ControlData.wLength = 0;
170 2 ControlData.wCount = 0;
171 2
172 2 if( D12_ReadEndpoint(0, (unsigned char *)(&(ControlData.DeviceRequest)),
173 2 sizeof(ControlData.DeviceRequest)) != sizeof(DEVICE_REQUEST) ) {
174 3
175 3 D12_SetEndpointStatus(0, 1);
176 3 D12_SetEndpointStatus(1, 1);
177 3 bEPPflags.bits.control_state = USB_IDLE;
178 3
179 3 return;
180 3 }
181 2
182 2 #ifdef __C51__
183 2 ControlData.DeviceRequest.wValue = SWAP(ControlData.DeviceRequest.wValue);
184 2 ControlData.DeviceRequest.wIndex = SWAP(ControlData.DeviceRequest.wIndex);
185 2 ControlData.DeviceRequest.wLength = SWAP(ControlData.DeviceRequest.wLength);
186 2 #endif
C51 COMPILER V8.02 ISR 07/27/2007 11:10:49 PAGE 17
187 2
188 2 // Acknowledge setup here to unlock in/out endp
189 2 D12_AcknowledgeEndpoint(0);
190 2 D12_AcknowledgeEndpoint(1);
191 2
192 2 ControlData.wLength = ControlData.DeviceRequest.wLength;
193 2 ControlData.wCount = 0;
194 2
195 2 if (ControlData.DeviceRequest.bmRequestType & (unsigned char)USB_ENDPOINT_DIRECTION_MASK) {
196 3 bEPPflags.bits.setup_packet = 1;
197 3 bEPPflags.bits.control_state = USB_IDLE; /* get command */
198 3 }
199 2 else {
200 3 if (ControlData.DeviceRequest.wLength == 0) {
201 4 bEPPflags.bits.setup_packet = 1;
202 4 bEPPflags.bits.control_state = USB_IDLE; /* set command */
203 4 }
204 3 else {
205 4 if(ControlData.DeviceRequest.wLength > MAX_CONTROLDATA_SIZE) {
206 5 bEPPflags.bits.control_state = USB_IDLE;
207 5 D12_SetEndpointStatus(0, 1);
208 5 D12_SetEndpointStatus(1, 1);
209 5 }
210 4 else {
211 5 bEPPflags.bits.control_state = USB_RECEIVE; /* set command with OUT token */
212 5 }
213 4 } // set command with data
214 3 } // else set command
215 2 } // if setup packet
216 1
217 1 else if (bEPPflags.bits.control_state == USB_RECEIVE) {
218 2 i = D12_ReadEndpoint(0, ControlData.dataBuffer + ControlData.wCount,
219 2 EP0_PACKET_SIZE);
220 2
221 2 ControlData.wCount += i;
222 2 if( i != EP0_PACKET_SIZE || ControlData.wCount >= ControlData.wLength) {
223 3 bEPPflags.bits.setup_packet = 1;
224 3 bEPPflags.bits.control_state = USB_IDLE;
225 3 }
226 2 }
227 1
228 1 else {
229 2 bEPPflags.bits.control_state = USB_IDLE;
230 2 }
231 1 }
232
233 void ep0_txdone(void)
234 {
235 1 short i = ControlData.wLength - ControlData.wCount;
236 1
237 1 D12_ReadLastTransactionStatus(1); // Clear interrupt flag
238 1
239 1 if (bEPPflags.bits.control_state != USB_TRANSMIT)
240 1 return;
241 1
242 1 if( i >= EP0_PACKET_SIZE) {
243 2 D12_WriteEndpoint(1, ControlData.pData + ControlData.wCount, EP0_PACKET_SIZE);
244 2 ControlData.wCount += EP0_PACKET_SIZE;
245 2
246 2 bEPPflags.bits.control_state = USB_TRANSMIT;
247 2 }
248 1 else if( i != 0) {
C51 COMPILER V8.02 ISR 07/27/2007 11:10:49 PAGE 18
249 2 D12_WriteEndpoint(1, ControlData.pData + ControlData.wCount, i);
250 2 ControlData.wCount += i;
251 2
252 2 bEPPflags.bits.control_state = USB_IDLE;
253 2 }
254 1 else if (i == 0){
255 2 D12_WriteEndpoint(1, 0, 0); // Send zero packet at the end ???
256 2
257 2 bEPPflags.bits.control_state = USB_IDLE;
258 2 }
259 1 }
260
261 void dma_eot(void)
262 {
263 1 if(bEPPflags.bits.dma_state == DMA_PENDING)
264 1 bEPPflags.bits.setup_dma = 1;
265 1 else
266 1 bEPPflags.bits.dma_state = DMA_IDLE;
267 1 }
268
269 void ep1_txdone(void)
270 {
271 1 D12_ReadLastTransactionStatus(3); /* Clear interrupt flag */
272 1 }
273
274 void ep1_rxdone(void)
275 {
276 1 unsigned char len;
277 1
278 1 D12_ReadLastTransactionStatus(2); /* Clear interrupt flag */
279 1
280 1 len = D12_ReadEndpoint(2, GenEpBuf, sizeof(GenEpBuf));
281 1
282 1 if(len != 0)
283 1 bEPPflags.bits.ep1_rxdone = 1;
284 1 }
285
286 void main_txdone(void)
287 {
288 1 #ifndef __C51__
unsigned short len;
unsigned char far *fp;
unsigned short seg, off;
#endif
293 1
294 1 D12_ReadLastTransactionStatus(5); /* Clear interrupt flag */
295 1
296 1 #ifndef __C51__
seg = (ioBuffer + ioCount)>>4;
off = (ioBuffer + ioCount)&0xf;
fp = MK_FP(seg, off);
len = ioSize - ioCount;
if(len == 0) {
if(bEPPflags.bits.dma_state == DMA_PENDING)
bEPPflags.bits.setup_dma = 1;
else
bEPPflags.bits.dma_state = DMA_IDLE;
}
else {
if(len > 64)
len = 64;
C51 COMPILER V8.02 ISR 07/27/2007 11:10:49 PAGE 19
len = D12_WriteEndpoint(5, fp, len);
ioCount += len;
}
#endif
315 1 }
316
317 void main_rxdone(void)
318 {
319 1 #ifndef __C51__
unsigned char len;
unsigned char far *fp;
unsigned short seg, off;
#endif
324 1
325 1 D12_ReadLastTransactionStatus(4); /* Clear interrupt flag */
326 1
327 1 #ifndef __C51__
seg = (ioBuffer + ioCount)>>4;
off = (ioBuffer + ioCount)&0xf;
fp = MK_FP(seg, off);
len = D12_ReadMainEndpoint( fp );
ioCount += len;
if(ioCount >= ioSize) {
if(bEPPflags.bits.dma_state == DMA_PENDING)
bEPPflags.bits.setup_dma = 1;
else
bEPPflags.bits.dma_state = DMA_IDLE;
}
#endif
341 1 }
342
C51 COMPILER V8.02 ISR 07/27/2007 11:10:49 PAGE 20
ASSEMBLY LISTING OF GENERATED OBJECT CODE
; FUNCTION timer_isr (BEGIN)
0000 C0E0 PUSH ACC
0002 C0F0 PUSH B
0004 C083 PUSH DPH
0006 C082 PUSH DPL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -