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

📄 malloc.inc

📁 用cy7c66113开发的HUB
💻 INC
字号:
;------------------------------------------------------------------------
; MALLOC.INC
;------------------------------------------------------------------------
; Global memory allocation listing/usage
;------------------------------------------------------------------------

;-------------------------------------------------------------------------
; Memory allocation for Endpoints
;-------------------------------------------------------------------------
; CY7C66113 
; USB Status and Control Register 0x1F Bit[7,6] = [0,0] 
; Each endpoint size is 8 bytes.
;-------------------------------------------------------------------------
    ; A address 3 endpoints
    EndpointA0:         EQU F8h     ; Default pipe, Status and Control I/O   
    EndpointA1:         EQU F0h     ; Status change endpoint
    EndpointA2:         EQU E8h     ; Status change endpoint

    ; B address 2 endpoints
    EndpointB0:         EQU E0h     ; Default pipe, Status and Control I/O
    EndpointB1:         EQU D8h     ; Status change endpoint

    ; bEndpointAddress
    ControlEndpoint:    EQU 00h     ;   
    InEndpoint:         EQU 81h     ;
    InEndpoint2:        EQU 82h     ; Use this search option to add endpoint2
                                    ; (InEndpoint2)

;-------------------------------------------------------------------------
; CK-Hub design
;-------------------------------------------------------------------------
    KBControlData:		EQU	EndpointA0		
    KBBuffer:		    EQU	EndpointA1
    KBBuffer2:		    EQU	EndpointA2
    HubControlData:		EQU EndpointB0
    HubStatusChangeData:EQU	EndpointB1

;-------------------------------------------------------------------------
; It is working with HubBase and KBBase as an offset.
;       HubBase     70h KBBase  88h
;  +)   Offset      70h         70h
;   ---------------------------------
;                   E0h         F8h
;-------------------------------------------------------------------------
Endpoint_FIFO:      EQU 70h     ; Offset
         
;-------------------------------------------------------------------------
; System variable space
;-------------------------------------------------------------------------
; !!!! Allocate ALL module variable data here !!!!
;-------------------------------------------------------------------------
;;KBControlData:		EQU	F8h		; pointer to endpoint A0 buffer
;;  FFh
;;  FEh
;;  FDh
;;  FCh
;;  FBh
;;  FAh
;;  F9h
;;  F8h

;;KBBuffer:		        EQU	F0h		; pointer to endpoint A1 buffer
;;  F7h
;;  F6h
;;  F5h
;;  F4h
;;  F3h
;;  F2h
;;  F1h
;;  F0h

;;KBBuffer2:		    EQU	E8h		; pointer to endpoint A2 buffer
;;  EFh
;;  EEh
;;  EDh
;;  ECh
;;  EBh
;;  EAh
;;  E9h
;;  E8h

;;HubControlData:		EQU	E0h		; pointer to endpoint B0 buffer
;;  E7h
;;  E6h
;;  E5h
;;  E4h
;;  E3h
;;  E2h
;;  E1h
;;  E0h

;;HubStatusChangeData:  EQU	D8h		; pointer to endpoint B1 buffer
;;  DFh
;;  DEh
;;  DDh
;;  DCh
;;  DBh
;;  DAh
;;  D9h
;;  D8h

;-------------------------------------------------------------------------
;   MAXPORT(5) x 5 arrays = 25 Bytes
;   MAXPORT(3) x 5 arrays = 15 Bytes
;-------------------------------------------------------------------------
HubPortBase:            equ D7h
;D7h
;D6h
;D5h
;D4h
;D3h
HubPortChangeHi:	    EQU	HubPortBase-MAXPORT+1   ; D3h
;D2h
;D1h
;D0h
;CFh
;CEh
HubPortChangeLo:	    EQU	HubPortChangeHi-MAXPORT ; CEh
HubPortChange:		    EQU	HubPortChangeLo
;CDh
;CCh
;CBh
;CAh
;C9h
HubPortStatusHi:	    EQU	HubPortChange-MAXPORT   ; C9h
;C8h
;C7h
;C6h
;C5h
;C4h
HubPortStatusLo:	    EQU	HubPortStatusHi-MAXPORT ; C4h
HubPortStatus:		    EQU	HubPortStatusLo
;C3h
;C2h
;C1h
;C0h
;BFh
HubPortCounter:		    EQU	HubPortStatus-MAXPORT   ; BFh   

;-------------------------------------------------------------------------
; PS2KB

ps2key_ram_base:        equ BEh

ps2key_key_count:       equ (ps2key_ram_base - 0)   ;count of keys in buffer
ps2key_inptr:           equ (ps2key_ram_base - 1)   ;in pointer to buffer
ps2key_outptr:          equ (ps2key_ram_base - 2)   ;out pointer to buffer
ps2key_old_count:       equ (ps2key_ram_base - 3)   ;storage  for copy of count
ps2key_old_inptr:       equ (ps2key_ram_base - 4)   ;and in pointer
ps2key_scan_set:        equ (ps2key_ram_base - 5)   ;current scan set
ps2key_numlock:         equ (ps2key_ram_base - 6)   ;=0 if numlock off
ps2key_flags:           equ (ps2key_ram_base - 7)   ;flag byte
ps2key_type_delay:      equ (ps2key_ram_base - 8)   ;typematic delay
ps2key_type_period:     equ (ps2key_ram_base - 9)   ;typematic interval
ps2key_delay_ctr:       equ (ps2key_ram_base - 10)  ;typematic delay counter
ps2key_last_key_made:   equ (ps2key_ram_base - 11)  ;typematic key
ps2key_last_flags:      equ (ps2key_ram_base - 12)  ;typematic flags
ps2key_ghost_counter:   equ (ps2key_ram_base - 13)  ;ghost counter

key_buffer_end:         equ (ps2key_ram_base - 14) 
PS2KeyBuffer:           equ (ps2key_ram_base - 30)  ;key buffer 17byte  ; A0h
ps2key_key_buffer:      equ PS2KeyBuffer

PS2KEY_RAM_SIZE:        equ 14 + 17 

;-------------------------------------------------------------------------
; 98h ~ 9Fh : 8 byte
;-------------------------------------------------------------------------
Tmp3:			        EQU	9Fh
Tmp2:			        EQU	9Eh
Tmp1:			        EQU	9Dh
dual_ifc_option:        EQU 9Ch		
dual_ifc_1ms:           EQU 9Bh		
dual_ifc_keyboard:      EQU 9Ah
ck_flags:               EQU 99h
    PS2_RESET_FLAG:     EQU 01h
    PS2_CHK_FLAG:       EQU 02h
    CK_CHK_1ms:         EQU 04h
    USBPortResume:      EQU 08h
    USB_RESET_FLAG:     EQU 10h
    
FLAG_GPIO:              EQU 98h
;-------------------------------------------------------------------------
KBControlState:		EQU	97h
KBDescriptorPointer:EQU	96h
KBDescriptorLength:	EQU	95h
;
background_flags:		equ 94h	    ; signal flags for background 
    SUSPEND_FLAG:       equ 1
    SCAN_FLAG:	        equ 2

last_key_report:        equ 93h
kbd_idle_period:		equ KBIdle  ; keyboard idle period
kbd_idle_period_ctr:	equ 92h     ; keyboard idle period
1ms_counter:            equ 91h     ; 4ms counter         
ForceResumeCtr:         equ 90h     

xBase:              EQU 8Fh 
KBLEDs:			    EQU	8Eh
KBIdle:			    EQU	8Dh
KBEndpoint1Status:	EQU	8Ch
KBEndpoint0Status:	EQU	8Bh
KBEndpointStatus:	EQU	8Bh
KBDeviceStatus:		EQU	8Ah
KBInterface:		EQU	89h
KBConfiguration:	EQU	88h
KBBase:			    EQU	88h
;
SHADOW_PORT_OC:         EQU	87h
HUB_OVERCURRENT_COUNT:  EQU	86h
KB_PROTOCOL:            EQU	85h
;EQU	84h		
;EQU	83h
;EQU	82h		
;EQU	81h
;EQU	80h
;
HubControlState:	    EQU	7Fh
HubDescriptorPointer:	EQU	7Eh
HubDescriptorLength:	EQU	7Dh
LastHubPortEnable:	EQU	7Ch
LastHubPortConnect:	EQU	7Bh
HubIdleCounter:		EQU	7Ah
HubChangeHi:		EQU	78h
HubChangeLo:		EQU	77h
HubChange:		    EQU	77h
HubStatusHi:		EQU	76h
HubStatusLo:		EQU	75h
HubStatus:		    EQU	75h
HubEndpoint1Status:	EQU	74h
HubEndpoint0Status:	EQU	73h
HubEndpointStatus:	EQU	73h
HubDeviceStatus:	EQU	72h
HubInterface:		EQU	71h
HubConfiguration:	EQU	70h
HubBase:		    EQU	70h


; Offset for HubBase & KBBase
    ControlState:		EQU	0Fh
    DescriptorPointer:	EQU	0Eh
    DescriptorLength:	EQU	0Dh
    TmpAddress:		    EQU	0Dh
    Endpoint1Status:	EQU	04h
    Endpoint0Status:	EQU	03h
    EndpointStatus:		EQU	03h
    DeviceStatus:		EQU	02h
    Interface:		    EQU	01h
    Configuration:		EQU	00h

;-------------------------------------------------------------------------
; 41h ~ 6Fh
;-------------------------------------------------------------------------
; AnyKB

ksc_ram_base:           equ 41h
ksc_x_index:            equ ksc_ram_base
ksc_y_index:            equ (ksc_ram_base + 1)
ksc_changes:            equ (ksc_ram_base + 2)       ; keypress ksc_changes in a column
ksc_matrix_addr:        equ (ksc_ram_base + 3)       ; keycode table index
ksc_down_up:            equ (ksc_ram_base + 4)       ; 00h: key went up, FFh: key went down
ksc_phantom:            equ (ksc_ram_base + 5)       ; flag indicates phantom key situation
							                         ; the debounce test.                                            ; 
ksc_p0out:              equ (ksc_ram_base + 6)
ksc_p1out:              equ (ksc_ram_base + 7)
ksc_p3out:              equ (ksc_ram_base + 8)
p3_shadow:		        EQU	 ksc_p3out
ksc_db_keys:            equ (ksc_ram_base + 9)       ; define 6 bytes to debounce a
							                         ; maximum of 6 keys pressed
                                                     ; DEBOUNCE_ARRAY_SIZE
ksc_db_counts:          equ (ksc_ram_base + 15)      ; define 6 counter bytes for

;keyswitch image contains 18 bytes
ksc_image:              equ (ksc_ram_base + 21)	    ;scan matrix image

ksc_mod0:			    equ (ksc_ram_base + 39)	    ;modifier byte 0 	
ksc_mod1:			    equ (ksc_ram_base + 40)      ;modifier byte 1
ksc_work:			    equ (ksc_ram_base + 41)      ;modifier byte 1
ksc_delay:			    equ (ksc_ram_base + 42)      ;delay byte

;the next three variables are used for phantom key detection
ksc_row_hits:			equ (ksc_ram_base + 43)      ;bit field containing 
							    			         ;all rows with at least 1 key pressed
ksc_col_hits:			equ (ksc_ram_base + 44)      ;current count of columns with at least
												     ;one key pressed
ksc_key_count:			equ (ksc_ram_base + 45)      ;total number of keys pressed

KSC_RAM_SIZE:           equ 46

;-------------------------------------------------------------------------
; 30h ~ 40h
;-------------------------------------------------------------------------
; USBKB

USB_KEY_BUFFER_SIZE:    EQU 8

; keyboard duplicate input report buffer (8 bytes)
; This buffer is sent to the host as a USB keyboard packet

usb_current_state:  	equ 40h         ;storage for type of last report 
                                        ;(error report or key report)
usb_key_count:          equ 3Fh         ; indicates number of keys pressed
usb_tx_required:        equ 3Eh         ; indicates a key(s) changed state
usb_power_id:           equ 3Dh         ; 
usb_power_keys:			equ 3Ch         ; 
usb_power_flag:         equ 3Bh         ; 
;;  3Ah
;;  39h   
;;  38h
;;  37h
;;  36h
;;  35h
;;  34h
usb_report_buffer:      equ 33h         ;   
usb_last_mod:           equ usb_report_buffer   ; last modifier

;-------------------------------------------------------------------------
; PS2KB

ps2main_ram_base:       equ 40h
ps2_last_xmit:          equ ps2main_ram_base    ;last sent byte     
ps2_temp0:              equ ps2main_ram_base-1  ;temp register 1
ps2_temp1:              equ ps2main_ram_base-2  ;temp register 2
ps2_delay:              equ ps2main_ram_base-3  ;used for BAT delay
ps2_scan_timeout:		equ	ps2main_ram_base-4  ;used for timing keyscans (4ms)
ps2_id_state:			equ	ps2main_ram_base-5  ;used to track id command sequence
ps2_send_timeout:		equ	ps2main_ram_base-6  ;used to send keystroke info
ps2_xmt_buf:			equ	ps2main_ram_base-11 ;5-byte transmit holding buffer
ps2_xmt_in:             equ ps2main_ram_base-12 ;in pointer to ps2_xmt_buf
ps2_xmt_out:	        equ	ps2main_ram_base-13 ;out pointer to ps2_xmt_buf
ps2_flags:              equ ps2main_ram_base-14
dummy:                  equ ps2main_ram_base-15
EndOfUserRAM:           equ dummy-1

;-------------------------------------------------------------------------
; Program/Data stack
;-------------------------------------------------------------------------
; Please see CY7C66113 specification chapter 5.4 PSP ~ 5.5 DSP
;
PSP_PRESET:         EQU 00h             ; Program Stack Pointer preset address
DSP_PRESET:         EQU EndOfUserRAM    ;(PSP_PRESET + PSP_SIZE + DSP_SIZE + 1)
                                        ; Data Stack Pointer preset address                            

⌨️ 快捷键说明

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