nimozhao
驱动牛犊
驱动牛犊
  • 注册日期2003-10-13
  • 最后登录2004-08-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2000回复:2

求教cypress芯片firmware

楼主#
更多 发布于:2003-11-28 09:02
;这是Cypress公布的利用Cy7c63723编写的USB和串口共用鼠标的例程节录
;===========================================================
; Process EP0 SETUP packet
;
;===========================================================
ep0SetupReceived:
    mov    A, NAK_IN_OUT         ; clear setup bit to enable
    iowr   EP0_MODE               ; writes to EP0 DMA buffer
    mov    A, [ep0DmaBuff + BMREQUESTTYPE]    
                  ; compact bmRequestType into 5 bit field
    and    A, E3h                    
          ; clear bits 4-3-2, these unused for our purposes
    push   A                            ; store value
    asr    A           ; move bits 7-6-5 into 4-3-2\'s place
    asr    A                            ;
    asr    A                            ;
    mov    [intTemp], A           ; store shifted value
    pop    A                            ; get original value
    or     A, [intTemp]      
                       ; or the two to get the 5-bit field
    and    A, 1Fh                      
                       ; clear bits 7-6-5 (asr wraps bit7)

;and后,A中的值为00h-1fh,这和bmRequestTypeJumptable的索引值范围刚好对应。

    asl    A                 ; shift to index jumptable

;为什么需要算术左移1位?这样,不是和bmRequestTypeJumptable的索引值范围不对应了吗?
;是不是jacc有特殊要求?

    jacc   bmRequestTypeJumptable      
                           ; jump to handle bmRequestType


;********************************************************************
;        USB REQUEST JUMP TABLES
;********************************************************************

    XPAGEOFF
    ORG    D00h

;
; bmRequestTypes commented out are not used for this device,
; but may be used for your device.  They are kept here as
; an example of how to use this jumptable.
;
bmRequestTypeJumptable:
    jmp    h2dStdDevice                 ; 00
    jmp    h2dStdInterface              ; 01    
    jmp    h2dStdEndpoint               ; 02    
    jmp    questNotSupported      ;h2d_std_other      03    
    jmp    requestNotSupported    ; h2d_class_device  04    
    jmp    h2dClassInterface            ; 05    
    jmp    requestNotSupported   ; h2d_classEndpoint  06    
    jmp    requestNotSupported    ; h2d_class_other  07    
    jmp    requestNotSupported   ; h2d_vendor_device  08    
    jmp    requestNotSupported  ; h2d_vendorInterface 09    
    jmp    requestNotSupported   ; h2d_vendorEndpoint 0A    
    jmp    requestNotSupported   ; h2d_vendor_other   0B    
    jmp    requestNotSupported          ; 0C    
    jmp    requestNotSupported          ; 0D    
    jmp    requestNotSupported          ; 0E    
    jmp    requestNotSupported          ; 0F    
    jmp    d2hStdDevice                 ; 10    
    jmp    d2hStdInterface              ; 11    
    jmp    d2hStdEndpoint               ; 12    
    jmp    requestNotSupported          
                               ; d2h_std_other        13    
    jmp    requestNotSupported          
                               ; d2h_class_device     14    
    jmp    d2hClassInterface            ; 15    
    jmp    requestNotSupported          
                               ; d2h_classEndpoint    16    
    jmp    requestNotSupported    
                               ; d2h_class_other      17    
    jmp    requestNotSupported    
                               ; d2h_vendor_device    18    
    jmp    requestNotSupported  
                               ; d2h_vendorInterface  19    
    jmp    requestNotSupported    
                               ; d2h_vendorEndpoint   1A    
    jmp    requestNotSupported  
                              ; d2h_vendor_other     1B    
    jmp    requestNotSupported          ; 1C    
    jmp    requestNotSupported          ; 1D    
    jmp    requestNotSupported          ; 1E    
    jmp    requestNotSupported          ; 1F


;
; Transaction Types
;
TRANS_NONE:                     equ    00h
TRANS_CONTROL_READ:             equ    02h
TRANS_CONTROL_WRITE:            equ    04h
TRANS_NO_DATA_CONTROL:          equ    06h

ep0InReceived:
    mov    A, [ep0Transtype]         ; ep0Transtype用于存放上述Transaction Type值之一。
    jacc   ep0InJumptable

;ep0InReceived中断处理中,没有了asl,但是,这样后,好像和下面的ep0InJumptable索引值对不上。

ep0InJumptable:
    jmp    requestNotSupported
    jmp    controlReadDataStage
    jmp    controlWriteStatusStage
    jmp    noDataControlStatusStage      

;望大家指点一下。谢谢。
firmerliu
驱动牛犊
驱动牛犊
  • 注册日期2003-02-19
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分71分
  • 威望206点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-03-01 16:09
由于后面的JMP指令是双地址的,故要Asl才能相配
冰冻三尺非一日之寒
firmerliu
驱动牛犊
驱动牛犊
  • 注册日期2003-02-19
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分71分
  • 威望206点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2004-03-02 12:02
;这是Cypress公布的利用Cy7c63723编写的USB和串口共用鼠标的例程节录
;===========================================================
; Process EP0 SETUP packet
;
;===========================================================
ep0SetupReceived:
    mov    A, NAK_IN_OUT         ; clear setup bit to enable
    iowr   EP0_MODE               ; writes to EP0 DMA buffer
    mov    A, [ep0DmaBuff + BMREQUESTTYPE]    
                  ; compact bmRequestType into 5 bit field
    and    A, E3h                    
          ; clear bits 4-3-2, these unused for our purposes
    push   A                            ; store value
    asr    A           ; move bits 7-6-5 into 4-3-2's place
    asr    A                            ;
    asr    A                            ;
    mov    [intTemp], A           ; store shifted value
    pop    A                            ; get original value
    or     A, [intTemp]      
                       ; or the two to get the 5-bit field
    and    A, 1Fh                      
                       ; clear bits 7-6-5 (asr wraps bit7)

;and后,A中的值为00h-1fh,这和bmRequestTypeJumptable的索引值范围刚好对应。

    asl    A                 ; shift to index jumptable

;为什么需要算术左移1位?这样,不是和bmRequestTypeJumptable的索引值范围不对应了吗?
;是不是jacc有特殊要求?

;(因为以下的JMP指令是双地址的,故要将A中的内容放大2倍才行。)

    jacc   bmRequestTypeJumptable      
                           ; jump to handle bmRequestType


;********************************************************************
;        USB REQUEST JUMP TABLES
;********************************************************************

    XPAGEOFF
    ORG    D00h

;
; bmRequestTypes commented out are not used for this device,
; but may be used for your device.  They are kept here as
; an example of how to use this jumptable.
;
bmRequestTypeJumptable:
    jmp    h2dStdDevice                 ; 00
    jmp    h2dStdInterface              ; 01    
    jmp    h2dStdEndpoint               ; 02    
    jmp    questNotSupported      ;h2d_std_other      03    
    jmp    requestNotSupported    ; h2d_class_device  04    
    jmp    h2dClassInterface            ; 05    
    jmp    requestNotSupported   ; h2d_classEndpoint  06    
    jmp    requestNotSupported    ; h2d_class_other  07    
    jmp    requestNotSupported   ; h2d_vendor_device  08    
    jmp    requestNotSupported  ; h2d_vendorInterface 09    
    jmp    requestNotSupported   ; h2d_vendorEndpoint 0A    
    jmp    requestNotSupported   ; h2d_vendor_other   0B    
    jmp    requestNotSupported          ; 0C    
    jmp    requestNotSupported          ; 0D    
    jmp    requestNotSupported          ; 0E    
    jmp    requestNotSupported          ; 0F    
    jmp    d2hStdDevice                 ; 10    
    jmp    d2hStdInterface              ; 11    
    jmp    d2hStdEndpoint               ; 12    
    jmp    requestNotSupported          
                               ; d2h_std_other        13    
    jmp    requestNotSupported          
                               ; d2h_class_device     14    
    jmp    d2hClassInterface            ; 15    
    jmp    requestNotSupported          
                               ; d2h_classEndpoint    16    
    jmp    requestNotSupported    
                               ; d2h_class_other      17    
    jmp    requestNotSupported    
                               ; d2h_vendor_device    18    
    jmp    requestNotSupported  
                               ; d2h_vendorInterface  19    
    jmp    requestNotSupported    
                               ; d2h_vendorEndpoint   1A    
    jmp    requestNotSupported  
                              ; d2h_vendor_other     1B    
    jmp    requestNotSupported          ; 1C    
    jmp    requestNotSupported          ; 1D    
    jmp    requestNotSupported          ; 1E    
    jmp    requestNotSupported          ; 1F


;
; Transaction Types
;
TRANS_NONE:                     equ    00h
TRANS_CONTROL_READ:             equ    02h
TRANS_CONTROL_WRITE:            equ    04h
TRANS_NO_DATA_CONTROL:          equ    06h

ep0InReceived:
    mov    A, [ep0Transtype]         ; ep0Transtype用于存放上述Transaction Type值之一。
    jacc   ep0InJumptable

;ep0InReceived中断处理中,没有了asl,但是,这样后,好像和下面的ep0InJumptable索引值对不上。

;(从上面的Transaction Types可以看出,每个定义都相差2,因此不用asl来放大了,这样和后面的地址恰好能对上。)

ep0InJumptable:
    jmp    requestNotSupported
    jmp    controlReadDataStage
    jmp    controlWriteStatusStage
    jmp    noDataControlStatusStage      

;望大家指点一下。谢谢。
冰冻三尺非一日之寒
游客

返回顶部