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

📄 kmain.lst

📁 飞利浦D12的AT89C52固件
💻 LST
📖 第 1 页 / 共 5 页
字号:
  43      =1  #define USB_VENDOR_REQUEST       (unsigned char)0x40
  44      =1  
  45      =1  #define USB_REQUEST_MASK         (unsigned char)0x0F
  46      =1  
  47      =1  #define DEVICE_ADDRESS_MASK      0x7F
  48      =1  
  49      =1  /*
  50      =1     //*************************************************************************
  51      =1     // macros
  52      =1     //*************************************************************************
  53      =1  */
  54      =1  #define SWAP(x)   ((((x) & 0xFF) << 8) | (((x) >> 8) & 0xFF))
  55      =1  
  56      =1  #define MSB(x)    (((x) >> 8) & 0xFF)
  57      =1  #define LSB(x)    ((x) & 0xFF)
  58      =1  
C51 COMPILER V6.20c  KMAIN                                                                 10/31/2002 21:55:46 PAGE 11  

  59      =1  #define FALSE   0
  60      =1  #define TRUE    (!FALSE)
  61      =1  
  62      =1  /*
  63      =1     //*************************************************************************
  64      =1     // basic typedefs
  65      =1     //*************************************************************************
  66      =1  */
  67      =1  typedef unsigned char   UCHAR;
  68      =1  typedef unsigned short  USHORT;
  69      =1  typedef unsigned long   ULONG;
  70      =1  typedef unsigned char   BOOL;
  71      =1  
  72      =1  /*
  73      =1     //*************************************************************************
  74      =1     // structure and union definitions
  75      =1     //*************************************************************************
  76      =1  */
  77      =1  typedef union _epp_flags
  78      =1  {
  79      =1  	struct _flags
  80      =1  	{
  81      =1  		unsigned char timer               	: 1;
  82      =1  		unsigned char bus_reset           	: 1;
  83      =1  		unsigned char suspend             	: 1;
  84      =1  		unsigned char setup_packet  	  	: 1;
  85      =1  		unsigned char remote_wakeup		   	: 1;
  86      =1  		unsigned char in_isr		      	: 1;
  87      =1  		unsigned char control_state			: 2;
  88      =1  
  89      =1  		unsigned char configuration			: 1;
  90      =1  		unsigned char verbose				: 1;
  91      =1  		unsigned char ep1_rxdone			: 1;
  92      =1  		unsigned char setup_dma				: 2; // V2.3
  93      =1  		unsigned char dma_state      		: 2;
  94      =1  		unsigned char power_down			: 1; // Smart Board
  95      =1  	} bits;
  96      =1  	unsigned short value;
  97      =1  } EPPFLAGS;
  98      =1  
  99      =1  typedef struct _device_request
 100      =1  {
 101      =1  	unsigned char bmRequestType;
 102      =1  	unsigned char bRequest;
 103      =1  	unsigned short wValue;
 104      =1  	unsigned short wIndex;
 105      =1  	unsigned short wLength;
 106      =1  } DEVICE_REQUEST;
 107      =1  
 108      =1  typedef struct _IO_REQUEST {
 109      =1  	unsigned short	uAddressL;
 110      =1  	unsigned char	bAddressH;
 111      =1  	unsigned short	uSize;
 112      =1  	unsigned char	bCommand;
 113      =1  } IO_REQUEST, *PIO_REQUEST;
 114      =1  
 115      =1  #define MAX_CONTROLDATA_SIZE	8
 116      =1  
 117      =1  typedef struct _control_xfer
 118      =1  {
 119      =1  	DEVICE_REQUEST DeviceRequest;
 120      =1  	unsigned short wLength;
C51 COMPILER V6.20c  KMAIN                                                                 10/31/2002 21:55:46 PAGE 12  

 121      =1  	unsigned short wCount;
 122      =1  	unsigned char * pData;
 123      =1  	unsigned char dataBuffer[MAX_CONTROLDATA_SIZE];
 124      =1  } CONTROL_XFER;
 125      =1  
 126      =1  /*
 127      =1     //*************************************************************************
 128      =1     // USB utility functions
 129      =1     //*************************************************************************
 130      =1  */
 131      =1  //extern void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv);
 132      =1  //extern void D12_SetDMA(unsigned char bMode);
 133      =1  //extern unsigned char D12_GetDMA(void);
 134      =1  //extern unsigned char D12_ReadEndpointStatus(unsigned char bEndp);
 135      =1  //extern void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled);
 136      =1  //extern void single_transmit(unsigned char * pData, unsigned char len);
 137      =1  //extern void stall_ep0(void);
 138      =1  //void D12_SendResume(void);
 139      =1  
 140      =1  //#define IN_TOKEN_DMA 	1
 141      =1  //#define OUT_TOKEN_DMA 	0
 142      =1  
 143      =1  #define DMA_BUFFER_SIZE		256
 144      =1  
 145      =1  #define DMA_IDLE	0
 146      =1  #define DMA_RUNNING	1
 147      =1  #define DMA_PENDING	2
 148      =1  
 149      =1  #define SETUP_DMA_REQUEST 		0x0471
 150      =1  #define GET_FIRMWARE_VERSION    0x0472
 151      =1  //#define GET_SET_TWAIN_REQUEST   0x0473
 152      =1  #define GET_BUFFER_SIZE		    0x0474
 153      =1  /*
 154      =1  typedef struct _TWAIN_FILEINFO {
 155      =1  	unsigned char	bPage;    // bPage bit 7 - 5 map to uSize bit 18 - 16
 156      =1  	unsigned char	uSizeH;    // uSize bit 15 - 8
 157      =1  	unsigned char	uSizeL;    // uSize bit 7 - 0
 158      =1  } TWAIN_FILEINFO, *PTWAIN_FILEINFO;
 159      =1  */
 160      =1  
 161      =1  
 162      =1  
   8          #include "kd12ci.h"
   1      =1  #define D12_NOLAZYCLOCK			0x02
   2      =1  #define D12_CLOCKRUNNING  	        0x04
   3      =1  #define D12_INTERRUPTMODE		0x08
   4      =1  #define D12_SOFTCONNECT			0x10
   5      =1  #define D12_ENDP_NONISO			0x00
   6      =1  #define D12_ENDP_ISOOUT			0x40
   7      =1  #define D12_ENDP_ISOIN			0x80
   8      =1  #define D12_ENDP_ISOIO			0xC0
   9      =1  
  10      =1  #define D12_CLOCK_12M			0x03
  11      =1  #define D12_CLOCK_4M			0x0b
  12      =1  #define D12_SETTOONE   		        0x40
  13      =1  #define D12_SOFONLY			0x80
  14      =1  
  15      =1  #define D12_DMASINGLE			0x00
  16      =1  #define D12_BURST_4			0x01
  17      =1  #define D12_BURST_8			0x02
  18      =1  #define D12_BURST_16			0x03
  19      =1  #define D12_DMAENABLE     	        0x04
C51 COMPILER V6.20c  KMAIN                                                                 10/31/2002 21:55:46 PAGE 13  

  20      =1  #define D12_DMA_INTOKEN			0x08
  21      =1  #define D12_AUTOLOAD			0x10
  22      =1  
  23      =1  //==============================================
  24      =1  #define D12_NORMALPLUSSOF		0x20
  25      =1  #define D12_ENDP4INTENABLE		0x40
  26      =1  #define D12_ENDP5INTENABLE		0x80	// bug fixed in V2.1
  27      =1  
  28      =1  #define D12_INT_ENDP0OUT		0x01
  29      =1  #define D12_INT_ENDP0IN			0x02
  30      =1  #define D12_INT_ENDP1OUT		0x04
  31      =1  #define D12_INT_ENDP1IN			0x08
  32      =1  #define D12_INT_ENDP2OUT		0x10
  33      =1  #define D12_INT_ENDP2IN			0x20
  34      =1  #define D12_INT_BUSRESET		0x40
  35      =1  #define D12_INT_SUSPENDCHANGE		0x80
  36      =1  #define D12_INT_EOT			0x0100
  37      =1  
  38      =1  #define D12_SETUPPACKET			0x20
  39      =1  
  40      =1  #define D12_BUFFER0FULL			0x20
  41      =1  #define D12_BUFFER1FULL			0x40
  42      =1  
  43      =1  #define D12_FULLEMPTY			0x01
  44      =1  #define D12_STALL			0x02
  45      =1  
  46      =1  
  47      =1  //#define D12_COMMAND			XBYTE[0xFF03]
  48      =1  //#define D12_DATA			XBYTE[0xFF02]
  49      =1  #define D12_COMMAND			0x0ff03
  50      =1  #define D12_DATA			0x0ff02
  51      =1  
  52      =1  //-----------------------------------------------------
  53      =1  void D12_SetEndpointEnable(unsigned char bEnable);
  54      =1  void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable);void D12_SetAddressEnable(unsigne
             -d char bAddress, unsigned char bEnable);void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable);
  55      =1  void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv);
  56      =1  void D12_SetDMA(unsigned char bMode);
  57      =1  unsigned char D12_GetDMA(void);
  58      =1  unsigned short D12_ReadInterruptRegister(void);
  59      =1  unsigned char D12_SelectEndpoint(unsigned char bEndp);
  60      =1  unsigned char D12_ReadLastTransactionStatus(unsigned char bEndp);
  61      =1  unsigned char D12_ReadEndpointStatus(unsigned char bEndp);
  62      =1  void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled);
  63      =1  void D12_SendResume(void);
  64      =1  
  65      =1  unsigned char D12_ReadEndpoint(unsigned char endp, unsigned char len, unsigned char * buf);
  66      =1  unsigned char D12_WriteEndpoint(unsigned char endp, unsigned char len, unsigned char * buf);
  67      =1  void D12_AcknowledgeEndpoint(unsigned char endp);
  68      =1  
  69      =1  
  70      =1  
   9          #include "kchap9.h"
   1      =1  /*
   2      =1     //*************************************************************************
   3      =1     // USB standard device requests
   4      =1     //*************************************************************************
   5      =1  */
   6      =1  void get_status(void);
   7      =1  void clear_feature(void);
   8      =1  void set_feature(void);
   9      =1  void set_address(void);
C51 COMPILER V6.20c  KMAIN                                                                 10/31/2002 21:55:46 PAGE 14  

  10      =1  void get_descriptor(void);
  11      =1  void get_configuration(void);
  12      =1  void set_configuration(void);
  13      =1  void get_interface(void);
  14      =1  void set_interface(void);
  15      =1  
  16      =1  void reserved(void);
  10          #include "kprotodma.h"
   1      =1  void read_write_register(void);
  11          //=====================================
  12          
  13          /*
  14          //*************************************************************************
  15          // USB protocol function pointer arrays
  16          //*************************************************************************
  17          */
  18          code void (*StandardDeviceRequest[])(void) =
  19          {
  20          	get_status,
  21          	clear_feature,
  22          	reserved,
  23          	set_feature,
  24          	reserved,
  25          	set_address,
  26          	get_descriptor,
  27          	reserved,
  28          	get_configuration,
  29          	set_configuration,
  30          	get_interface,
  31          	set_interface,
  32          	reserved,
  33          	reserved,
  34          	reserved,
  35          	reserved
  36          };
  37          
  38          code void (*VendorDeviceRequest[])(void) =
  39          {
  40          	reserved,
  41          	reserved,
  42          	reserved,
  43          	reserved,
  44          	reserved,
  45          	reserved,
  46          	reserved,
  47          	reserved,
  48          	reserved,
  49          	reserved,
  50          	reserved,
  51          	reserved,
  52          	read_write_register,
  53          	reserved,
  54          	reserved,
  55          	reserved
  56          };
  57          
  58          
  59          
  60          /*
  61          //*************************************************************************
  62          //  Public static data
  63          //*************************************************************************
C51 COMPILER V6.20c  KMAIN                                                                 10/31/2002 21:55:46 PAGE 15  

  64          */
  65          extern EPPFLAGS bEPPflags;
  66          extern unsigned long ClockTicks;
  67          
  68          extern unsigned char idata GenEpBuf[];
  69          extern IO_REQUEST idata ioRequest;
  70          
  71          extern unsigned char ioSize, ioCount;
  72          extern unsigned char xdata MainEpBuf[];
  73          extern unsigned char idata EpBuf[];
  74          //------------
  75          extern void fn_usb_isr(void);
  76          //-----------
  77          
  78          CONTROL_XFER ControlData;
  79          unsigned char bNoRAM;
  80          
  81          
  82          //==================================================
  83          /*
  84            PCON:		SMOD | - | - | - | GF1|GF0|PD |IDL|
  85            TCON:		TF1  | - |TF0| - |IE1 |IT1|IE0|IT0|
  86              
  87          */
  88          /* Configure Timer 0
  89             - Mode                  = 1
  90             - Interrupt                   = ENABLED
  91             - Clock Source                = INTERNAL
  92             - Enable Gating Control    = DISABLED
  93          */
  94          
  95          
  96          void init_timer0(void)
  97          {
  98   1      	TMOD &= 0XF0;                /* clear Timer 0   */
  99   1      	TMOD  |= 0X1;
 100   1      	TL0 = 0X0;                   /* value set by user    */
 101   1      	TH0 = 0X0;                   /* value set by user  */

⌨️ 快捷键说明

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