⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chap9.lst

📁 usb程序 硬件用的是isp1518
💻 LST
📖 第 1 页 / 共 3 页
字号:
 205                  USB_ENDPOINT_DESCRIPTOR_TYPE,                   // bDescriptorType
 206                  0x1,                                            // bEndpointAddress
 207                  USB_ENDPOINT_TYPE_BULK,                         // bmAttributes
 208                  SWAP(maxepsize_HS),                             // wMaxPacketSize
 209                  //SWAP(maxepsize_FS),
 210                  10                                              // bInterval
 211          };
 212          
 213          code USB_ENDPOINT_DESCRIPTOR EP2_TXDescr_H =
 214          {
 215                  sizeof(USB_ENDPOINT_DESCRIPTOR),                // bLength
 216                  USB_ENDPOINT_DESCRIPTOR_TYPE,                   // bDescriptorType
 217                  0x82,                                                                   // bEndpointAddress
 218                  USB_ENDPOINT_TYPE_BULK,                                 // bmAttributes
 219                  SWAP(maxepsize_HS),                                     // wMaxPacketSize
 220                  10                                                                              // bInterval
 221          };
 222          
 223          code USB_ENDPOINT_DESCRIPTOR EP2_RXDescr_H =
 224          {
 225                  sizeof(USB_ENDPOINT_DESCRIPTOR),                // bLength
 226                  USB_ENDPOINT_DESCRIPTOR_TYPE,                   // bDescriptorType
 227                  0x2,                                                                    // bEndpointAddress
 228                  USB_ENDPOINT_TYPE_BULK,                                 // bmAttributes
 229                  SWAP(maxepsize_HS),                                     // wMaxPacketSize
 230                  10                                                                              // bInterval
 231          };
 232          /*
 233          code USB_ENDPOINT_DESCRIPTOR EP3_TXDescr_H =
 234          {
 235                  sizeof(USB_ENDPOINT_DESCRIPTOR),                // bLength
 236                  USB_ENDPOINT_DESCRIPTOR_TYPE,                   // bDescriptorType
 237                  0x83,                                                                   // bEndpointAddress
 238                  USB_ENDPOINT_TYPE_ISOCHRONOUS,                                  // bmAttributes
 239                  SWAP(maxepsize_256),                                    // wMaxPacketSize
 240                  1                                                                               // bInterval
C51 COMPILER V8.02   CHAP9                                                                 08/03/2006 10:10:36 PAGE 5   

 241          };
 242          
 243          code USB_ENDPOINT_DESCRIPTOR EP3_RXDescr_H =
 244          {
 245                  sizeof(USB_ENDPOINT_DESCRIPTOR),                // bLength
 246                  USB_ENDPOINT_DESCRIPTOR_TYPE,                   // bDescriptorType
 247                  0x3,                                                                    // bEndpointAddress
 248                  USB_ENDPOINT_TYPE_ISOCHRONOUS,                                  // bmAttributes
 249                  SWAP(maxepsize_256),                                    // wMaxPacketSize
 250                  1                                                                               // bInterval
 251          };
 252          */
 253          code USB_ENDPOINT_DESCRIPTOR EP4_TXDescr_H =
 254          {
 255                  sizeof(USB_ENDPOINT_DESCRIPTOR),                // bLength
 256                  USB_ENDPOINT_DESCRIPTOR_TYPE,                   // bDescriptorType
 257                  0x84,                                           // bEndpointAddress
 258                  USB_ENDPOINT_TYPE_INTERRUPT,                            // bmAttributes
 259                  SWAP(maxepsize_16),                             // wMaxPacketSize
 260                  //SWAP(maxepsize_FS),
 261                  10                                              // bInterval
 262          };
 263          
 264          code USB_ENDPOINT_DESCRIPTOR EP4_RXDescr_H =
 265          {
 266                  sizeof(USB_ENDPOINT_DESCRIPTOR),                // bLength
 267                  USB_ENDPOINT_DESCRIPTOR_TYPE,                   // bDescriptorType
 268                  0x4,                                            // bEndpointAddress
 269                  USB_ENDPOINT_TYPE_BULK,                         // bmAttributes
 270                  SWAP(maxepsize_HS),                             // wMaxPacketSize
 271                  //SWAP(maxepsize_FS),
 272                  10                                              // bInterval
 273          };
 274          
 275          USB_DEVICEQUALIFIER_DESCRIPTOR DeviceQualifierDescr_H =
 276          {
 277                  sizeof(USB_DEVICEQUALIFIER_DESCRIPTOR),
 278                  USB_DEVICEQUALIFIER_DESCRIPTOR_TYPE,
 279                  0x0200, // USB spec version number, 2.0
 280                  USB_CLASS_CODE_TEST_CLASS_DEVICE,
 281                  USB_SUBCLASS_CODE_TEST_CLASS,
 282                  USB_PROTOCOL_CODE_TEST_CLASS,
 283                  0x40,//max packet size(endpoint 0) for other speed configuration(high speed, 64)
 284                  0x1, // number of other speed configuratons
 285                  0x0 //reserved, must be 0
 286          };
 287          
 288          USB_CONFIGURATION_DESCRIPTOR Otherspeed_ConfigDescr_H=
 289          {
 290                  sizeof(USB_CONFIGURATION_DESCRIPTOR),
 291                  USB_OTEHRSPEEDCONFIGURATION_DESCRIPTOR_TYPE,
 292                  SWAP(CONFIG_DESCRIPTOR_LENGTH),
 293                  1,
 294                  1, // value to select this configuration;
 295                  4,//STRING_EN * STR_INDEX_CONFIGURATION,
 296                  0x80,//USB_Configureation_bmAttributes, // set-to-one, self-power, remote wakeup,;
 297                  0x40//0x1
 298          };
 299          
 300          //////////////////////////////////////////////////////////////////////////
 301          code unsigned char StringLANGID[] = 
 302          {
C51 COMPILER V8.02   CHAP9                                                                 08/03/2006 10:10:36 PAGE 6   

 303                  4,                                                                              // bLength
 304                  USB_STRING_DESCRIPTOR_TYPE,                             // bDescriptorType
 305                  0x09, 0x04//SWAP(0x0409)                                                        // wLANGID
 306          };
 307          
 308          
 309          code unsigned char szManufacturer[] =
 310          {
 311                  40,                                                     // bLength
 312                  USB_STRING_DESCRIPTOR_TYPE,                             // bDescriptorType
 313                  // String...
 314                  'T', 0, 's', 0, 'i', 0, 'n', 0, 'g', 0, 'h', 0, 'u', 0, 'a', 0, ' ', 0, 'U', 0,
 315                  'n', 0, 'i', 0, 'v', 0, 'e', 0, 'r', 0, 's', 0, 'i', 0, 't', 0, 'y', 0
 316          };
 317          code unsigned char szProduct[] =
 318          {
 319                  90,                                                     // bLength
 320                  USB_STRING_DESCRIPTOR_TYPE,                             // bDescriptorType
 321                  // String...
 322                  'U', 0, 'S', 0, 'B', 0, '2', 0, '.', 0, '0', 0, ' ', 0, 'D', 0, 'e', 0, 'v', 0,
 323                  'e', 0, 'l', 0, 'o', 0, 'p', 0, 'e', 0, ' ', 0, 'K', 0, 'i', 0, 't', 0, ' ', 0,
 324                  'B', 0, 'y', 0, ' ', 0, 'X', 0, 'X', 0, 'G', 0, ':', 0, ' ', 0, 'x', 0, 'x', 0,
 325                  'g', 0, 'a', 0, 'n', 0, 'g', 0, '@', 0, '2', 0, '6', 0, '3', 0, '.', 0, 'n', 0,
 326                  'e', 0, 't', 0, ' ', 0, ' ', 0
 327          };
 328          
 329          code unsigned char szSerialNumber[] =
 330          {
 331                  22,                                                                             // bLength
 332                  USB_STRING_DESCRIPTOR_TYPE,                             // bDescriptorType
 333                  // String...
 334                  '0', 0, '0', 0, '0', 0, '0', 0, '-', 0, '0', 0, '0', 0, '0', 0, '0', 0, '0', 0
 335          };
 336          
 337          code unsigned char szConfiguration[] =
 338          {
 339                  40,                                                                             // bLength
 340                  USB_STRING_DESCRIPTOR_TYPE,                             // bDescriptorType
 341                  // String...
 342                  'E', 0, 'n', 0, 'd', 0, 'i', 0, 'a', 0, 'n', 0, ' ', 0, 'T', 0, 'e', 0, 'c', 0,
 343                  'h', 0, ' ', 0, 'B', 0, 'y', 0, ':', 0, ' ', 0, 'X', 0, 'X', 0, 'G', 0
 344          };
 345          
 346          code unsigned char szInterface[] =
 347          {
 348                  70,                                                                             // bLength
 349                  USB_STRING_DESCRIPTOR_TYPE,                             // bDescriptorType
 350                  // String...
 351                  'I', 0, 'n', 0, 't', 0, 'e', 0, 'r', 0, 'f', 0, 'a', 0, 'c', 0, 'e', 0, ' ', 0,
 352                  't', 0, 'o', 0, ' ', 0, 't', 0, 'h', 0, 'e', 0, ' ', 0, 'C', 0, 'P', 0, 'U', 0,
 353                  ' ', 0, 'C', 0, 'o', 0, 'o', 0, 'l', 0, 'e', 0, 'r', 0, ' ', 0, 's', 0, 'y', 0,
 354                  's', 0, 't', 0, 'e', 0, 'm', 0
 355          };
 356          
 357          code unsigned char szUserInfo[] =
 358          {
 359                  114,                                                                    // bLength
 360                  USB_STRING_DESCRIPTOR_TYPE,                             // bDescriptorType
 361                  // String...
 362                  'T', 0, 'h', 0, 'e', 0, ' ', 0, 'o', 0, 'r', 0, 'i', 0, 'g', 0, 'i', 0, 'n', 0,
 363                  'a', 0, 'l', 0, ' ', 0, 'u', 0, 's', 0, 'e', 0, 'r', 0, ' ', 0, 'o', 0, 'f', 0,
 364                  ' ', 0, 't', 0, 'h', 0, 'i', 0, 's', 0, ' ', 0, 'b', 0, 'o', 0, 'a', 0, 'r', 0,
C51 COMPILER V8.02   CHAP9                                                                 08/03/2006 10:10:36 PAGE 7   

 365                  'd', 0, ' ', 0, 'i', 0, 's', 0, ' ', 0, 'x', 0, 'u', 0, 'x', 0, 'i', 0, 'g', 0,
 366                  'a', 0, 'n', 0, 'g', 0, ' ', 0, '@', 0, '2', 0, '6', 0, '3', 0, '.', 0, 'n', 0,
 367                  'e', 0, 't', 0, ' ', 0, ' ', 0, ' ', 0, ' ', 0
 368          };
 369          
 370          /*
 371             //*************************************************************************
 372             // USB Protocol Layer
 373             //*************************************************************************
 374          */
 375          
 376          void reserved(void)
 377          {
 378   1          USB_Stall_EP0();
 379   1      }
 380          
 381          /*
 382             //*************************************************************************
 383             // USB standard device requests
 384             //*************************************************************************
 385          */
 386          void USBClassRequest_GetStatus(void)  //OK
 387          {
 388   1              unsigned char endp, txdat[2];
 389   1              unsigned char bRecipient = ControlData.DeviceRequest.bmRequestType & USB_RECIPIENT;
 390   1              unsigned char c;
 391   1              
 392   1              if (bRecipient == USB_RECIPIENT_DEVICE) {
 393   2                      if(bZBoardFlags.bits.bRemote_Wakeup == 1)
 394   2                              txdat[0] = 3;
 395   2                      else
 396   2                              txdat[0] = 1;
 397   2                      txdat[1]=0;
 398   2                      USB_Single_Transmit(txdat, 2);
 399   2              } else if (bRecipient == USB_RECIPIENT_INTERFACE) {
 400   2                      txdat[0]=0;
 401   2                      txdat[1]=0;
 402   2                      USB_Single_Transmit(txdat, 2);
 403   2              } else if (bRecipient == USB_RECIPIENT_ENDPOINT) {
 404   2                      //endp = (unsigned char)(ControlData.DeviceRequest.wIndex & MAX_ENDPOINTS);
 405   2                      if (ControlData.DeviceRequest.wIndex & (unsigned char)USB_ENDPOINT_DIRECTION_MASK)
 406   2                              //c = USBD12_SelectEndpoint(endp*2 + 1);        /* Control-in */
 407   2                              endp = endp*2 + 1;      /* Control-in */
 408   2                      else
 409   2                              endp = endp*2;  /* Control-out */
 410   2                      
 411   2                      c = ISP1581_GetEndpointStatus(endp);
 412   2                      
 413   2                      txdat[0] = c & epctlfc_stall;   /* Halt */
 414   2                      txdat[1] = 0;
 415   2                      USB_Single_Transmit(txdat, 2);
 416   2              } else
 417   1                      USB_Stall_EP0();
 418   1      }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -