EZ−USB FX2LPの概要 (その2)
ディスクリプタ
ターゲットUSBデバイスの仕様を規定しているところです。 これが、USBが難しいと思わせる原因になっています。このディスクリプタは1から作るのは大変です。そこで、開発ツールのExamplesから近いものを選んで修正することになります。ここではオリジナルのBulkloopのディスクリプタをみていきます。ソースファイル名はdscr.a51です。赤字は私のコメントで、オリジナルのソースファイルにはありません。
;;-----------------------------------------------------------------------------
;; File: dscr.a51
;; Contents: This file contains descriptor data tables.
;;
;; $Archive: /USB/Examples/Fx2lp/bulkloop/dscr.a51 $
;; $Date: 9/01/03 8:51p $
;; $Revision: 3 $
;;
;;
;;-----------------------------------------------------------------------------
;; Copyright 2003, Cypress Semiconductor Corporation
;;-----------------------------------------------------------------------------
;;-----------------------------------------------------------------------------
equは数値を文字で置き換えます
DSCR_DEVICE equ 1 ;; Descriptor type: Device
DSCR_CONFIG equ 2 ;; Descriptor type: Configuration
DSCR_STRING equ 3 ;; Descriptor type: String
DSCR_INTRFC equ 4 ;; Descriptor type: Interface
DSCR_ENDPNT equ 5 ;; Descriptor type: Endpoint
DSCR_DEVQUAL equ 6 ;; Descriptor type: Device Qualifier
DSCR_DEVICE_LEN equ 18
DSCR_CONFIG_LEN equ 9
DSCR_INTRFC_LEN equ 9
DSCR_ENDPNT_LEN equ 7
DSCR_DEVQUAL_LEN equ 10
ET_CONTROL equ 0 ;; Endpoint type: Control
ET_ISO equ 1 ;; Endpoint type: Isochronous
ET_BULK equ 2 ;; Endpoint type: Bulk
ET_INT equ 3 ;; Endpoint type: Interrupt
publicは他のソースから参照できるようにします
public DeviceDscr, DeviceQualDscr, HighSpeedConfigDscr, FullSpeedConfigDscr, StringDscr, UserDscr
DSCR SEGMENT CODE PAGEはリンカーに対する指示です
DSCR SEGMENT CODE PAGE
;;以降の文字はコメントです
;;-----------------------------------------------------------------------------
;; Global Variables
;;-----------------------------------------------------------------------------
rseg DSCR ;; locate the descriptor table in on-part memory.
DeviceDscr: :の付くものはラベルといってアセンブルしたときに場所を特定できます
db DSCR_DEVICE_LEN ;; Descriptor length このディスクリプタのバイト数
db DSCR_DEVICE ;; Decriptor type ディスクリプタの種類 デバイスタイプ
dw 0002H ;; Specification Version (BCD) バージョン(BCDコード 1.34なら 0134H)
db 00H ;; Device class
db 00H ;; Device sub-class
db 00H ;; Device sub-sub-class
db 64 ;; Maximum packet size エンドポイント0(EP0)の最大パケット数
dw 0B404H ;; Vendor ID ベンダーIDといってメーカー固有の番号です
dw 0410H ;; Product ID (Sample Device) プロダクトIDといって製品固有の番号です
dw 0000H ;; Product version ID
db 1 ;; Manufacturer string index このページ最後にあるStringDscr1:を示していると思われます
db 2 ;; Product string index このページ最後にあるStringDscr2:を示していると思われます
db 0 ;; Serial number string index このページ最後にあるStringDscr0:を示していると思われます
db 1 ;; Number of configurations コンフィグレーションの数
DeviceQualDscr: 意味は同上
db DSCR_DEVQUAL_LEN ;; Descriptor length
db DSCR_DEVQUAL ;; Decriptor type
dw 0002H ;; Specification Version (BCD)
db 00H ;; Device class
db 00H ;; Device sub-class
db 00H ;; Device sub-sub-class
db 64 ;; Maximum packet size
db 1 ;; Number of configurations
db 0 ;; Reserved
-------------------------------------------------------------------------------
HighSpeedConfigDscr: ★ハイスピード用コンフィグレーション
db DSCR_CONFIG_LEN ;; Descriptor lengthこのディスクリプタのバイト数
db DSCR_CONFIG ;; Descriptor type ディスクリプタの種類 CONFIG
db (HighSpeedConfigDscrEnd-HighSpeedConfigDscr) mod 256 ;; Total Length (LSB)
db (HighSpeedConfigDscrEnd-HighSpeedConfigDscr) / 256 ;; Total Length (MSB)
このディスクリプタのバイト数で2バイト(MSB、上記LSB)
db 1 ;; Number of interfaces このコンフィグレーションの Interface数
db 1 ;; Configuration number コンフィグレーションの番号
db 0 ;; Configuration string このページ最後にあるStringDscr0:を示していると思われます
db 10000000b ;; Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu)
バスパワー、セルフパワー、リモートウエイクアップビット(1で有効)
db 50 ;; Power requirement (div 2 ma) バスからの供給電力 50mA x 2 = 100mA
;; Interface Descriptor
db DSCR_INTRFC_LEN ;; Descriptor length
db DSCR_INTRFC ;; Descriptor type
db 0 ;; Zero-based index of this interface
db 0 ;; Alternate setting
db 4 ;; Number of end points エンドポイント数 4個
db 0ffH ;; Interface class 別途ENDPOINTの説明ディスクリプション有り?
db 00H ;; Interface sub class
db 00H ;; Interface sub sub class
db 0 ;; Interface descriptor string index
以下は ENDPOINTの説明ディスクリプション
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 02H ;; Endpoint number, and direction エンドポイント2、OUT方向
db ET_BULK ;; Endpoint type バルク転送用
db 00H ;; Maximun packet size (LSB)
db 02H ;; Max packect size (MSB) 最大パケットサイズ 0x0200 (MSB,上記LSB)
db 00H ;; Polling interval
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 04H ;; Endpoint number, and direction エンドポイント4、OUT方向
db ET_BULK ;; Endpoint type バルク転送用
db 00H ;; Maximun packet size (LSB)
db 02H ;; Max packect size (MSB) 最大パケットサイズ 0x0200 (MSB,上記LSB)
db 00H ;; Polling interval
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 86H ;; Endpoint number, and direction エンドポイント6、IN方向(bit7=1がINを示す)
db ET_BULK ;; Endpoint type バルク転送用
db 00H ;; Maximun packet size (LSB)
db 02H ;; Max packect size (MSB) 最大パケットサイズ 0x0200 (MSB,上記LSB)
db 00H ;; Polling interval
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 88H ;; Endpoint number, and direction エンドポイント8、IN方向(bit7=1がINを示す)
db ET_BULK ;; Endpoint type バルク転送用
db 00H ;; Maximun packet size (LSB)
db 02H ;; Max packect size (MSB) 最大パケットサイズ 0x0200 (MSB,上記LSB)
db 00H ;; Polling interval
HighSpeedConfigDscrEnd:
-------------------------------------------------------------------------------
FullSpeedConfigDscr: ★フルスピード用コンフィグレーション パケットサイズを見てください64バイトに設定
db DSCR_CONFIG_LEN ;; Descriptor length
db DSCR_CONFIG ;; Descriptor type
db (FullSpeedConfigDscrEnd-FullSpeedConfigDscr) mod 256 ;; Total Length (LSB)
db (FullSpeedConfigDscrEnd-FullSpeedConfigDscr) / 256 ;; Total Length (MSB)
db 1 ;; Number of interfaces
db 1 ;; Configuration number
db 0 ;; Configuration string
db 10000000b ;; Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu)
db 50 ;; Power requirement (div 2 ma)
;; Interface Descriptor
db DSCR_INTRFC_LEN ;; Descriptor length
db DSCR_INTRFC ;; Descriptor type
db 0 ;; Zero-based index of this interface
db 0 ;; Alternate setting
db 4 ;; Number of end points
db 0ffH ;; Interface class
db 00H ;; Interface sub class
db 00H ;; Interface sub sub class
db 0 ;; Interface descriptor string index
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 02H ;; Endpoint number, and direction
db ET_BULK ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB) 最大パケットサイズ 0x0040 (MSB,上記LSB)
db 00H ;; Polling interval
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 04H ;; Endpoint number, and direction
db ET_BULK ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB) 最大パケットサイズ 0x0040 (MSB,上記LSB)
db 00H ;; Polling interval
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 86H ;; Endpoint number, and direction
db ET_BULK ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB) 最大パケットサイズ 0x0040 (MSB,上記LSB)
db 00H ;; Polling interval
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 88H ;; Endpoint number, and direction
db ET_BULK ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB) 最大パケットサイズ 0x0040 (MSB,上記LSB)
db 00H ;; Polling interval
FullSpeedConfigDscrEnd:
-------------------------------------------------------------------------------
StringDscr: 以下はストリングディスクリプター(文字列) ここは偶数番地に置くとの情報があります?
StringDscr0:
db StringDscr0End-StringDscr0 ;; String descriptor length
db DSCR_STRING
db 09H,04H
StringDscr0End:
StringDscr1:
db StringDscr1End-StringDscr1 ;; String descriptor length
db DSCR_STRING
db 'C',00
db 'y',00
db 'p',00
db 'r',00
db 'e',00
db 's',00
db 's',00
StringDscr1End:
StringDscr2:
db StringDscr2End-StringDscr2 ;; Descriptor length
db DSCR_STRING
db 'E',00
db 'Z',00
db '-',00
db 'U',00
db 'S',00
db 'B',00
StringDscr2End:
UserDscr:
dw 0000H
end