?? isr.lst
字號:
C51 COMPILER V7.07 ISR 06/04/2004 18:36:50 PAGE 1
C51 COMPILER V7.07, COMPILATION OF MODULE ISR
OBJECT MODULE PLACED IN ISR.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE ISR.c DB OE SMALL ROM(LARGE)
stmt level source
1 //**********************************************************************************************//
2 /* */
3 /* USB to Serial V1.0版 */
4 /* */
5 /* FirmWare Files */
6 /* COPYRIGHT (c) 2004 BY GARY 應用物理學 物理實驗中心 */
7 /* */
8 /* Files Name: ISR.C */
9 /* Author: Gary Zou LuDing */
10 /* Created: March 2004 */
11 /* Modified: */
12 /* Revision: 1.0 */
13 /* Other Details: */
14 /* */
15 /* */
16 /* */
17 //**********************************************************************************************//
18
19 #include <stdio.h>
20 #include <string.h>
21
22 #include "usb100.h"
23 #include "reg52.h"
24 #include "hal.h"
25 #include "d12ci.h"
26 #include "isr.h"
27 #include "chap_9.h"
28 #include "vendor.h"
29 #include "main.h"
30
31 extern FLAG flag;
32 extern CTRL_BUF ctrl_buf;
33 extern unsigned char idata enp1_buf[16];
34 extern unsigned char idata enp2_buf[64];
35
36 void d12_isr()
37 {
38 1 int isr_flag;
39 1 flag.bits.in_isr=1;
40 1 isr_flag=d12_read_interrupt_status(); //讀取中斷寄存器
41 1 if(isr_flag!=0)
42 1 {
43 2 if(isr_flag & D12_INT_BUS_RST){
44 3 flag.bits.bus_reset=1;
45 3 flag.bits.in_isr=0;
46 3 return;
47 3 }
48 2 if(isr_flag & D12_INT_DMA_EOT)
49 2 d12_dma_eot(); //DMA傳輸結束,未使用
50 2 if(isr_flag & D12_INT_SUSPEND)
51 2 flag.bits.suspend=1;
52 2 if(isr_flag & D12_INT_ENDP0IN)
53 2 d12_ep0_send_done();
54 2 if(isr_flag & D12_INT_ENDP0OUT)
55 2 d12_ep0_receive_done();
C51 COMPILER V7.07 ISR 06/04/2004 18:36:50 PAGE 2
56 2 if(isr_flag & D12_INT_ENDP1OUT)
57 2 d12_ep1_receive_done();
58 2 if(isr_flag & D12_INT_ENDP1IN)
59 2 d12_ep1_send_done();
60 2 if(isr_flag & D12_INT_ENP2OUT)
61 2 d12_ep2_receive_done();
62 2 if(isr_flag & D12_INT_ENP2IN)
63 2 d12_ep2_send_done();
64 2 }
65 1 flag.bits.in_isr=0;
66 1 }
67
68
69
70 void d12_ep0_send_done()
71 {
72 1 unsigned short i;
73 1 i=ctrl_buf.len-ctrl_buf.count;
74 1 d12_read_last_transaction_status(1);
75 1 if(flag.bits.ctrl_state!=USB_TRANSMIT)
76 1 return;
77 1 if(i>=EP0_PACKET_SIZE)
78 1 {
79 2 d12_write_endpoint(1,ctrl_buf.buf+ctrl_buf.count,EP0_PACKET_SIZE);
80 2 ctrl_buf.count+=EP0_PACKET_SIZE;
81 2 flag.bits.ctrl_state=USB_TRANSMIT;
82 2 }
83 1 else if (i!=0)
84 1 {
85 2 d12_write_endpoint(1,ctrl_buf.buf+ctrl_buf.count,i);
86 2 ctrl_buf.count+=i;
87 2 flag.bits.ctrl_state=USB_IDLE;
88 2 }
89 1 else if (i==0)
90 1 {
91 2 d12_write_endpoint(1,0,0);
92 2 flag.bits.ctrl_state=USB_IDLE;
93 2 }
94 1 }
95
96 void d12_ep0_receive_done()
97 {
98 1 unsigned char status;
99 1 status=d12_read_last_transaction_status(0);
100 1 if(status&D12_SETUPPACKET_MASK)
101 1 {
102 2 if(d12_read_endpoint(0,(unsigned char *)(&ctrl_buf.dev_req),sizeof(ctrl_buf.dev_req))!=sizeof(DEV_REQ))
103 2 {
104 3 d12_set_endpoint_status(0,1);
105 3 d12_set_endpoint_status(1,1);
106 3 flag.bits.ctrl_state=USB_IDLE;
107 3 return;
108 3 }
109 2 ctrl_buf.dev_req.value=SWAP(ctrl_buf.dev_req.value);
110 2 ctrl_buf.dev_req.index=SWAP(ctrl_buf.dev_req.index);
111 2 ctrl_buf.dev_req.len=SWAP(ctrl_buf.dev_req.len);
112 2
113 2 d12_ack_endpoint(0);
114 2 d12_ack_endpoint(1);
115 2
116 2 ctrl_buf.count=0;
117 2 ctrl_buf.len=ctrl_buf.dev_req.len;
C51 COMPILER V7.07 ISR 06/04/2004 18:36:50 PAGE 3
118 2
119 2 if(ctrl_buf.dev_req.req_type&USB_ENDPOINT_DIRECTION_MASK )
120 2 {
121 3 flag.bits.setup_packet=1;
122 3 flag.bits.ctrl_state=USB_TRANSMIT;
123 3 }
124 2 else
125 2 {
126 3 if(ctrl_buf.dev_req.len==0)
127 3 {
128 4 flag.bits.setup_packet=1;
129 4 flag.bits.ctrl_state=USB_IDLE;
130 4 }
131 3 else
132 3 {
133 4 if(ctrl_buf.dev_req.len>MAX_CTRL_SIZE)
134 4 {
135 5 flag.bits.ctrl_state=USB_IDLE;
136 5 d12_set_endpoint_status(0,1);
137 5 d12_set_endpoint_status(1,1);
138 5 }
139 4 else
140 4 {
141 5 flag.bits.ctrl_state=USB_RECEIVE;
142 5 }
143 4 }
144 3 }
145 2 }
146 1 else if(flag.bits.ctrl_state==USB_RECEIVE)
147 1 {
148 2 flag.bits.setup_packet=1;
149 2 d12_read_endpoint(0,ctrl_buf.databuf,EP0_PACKET_SIZE);
150 2 flag.bits.ctrl_state=USB_IDLE;
151 2 }
152 1 else
153 1 flag.bits.ctrl_state=USB_IDLE;
154 1 }
155
156 void d12_ep1_receive_done()
157 {
158 1 extern unsigned char idata enp1_len;
159 1 d12_read_last_transaction_status(2);
160 1 enp1_len=d12_read_endpoint(2,enp1_buf,sizeof(enp1_buf));
161 1 if(enp1_len!=0)
162 1 flag.bits.enp1_rxdone=1;
163 1 }
164
165 void d12_ep1_send_done()
166 {
167 1 d12_read_last_transaction_status(3);
168 1 }
169
170 void d12_ep2_receive_done()
171 {
172 1 extern unsigned char idata enp2_len;
173 1 unsigned char status;
174 1 d12_read_last_transaction_status(4);
175 1 status=d12_read_endpoint_status(4);
176 1 status &= 0x60;
177 1 enp2_len=d12_read_endpoint(4,enp2_buf,sizeof(enp2_buf));
178 1 if(status==0x60){
179 2 flag.bits.enp2buf_full=1;
C51 COMPILER V7.07 ISR 06/04/2004 18:36:50 PAGE 4
180 2 enp2_len=d12_read_endpoint(4,enp2_buf,sizeof(enp2_buf));//若雙緩沖區滿此處只是簡單地舍棄前64個字節,還沒
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -