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

📄 usbhidio.lst

📁 单片机开发的与PC机的VB程序通信方法
💻 LST
📖 第 1 页 / 共 5 页
字号:
CYASM Version 1.75
(C) 1997 Cypress Semiconductor Corp.

0000            ;Filename: usbhidio.asm
0000            ;Version: 1.3
0000            ;Date: 11/5/99
0000            ;Copyright 1999 by Jan Axelson (jan@lvr.com)
0000            ;
0000            ;Chip: Cypress Semiconductor CY7C63001 USB Microcontroller
0000            ;Assembler: cyasm.exe
0000            ;Purpose: demonstrates USB communications with an HID-class device
0000            ;Description:
0000            ;Handles all required standard USB and HID-class requests.
0000            ;Receives data from the host in output reports
0000            ;using Interrupt transfers on endpoint 1.
0000            ;Sends data to the host in input reports
0000            ;using Control transfers on endpoint 0
0000            ;(because the chip doesn't support OUT transfers on endpoint 1).
0000            ;I used Cypress Semiconductor's js50.asm joystick example code as a base 
0000            ;in creating this program.
0000            ;The companion host software is the Visual-Basic project usbhidio.vbp.
0000            ;For more information, visit Lakeview Research at http://www.lvr.com .
0000            ;Send comments, bug reports, etc. to jan@lvr.com .
0000            
0000            ;Changes:
0000            
0000            ;V1.3: 11/20/99
0000            ;The length of the string descriptors is now correct.
0000            ;(Thanks, John Hyde)
0000            ;Changed the control_read routine to prevent error when sending a 
0000            ;multiple of 8 bytes.
0000            ;(Thanks, Dave Wright)
0000            
0000            ;V1.2:
0000            ;added watchdog resets in wait loops,
0000            ;no watchdog reset in the 1-msec. timer ISR.
0000            
0000            ;V1.1:
0000            ;Clears the watchdog only in the main routine
0000            ;(so the watchdog will detect if the main routine crashes).
0000            ;Some additions to the comments.
0000            
0000            ;V1.0:
0000            ;Clears the Watchdog timer on 1-msec. interrupt.
0000            ;(Not needed on the development board, but needed for stand-alone.)
0000            ;The Endpoint 1 ISR now sets bit 7 of Endpoint 1 TX config to 1.
0000            ;(The bit is cleared on EP1 interrupt.)
0000            
0000            ;======================================================================
0000            ;assembler directives (equates)
0000            ;======================================================================
0000            
0000            ;----------------------------------------------------------------------
0000            ;I/O registers
0000            ;----------------------------------------------------------------------
0000            
0000            ;I/O ports
0000            Port0_Data:            equ     00h      ; GPIO data port 0
0000            Port1_Data:            equ     01h      ; GPIO data port 1
0000            Port0_Interrupt:       equ     04h      ; Interrupt enable for port 0
0000            Port1_Interrupt:       equ     05h      ; Interrupt enable for port 1
0000            Port0_Pullup:          equ     08h      ; Pullup resistor control for port 0
0000            Port1_Pullup:          equ     09h      ; Pullup resistor control for port 1
0000            
0000            ;USB ports
0000            USB_EP0_TX_Config:      equ     10h     ; USB EP0 transmit configuration
0000            USB_EP1_TX_Config:      equ     11h     ; USB EP1 transmit configuration
0000            USB_Device_Address:     equ     12h     ; USB device address assigned by host
0000            USB_Status_Control:     equ     13h     ; USB status and control register
0000            USB_EP0_RX_Status:      equ     14h     ; USB EP0 receive status
0000            
0000            ;Control ports
0000            Global_Interrupt:       equ     20h     ; Global interrupt enable
0000            Watchdog:               equ     21h     ; clear watchdog Timer
0000            Timer:                  equ     23h     ; free-running Timer
0000            
0000            ;GPIO Isink registers
0000            Port0_Isink:            equ     30h
0000            Port0_Isink0:           equ     30h
0000            Port0_Isink1:           equ     31h
0000            Port0_Isink2:           equ     32h
0000            Port0_Isink3:           equ     33h
0000            Port0_Isink4:           equ     34h
0000            Port0_Isink5:           equ     35h
0000            Port0_Isink6:           equ     36h
0000            Port0_Isink7:           equ     37h
0000            Port1_Isink:            equ     38h
0000            Port1_Isink0:           equ     38h
0000            Port1_Isink1:           equ     39h
0000            Port1_Isink2:           equ     3Ah
0000            Port1_Isink3:           equ     3Bh
0000            
0000            ;Control port
0000            Status_Control:         equ     FFh
0000            
0000            ;----------------------------------------------------------------------
0000            ;Register bit values
0000            ;----------------------------------------------------------------------
0000            
0000            ;CPU Status and Control (Status_Control)
0000            RunBit:                 equ     1h     ; CPU Run bit
0000            USBReset:               equ    20h     ; USB Bus Reset bit
0000            WatchDogReset:          equ    40h     ; Watchdog Reset bit
0000            
0000            ; USB EP1 transmit configuration (USB_EP1_TX_Config)
0000            DataToggle:               equ     40h     ; Data 0/1 bit
0000            
0000            DISABLE_REMOTE_WAKEUP:  equ   0         ; bit[1] = 0
0000            ENABLE_REMOTE_WAKEUP:   equ   2         ; bit[1] = 1
0000            
0000            ;----------------------------------------------------------------------
0000            ;Interrupt masks
0000            ;----------------------------------------------------------------------
0000            
0000            ;The timer-only mask enables the 1-millisecond timer interrupt.
0000            TIMER_ONLY:               equ      4h
0000            
0000            ;The enumerate mask enables the following interrupts:
0000            ;1-millisecond timer, USB Endpoint 0
0000            ENUMERATE_MASK:          equ     0Ch
0000            
0000            ;The runtime mask enables the following interrupts:
0000            ;1-millisecond timer, USB Endpoint 0, USB Endpoint 1, GPIO
0000            RUNTIME_MASK:          equ     5Ch
0000            
0000            ;----------------------------------------------------------------------
0000            ; USB Constants
0000            ; from the USB Spec v1.1
0000            ;----------------------------------------------------------------------
0000            
0000            ;standard request codes
0000            get_status:             equ   0
0000            clear_feature:          equ   1
0000            set_feature:            equ   3
0000            set_address:            equ   5
0000            get_descriptor:         equ   6
0000            set_descriptor:         equ   7
0000            get_configuration:      equ   8
0000            set_configuration:      equ   9
0000            get_interface:          equ  10
0000            set_interface:          equ  11
0000            synch_frame:            equ  12
0000            
0000            ; standard descriptor types
0000            device:              equ  1
0000            configuration:       equ  2
0000            string:              equ  3
0000            interface:           equ  4
0000            endpoint:            equ  5
0000            
0000            ; standard feature selectors
0000            endpoint_stalled:       equ  0              ; recipient endpoint
0000            device_remote_wakeup:   equ  1              ; recipient device
0000            
0000            ;----------------------------------------------------------------------
0000            ;HID-class descriptors
0000            ;from HID Class Definition v1.1 Draft
0000            ;----------------------------------------------------------------------
0000            
0000            ;Class-specific descriptor types from section 7.1 Standard Requests
0000            HID:                    equ  21h
0000            report:                 equ  22h
0000            physical:               equ  23h
0000              
0000            ;Class-specific request codes from section 7.2 Class Specific Requests
0000            get_report:             equ   1
0000            get_idle:               equ   2
0000            get_protocol:           equ   3
0000            set_report:             equ   9
0000            set_idle:               equ  10
0000            set_protocol:           equ  11
0000            
0000            ;----------------------------------------------------------------------
0000            ;USB buffer bytes
0000            ;----------------------------------------------------------------------
0000            
0000            ;Control Endpoint 0 buffer
0000            Endpoint_0:             equ  70h        ; control endpoint
0000            Endpoint0_Byte0:        equ  70h        ; Endpoint 0, byte 0
0000            Endpoint0_Byte1:        equ  71h        ; Endpoint 0 byte 1
0000            Endpoint0_Byte2:        equ  72h        ; Endpoint 0 byte 2
0000            Endpoint0_Byte3:        equ  73h        ; Endpoint 0 byte 3
0000            Endpoint0_Byte4:        equ  74h        ; Endpoint 0 byte 4
0000            Endpoint0_Byte5:        equ  75h        ; Endpoint 0 byte 5
0000            Endpoint0_Byte6:        equ  76h        ; Endpoint 0 byte 6
0000            Endpoint0_Byte7:        equ  77h        ; Endpoint 0 byte 7
0000            
0000            
0000            ;Endpoint 0 SETUP packet bytes
0000            bmRequestType:          equ  70h
0000            bRequest:               equ  71h
0000            wValue:                 equ  72h        ; default wValue (8 bits)
0000            wValueHi:               equ  73h
0000            wIndex:                 equ  74h        ; default wIndex (8 bits)
0000            wIndexHi:               equ  75h
0000            wLength:                equ  76h        ; default wLength (8 bits)
0000            wLengthHi:              equ  77h
0000            
0000            ;Endpoint 1 buffer
0000            endpoint_1:             equ  78h
0000            Endpoint1_Byte0:        equ  78h        ; Endpoint 1, byte 0
0000            Endpoint1_Byte1:        equ  79h        ; Endpoint 1 byte 1
0000            Endpoint1_Byte2:        equ  7Ah        ; Endpoint 1 byte 2
0000            Endpoint1_Byte3:        equ  7Bh        ; Endpoint 1 byte 3
0000            Endpoint1_Byte4:        equ  7Ch        ; Endpoint 1 byte 4
0000            Endpoint1_Byte5:        equ  7Dh        ; Endpoint 1 byte 5
0000            Endpoint1_Byte6:        equ  7Eh        ; Endpoint 1 byte 6
0000            Endpoint1_Byte7:        equ  7Fh        ; Endpoint 1 byte 7
0000            
0000            ;----------------------------------------------------------------------
0000            ; Variables stored in data memory
0000            ;----------------------------------------------------------------------
0000            ;USB status
0000            remote_wakeup_status:   equ  30h          ;0=disabled, 2-enabled
0000            configuration_status:   equ  31h          ;0=unconfigured, 1=configured
0000            ;idle_status:           equ  33h          ;support SetIdle and GetIdle
0000            protocol_status:        equ  34h          ;0=boot protocol, 1=report protocol
0000            
0000            ;Other variables:
0000            suspend_counter:        equ  35h          ;number of idle bus milliseconds 
0000            loop_temp:              equ  37h          ;temporary loop variable
0000            start_send:             equ  32h          ;0=false, 1=true
0000            
0000            ;Received data:
0000            Data_Byte0:               equ  38h
0000            Data_Byte1:               equ  39h
0000            Data_Byte2:               equ  3Ah
0000            Data_Byte3:               equ  3Bh
0000            Data_Byte4:               equ  3Ch
0000            Data_Byte5:               equ  3Dh
0000            Data_Byte6:               equ  3Eh
0000            Data_Byte7:               equ  3Fh
0000            
0000            temp:                   equ  25h
0000            start_time:             equ  21h
0000            testbit:                equ  22h
0000            interrupt_mask:         equ  20h
0000            endp0_data_toggle:      equ  23h
0000            loop_counter:           equ  24h
0000            data_start:             equ  27h
0000            data_count:             equ  28h
0000            endpoint_stall:         equ  29h
0000            
0000            ;======================================================================
0000            ;interrupt vectors
0000            ;======================================================================
0000            
0000            org  00h                ; Reset vector; begin here after a reset.
0000 80 99 [05] jmp  Reset
0002            
0002            org  02h                ; 128-microsecond interrupt
0002 80 10 [05] jmp  DoNothing_ISR
0004            
0004            org  04h                ; 1024-millisecond interrupt 
0004 80 15 [05] jmp  One_mSec_ISR
0006            
0006            org  06h                ; endpoint 0 interrupt 
0006 81 24 [05] jmp  USB_EP0_ISR
0008            
0008            org  08h                ; endpoint 1 interrupt 
0008 80 8C [05] jmp  USB_EP1_ISR
000A            
000A            org  0Ah                ; reserved interrupt 
000A 80 99 [05] jmp  Reset
000C            
000C            org  0Ch                ; general purpose I/O interrupt 
000C 80 85 [05] jmp  GPIO_ISR           ; not used
000E            
000E            org  0Eh                ; Wakeup_ISR or resume interrupt 
000E 80 10 [05] jmp  DoNothing_ISR      ; not used
0010            
0010            ORG  10h
0010            
0010            ;======================================================================
0010            ;Interrupt routines

⌨️ 快捷键说明

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