質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
マイコン

マイクロコンピュータの略で、CPUにマイクロプロセッサを用いたコンピュータのこと。家電製品、電磁機器などの制御に用いられています。単体でコンピュータとしての機能を一通り備えています。 現代のパーソナルコンピュータに近く、同時期のメインフレームやミニコンピュータと比べ、小さいことが特徴です。

Q&A

0回答

1404閲覧

EZ-USB FX2で HID入出力が出来ない

Fritha

総合スコア33

マイコン

マイクロコンピュータの略で、CPUにマイクロプロセッサを用いたコンピュータのこと。家電製品、電磁機器などの制御に用いられています。単体でコンピュータとしての機能を一通り備えています。 現代のパーソナルコンピュータに近く、同時期のメインフレームやミニコンピュータと比べ、小さいことが特徴です。

0グッド

0クリップ

投稿2017/05/12 05:53

###前提・実現したいこと

EZ-USB FX2LPを使用してHIDで入出力をしたい

###発生している問題・エラーメッセージ
PC側でHID認識まではできて、PC側での入力はできるのですが
PCからの出力を受け付けてくれない。

PC側出力はWritefile()にて行っていますがコールすると返ってきません。
(ハングアップ状態になります)
CreateFile()は正常にオープンしています。
今までいろいろと試してみて予測としてはEZ-USB FX2の
ENDPOINTのレジスタ設定あたりが良くないのだと思っていますが
調査しても資料が少なくお手上げ状態です。
どなたかご存知 助言をお願いいたします。

###該当のソースコード

8051 アセンブラ ディスクリプタ設定部分

;;-----------------------------------------------------------------------------
;; File: dscr.a51
;; Contents: This file contains descriptor data tables.
;;
;; Copyright (c) 1997 AnchorChips, Inc. All rights reserved
;;-----------------------------------------------------------------------------

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 DeviceDscr, DeviceQualDscr, HighSpeedConfigDscr, FullSpeedConfigDscr, StringDscr, UserDscr

public hidDscr,ReportDscr,ReportDscrEnd

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)
db 00H ;; Device class
db 00H ;; Device sub-class
db 00H ;; Device sub-sub-class
db 64 ;; Maximum packet size
dw 3412H ;; Vendor ID
dw 7856H ;; Product ID (Sample Device)
dw 0000H ;; Product version ID
db 1 ;; Manufacturer string index
db 2 ;; Product string index
db 0 ;; Serial number string index
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
db (HighSpeedConfigDscrEnd-HighSpeedConfigDscr) mod 256 ;; Total Length (LSB)
db (HighSpeedConfigDscrEnd-HighSpeedConfigDscr) / 256 ;; Total Length (MSB)
db 1 ;; Number of interfaces
db 1 ;; Configuration number
db 0 ;; Configuration string
db 11000000b ;; 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 1 ;; Number of end points
db 03H ;; Interface class
db 00H ;; Interface sub class
db 00H ;; Interface sub sub class
db 0 ;; Interface descriptor string index

;; HID Descriptor
hidDscr:
db 9 ;; length of this desc.
db 21h ;; HID descriptor
db 10h ;;
db 01h ;; version
db 00h ;; Country Code (not use)
db 01h ;; Num HID descriptor (1)
db 22h ;; report descriptor
db ReportDscrEnd-ReportDscr
db 0 ;; HID descriptor size

;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 81H ;; Endpoint number, and direction
db ET_INT ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB)
db 10H ;; Polling interval

;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 01H ;; Endpoint number, and direction
db ET_INT ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB)
db 10H ;; Polling interval

HighSpeedConfigDscrEnd:

FullSpeedConfigDscr:
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 11000000b ;; 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 1 ;; Number of end points
db 03H ;; Interface class
db 00H ;; Interface sub class
db 00H ;; Interface sub sub class
db 0 ;; Interface descriptor string index

;; HID Descriptor
db 9 ;; length of this desc.
db 21h ;; HID descriptor
db 10h ;;
db 01h ;; version
db 00h ;; Country Code (not use)
db 01h ;; Num HID descriptor (1)
db 22h ;; report descriptor
db ReportDscrEnd-ReportDscr
db 0 ;; HID descriptor size

;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 81H ;; Endpoint number, and direction
db ET_INT ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB)
db 10H ;; Polling interval
;; Endpoint Descriptor
db DSCR_ENDPNT_LEN ;; Descriptor length
db DSCR_ENDPNT ;; Descriptor type
db 01H ;; Endpoint number, and direction
db ET_INT ;; Endpoint type
db 40H ;; Maximun packet size (LSB)
db 00H ;; Max packect size (MSB)
db 10H ;; Polling interval

FullSpeedConfigDscrEnd:

ReportDscr:
db 06h ; Usage Page = 0xFF00 (Vendor Defined Page 1)
db 00h, 0FFh ; Usage Page = 0xFF00 (Vendor Defined Page 1)
db 09h, 01h ; Usage (Vendor Usage 1)
db 0A1h, 01h ; Collection (Application)
db 19h, 01h ; Usage Page (Key codes)
db 29h, 10h ; Usage minimum (234)
db 15h, 01h ; Logical minimum (0)
db 25h, 10h ; Logical maximum (1)
db 75h, 08h ; Report size (1)
db 95h, 10h ; Report count (8)
db 81h, 00h ; Input (data, variable, absolute)
db 19h, 01h ; Usage minimum (1)
db 29h, 10h ; Usage maximum (5)
db 91h, 00h ; Output (data, variable, absolute)
db 0C0h ; End Collection
ReportDscrEnd:

;; db 00H ;; WORD ALIGN

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 'M',00
db 'y',00
db 'N',00
db 'a',00
db 'm',00
db 'e',00
StringDscr1End:

StringDscr2:
db StringDscr2End-StringDscr2 ;; String Descriptor length
db DSCR_STRING
db 'T',00
db 'E',00
db 'S',00
db 'T',00
db '',00
db '
',00
db '',00
db '
',00
StringDscr2End:

UserDscr:
dw 0000H
end

8051 C イニシャライズ

void TD_Init(void) // Called once at startup
{
// set the CPU clock to 48MHz
CPUCS = ((CPUCS & ~bmCLKSPD) | bmCLKSPD1) ;

// set the slave FIFO interface to 48MHz
IFCONFIG |= 0x40;

// we are just using the default values, yes this is not necessary...
EP1OUTCFG = 0xA0;
EP1INCFG = 0xA0;
SYNCDELAY; // see TRM section 15.14

/////////////////////////////////////////////////////////
AUTOPTRSETUP |= 0x01;

Rwuen = TRUE; // Enable remote-wakeup
}

###試したこと
考えられるレジスタ設定
EP1OUTCFG
EP1INCFG
に関しては試してみましたが全て同じ状態でした。
その他のENDPOINTは設定しても状態が変わらないので削除しています。

データ転送サイズ等も変更しましたがやはりPC側から入力はできても出力を受け付けてくれません。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問