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

📄 usb_9602.lst

📁 USB9602 source code for C 8051
💻 LST
📖 第 1 页 / 共 5 页
字号:
  36      =1                           INT_LENGTH,        /*length of this desc.    */
  37      =1                           INTERFACE,         /*INTERFACE descriptor    */
  38      =1                           0x00,              /*interface number        */
  39      =1                           0x00,              /*alternate setting       */
  40      =1                           0x01,              /*# of (non 0) endpoints  */
  41      =1                           HIDCLASS,          /*interface class         */
  42      =1                           NOSUBCLASS,        /*interface subclass      */
  43      =1                           0x00,              /*interface protocol      */
  44      =1                           INT_STR_OFS,       /*index of intf. string   */
  45      =1  
  46      =1                           HID_LENGTH,        /*length of this desc.    */
  47      =1                           HID,               /*HID descriptor          */
  48      =1                           0x00,0x01,         /*HID spec rev level (BCD)*/
  49      =1                           0x00,              /*target country          */
  50      =1                           1,                 /*# HID class desc follow.*/
  51      =1                           HIDREPORT,         /*report descr. type      */
  52      =1                           RPT_DESC_SIZE,0x00, /*report descr. length   */
  53      =1  
  54      =1  /*The WDM driver for this board references the endpoints by 'pipe'    */
  55      =1  /*number: 0, 1, 2 et al in order below:                               */
  56      =1  
  57      =1                         /*Pipe 0 (endpoint 5)                          */
  58      =1                           END_LENGTH,        /*length of this desc.    */
  59      =1                           ENDPOINT,          /*ENDPOINT descriptor     */
  60      =1                           0x85,              /*address (IN)            */
  61      =1                           0x03,              /*attributes  (INTERRUPT) */
  62      =1                           0x40,0x00,         /*max packet size (64)    */
  63      =1                           0xFF};             /*interval (ms)           */
  64      =1  
 134          
 135          
 136          xdata unsigned char status;
 137          xdata unsigned char usb_cfg;
 138          xdata unsigned char evnt, rxstat, txstat;          /*USB status temp storage */
 139          xdata unsigned char desc_typ, desc_idx;
 140          xdata unsigned char setaddr;                       /*SET_ADDRESS state var.  */
 141          xdata unsigned char dtapid;                        /*PID related status      */
 142          xdata unsigned char usb_buf[8];                    /*buffer used for USB     */
 143                /*This is the cmd buffer for cmds received via the cmd channel **/
 144                /*the order here is critical, and should not change *************/
 145          xdata unsigned char  rsnc;                          /*[+0]sync code (AAh exp) */
 146          xdata unsigned char  rcmd;                          /*[+1]command op code     */
 147          xdata unsigned char  rdta;                          /*[+2]data for command    */
 148          xdata unsigned char  radh;                          /*[+3]address (msb)       */
 149          xdata unsigned char  radl;                          /*[+4]        (lsb)       */
 150          xdata unsigned char  rcks;                          /*[+5]checksum            */
 151          
 152          xdata unsigned char  stalld;                        /*bits 0-6 correspond to  */
 153          xdata unsigned char  rcount3;                       /*cnt of bytes in RX FIFO3*/
 154          xdata unsigned char  usb_idl;                       /*usb idle    setting     */
 155          xdata unsigned char  outq_idx;                      /*outq index              */
 156          xdata unsigned char  brd_id;                        /*our unique ID           */
C51 COMPILER V5.50,  USB_9602                                                              02/12/99  16:05:13  PAGE 12  

 157          xdata unsigned char  suscntr;                       /*suspend timeout counter */
 158          
 159          xdata char outq[8];                       /*serial transmit queue   */
 160          
 161          xdata long desc_sze;
 162          
 163          /************ Zasobnik pro seriak ****************/
 164          extern xdata unsigned char PoleCh[200];
 165          extern xdata unsigned char PointCh;
 166          xdata unsigned char CountInt;
 167          
 168          /******************************************************************************/
 169          /* Ovladani obvodu ( non-multiplexed parallel interface mode ) */
 170          void write_usb(unsigned char adr, Dat)
 171          {
 172   1      // XBYTE[Adr_9602|adr]=Dat;
 173   1       XBYTE[Adr_9602_Adr]=adr;       /* set Adr 01 */
 174   1       XBYTE[Adr_9602_Dat]=Dat;       /* sed Data */
 175   1      }
 176          
 177          unsigned char read_usb(unsigned char adr)
 178          {
 179   1       XBYTE[Adr_9602_Adr]=adr;       /* set Adr 01 */
 180   1       return (XBYTE[Adr_9602_Dat]);
 181   1      }
 182          
 183          /**********************************************************************/
 184          /* This sets a bit in the specified 9602 register                     */
 185          /**********************************************************************/
 186          void bitset(unsigned char adr, mask)
 187          {
 188   1        write_usb(adr,(read_usb(adr)|(mask)));   /*set the bit (RMW)  */
 189   1      }
 190          
 191          /**********************************************************************/
 192          /* This clears a bit in the specified 9602 register                   */
 193          /**********************************************************************/
 194          void bitclr(unsigned char adr, mask)
 195          {
 196   1        write_usb(adr,(read_usb(adr)&(~mask)));  /*clr the bit (RMW)  */
 197   1      }
 198          
 199          /**********************************************************************/
 200          /* This subroutine loads a byte from a descriptor or report into the  */
 201          /* specified fifo.                                                    */
 202          /**********************************************************************/
 203          void queue_rpt(unsigned char txd)
 204          {
 205   1        write_usb(txd,0);                   /*no throttle data yet    */
 206   1      //  write_usb(txd,report[JOYX]); !!!
 207   1      //  write_usb(txd,report[JOYY]);   !!!
 208   1      //  write_usb(txd,report[SWITCHES]); !!!
 209   1      }
 210          
 211          /**********************************************************************/
 212          /* The HID class specific GET_REPORT request is done here             */
 213          /**********************************************************************/
 214          void getreport(void)
 215          {
 216   1        desc_typ = usb_buf[3];              /*store the type requested*/
 217   1        queue_rpt(TXD0);                    /*queue up the report     */
 218   1      }
 219          
 220          /**********************************************************************/
 221          /* The HID class specific SET_REPORT request is done here             */
 222          /**********************************************************************/
C51 COMPILER V5.50,  USB_9602                                                              02/12/99  16:05:13  PAGE 13  

 223          void setreport(void)
 224          {
 225   1        desc_typ = usb_buf[3];              /*store the report req'd  */
 226   1      }
 227          
 228          /**********************************************************************/
 229          /* The HID class specific GET_IDLE request is done here               */
 230          /**********************************************************************/
 231          void getidle(void)
 232          {
 233   1        write_usb(TXD0,usb_idl);            /*send back idle value    */
 234   1      }
 235          
 236          /**********************************************************************/
 237          /* The HID class specific SET_IDLE request is done here               */
 238          /**********************************************************************/
 239          void setidle(void)
 240          {
 241   1        usb_idl = usb_buf[3];               /*store the idle value    */
 242   1      }
 243          
 244          /**********************************************************************/
 245          /* This is the handler for the RS232 port.                            */
 246          /**********************************************************************/
 247          //void xmitih(void)
 248          //{
 249          //unsigned char i;
 250          //  if(outq_idx>0)
 251          //   {
 252          //    PUT_TX(outq[0]);                /*transmit top of queue   */
 253          //    for(i=0; i<outq_idx; i++) outq[i]=outq[i+1];  /*move queue*/
 254          //    outq_idx--;                     /*decriment index         */
 255          //   }
 256          //
 257          //  if(outq_idx==0) TXINTOFF;           /*turn off int if done    */
 258          //}
 259          
 260          
 261          /**********************************************************************/
 262          /* This subroutine sends a character through the UART transmitter or  */
 263          /* The usb interface, depending on the mode.                          */
 264          /**********************************************************************/
 265          void xmit(char c)
 266          {
 267   1      /*USB mode: move character to endpoint 1 FIFO *******************/
 268   1        if(TSTBIT(status,USB_CMD))
 269   1         {
 270   2          write_usb(TXD1,c);              /*send data to the FIFO   */
 271   2         }
 272   1      
 273   1      /*UART mode: move character to UART queue ***********************/
 274   1        else
 275   1         {
 276   2          while (outq_idx>=OUTQLEN)       /*wait for room in queue  */
 277   2      //      if (TX_EMPTY) xmitih();       /*or make it if we can   !!! */
 278   2          outq[outq_idx++]=c;             /*post character          */
 279   2      //    TXINTON;                        /*turn on interrupt       */
 280   2      //    if (TX_EMPTY) xmitih();         /*start xmission if ready !!! */
 281   2         }
 282   1      }
 283          
 284          /**********************************************************************/
 285          /* This subroutine puts the board to sleep, to reduce the overall     */
 286          /* current consumption in the suspend mode.                           */
 287          /**********************************************************************/
 288          void deep_sleep(void)
C51 COMPILER V5.50,  USB_9602                                                              02/12/99  16:05:13  PAGE 14  

 289            {
 290   1        }
 291          
 292          /**********************************************************************/
 293          /* The SET_FEATURE request is done here                               */
 294          /**********************************************************************/
 295          void setfeature(void)
 296          {
 297   1        switch (usb_buf[0]&0x03)            /*find request target     */
 298   1         {
 299   2          case 0:                         /*DEVICE                  */
 300   2            break;
 301   2      
 302   2          case 1:                         /*INTERFACE               */
 303   2            break;
 304   2      
 305   2          case 2:                         /*ENDPOINT                */
 306   2            switch (usb_buf[4]&0x0F)      /*find specific endpoint  */
 307   2             {                           /*  (strip off dir. bit)  */
 308   3              case 0:
 309   3               /*control pipes must accept setup requests even if  */
 310   3               /*stalled, so we log the stall here, but don't      */
 311   3               /*actually do it                                    */
 312   3               /*bitset(EPC0,STALL);*/
 313   3                SETBIT(stalld,BIT0);
 314   3                break;
 315   3              case 1:
 316   3                bitset(EPC1,STALL);
 317   3                SETBIT(stalld,BIT1);
 318   3                break;
 319   3              case 2:
 320   3                bitset(EPC2,STALL);
 321   3                SETBIT(stalld,BIT2);
 322   3                break;
 323   3              case 3:
 324   3                bitset(EPC3,STALL);
 325   3                SETBIT(stalld,BIT3);
 326   3                break;
 327   3              case 4:
 328   3                bitset(EPC4,STALL);
 329   3                SETBIT(stalld,BIT4);
 330   3                break;

⌨️ 快捷键说明

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