RXduino  1.20a
RXduinoマニュアル 最終更新日 平成26年6月29日
tkusbhost.h
説明を見る。
1 /*******************************************************************************
2 * RXduinoライブラリ & 特電HAL
3 *
4 * このソフトウェアは特殊電子回路株式会社によって開発されたものです。
5 * 当社Webサイトを通じてダウンロードすることによって使用許諾されます。
6 * このファイルを第三者へ開示・再配布・貸与・譲渡することはできません。
7 * このソフトウェアはあるがままの状態で提供され、内容および動作についての保障はあ
8 * りません。弊社はファイルの内容および実行結果についていかなる責任も負いません。
9 * お客様は、お客様の製品開発のために当ソフトウェアのソースコードを自由に参照し、
10 * 引用していただくことができます。
11 * コンパイル・リンク後のオブジェクトファイル(ELF ファイルまたはMOT,SRECファイル)
12 * であって、デバッグ情報が削除されている場合は第三者に再配布することができます。
13 * (C) Copyright 2011-2014 TokushuDenshiKairo Inc. 特殊電子回路株式会社
14 * http://rx.tokudenkairo.co.jp/
15 *******************************************************************************/
16 
17 #ifndef TKUSBHOST_H
18 #define TKUSBHOST_H
19 /**************************************************************************/
24 #define TIMEOUT 1000 //1000ms
25 #define TIMEOUT_INFINITE -1
26 
27 #define DEVICE_DESCRIPTOR_TYPE 0x01
28 #define CONFIG_DESCRIPTOR_TYPE 0x02
29 #define STRING_DESCRIPTOR_TYPE 0x03
30 #define INTERFACE_DESCRIPTOR_TYPE 0x04
31 #define ENDPOINT_DESCRIPTOR_TYPE 0x05
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
38 typedef struct DeviceDesc_t
39 {
40  unsigned char bLength;
41  unsigned char bDescriptorType;
42  unsigned short bcdUSB;
43  unsigned char bDeviceClass;
44  unsigned char bDeviceSubClass;
45  unsigned char bDeviceProtocol;
46  unsigned char bMaxPacketSize0;
47  unsigned short idVendor;
48  unsigned short idProduct;
49  unsigned short bcdDevice;
50  unsigned char iManufacture;
51  unsigned char iProduct;
52  unsigned char iSerialNumber;
53  unsigned char bNumConfigurations;
54 } DeviceDesc_t;
55 
57 typedef struct ConfigDesc_t
58 {
59  unsigned char bLength;
60  unsigned char bDescriptorType;
61  unsigned short wTotalLength;
62  unsigned char bNumInterfaces;
63  unsigned char bConfigurationValue;
64  unsigned char iConfiguraion;
65  unsigned char bmAttributes;
66  unsigned char bMaxPower;
67 } ConfigDesc_t;
68 
70 typedef struct EndpointDesc_t
71 {
72  unsigned char bLength;
73  unsigned char bDescriptorType;
74  unsigned char bEndpointAddress;
75  unsigned char bmAttributes;
76  unsigned short wMaxPacketSize;
77  unsigned char bInterval;
78  unsigned char bRefresh;
79  unsigned char bSynchAddress;
81 
83 typedef struct InterfaceDesc_t
84 {
85  unsigned char bLength;
86  unsigned char bDescriptorType;
87  unsigned char bInterfaceNumber;
88  unsigned char bAlternateSetting;
89  unsigned char bNumEndpoints;
90  unsigned char bInterfaceClass;
91  unsigned char bInterfaceSubClass;
92  unsigned char bInterfaceProtocol;
93  unsigned char iInterface;
95 
97 typedef struct USBHostInfo_t
98 {
103  unsigned short LangId;
104  unsigned char FullSpeed;
105  unsigned char FlagAttach;
106  unsigned char DCPMaxSize;
107 } USBHostInfo_t;
108 
110 typedef enum TKUSBH_RESULT
111 {
112  TKUSBH_OK = 0,
119 } TKUSBH_RESULT;
120 
121 extern USBHostInfo_t USBHostInfo;
122 
123 /*********************************************************************/
132 extern int gUsbHostGpioPulldown;
133 
134 /****************************************************************************************
135  USB Hostの関数
136 ****************************************************************************************/
137 
138 /*********************************************************************/
146 
147 /*********************************************************************/
152 
153 /*********************************************************************/
162 TKUSBH_RESULT tkusbh_connect(int timeout_ms);
163 
164 /*********************************************************************/
173 TKUSBH_RESULT tkusbh_halfway_connect(int timeout_ms);
174 
175 /*********************************************************************/
182 TKUSBH_RESULT tkusbh_disconnect(int timeout_ms);
183 
184 /*********************************************************************/
194 int tkusbh_get_descriptor(unsigned char type,unsigned char index, void *buf, int size);
195 
196 /*********************************************************************/
206 int tkusbh_get_string(unsigned short index, unsigned short langid, char *buf,int buflen);
207 
208 /*********************************************************************/
219 int tkusbh_control_msg(unsigned short req,unsigned short val,
220  unsigned short index,unsigned short len,
221  unsigned char *buf, int timeout);
222 
223 /*********************************************************************/
230 TKUSBH_RESULT tkusbh_set_configuration(int configuration);
231 
232 /*********************************************************************/
242 int tkusbh_bulk_write(int ep, unsigned char *bytes, int size,int timeout);
243 
244 /*********************************************************************/
254 int tkusbh_bulk_read(int ep, unsigned char *bytes, int size,int timeout);
255 
257 typedef enum {
260 } INTTRANS_TYPE;
261 
262 /*********************************************************************/
273 void tkusbh_start_interrupt_trans(int ep, int time,INTTRANS_TYPE type, void *callback);
274 
275 /*********************************************************************/
283 int tkusbh_interrupt_write(int ep, unsigned char *buf, int size);
284 
285 /*********************************************************************/
294 int tkusbh_interrupt_read(int ep, unsigned char *buf, int size);
295 
296 
297 // 以下の関数はまだ作っていない
298 // int tkusbh_clear_halt(unsigned int ep);
299 // int tkusbh_resetep(unsigned int ep);
300 // int tkusbh_reset();
301 
302 /****************************************************************************************
303  USBホストユーティリティ
304 ****************************************************************************************/
305 
306 #ifdef __cplusplus
307  }
308 #endif
309 
310 #endif
コンフィグディスクリプタ構造体
Definition: tkusbhost.h:57
struct USBHostInfo_t USBHostInfo_t
USBホストの情報が格納された構造体
USBホストの情報が格納された構造体
Definition: tkusbhost.h:97
TKUSBH_RESULT tkusbh_init(void)
USBホストモジュールを初期化する。
struct EndpointDesc_t EndpointDesc_t
エンドポイントディスクリプタ構造体
unsigned short LangId
ターゲットデバイスの言語ID
Definition: tkusbhost.h:103
TKUSBH_RESULT tkusbh_set_configuration(int configuration)
SET CONFIGURATIONを実行する
インタラプトIN転送
Definition: tkusbhost.h:258
int tkusbh_get_descriptor(unsigned char type, unsigned char index, void *buf, int size)
接続されているターゲットのディスクリプタを取得する
struct ConfigDesc_t ConfigDesc_t
コンフィグディスクリプタ構造体
初期化されていない
Definition: tkusbhost.h:115
ConfigDesc_t ConfigDesc
ターゲットデバイスのコンフィグディスクリプタ
Definition: tkusbhost.h:100
その他のエラー
Definition: tkusbhost.h:118
struct InterfaceDesc_t InterfaceDesc_t
インタフェースディスクリプタ構造体
デバイスディスクリプタ構造体
Definition: tkusbhost.h:38
EndpointDesc_t EndpointDesc
ターゲットデバイスのエンドポイントディスクリプタ
Definition: tkusbhost.h:101
int gUsbHostGpioPulldown
GR-SAKURAのUSBホスト初期化時に、IO2(USB0_DRPD)とIO5(USB0_DPRPD)をどう扱うかを決める
STALLが返された
Definition: tkusbhost.h:117
TKUSBH_RESULT tkusbh_halfway_connect(int timeout_ms)
ターゲットに接続する。ただしenumerationはSET_ADDRESSまでしか実行しない。
エラーなし
Definition: tkusbhost.h:112
InterfaceDesc_t InterfaceDesc
ターゲットデバイスのインタフェースディスクリプタ
Definition: tkusbhost.h:102
タイムアウト(NAK)
Definition: tkusbhost.h:116
TKUSBH_RESULT tkusbh_is_connected()
ターゲットが接続されているかどうかを調べる
DeviceDesc_t DeviceDesc
ターゲットデバイスのデバイスディスクリプタ
Definition: tkusbhost.h:99
int tkusbh_interrupt_read(int ep, unsigned char *buf, int size)
インタラプトIN転送で受信したデータを取得する
int tkusbh_get_string(unsigned short index, unsigned short langid, char *buf, int buflen)
接続されているターゲットのストリングディスクリプタを取得する
void tkusbh_start_interrupt_trans(int ep, int time, INTTRANS_TYPE type, void *callback)
インタラプト転送を行う
struct DeviceDesc_t DeviceDesc_t
デバイスディスクリプタ構造体
インタフェースディスクリプタ構造体
Definition: tkusbhost.h:83
TKUSBH_RESULT tkusbh_connect(int timeout_ms)
ターゲットに接続する
ターゲットが接続されていない
Definition: tkusbhost.h:114
エンドポイントディスクリプタ構造体
Definition: tkusbhost.h:70
unsigned char DCPMaxSize
デフォルトコントロールパイプの最大サイズ
Definition: tkusbhost.h:106
インタラプトOUT転送
Definition: tkusbhost.h:259
INTTRANS_TYPE
インタラプト転送のタイプ
Definition: tkusbhost.h:257
TKUSBH_RESULT tkusbh_disconnect(int timeout_ms)
ターゲットを切断する。切断されるまで待つ。
int tkusbh_interrupt_write(int ep, unsigned char *buf, int size)
インタラプトOUT転送で送信されるデータを登録する
USBホストはサポートされていない
Definition: tkusbhost.h:113
int tkusbh_bulk_read(int ep, unsigned char *bytes, int size, int timeout)
バルクIN転送を実行する
TKUSBH_RESULT
USBホスト関数が返すエラーコード
Definition: tkusbhost.h:110
int tkusbh_control_msg(unsigned short req, unsigned short val, unsigned short index, unsigned short len, unsigned char *buf, int timeout)
コントロールトランザクションを発行する
unsigned char FullSpeed
1:Fullspeed, 0:Lowspeed
Definition: tkusbhost.h:104
int tkusbh_bulk_write(int ep, unsigned char *bytes, int size, int timeout)
バルクOUT転送を実行する