RXマイコンとAndroid携帯をつなぐ
RXマイコンのUSBホスト機能ができてきました。
といっても、ディスクリプタを解析して表示するだけなのですが。。
とりあえず、究極のRX62Nボードに、Android携帯をつないでみました。

AndroidのUSB接続モードがデフォルト(外部メモリ転送モード)のときに、デスクリプタを取得したところ、InterfaceClass=8なので、USBメモリになっています。
AndroidのほうでUSB接続モードを「高速転送モード」に切り替えると、InterfaceClass=2になるので、通信クラスになります。
Device Desriptor:
bLength = 18
bDescriptorType = 1
bcdUSB = 0x200
bDeviceClass = 0x0
bDeviceSubClass = 0x0
bDeviceProtocol = 0x0
bMaxPacketSize = 64
idVendor = 0x04c5
idProduct = 0x12aa
bcdDevice = 0x0227
iManufacture = 1 ()
iProduct = 2 ()
iSerialNumber = 3 ()
bNumConfigurations = 1
Configuration Desriptor:
bLength = 9
bDescriptorType = 2
wTotalLength = 58
bConfigurationValue = 1
iConfiguraion = 0
bmAttributes = 0x80 (Bus powered)
bMaxPower = 250 (500mA)
+ Interface Desriptor:
bLength = 9
bDescriptorType = 4
bInterfaceNumber = 0
bAlternateSetting = 0
bNumEndpoints = 2
bInterfaceClass = 0x2
bInterfaceSubClass = 0xa
bInterfaceProtocol = 0x1
iInterface = 0
Unknown Descriptor
0000 05 24 00 10 01
Unknown Descriptor
0000 15 24 12 00 01 C2 29 9F CC D4 89 40 66 89 2B 10
0010 C3 41 DD 98 A9
+ Endpoint Desriptor: (EP1 IN)
bLength = 7
bDescriptorType = 5
bEndpointAddress = 129
bmAttributes = 0x2 BULK
wMaxPacketSize = 64
bInterval = 0
bRefresh = 0
bSynchAddress = 0
+ Endpoint Desriptor: (EP1 OUT)
bLength = 7
bDescriptorType = 5
bEndpointAddress = 1
bmAttributes = 0x2 BULK
wMaxPacketSize = 64
bInterval = 0
bRefresh = 0
bSynchAddress = 0
タイプ0x24という謎のディスクリプタが見えています。
AndroidのUSBデバッグモードをONにすると、USBメモリと、ベンダ定義クラス(FF)の2つのインタフェースが見えました。
Device Desriptor:
bLength = 18
bDescriptorType = 1
bcdUSB = 0x200
bDeviceClass = 0x0
bDeviceSubClass = 0x0
bDeviceProtocol = 0x0
bMaxPacketSize = 64
idVendor = 0x04c5
idProduct = 0x12a8
bcdDevice = 0x0227
iManufacture = 1 ()
iProduct = 2 ()
iSerialNumber = 3 ()
bNumConfigurations = 1
Configuration Desriptor:
bLength = 9
bDescriptorType = 2
wTotalLength = 55
bConfigurationValue = 1
iConfiguraion = 0
bmAttributes = 0x80 (Bus powered)
bMaxPower = 250 (500mA)
+ Interface Desriptor:
bLength = 9
bDescriptorType = 4
bInterfaceNumber = 0
bAlternateSetting = 0
bNumEndpoints = 2
bInterfaceClass = 0x8
bInterfaceSubClass = 0x6
bInterfaceProtocol = 0x50
iInterface = 5
+ Endpoint Desriptor: (EP2 IN)
bLength = 7
bDescriptorType = 5
bEndpointAddress = 130
bmAttributes = 0x2 BULK
wMaxPacketSize = 64
bInterval = 0
bRefresh = 0
bSynchAddress = 0
+ Endpoint Desriptor: (EP2 OUT)
bLength = 7
bDescriptorType = 5
bEndpointAddress = 2
bmAttributes = 0x2 BULK
wMaxPacketSize = 64
bInterval = 0
bRefresh = 0
bSynchAddress = 0
+ Interface Desriptor:
bLength = 9
bDescriptorType = 4
bInterfaceNumber = 1
bAlternateSetting = 0
bNumEndpoints = 2
bInterfaceClass = 0xff
bInterfaceSubClass = 0x42
bInterfaceProtocol = 0x1
iInterface = 0
+ Endpoint Desriptor: (EP3 IN)
bLength = 7
bDescriptorType = 5
bEndpointAddress = 131
bmAttributes = 0x2 BULK
wMaxPacketSize = 64
bInterval = 0
bRefresh = 0
bSynchAddress = 0
+ Endpoint Desriptor: (EP3 OUT)
bLength = 7
bDescriptorType = 5
bEndpointAddress = 3
bmAttributes = 0x2 BULK
wMaxPacketSize = 64
bInterval = 0
bRefresh = 0
bSynchAddress = 0
おおっ、複合デバイスってやつでしょう!
次はバルク転送ができるようにします。
| 固定リンク



コメント