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

📄 a2810.asm

📁 用usb接品 实现主机与外设之间的通信!
💻 ASM
字号:
;-----------------------------------------------------------------------------
;
; Hardest Italia Srl
;
; Chip: Cypress Semiconductor CY7C63001 USB Microcontroller
;
;----------------------------------------------------------------------
; Modello di CPU
;   ID      CPU Type    RAM        ROM
;   63000   63 / A CPU  128 bytes  2K bytes
;   63001   63 / A CPU  128 bytes  4K bytes
;

        CPU     63001

;----------------------------------------------------------------------
; I/O registers
;
; I/O ports
;
Port0_Data:             equ     00h     ; GPIO data port 0
Port1_Data:             equ     01h     ; GPIO data port 1
Port0_Interrupt:        equ     04h     ; Interrupt enable for port 0
Port1_Interrupt:        equ     05h     ; Interrupt enable for port 1
Port0_PullUp:           equ     08h     ; Pullup resistor control for port 0
Port1_PullUp:           equ     09h     ; Pullup resistor control for port 1

; USB ports
;
USB_EP0_TX_Config:      equ     10h     ; USB EP0 transmit configuration
USB_EP1_TX_Config:      equ     11h     ; USB EP1 transmit configuration
USB_Device_Address:     equ     12h     ; USB device address assigned by host
USB_Status_Control:     equ     13h     ; USB status and control register
USB_EP0_RX_Status:      equ     14h     ; USB EP0 receive status

; Control ports
;
Global_Interrupt:       equ     20h     ; Global interrupt enable
WatchDog:               equ     21h     ; clear watchdog Timer
CextClear:              equ     22h     ; clear External R-C Timing circuit
Timer:                  equ     23h     ; free-running Timer

; GPIO Isink registers
;
Port0_Isink:            equ     30h
Port0_Isink0:           equ     30h
Port0_Isink1:           equ     31h
Port0_Isink2:           equ     32h
Port0_Isink3:           equ     33h
Port0_Isink4:           equ     34h
Port0_Isink5:           equ     35h
Port0_Isink6:           equ     36h
Port0_Isink7:           equ     37h
Port1_Isink:            equ     38h
Port1_Isink0:           equ     38h
Port1_Isink1:           equ     39h
Port1_Isink2:           equ     3Ah
Port1_Isink3:           equ     3Bh
Port1_Isink4:           equ     3Ch
Port1_Isink5:           equ     3Dh
Port1_Isink6:           equ     3Eh

; Control port
;
Status_Control:         equ     FFh

;----------------------------------------------------------------------
; Register bit values
;

; CPU Status and Control (Status_Control)
;
RunBit:                 EQU     01h     ; CPU Run bit
SuspendBits:            EQU     09h     ; Run and suspend bits set
PowerOnReset:           EQU     10h     ; Power on reset bit
USBReset:               EQU     20h     ; USB Bus Reset bit
WatchDogReset:          EQU     40h     ; Watchdog Reset bit

; USB Status and Control
;
BusActivity:            equ      1h     ; USB bus activity bit
ForceResume:            equ      3h     ; force resume to host

; USB EP1 transmit configuration (USB_EP1_TX_Config)
;
DataToggle:             equ     40h     ; Data 0/1 bit

;----------------------------------------------------------------------
; Interrupt masks
;

; The timer-only mask enables the 1-millisecond timer interrupt.
;
TIMER_ONLY:             equ     00000100b       ; 04h

; The enumerate mask enables the following interrupts:
; 1-millisecond timer, USB Endpoint 0
;
ENUMERATE_MASK:         equ     00001100b       ; 0Ch

; The runtime mask enables the following interrupts:
; 1-millisecond timer, USB Endpoint 0, USB Endpoint 1, GPIO
;
RUNTIME_MASK:           equ     01011100b       ; 5Ch

; Cext wakeup interrupt
;
WAKEUP_MASK:            equ     80h

;----------------------------------------------------------------------
; USB Constants
; from the USB Spec v1.1
;

; standard request codes
;
get_status:             equ     0
clear_feature:          equ     1
set_feature:            equ     3
set_address:            equ     5
get_descriptor:         equ     6
set_descriptor:         equ     7
get_configuration:      equ     8
set_configuration:      equ     9
get_interface:          equ     10
set_interface:          equ     11
synch_frame:            equ     12

; standard descriptor types
;
device:                 equ     1
configuration:          equ     2
string:                 equ     3
interface:              equ     4
endpoint:               equ     5

; standard feature selectors
;
endpoint_stalled:       equ     0       ; recipient endpoint
device_remote_wakeup:   equ     1       ; recipient device

; 
;
DISABLE_REMOTE_WAKEUP:  equ     0       ; bit[1] = 0
ENABLE_REMOTE_WAKEUP:   equ     2       ; bit[1] = 1

;----------------------------------------------------------------------
; HID-class descriptors
; from HID Class Definition v1.1 Draft #4
;

; Class-specific descriptor types from section 7.1 Standard Requests
;
HID:                    equ     21h
report:                 equ     22h
physical:               equ     23h
  
; Class-specific request codes from section 7.2 Class Specific Requests
;
get_report:             equ     1
get_idle:               equ     2
get_protocol:           equ     3
set_report:             equ     9
set_idle:               equ     10
set_protocol:           equ     11

;----------------------------------------------------------------------
;USB buffer bytes
;----------------------------------------------------------------------

; Control Endpoint 0 buffer
;
Endpoint_0:             equ     70h     ; control endpoint
Endpoint0_Byte0:        equ     70h     ; Endpoint 0, byte 0
Endpoint0_Byte1:        equ     71h     ; Endpoint 0 byte 1
Endpoint0_Byte2:        equ     72h     ; Endpoint 0 byte 2
Endpoint0_Byte3:        equ     73h     ; Endpoint 0 byte 3
Endpoint0_Byte4:        equ     74h     ; Endpoint 0 byte 4
Endpoint0_Byte5:        equ     75h     ; Endpoint 0 byte 5
Endpoint0_Byte6:        equ     76h     ; Endpoint 0 byte 6
Endpoint0_Byte7:        equ     77h     ; Endpoint 0 byte 7


; Endpoint 0 SETUP packet bytes
;
bmRequestType:          equ     70h
bRequest:               equ     71h
wValue:                 equ     72h     ; default wValue (8 bits)
wValueHi:               equ     73h
wIndex:                 equ     74h     ; default wIndex (8 bits)
wIndexHi:               equ     75h
wLength:                equ     76h     ; default wLength (8 bits)
wLengthHi:              equ     77h

; Endpoint 1 buffer
;
EndPoint1_Start:        EQU     78h
Endpoint1_Byte0:        equ     78h     ; Endpoint 1, byte 0
Endpoint1_Byte1:        equ     79h     ; Endpoint 1 byte 1
Endpoint1_Byte2:        equ     7Ah     ; Endpoint 1 byte 2
Endpoint1_Byte3:        equ     7Bh     ; Endpoint 1 byte 3
Endpoint1_Byte4:        equ     7Ch     ; Endpoint 1 byte 4
Endpoint1_Byte5:        equ     7Dh     ; Endpoint 1 byte 5
Endpoint1_Byte6:        equ     7Eh     ; Endpoint 1 byte 6
Endpoint1_Byte7:        equ     7Fh     ; Endpoint 1 byte 7


EP0_Block_Size: EQU     8
EP1_Block_Size: EQU     8

ReportNum:      EQU     24h
KData_Flags:    EQU     25h             ; flags trasmissione/ricezione

KData_DR_S:     EQU     00000001b       ; Data Ready  - Send    (USB --> PC)
KData_DR_R:     EQU     00000010b       ; Data Ready  - Receive (PC --> USB)
KData_DR_P:     EQU     00000100b       ; Data Ready  - Password
KData_ACK_S:    EQU     00010000b       ; Acknowledge - Send    (USB --> PC)
KData_ACK_R:    EQU     00100000b       ; Acknowledge - Receive (PC --> USB)
KData_EP1_INT:  EQU     10000000b       ; End Point 1 interrupt
KData_DR_X:     EQU     01000000b       ;

;-----------------------------------------------------------------------------
;
; Versione FirmWare e HardWare
;
Version_FirmWare_Major: EQU     1
Version_FirmWare_Minor: EQU     9
Version_HardWare:       EQU     1

;----------------------------------------------------------------------
;                                 
;   CLOCK     }------------------------+
;   DATA OUT  }-----------------------+|
;   DATA IN   }----------------------+||    INPUT
;   DATA SEL  }---------------------+|||
;   CMD VDD   }--------------------+||||
;   CMD VPP   }-------------------+|||||
;   CLOCK SEL }------------------+||||||
;   PROGR SEL }-----------------+|||||||
;                               ||||||||
;                               ||||||||
;                               VVVVVVVV
Port0_InitData:         EQU     00110100b
Port0_InitPullUp:       EQU     00000100b
;
;   CMD MOT   }------------------------+    INPUT
;   CMD RES   }-----------------------+|    INPUT
;   POMPA     }----------------------+||
;   NTC       }---------------------+|||
;   STOP      }--------------------+||||
;   POD0      }-------------------+|||||    INPUT
;   POD1      }------------------+||||||    INPUT
;                                ||||||| 
;                                |||||||
;                                |||||||
;                                VVVVVVV
Port1_InitData:         EQU     11111111b
Port1_InitPullUp:       EQU     11100011b

PIN_CLOCK:              EQU     30h
PIN_DATAOUT:            EQU     31h
PIN_DATAIN:             EQU     32h
PIN_DATASEL:            EQU     33h
PIN_VDD:                EQU     34h
PIN_VPP:                EQU     35h
PIN_CSEL:               EQU     36h
PIN_PROGSEL:            EQU     37h

PIN_CMDMOT:             EQU     38h
PIN_CMDRES:             EQU     39h
PIN_POMPA:              EQU     3Ah
PIN_NTC:                EQU     3Bh
PIN_STOP:               EQU     3Ch
PIN_POD0:               EQU     3Dh
PIN_POD1:               EQU     3Eh

;----------------------------------------------------------------------
; Variables stored in data memory
;

; USB status
;
remote_wakeup_status:   equ     50h             ; 0 = disabled, 2 = enabled
configuration_status:   equ     51h             ; 0 = unconfigured, 1 = configured
;idle_status:            equ    52h             ; support SetIdle and GetIdle
protocol_status:        equ     53h             ; 0 = boot protocol, 1 = report protocol

;Other variables:
;
suspend_counter:        equ     54h             ; number of idle bus milliseconds 
loop_temp:              equ     55h             ; temporary loop variable
start_send:             equ     56h             ; 0 = false, 1 = true

interrupt_mask:         equ     57h
endp0_data_toggle:      equ     58h
loop_counter:           equ     59h
data_start:             equ     5Ah
data_count:             equ     5Bh
endpoint_stall:         equ     5Ch
 

;-----------------------------------------------------------------------------
; variabili utilizzate

Stato:     EQU   20h     ; tiene traccia dello stato della periferica

RESET:       EQU   00000001b     ; stato iniziale in attesa di un comando
LETTURA:     EQU   00000010b     ; stato lettura, la periferica sta inviando dati all'host
SCRITTURA:   EQU   00000011b     ; stato scrittura, la periferica sta ricevendo dati dall'host

Dati:      EQU   28h     ; posizione iniziale del pacchetto dati che verr

⌨️ 快捷键说明

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