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

📄 combi.lst

📁 这是使用CYPRESS的7C637xx芯片完成USB鼠标的例子。
💻 LST
📖 第 1 页 / 共 5 页
字号:
                                  
                                  
                                  //*************************************************************************************************
                                  //COMMON DECLARATIONS USED BY BOTH INTERFACES
                                  
                                  #asm
                        
                        ;define special macros for manipulating PS2 clock and data.
                        ;
                        
                        
                            MACRO READ_PS2_CLOCK_DATA
                            iord    PORT2
                            ENDM
                        
                            MACRO WRITE_PS2_CLOCK_DATA VALUE
                            mov     A,(VALUE | a0h)
                            iowr    USB_STATUS
                            ENDM
                            MACRO WRITE_ACC_PS2_CLOCK_DATA
                            or    A,a0h
                            iowr    USB_STATUS
                            and    A,07h
                            ENDM
                        
                            MACRO   ASSERT_PS2_CLOCK
                            index   drive_table
                            or      A,a0h
                            iowr    USB_STATUS
                            and    A,07h
                            ENDM
                        
                            MACRO   DEASSERT_PS2_CLOCK
                            index   drive_table
                            or      A,a0h
                            iowr    USB_STATUS
                            and     A,07h
                            ENDM
                        
                        
                        
                            ;delay macro is the front-end for a call to the delay subroutine
                            ;The fixed overhead of the macro plus the subroutine is 3 us,
                            ;so this technique is good for delays of 4us or greater.
                            ;
                        
                            MACRO DELAY US
                            push    A
                            mov     A, (US-3)
                            call    delay
                            ENDM
                        ;
                        
                            ;clear carry
                            MACRO CLEARC
                            or    A,0
                            ENDM
                        
                            MACRO SETC
                            cpl
                            cpl
                            ENDM
                        
                        
                           ;set carry
                            MACRO CARRY
                            push    A
                            mov     A, (US-3)
                            call    delay
                             ENDM
                        
                                  #endasm
                                  
                                  
                                  
                                  /*
                                  ** define port data and mode initial values for the 3 operating states -- normal, suspend, and suspend with remote
                                  ** wakeup -- based on the masks provided by the user
                                  */
                                  /*
                                  **normal operating mode
                                  */
0080                              #define PORT0_INIT    PORT0_SWITCH_MASK
0003                              #define PORT1_INIT    PORT1_SWITCH_MASK
0080                              #define PORT0_MODE1_INIT  PORT0_SWITCH_MASK
0003                              #define PORT1_MODE1_INIT  PORT1_SWITCH_MASK
0040                              #define PORT0_MODE0_INIT  PORT0_LED_MASK
0000                              #define PORT1_MODE0_INIT  PORT1_LED_MASK
                                  
                                  /*
                                  ** suspend mode (no remote wakeup)
                                  */
                                  
                                  
0040                              #define PORT0_SUSPEND     PORT0_LED_MASK
0000                              #define PORT1_SUSPEND     PORT1_LED_MASK
0040                              #define PORT0_MODE1_SUSPEND    PORT0_LED_MASK
0000                              #define PORT1_MODE1_SUSPEND    PORT1_LED_MASK
0080                              #define PORT0_MODE0_SUSPEND    PORT0_SWITCH_MASK
0003                              #define PORT1_MODE0_SUSPEND    PORT1_SWITCH_MASK
                                  /*
                                  ** remote wakeup
                                  */
0031                              #define PORT0_RW      (PORT0_LED_MASK | PORT0_SWITCH_MASK)
0032                              #define PORT1_RW      (PORT1_LED_MASK | PORT1_SWITCH_MASK)
0033                              #define PORT0_MODE1_RW     (PORT0_SWITCH_MASK | PORT0_LED_MASK)
0034                              #define PORT1_MODE1_RW     (PORT1_SWITCH_MASK | PORT1_LED_MASK)
0000                              #define PORT0_MODE0_RW     0
0000                              #define PORT1_MODE0_RW     0
                                  
                                  
0035                              #define LEFT_SWITCH_ASSERTED  (!(LEFT_SWITCH_PORT & LEFT_SWITCH_MASK))
0036                              #define MIDDLE_SWITCH_ASSERTED  (!(MIDDLE_SWITCH_PORT & MIDDLE_SWITCH_MASK))
0037                              #define RIGHT_SWITCH_ASSERTED  (!(RIGHT_SWITCH_PORT & RIGHT_SWITCH_MASK))
                                  
                                  
                                  /*
                                  ** switches are debounced in a routine that is called every 4 msec.  10
                                  ** successive stable samples are required for a switch change to be reported.
                                  */
000A                              #define DEBOUNCE_COUNT    10    //10 identical samples must be taken to recognize switch changes
                                  
                                  
                                  
                                  
                                  
                                  /*
                                  ** define a structure containing variables updated in the 1-msec interrupt
                                  */
                                  
                                  typedef struct
                                  {
                                   char b1msCounter;    //incremented inside 1msec interrupt for general timing
                                   char b1msFlags;     //flag set inside 1msec interrupt
0038                              }ONE_MSEC_STATUS;
0001                              #define ONE_MSEC_FLAG 1
                                  
                                  
                                  /*
                                  ** Quadrature inputs are sampled inside the 128 usec interrupt and placed in a queue for later
                                  ** processing in the main loop.
                                  **
                                  */
                                  typedef struct
                                  {
                                   char near *headP;     //head of queue
                                   char near *tailP;     //tail of queue
                                   char bLen;       //length of queue
0039                              }QUEUE_STRUCT;
                                  
                                  
                                  /*
                                  ** current state of each quadrature pair is stored to compare with the next sample.
                                  **
                                  */
                                  
                                  typedef struct
                                  {
                                   char bXstate;      //current state of X optics
                                   char bYstate;      //current state of Y optics
                                   char bZstate;      //current state of Z optics
                                  
003A                              }OPTICS_STATE;
                                  
                                  
                                  
                                  /*
                                  ** the order of the bytes in this structure is important! These bytes are in the
                                  ** proper order for a packet returned to a USB host in response to a Get_Report command.
                                  */
                                  typedef struct
                                  {
                                   char bChange;      //set to 1 if mouse state has changed
                                   char bButtons;      //current state of mouse buttons
                                   signed char bXcount;      //current accumulation of X counts
                                   signed char bYcount;      //current accumulation of Y counts
                                   signed char bZcount;      //current accumulation of Z counts
003B                              }MOUSE_STATE;
                                  
                                  
                                  
                                  /*
                                  ** global variables used by both USB and PS2 interfaces
                                  */
                                  
004E 0003                         QUEUE_STRUCT  OpticsQueue;  //optics queue
                                  
0051 0002                         ONE_MSEC_STATUS  MsecStatus;   //status of 1msec interrupt
0053 0003                         OPTICS_STATE  Optics;    //current state of optics
0056 0005                         MOUSE_STATE   Mouse;    //current state of mouse (buttons, x,y,z)
0030                              char bLastButtons;
0031                              char bDebounceCount;
                                  
                                  
0032 0010                         char bOpticsArray[16];     //16-byte array used for optics queue data
                                  
                                  
                                  const signed char quad_table[] =
                                  /*
                                  ;***
                                  ; Quadrature state table. This table assists processing of quadrature state
                                  ; transitions. The table index is calculated as:
                                  ;       [(last_state)*4 + current_state],
                                  ; and the table entry at that point is 1, 0 or -1 indicating increment, hold
                                  ; or decrement the count, respectively.
                                  ;***
                                  */
                                  {
                                   0,     //;State 0 => state 0 (NoChange)
                                   1,     //;        => state 1 (Increment)

⌨️ 快捷键说明

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