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

📄 combi.lst

📁 这是使用CYPRESS的7C637xx芯片完成USB鼠标的例子。
💻 LST
📖 第 1 页 / 共 5 页
字号:
                                  #define POPX() #asm( pop x )
                                  #define SWAP(A,DEST) #asm( swap A,DEST)
                                  
                                  #define RLC() #asm( rlc)
                                  #define RRC() #asm( rrc)
                                  #define ASL() #asm( asl a)
                                  #define ASR() #asm( asr a)
                                  #define HALT() #asm( halt);
                                  #define RESET_COP() WATCHDOG=AC
                                  
                                  //make some handy defines to augment those supplied by ByteCraft in chip.h
                                  
                                  #define ADDRESS_ENABLE_BIT   0x80
                                  #define ACK_RECEIVED_MASK   (1 << ACKNOWLEDGE)
                                  #define SETUP_RECEIVED_MASK   (1 << SETUP_RECEIVED)
                                  #define IN_RECEIVED_MASK   (1 << IN_RECEIVED)
                                  #define OUT_RECEIVED_MASK   (1 << OUT_RECEIVED)
                                  #define DATATOGGLE 0x80
                                  
                                  #define WATCHDOG_RESET_MASK   (1 << WATCHDOG_RESET)
                                  #define USB_BUS_RESET_MASK   (1 << USB_RESET)
                                  #define POWER_ON_RESET_MASK   (1 << POWERON_RESET)
                                  #define BUS_RESET_ENABLE   1
                                  #define DATAVALID     0x40
                                  #define COUNT_MASK     0x0F
                                  #define DATATOGGLE     0x80
                                  
                                  #define __BIG_ENDIAN     /* most significant byte is stored in small address */
                                  
                                  #endif /* __CYC_H */
                                  
0001                              #define CONFIGURED                      0x01 /* configuration status values */
0000                              #define UNCONFIGURED                    0x00
                                  
0000                              #define USB_GET_STATUS                  0x00 /*bRequestTypes*/
0001                              #define USB_CLEAR_FEATURE               0x01
0003                              #define USB_SET_FEATURE                 0x03
0005                              #define USB_SET_ADDRESS                 0x05
0006                              #define USB_GET_DESCRIPTOR              0x06
0007                              #define USB_SET_DESCRIPTOR              0x07
0008                              #define USB_GET_CONFIGURATION           0x08
0009                              #define USB_SET_CONFIGURATION           0x09
000A                              #define USB_GET_INTERFACE               0x0A
000B                              #define USB_SET_INTERFACE               0x0B
000C                              #define USB_SYNCH_FRAME                 0x0C
                                  
0000                              #define HOST_TO_DEVICE                  0b00000000
0080                              #define DEVICE_TO_HOST                  0b10000000
0000                              #define STANDARD                        0b00000000
0020                              #define CLASS                           0b00100000
0040                              #define VENDOR                          0b01000000
0000                              #define DEVICE                          0b00000000
0001                              #define INTERFACE                       0b00000001
0002                              #define ENDPOINT                        0b00000010
0003                              #define OTHER                           0b00000011
                                  
                                  /* standard descriptor types */
0001                              #define USB_DEVICE                      0x01
0002                              #define USB_CONFIGURATION               0x02
0003                              #define USB_STRING                      0x03
0004                              #define USB_INTERFACE                   0x04
0005                              #define USB_ENDPOINT                    0x05
                                  
0000                              #define DISABLE_REMOTE_WAKEUP           0x00 /* bit[1] = 0 */
0002                              #define ENABLE_REMOTE_WAKEUP            0x02 /* bit[1] = 1 */
                                  
                                  /* standard feature selectors */
0000                              #define USB_ENDPOINT_STALL              0x00 /* recipient endpoint */
0001                              #define USB_DEVICE_REMOTE_WAKEUP        0x01 /* recipient device */
                                  
                                  /* from HID Class v1.0 Draft #4
                                   * class specific descriptor types from section 7.1 Standard R ests
                                   ***/
0021                              #define USB_HID                         0x21
0022                              #define USB_REPORT                      0x22
0023                              #define USB_PHYSICAL                    0x23
                                  
                                  /* class specific request codes from section 7.2 Class Specific R ests */
0001                              #define USB_GET_REPORT                  0x01
0002                              #define USB_GET_IDLE                    0x02
0003                              #define USB_GET_PROTOCOL                0x03
0009                              #define USB_SET_REPORT                  0x09
000A                              #define USB_SET_IDLE                    0x0A
000B                              #define USB_SET_PROTOCOL                0x0B
                                  
0000                              #define BOOT_PROTOCOL 0
0001                              #define REPORT_PROTOCOL 1
                                  
                                  
                                  
                                  /*
                                  ** ps2 commands
                                  */
                                  
                                  
00FF                              #define PS2_RESET_CMD    0xff
00FE                              #define PS2_RESEND_CMD    0xfe
00F6                              #define PS2_SET_DEFAULT_CMD   0xf6
00F5                              #define PS2_DISABLE_CMD    0xf5
00F4                              #define PS2_ENABLE_CMD    0xf4
00F3                              #define PS2_SET_SAMPLE_RATE_CMD  0xf3
00F2                              #define PS2_READ_DEVICE_TYPE_CMD 0xf2
00F0                              #define PS2_SET_REMOTE_MODE_CMD  0xf0
00EE                              #define PS2_SET_WRAP_MODE_CMD  0xee
00EC                              #define PS2_RESET_WRAP_MODE_CMD  0xec
00EB                              #define PS2_READ_DATA_CMD   0xeb
00EA                              #define PS2_SET_STREAM_MODE_CMD  0xea
00E9                              #define PS2_STATUS_REQUEST_CMD  0xe9
00E8                              #define PS2_SET_RESOLUTION_CMD  0xe8
00E7                              #define PS2_SET_SCALING_2_1_CMD  0xe7
00E6                              #define PS2_RESET_SCALING_CMD  0xe6
                                  
                                  
                                  
                                  
0024                              #define PS2_CLOCK_BIT    (1 << 5)   //clock bit can be read as bit 5 of port 2
0025                              #define PS2_DATA_BIT    (1 << 4)   //data bit can be read as bit 4 of port 2
                                  
                                  
0000                              #define SC_1_1      0     //scaling constants
0001                              #define SC_2_1      1
0000                              #define RES_1MM      0     //resolution constants
0001                              #define RES_2MM      1
0002                              #define RES_4MM      2
0003                              #define RES_8MM      3
00FE                              #define PS2_RESEND     0xFE    //misc. responses to host
00FA                              #define PS2_ACK      0xFA
00FC                              #define PS2_ERROR     0xFC
0001                              #define RIGHT_BUTTON    1     //button positions
0002                              #define LEFT_BUTTON     2
0004                              #define MIDDLE_BUTTON    4
                                  
                                  
                                  
                                  
0026                              #define HOST_RTS ((PORT2 & (PS2_CLOCK_BIT | PS2_DATA_BIT)) == PS2_CLOCK_BIT)
0027                              #define HOST_INHIBIT (!(PORT2 & PS2_CLOCK_BIT))
                                  
                                  
                                  
                                  
                                  
0001                              #define BIT0 1
0002                              #define BIT1 2
0004                              #define BIT2 4
0008                              #define BIT3 8
0010                              #define BIT4 0x10
0020                              #define BIT5 0x20
0040                              #define BIT6 0x40
0080                              #define BIT7 0x80
                                  
                                  
                                  //*************************************************************************************************
                                  //USER_DEFINES
                                  /*
                                  **
                                  ** the following defines can be changed to accomodate different I/O pinouts.  It is assumed that
                                  ** all 6 quadrature inputs (optics) are connected to the same port.
                                  **
                                  */
                                  
0028                              #define OPTICS_PORT    PORT0    //optics port
003F                              #define OPTICS_MASK    0x3f    //mask of all optics inputs
                                  /*
                                  ** for each set of x,y, and z optics, define a macro that will move the corresponding 2 quadrature bits
                                  ** into bit1 and bit0.  For instance, in the reference design
                                  ** the y- quadrature inputs are at bits 3 and 2, so the macro shifts the bits by 2 and
                                  ** masks them.
                                  */
                                  
0029                              #define GET_X_OPTICS(x) ((x >> 0) & 0x3)   //no shift necessary
002A                              #define GET_Y_OPTICS(x) ((x >> 2) & 0x3)   //shift bits [3:2] into [1:0]
002B                              #define GET_Z_OPTICS(x) ((x >> 4) & 0x3)   //shift bits [5:4] into [1:0]
                                  
                                  
                                  /*
                                  ** define each switch's port and bit position
                                  */
002C                              #define LEFT_SWITCH_PORT  PORT0
0080                              #define LEFT_SWITCH_MASK  BIT7
002D                              #define RIGHT_SWITCH_PORT  PORT1
0001                              #define RIGHT_SWITCH_MASK  BIT0
002E                              #define MIDDLE_SWITCH_PORT  PORT1
0002                              #define MIDDLE_SWITCH_MASK  BIT1
                                  
                                  
                                  /*
                                  **define masks for the port pin functions.  This information is used to establish the mode
                                  **settings for the GPIO pins
                                  **
                                  */
003F                              #define PORT0_OPTICS_MASK  0b00111111   //optics pins [5:0] on port 0
0000                              #define PORT1_OPTICS_MASK  0b00000000   //no optics on port 1
0040                              #define PORT0_LED_MASK      0b01000000   //led drive at pin [6] on port 0
0000                              #define PORT1_LED_MASK   0b00000000   //no led drive on port 1
0080                              #define PORT0_SWITCH_MASK  0b10000000   //switch input at pin [7] on port 0
0003                              #define PORT1_SWITCH_MASK  0b00000011   //switch inputs at [1:0] on port 1
                                  
                                  
                                  
                                  
                                  //comment the following lines if you do not want PS2 resolution and scaling commands to be implemented
                                  //in the code.
002F                              #define ENABLE_RESOLUTION
0030                              #define ENABLE_SCALING
                                  //END OF USER DEFINES
                                  //*************************************************************************************************
                                  
                                  
                                  

⌨️ 快捷键说明

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