Isr.LST
上传用户:lyfy_2008
上传日期:2014-07-13
资源大小:3016k
文件大小:13k
- C51 COMPILER V7.02b ISR 09/28/2006 22:04:34 PAGE 1
- C51 COMPILER V7.02b, COMPILATION OF MODULE ISR
- OBJECT MODULE PLACED IN Isr.OBJ
- COMPILER INVOKED BY: C:KeilC51BINC51.EXE Isr.c BROWSE DEBUG OBJECTEXTEND
- stmt level source
- 1 #include <stdio.h>
- 2 #include <string.h>
- 3
- 4 #include <reg51.h> /* special function register declarations */
- 5
- 6 //#include "epphal.h"
- 7 #include "d12ci.h"
- 8 #include "mainloop.h"
- 9 #include "usb100.h"
- 10 #include"address.h"
- 11 //#include"24C00.H"
- 12 extern void bus_reset(void);
- 13 extern void ep0_txdone(void);
- 14 extern void ep0_rxdone(void);
- 15 extern void ep1_txdone(void);
- 16 extern void ep1_rxdone(void);
- 17 extern void main_txdone(void);
- 18 extern void main_rxdone(void);
- 19 extern void dma_eot(void);
- 20
- 21 /*
- 22 //*************************************************************************
- 23 // Public static data
- 24 //*************************************************************************
- 25 */
- 26 #define uchar unsigned char
- 27 EPPFLAGS bEPPflags;
- 28
- 29 /* Control endpoint TX/RX buffers */
- 30 extern CONTROL_XFER ControlData;
- 31
- 32 /* ISR static vars */
- 33 unsigned char idata GenEpBuf[EP1_PACKET_SIZE];
- 34 unsigned char idata EpBuf[EP2_PACKET_SIZE];
- 35 unsigned char idata mainbuflen;
- 36 IO_REQUEST idata ioRequest;
- 37 unsigned char ioSize, ioCount;
- 38 unsigned long ClockTicks = 0;
- 39
- 40 extern BOOL bNoRAM;
- 41
- 42 //定时器0中断处理
- 43 timer_isr() interrupt 1
- 44 {
- 45 1 DISABLE;
- 46 1 ClockTicks++;
- 47 1 bEPPflags.bits.timer = 1;
- 48 1 ENABLE;
- 49 1 }
- 50
- 51 //USB中断处理
- 52 usb_isr() interrupt 2
- 53 {
- 54 1 DISABLE;
- 55 1 fn_usb_isr();
- C51 COMPILER V7.02b ISR 09/28/2006 22:04:34 PAGE 2
- 56 1 ENABLE;
- 57 1 }
- 58
- 59 //USB中断服务子程序
- 60 void fn_usb_isr()
- 61 {
- 62 1 unsigned int i_st;
- 63 1
- 64 1 bEPPflags.bits.in_isr = 1;
- 65 1
- 66 1 i_st = D12_ReadInterruptRegister();//读取中断寄存器
- 67 1
- 68 1 if(i_st != 0) {
- 69 2 if(i_st & D12_INT_BUSRESET) {
- 70 3 bus_reset();//USB总线服务
- 71 3 bEPPflags.bits.bus_reset = 1;
- 72 3 }
- 73 2
- 74 2 if(i_st & D12_INT_EOT)
- 75 2 dma_eot();//DMA传输结束
- 76 2
- 77 2 if(i_st & D12_INT_SUSPENDCHANGE)
- 78 2 bEPPflags.bits.suspend = 1;//挂起改变
- 79 2
- 80 2 if(i_st & D12_INT_ENDP0IN)
- 81 2 ep0_txdone();//端点0IN中断
- 82 2 if(i_st & D12_INT_ENDP0OUT)
- 83 2 ep0_rxdone();//端点0OUT中断
- 84 2 if(i_st & D12_INT_ENDP1IN)
- 85 2 ep1_txdone();//端点1IN中断
- 86 2 if(i_st & D12_INT_ENDP1OUT)
- 87 2 ep1_rxdone();//端点1OUT中断
- 88 2 if(i_st & D12_INT_ENDP2IN)
- 89 2 main_txdone();//端点2IN中断
- 90 2 if(i_st & D12_INT_ENDP2OUT)
- 91 2 main_rxdone();//端点2OUT中断
- 92 2 }
- 93 1
- 94 1 bEPPflags.bits.in_isr = 0;
- 95 1 }
- 96
- 97 //总线复位处理子程序
- 98 void bus_reset(void)
- 99 {
- 100 1 }
- 101
- 102 //端点0 OUT中断
- 103 void ep0_rxdone(void)
- 104 {
- 105 1 unsigned char ep_last, i;
- 106 1
- 107 1 ep_last = D12_ReadLastTransactionStatus(0); //清中断标志
- 108 1
- 109 1 if (ep_last & D12_SETUPPACKET)
- 110 1 {
- 111 2 //接收到SETUP包(命令相位)
- 112 2 ControlData.wLength = 0;
- 113 2 ControlData.wCount = 0;
- 114 2
- 115 2 if( D12_ReadEndpoint(0, sizeof(ControlData.DeviceRequest),
- 116 2 (unsigned char *)(&(ControlData.DeviceRequest))) != sizeof(DEVICE_REQUEST) )
- 117 2 {
- C51 COMPILER V7.02b ISR 09/28/2006 22:04:34 PAGE 3
- 118 3 //SETUP包出错,返回
- 119 3 D12_SetEndpointStatus(0, 1);
- 120 3 D12_SetEndpointStatus(1, 1);
- 121 3 bEPPflags.bits.control_state = USB_IDLE;
- 122 3 return;
- 123 3 }
- 124 2
- 125 2 ControlData.DeviceRequest.wValue = SWAP(ControlData.DeviceRequest.wValue);
- 126 2 ControlData.DeviceRequest.wIndex = SWAP(ControlData.DeviceRequest.wIndex);
- 127 2 ControlData.DeviceRequest.wLength = SWAP(ControlData.DeviceRequest.wLength);
- 128 2
- 129 2 //对控制端点的输入/输出进行应答
- 130 2 D12_AcknowledgeEndpoint(0);
- 131 2 D12_AcknowledgeEndpoint(1);
- 132 2
- 133 2 ControlData.wLength = ControlData.DeviceRequest.wLength;
- 134 2 ControlData.wCount = 0;
- 135 2
- 136 2 if (ControlData.DeviceRequest.bmRequestType & (unsigned char)USB_ENDPOINT_DIRECTION_MASK)
- 137 2 {
- 138 3 //向主机传输数据
- 139 3 bEPPflags.bits.setup_packet = 1;
- 140 3 bEPPflags.bits.control_state = USB_TRANSMIT; /* get command */
- 141 3 }
- 142 2 else
- 143 2 { //从主机接收数据
- 144 3 if (ControlData.DeviceRequest.wLength == 0) //如果接收长度是0
- 145 3 {
- 146 4 bEPPflags.bits.setup_packet = 1;
- 147 4 bEPPflags.bits.control_state = USB_IDLE; /* set command */
- 148 4 }
- 149 3 else
- 150 3 {
- 151 4 if(ControlData.DeviceRequest.wLength > MAX_CONTROLDATA_SIZE)
- 152 4 {
- 153 5
- 154 5 bEPPflags.bits.control_state = USB_IDLE;
- 155 5 D12_SetEndpointStatus(0, 1);
- 156 5 D12_SetEndpointStatus(1, 1);
- 157 5 }
- 158 4 else
- 159 4 {
- 160 5 bEPPflags.bits.control_state = USB_RECEIVE; //设置接收状态
- 161 5 }
- 162 4 } // set command with data
- 163 3 } // else set command
- 164 2 } // if setup packet
- 165 1
- 166 1 else if (bEPPflags.bits.control_state == USB_RECEIVE)
- 167 1 {
- 168 2 //接收数据 (数据相位)
- 169 2 i = D12_ReadEndpoint(0, EP0_PACKET_SIZE,
- 170 2 ControlData.dataBuffer + ControlData.wCount);
- 171 2 ControlData.wCount += i;
- 172 2 if( i != EP0_PACKET_SIZE || ControlData.wCount >= ControlData.wLength)
- 173 2 {
- 174 3 //数据接收完毕
- 175 3 bEPPflags.bits.setup_packet = 1;
- 176 3 bEPPflags.bits.control_state = USB_IDLE;
- 177 3 }
- 178 2 }
- 179 1 else
- C51 COMPILER V7.02b ISR 09/28/2006 22:04:34 PAGE 4
- 180 1 {
- 181 2 bEPPflags.bits.control_state = USB_IDLE;//进入等待状态
- 182 2 }
- 183 1 }
- 184
- 185 //端点0IN处理
- 186 void ep0_txdone(void)
- 187 {
- 188 1 short i = ControlData.wLength - ControlData.wCount;
- 189 1 D12_ReadLastTransactionStatus(1); //清中断标志位
- 190 1 if (bEPPflags.bits.control_state != USB_TRANSMIT)
- 191 1 return;//非发送状态,返回
- 192 1
- 193 1 if( i >= EP0_PACKET_SIZE)
- 194 1 {
- 195 2 //剩下数据大于16字节,发送16字节
- 196 2 D12_WriteEndpoint(1, EP0_PACKET_SIZE, ControlData.pData + ControlData.wCount);
- 197 2 ControlData.wCount += EP0_PACKET_SIZE;
- 198 2 bEPPflags.bits.control_state = USB_TRANSMIT;
- 199 2 }
- 200 1 else if( i != 0)
- 201 1 {
- 202 2 //发送剩下数据
- 203 2 D12_WriteEndpoint(1, i, ControlData.pData + ControlData.wCount);
- 204 2 ControlData.wCount += i;
- 205 2 bEPPflags.bits.control_state = USB_IDLE;
- 206 2 }
- 207 1 else if (i == 0){
- 208 2 D12_WriteEndpoint(1, 0, 0); //发送完毕,发送0字节
- 209 2 bEPPflags.bits.control_state = USB_IDLE;
- 210 2 }
- 211 1 }
- 212
- 213 //DMA结束处理
- 214 void dma_eot(void)
- 215 {
- 216 1 }
- 217
- 218 //端点1IN处理
- 219 void ep1_txdone(void)
- 220 {
- 221 1 D12_ReadLastTransactionStatus(3); //清中断标志位
- 222 1 }
- 223
- 224 //端点1OUT处理
- 225 void ep1_rxdone(void)
- 226 { //控制LED/数码管/
- 227 1 unsigned char len;
- 228 1
- 229 1 D12_ReadLastTransactionStatus(2); //清中断标志位
- 230 1 len = D12_ReadEndpoint(2, sizeof(GenEpBuf), GenEpBuf);//读取数据
- 231 1 if(len != 0)
- 232 1 bEPPflags.bits.ep1_rxdone = 1;//标志接收到数据
- 233 1 }
- 234
- 235 //主端点IN控制
- 236 void main_txdone(void)
- 237 {
- 238 1 D12_ReadLastTransactionStatus(5); //清中断标志位
- 239 1
- 240 1 }
- 241
- C51 COMPILER V7.02b ISR 09/28/2006 22:04:34 PAGE 5
- 242 //主端点OUT控制
- 243 void main_rxdone(void)
- 244 {
- 245 1 unsigned char len,epstatus;
- 246 1 D12_ReadLastTransactionStatus(4); //清中断标志位
- 247 1 //接收数据
- 248 1 len = D12_ReadEndpoint(4, 64, EpBuf);
- 249 1 epstatus=D12_ReadEndpointStatus(4);
- 250 1 epstatus &= 0x60;
- 251 1 if (epstatus == 0x60)
- 252 1 len = D12_ReadEndpoint(4, 64, EpBuf);//读取双缓冲区数据
- 253 1 if(len != 0)
- 254 1 {
- 255 2 bEPPflags.bits.main_rxdone = 1;//标志接收到数据
- 256 2 mainbuflen=len;
- 257 2 }
- 258 1 }
- 259
- 260
- 261
- 262
- 263
- 264
- 265
- 266
- 267
- 268
- 269
- 270
- 271
- 272
- 273
- 274
- 275
- 276
- 277
- 278
- 279
- 280
- 281
- MODULE INFORMATION: STATIC OVERLAYABLE
- CODE SIZE = 716 ----
- CONSTANT SIZE = ---- ----
- XDATA SIZE = ---- ----
- PDATA SIZE = ---- ----
- DATA SIZE = 8 5
- IDATA SIZE = 87 ----
- BIT SIZE = ---- ----
- END OF MODULE INFORMATION.
- C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)