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

📄 d12ci.lst

📁 飞利浦usb D12芯片fireware 源程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
  86      =1  
  87      =1  #define MSB(x)    (((x) >> 8) & 0xFF)
  88      =1  #define LSB(x)    ((x) & 0xFF)
  89      =1  
  90      =1  #define FALSE   0
  91      =1  #define TRUE    (!FALSE)
  92      =1  
  93      =1  /*
  94      =1     //*************************************************************************
  95      =1     // basic typedefs
  96      =1     //*************************************************************************
  97      =1  */
  98      =1  typedef unsigned char   UCHAR;
C51 COMPILER V8.02   D12CI                                                                 07/27/2007 11:10:49 PAGE 6   

  99      =1  typedef unsigned short  USHORT;
 100      =1  typedef unsigned long   ULONG;
 101      =1  typedef unsigned char   BOOL;
 102      =1  
 103      =1  /*
 104      =1     //*************************************************************************
 105      =1     // structure and union definitions
 106      =1     //*************************************************************************
 107      =1  */
 108      =1  typedef union _epp_flags
 109      =1  {
 110      =1          struct _flags
 111      =1          {
 112      =1                  unsigned char timer                     : 1;
 113      =1                  unsigned char bus_reset                 : 1;
 114      =1                  unsigned char suspend                   : 1;
 115      =1                  unsigned char setup_packet              : 1;
 116      =1                  unsigned char remote_wakeup                     : 1;
 117      =1                  unsigned char in_isr                    : 1;
 118      =1                  unsigned char control_state                     : 2;
 119      =1  
 120      =1                  unsigned char configuration                     : 1;
 121      =1                  unsigned char verbose                           : 1;
 122      =1                  unsigned char ep1_rxdone                        : 1;
 123      =1                  unsigned char setup_dma                         : 1;
 124      =1                  unsigned char dma_state                 : 2;
 125      =1                  unsigned char dma_disable                       : 1; // V2.1
 126      =1          } bits;
 127      =1          unsigned short value;
 128      =1  } EPPFLAGS;
 129      =1  
 130      =1  typedef struct _device_request
 131      =1  {
 132      =1          unsigned char bmRequestType;
 133      =1          unsigned char bRequest;
 134      =1          unsigned short wValue;
 135      =1          unsigned short wIndex;
 136      =1          unsigned short wLength;
 137      =1  } DEVICE_REQUEST;
 138      =1  
 139      =1  typedef struct _IO_REQUEST {
 140      =1          unsigned short  uAddressL;
 141      =1          unsigned char   bAddressH;
 142      =1          unsigned short  uSize;
 143      =1          unsigned char   bCommand;
 144      =1  } IO_REQUEST, *PIO_REQUEST;
 145      =1  
 146      =1  #define MAX_CONTROLDATA_SIZE    8
 147      =1  
 148      =1  typedef struct _control_xfer
 149      =1  {
 150      =1          DEVICE_REQUEST DeviceRequest;
 151      =1          unsigned short wLength;
 152      =1          unsigned short wCount;
 153      =1          unsigned char * pData;
 154      =1          unsigned char dataBuffer[MAX_CONTROLDATA_SIZE];
 155      =1  } CONTROL_XFER;
 156      =1  
 157      =1  /*
 158      =1     //*************************************************************************
 159      =1     // USB utility functions
 160      =1     //*************************************************************************
C51 COMPILER V8.02   D12CI                                                                 07/27/2007 11:10:49 PAGE 7   

 161      =1  */
 162      =1  #ifndef __C51__
           =1 void interrupt timer_isr(void);
           =1 void interrupt usb_isr(void);
           =1 #endif
 166      =1  
 167      =1  void fn_usb_isr();
 168      =1  
 169      =1  extern void suspend_change(void);
 170      =1  extern void stall_ep0(void);
 171      =1  extern void disconnect_USB(void);
 172      =1  extern void connect_USB(void);
 173      =1  extern void reconnect_USB(void);
 174      =1  extern void init_unconfig(void);
 175      =1  extern void init_config(void);
 176      =1  extern void single_transmit(unsigned char * pData, unsigned char len);
 177      =1  extern void code_transmit(unsigned char code * pRomData, unsigned short len);
 178      =1  
 179      =1  extern void control_handler();
 180      =1  extern void check_key_LED(void);
 181      =1  extern void setup_dma();
 182      =1  #ifndef __C51__
           =1 extern void setup_io(); // V2.1, x86 only
           =1 #endif
 185      =1  
 186      =1  void dma_start(PIO_REQUEST);
 187      =1  
 188      =1  #define IN_TOKEN_DMA    1
 189      =1  #define OUT_TOKEN_DMA   0
 190      =1  
 191      =1  #ifndef __C51__
           =1         #define DMA_BUFFER_SIZE         64000
           =1 #else
 194      =1          #define DMA_BUFFER_SIZE         16384
 195      =1  #endif
 196      =1  
 197      =1  #define DMA_IDLE        0
 198      =1  #define DMA_RUNNING     1
 199      =1  #define DMA_PENDING     2
 200      =1  
 201      =1  #define SETUP_DMA_REQUEST               0x0471
 202      =1  #define GET_FIRMWARE_VERSION    0x0472
 203      =1  #define GET_SET_TWAIN_REQUEST   0x0473
 204      =1  
 205      =1  typedef struct _TWAIN_FILEINFO {
 206      =1          unsigned char   bPage;    // bPage bit 7 - 5 map to uSize bit 18 - 16
 207      =1          unsigned char   uSizeH;    // uSize bit 15 - 8
 208      =1          unsigned char   uSizeL;    // uSize bit 7 - 0
 209      =1  } TWAIN_FILEINFO, *PTWAIN_FILEINFO;
 210      =1  
 211      =1  #endif
 212      =1  
  29          #include "d12ci.h"
   1      =1  /*
   2      =1     //*************************************************************************
   3      =1     //
   4      =1     //                  P H I L I P S   P R O P R I E T A R Y
   5      =1     //
   6      =1     //           COPYRIGHT (c)   1997 BY PHILIPS SINGAPORE.
   7      =1     //                     --  ALL RIGHTS RESERVED  --
   8      =1     //
   9      =1     // File Name:        D12CI.H
C51 COMPILER V8.02   D12CI                                                                 07/27/2007 11:10:49 PAGE 8   

  10      =1     // Author:           Wenkai Du
  11      =1     // Created:          8 Jun 98
  12      =1     // Modified:
  13      =1     // Revision:         2.2
  14      =1     //
  15      =1     //*************************************************************************
  16      =1     //
  17      =1     // 98/11/26          Bug fix: D12_ENDP5INTENABLE (WK)
  18      =1     // 98/12/2       Added D12_ReadMainEndpoint to support double buffer (WK)
  19      =1     //*************************************************************************
  20      =1     */
  21      =1  #ifndef __D12CI_H__
  22      =1  #define __D12CI_H__
  23      =1  
  24      =1  #define D12_NOLAZYCLOCK                 0x02
  25      =1  #define D12_CLOCKRUNNING        0x04
  26      =1  #define D12_INTERRUPTMODE               0x08
  27      =1  #define D12_SOFTCONNECT                 0x10
  28      =1  #define D12_ENDP_NONISO                 0x00
  29      =1  #define D12_ENDP_ISOOUT                 0x40
  30      =1  #define D12_ENDP_ISOIN                  0x80
  31      =1  #define D12_ENDP_ISOIO                  0xC0
  32      =1  
  33      =1  #define D12_CLOCK_12M                   0x03
  34      =1  #define D12_CLOCK_4M                    0x0b
  35      =1  #define D12_SETTOONE            0x40
  36      =1  #define D12_SOFONLY                             0x80
  37      =1  
  38      =1  #define D12_DMASINGLE                   0x00
  39      =1  #define D12_BURST_4                             0x01
  40      =1  #define D12_BURST_8                             0x02
  41      =1  #define D12_BURST_16                    0x03
  42      =1  #define D12_DMAENABLE           0x04
  43      =1  #define D12_DMA_INTOKEN                 0x08
  44      =1  #define D12_AUTOLOAD                    0x10
  45      =1  #define D12_NORMALPLUSSOF               0x20
  46      =1  #define D12_ENDP4INTENABLE              0x40
  47      =1  #define D12_ENDP5INTENABLE              0x80    // bug fixed in V2.1
  48      =1  
  49      =1  #define D12_INT_ENDP0OUT                0x01
  50      =1  #define D12_INT_ENDP0IN                 0x02
  51      =1  #define D12_INT_ENDP1OUT                0x04
  52      =1  #define D12_INT_ENDP1IN                 0x08
  53      =1  #define D12_INT_ENDP2OUT                0x10
  54      =1  #define D12_INT_ENDP2IN                 0x20
  55      =1  #define D12_INT_BUSRESET                0x40
  56      =1  #define D12_INT_SUSPENDCHANGE   0x80
  57      =1  #define D12_INT_EOT                             0x0100
  58      =1  
  59      =1  #define D12_SETUPPACKET                 0x20
  60      =1  
  61      =1  #define D12_BUFFER0FULL                 0x20
  62      =1  #define D12_BUFFER1FULL                 0x40
  63      =1  
  64      =1  #define D12_FULLEMPTY                   0x01
  65      =1  #define D12_STALL                               0x02
  66      =1  
  67      =1  void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable);
  68      =1  void D12_SetEndpointEnable(unsigned char bEnable);
  69      =1  void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv);
  70      =1  void D12_SetDMA(unsigned char bMode);
  71      =1  unsigned short D12_ReadInterruptRegister(void);
C51 COMPILER V8.02   D12CI                                                                 07/27/2007 11:10:49 PAGE 9   

  72      =1  unsigned char D12_SelectEndpoint(unsigned char bEndp);
  73      =1  unsigned char D12_ReadLastTransactionStatus(unsigned char bEndp);
  74      =1  unsigned char D12_ReadEndpointStatus(unsigned char bEndp);
  75      =1  void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled);
  76      =1  void D12_SendResume(void);
  77      =1  unsigned short D12_ReadCurrentFrameNumber(void);
  78      =1  unsigned short D12_ReadChipID(void);
  79      =1  
  80      =1  unsigned char D12_ReadEndpoint(unsigned char endp, unsigned char * buf, unsigned char len);
  81      =1  unsigned char D12_WriteEndpoint(unsigned char endp, unsigned char * buf, unsigned char len);
  82      =1  void D12_AcknowledgeEndpoint(unsigned char endp);
  83      =1  
  84      =1  unsigned char D12_ReadMainEndpoint(unsigned char * buf); // V2.2
  85      =1  
  86      =1  unsigned char D12Eval_inportb(void);
  87      =1  void D12Eval_outportb(unsigned char val, unsigned char mask);
  88      =1  
  89      =1  #endif
  30          
  31          extern EPPFLAGS bEPPflags;
  32          
  33          void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable)
  34          {
  35   1              if(bEPPflags.bits.in_isr == 0)
  36   1                      DISABLE;
  37   1      
  38   1              outportb(D12_COMMAND, 0xD0);
  39   1              if(bEnable)
  40   1                      bAddress |= 0x80;
  41   1              outportb(D12_DATA, bAddress);
  42   1      
  43   1              if(bEPPflags.bits.in_isr == 0)
  44   1                      ENABLE;
  45   1      }
  46          
  47          void D12_SetEndpointEnable(unsigned char bEnable)
  48          {
  49   1              if(bEPPflags.bits.in_isr == 0)
  50   1                      DISABLE;
  51   1      
  52   1              outportb(D12_COMMAND, 0xD8);
  53   1              if(bEnable)
  54   1                      outportb(D12_DATA, 1);
  55   1              else
  56   1                      outportb(D12_DATA, 0);
  57   1      
  58   1              if(bEPPflags.bits.in_isr == 0)
  59   1                      ENABLE;
  60   1      }
  61          
  62          void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv)
  63          {
  64   1              if(bEPPflags.bits.in_isr == 0)
  65   1                      DISABLE;
  66   1      
  67   1              outportb(D12_COMMAND, 0xF3);
  68   1              outportb(D12_DATA, bConfig);
  69   1              outportb(D12_DATA, bClkDiv);
  70   1      
  71   1              if(bEPPflags.bits.in_isr == 0)
  72   1                      ENABLE;
  73   1      }
C51 COMPILER V8.02   D12CI                                                                 07/27/2007 11:10:49 PAGE 10  

  74          
  75          void D12_SetDMA(unsigned char bMode)
  76          {
  77   1              if(bEPPflags.bits.in_isr == 0)
  78   1                      DISABLE;
  79   1      
  80   1              outportb(D12_COMMAND, 0xFB);
  81   1              outportb(D12_DATA, bMode);
  82   1      
  83   1              if(bEPPflags.bits.in_isr == 0)
  84   1                      ENABLE;
  85   1      }
  86          
  87          unsigned short D12_ReadInterruptRegister(void)
  88          {
  89   1              unsigned char b1;
  90   1              unsigned int j;
  91   1      
  92   1              outportb(D12_COMMAND, 0xF4);
  93   1              b1 = inportb(D12_DATA);
  94   1              j = inportb(D12_DATA);
  95   1      
  96   1              j <<= 8;
  97   1              j += b1;
  98   1      
  99   1              return j;
 100   1      }
 101          
 102          unsigned char D12_SelectEndpoint(unsigned char bEndp)
 103          {
 104   1              unsigned char c;
 105   1      
 106   1              if(bEPPflags.bits.in_isr == 0)
 107   1                      DISABLE;
 108   1      
 109   1              outportb(D12_COMMAND, bEndp);

⌨️ 快捷键说明

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