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

📄 usbproto.ls1

📁 Comlete files for fullfile the slave USB function!
💻 LS1
📖 第 1 页 / 共 5 页
字号:
0164 0000                    
0166 00000000        406             DB  000H,000H,000H,000H,000H,000H,000H,000H,000H,000H
016A 00000000                
016E 0000                    
0170 00000000        407             DB  000H,000H,000H,000H,000H,000H,000H,000H,000H
0174 00000000                
0178 00                      
                     408     
                     409     
                     410     ; /*
                     411     ; //*************************************************************************
                     412     ; //
                     413     ; //                  BASBA   P R O P R I E T A R Y
                     414     ; //                     --  ALL RIGHTS RESERVED  --
                     415     ; //
                     416     ; // File Name: USBProto.c
                     417     ; // Purpose:           Handles the standard USB device requests
                     418     ; // Author:            Shuming Yu
                     419     ; // Created:           10 May 2003
                     420     ; // Modified:
                     421     ; // Revision:  1.0
                     422     ; //
                     423     ; //*************************************************************************
                     424     ; */
                     425     ; 
                     426     ; #include <stdio.h>
                     427     ; #include <string.h>
                     428     ; 
                     429     ; #include <reg51.h>                /* special function register declarations   */
A51 MACRO ASSEMBLER  USBPROTO                                                             03/23/2005 21:15:54 PAGE     8

                     430     ; 
                     431     ; #include "d12hal.h"
                     432     ; #include "cmds.h"
                     433     ; #include "mainloop.h"
                     434     ; #include "usbStruc.h"
                     435     ; #include "USBProto.h"
                     436     ; 
                     437     ; //#define NUM_ENDPOINTS       4
                     438     ; #define NUM_ENDPOINTS 1
                     439     ; 
                     440     ; unsigned char IDLE_TIME;
                     441     ; 
                     442     ; //#define CONFIG_DESCRIPTOR_LENGTH    sizeof(USB_CONFIGURATION_DESCRIPTOR) \
                     443     ; //                                                                    + sizeof(USB_INTERF
                             ACE_DESCRIPTOR) \
                     444     ; //                                                                    + (NUM_ENDPOINTS * 
                             sizeof(USB_ENDPOINT_DESCRIPTOR))
                     445     ; 
                     446     ; extern CONTROL_XFER ControlData;
                     447     ; //extern IO_REQUEST idata ioRequest;
                     448     ; extern EPPFLAGS bEPPflags;
                     449     ; //
                     450     ; //           COPYRIGHT (c)   2003 BY BASBA USA.PPflags;
                     451     ; extern unsigned char idata GenEpBuf[];        //Buffer which store data got from host
                     452     ; 
                     453     ; UCHAR code REPORT_DESCRIPTOR[] = {
                     454     ;     0x06,0x00,0xFF, //Usage Page(vendor defined)
                     455     ;       0x09,0x01, //Usage (I/O Device)
                     456     ;       0xA1,0x01, //Collection (Application)
                     457     ;       0x19,0x01, //Usage minimum (button1)
                     458     ;       0x29,0x08, //Usage maximun (button8)
                     459     ;       0x15,0x00, //Logic mininum (0)
                     460     ;       0x25,0x01, //logic maximum (1)
                     461     ;       0x75,0x01, //Report size (1)
                     462     ;       0x95,0x08, //Report count (8)
                     463     ;       0x81,0x02, //Input(Data,Var,Abs)
                     464     ;       0x19,0x01, //Usage Minimum (LED1)
                     465     ;       0x29,0x08, //Usage Maximum (LED8)
                     466     ;       0x91,0x02, //Output(Data,Var,Abs)
                     467     ;       0xC0       //End of collection
                     468     ; };
                     469     ; 
                     470     ; struct CONFIG { USB_CONFIGURATION_DESCRIPTOR sConfig;
                     471     ;                 USB_INTERFACE_DESCRIPTOR sInterface;
                     472     ;                 USB_HID_DESCRIPTOR sHID;
                     473     ;                 USB_ENDPOINT_DESCRIPTOR sEndpoint;
                     474     ; };
                     475     ; 
                     476     ; #define CONFIG_DESCRIPTOR_LENGTH    sizeof(struct CONFIG)
                     477     ; #define REPORT_DESC_LENGTH sizeof(REPORT_DESCRIPTOR)
                     478     ; 
                     479     ; 
                     480     ; code USB_DEVICE_DESCRIPTOR DeviceDescr =
                     481     ; {
                     482     ;       sizeof(USB_DEVICE_DESCRIPTOR), //BYTE bLength,
                     483     ;     USB_DEVICE_DESCRIPTOR_TYPE, //BYTE bDescriptorType
                     484     ;     SWAP(0x0100), //WORD bcdUSB, USB Rev1.0
                     485     ;       0x00, //Byte bDeviceClass
                     486     ;     0x00, //BYTE bDeviceSubClass
                     487     ;     0x00, //BYTE bDeviceProtocol
                     488     ;       EP0_PACKET_SIZE,//BYTE bMaxPacketSize of 16
                     489     ;       SWAP(0x4242), //WORD idVendor
                     490     ;       SWAP(0x0100), //WORD idProduct
                     491     ;     SWAP(0x0100), //WORD bcdDevice
                     492     ;     0x01,  //BYTE iManufacturer name
                     493     ;     0x02,  //BYTE iProduct name
A51 MACRO ASSEMBLER  USBPROTO                                                             03/23/2005 21:15:54 PAGE     9

                     494     ;     0x00,  //BYTE iSerialNumber name
                     495     ;     0x01  //BYTE bNumConfigurations, number of configurations
                     496     ; };
                     497     ; 
                     498     ; /*
                     499     ; code USB_CONFIGURATION_DESCRIPTOR  ConfigDescr =
                     500     ; {
                     501     ;     sizeof(USB_CONFIGURATION_DESCRIPTOR), //BYTE bLength
                     502     ;     USB_CONFIGURATION_DESCRIPTOR_TYPE, //BYTE bDescriptorType //Assigned by USB
                     503     ;     SWAP(CONFIG_DESCRIPTOR_LENGTH), //WORD wTotalLength
                     504     ;     0x01, //BYTE bNumInterfaces
                     505     ;     0x01, //BYTE bConfigurationValue
                     506     ;     0x03, //BYTE iConfiguration
                     507     ;     0x80, //BYTE bmAttributes, Bus powered
                     508     ;     50, //BYTE MaxPower, 50x2=100mA
                     509     ; };
                     510     ; 
                     511     ; code USB_INTERFACE_DESCRIPTOR InterfaceDescr =
                     512     ; {
                     513     ;     sizeof(USB_INTERFACE_DESCRIPTOR),//BYTE bLength
                     514     ;     USB_INTERFACE_DESCRIPTOR_TYPE,//BYTE bDescriptionType, assigned by USB
                     515     ;     0x00, //BYTE bInterfaceNumber
                     516     ;     0x00, //BYTE bAlternateSetting, no alternate setting
                     517     ;     0x01, //BYTE bNumEndpoints, HID uses endpoint 1
                     518     ;     0x03, //BYTE bInterfaceClass, HID Class - 0x03
                     519     ;     0x00, //BYTE bInterfaceSubClass
                     520     ;     0x00, //BYTE bInterfaceProtocol
                     521     ;     0x04  //BYTE iInterface, interface name
                     522     ; };
                     523     ; 
                     524     ; code USB_HID_DESCRIPTOR HIDDescr = 
                     525     ; {
                     526     ;     sizeof(USB_HID_DESCRIPTOR), //BYTE bLength;
                     527     ;     0x21, //BYTE bDescriptorType;
                     528     ;     0x0001, //WORD bcdHID;
                     529     ;     0x00, //BYTE bCountryCode, country localization = None;
                     530     ;     0x01, //BYTE bNumDescriptors, number of descriptor follow
                     531     ;     0x22, //BYTE bReportDescriptorType And it's a Report descriptor
                     532     ;     SWAP(REPORT_DESC_LENGTH) //WORD wItemLength, total length of report descriptor
                     533     ; };
                     534     ; 
                     535     ; code USB_ENDPOINT_DESCRIPTOR EP1_TXDescr =
                     536     ; {
                     537     ;     sizeof(USB_ENDPOINT_DESCRIPTOR), //BYTE bLength
                     538     ;     0x05, //BYTE bDescriptorType, assigned by USB
                     539     ;     0x81, //BYTE bEndpointAddress, IN endpoint, endpoint 1
                     540     ;     USB_ENDPOINT_TYPE_INTERRUPT, //BYTE bmAttributes, Interrupt endpoint
                     541     ;     SWAP(EP1_PACKET_SIZE), //WORD wMaxPacketSize
                     542     ;     100 //Polling Time, poll over 100 ms
                     543     ; };
                     544     ; */
                     545     ; 
                     546     ; struct CONFIG code sConfiguration= {
                     547     ;       sizeof(USB_CONFIGURATION_DESCRIPTOR), //BYTE bLength
                     548     ;       USB_CONFIGURATION_DESCRIPTOR_TYPE, //BYTE bDescriptorType //Assigned by USB
                     549     ;       SWAP(CONFIG_DESCRIPTOR_LENGTH), //WORD wTotalLength
                     550     ;       0x01, //BYTE bNumInterfaces
                     551     ;       0x01, //BYTE bConfigurationValue
                     552     ;       0x03, //BYTE iConfiguration
                     553     ;       0x80, //BYTE bmAttributes, Bus powered
                     554     ;       50, //BYTE MaxPower, 50x2=100mA
                     555     ; 
                     556     ;       sizeof(USB_INTERFACE_DESCRIPTOR),//BYTE bLength
                     557     ;               USB_INTERFACE_DESCRIPTOR_TYPE,//BYTE bDescriptionType, assigned by USB
                     558     ;               0x00, //BYTE bInterfaceNumber
                     559     ;               0x00, //BYTE bAlternateSetting, no alternate setting
A51 MACRO ASSEMBLER  USBPROTO                                                             03/23/2005 21:15:54 PAGE    10

                     560     ;               0x01, //BYTE bNumEndpoints, HID uses endpoint 1
                     561     ;           0x03, //BYTE bInterfaceClass, HID Class - 0x03
                     562     ;           0x00, //BYTE bInterfaceSubClass
                     563     ;           0x00, //BYTE bInterfaceProtocol
                     564     ;           0x04,  //BYTE iInterface, interface name
                     565     ; 
                     566     ;       sizeof(USB_HID_DESCRIPTOR), //BYTE bLength;
                     567     ;               0x21, //BYTE bDescriptorType;
                     568     ;               0x0001, //WORD bcdHID;
                     569     ;               0x00, //BYTE bCountryCode, country localization = None;
                     570     ;               0x01, //BYTE bNumDescriptors, number of descriptor follow
                     571     ;               0x22, //BYTE bReportDescriptorType And it's a Report descriptor
                     572     ;               SWAP(REPORT_DESC_LENGTH), //WORD wItemLength, total length of report descri
                             ptor
                     573     ; 
                     574     ;       sizeof(USB_ENDPOINT_DESCRIPTOR), //BYTE bLength
                     575     ;               0x05, //BYTE bDescriptorType, assigned by USB
                     576     ;               0x81, //BYTE bEndpointAddress, 0x80=IN endpoint, endpoint 1
                     577     ;               USB_ENDPOINT_TYPE_INTERRUPT, //BYTE bmAttributes, Interrupt
                     578     ;               SWAP(EP1_PACKET_SIZE), //WORD wMaxPacketSize
                     579     ;           100 //Polling Time unit ms, poll over 100 ms
                     580     ;  };
                     581     ; 
                     582     ; 
                     583     ; code USB_ENDPOINT_DESCRIPTOR EP1_RXDescr =
                     584     ; {
                     585     ;       sizeof(USB_ENDPOINT_DESCRIPTOR),
                     586     ;       USB_ENDPOINT_DESCRIPTOR_TYPE,
                     587     ;       0x1,
                     588     ;       USB_ENDPOINT_TYPE_INTERRUPT,
                     589     ;       SWAP(EP1_PACKET_SIZE),
                     590     ;       10
                     591     ; };
                     592     ; 
                     593     ; code USB_ENDPOINT_DESCRIPTOR EP2_TXDescr =
                     594     ; {
                     595     ;       sizeof(USB_ENDPOINT_DESCRIPTOR),
                     596     ;       USB_ENDPOINT_DESCRIPTOR_TYPE,
                     597     ;       0x82,
                     598     ;       USB_ENDPOINT_TYPE_BULK,
                     599     ;       SWAP(EP2_PACKET_SIZE),
                     600     ;       10
                     601     ; };
                     602     ; 
                     603     ; code USB_ENDPOINT_DESCRIPTOR EP2_RXDescr =
                     604     ; {
                     605     ;       sizeof(USB_ENDPOINT_DESCRIPTOR),
                     606     ;       USB_ENDPOINT_DESCRIPTOR_TYPE,
                     607     ;       0x2,
                     608     ;       USB_ENDPOINT_TYPE_BULK,
                     609     ;       SWAP(EP2_PACKET_SIZE),
                     610     ;       10
                     611     ; };
                     612     ; 
                     613     ; 
                     614     ; unsigned char code LANG_ID[4] = {

⌨️ 快捷键说明

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