source: azure_iot_hub_f767zi/trunk/asp_baseplatform/usb/tusb_types.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 8.3 KB
Line 
1/*
2 * TOPPERS BASE PLATFORM MIDDLEWARE
3 *
4 * Copyright (C) 2017-2018 by TOPPERS PROJECT
5 * Educational Working Group.
6 *
7 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
8 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
9 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
10 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
11 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
12 * スコード中に含まれていること.
13 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
14 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
15 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
16 * の無保証規定を掲載すること.
17 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
18 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
19 * と.
20 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
21 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
22 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
23 * 報告すること.
24 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
25 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
26 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
27 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
28 * 免責すること.
29 *
30 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
31 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
32 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
33 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
34 * の責任を負わない.
35 *
36 * @(#) $Id$
37 */
38/* mbed USBHost Library
39 * Copyright (c) 2006-2013 ARM Limited
40 *
41 * Licensed under the Apache License, Version 2.0 (the "License");
42 * you may not use this file except in compliance with the License.
43 * You may obtain a copy of the License at
44 *
45 * http://www.apache.org/licenses/LICENSE-2.0
46 *
47 * Unless required by applicable law or agreed to in writing, software
48 * distributed under the License is distributed on an "AS IS" BASIS,
49 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
50 * See the License for the specific language governing permissions and
51 * limitations under the License.
52 */
53/*
54 * USB Host/Device Middleware 型外部宣言
55 */
56
57#ifndef _TUSB_TYPES_H_
58#define _TUSB_TYPES_H_
59
60
61#ifdef __cplusplus
62 extern "C" {
63#endif
64
65/* Control RequestType Fields */
66#define USB_DEVICE_TO_HOST 0x80
67#define USB_HOST_TO_DEVICE 0x00
68#define USB_REQUEST_DIR_MASK USB_DEVICE_TO_HOST
69#define USB_REQUEST_TYPE_VENDOR 0x40
70#define USB_REQUEST_TYPE_CLASS 0x20
71#define USB_REQUEST_TYPE_STANDARD 0x00
72#define USB_RECIPIENT_OTHER 0x03
73#define USB_RECIPIENT_ENDPOINT 0x02
74#define USB_RECIPIENT_INTERFACE 0x01
75#define USB_RECIPIENT_DEVICE 0x00
76
77/* USB Standard Requests */
78#define GET_STATUS 0x00
79#define CLEAR_FEATURE 0x01
80#define SET_FEATURE 0x03
81#define SET_ADDRESS 0x05
82#define GET_DESCRIPTOR 0x06
83#define SET_DESCRIPTOR 0x07
84#define GET_CONFIGURATION 0x08
85#define SET_CONFIGURATION 0x09
86#define GET_INTERFACE 0x0A
87#define SET_INTERFACE 0x0B
88
89/* Descriptor Types of USB Specifications */
90#define DEVICE_DESCRIPTOR (1)
91#define CONFIGURATION_DESCRIPTOR (2)
92#define STRING_DESCRIPTOR (3)
93#define INTERFACE_DESCRIPTOR (4)
94#define ENDPOINT_DESCRIPTOR (5)
95#define DEVICE_QUALIFIER_DESCRIPTOR (6)
96#define OTHER_SPEED_CONFIGURATION_DESC (7)
97#define BOS_DESCRIPTOR (15)
98#define HID_DESCRIPTOR (33)
99#define HID_REPORT_DESCRIPTOR (34)
100
101#define SET_CONFIGURATION_TYPE (USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE | USB_REQUEST_TYPE_STANDARD)
102#define SET_ADDRESS_TYPE (USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE | USB_REQUEST_TYPE_STANDARD)
103#define SET_INTERFACE_TYPE (USB_HOST_TO_DEVICE | USB_RECIPIENT_INTERFACE | USB_REQUEST_TYPE_STANDARD)
104#define CLEAR_FEATURE_TYPE (USB_HOST_TO_DEVICE | USB_RECIPIENT_ENDPOINT | USB_REQUEST_TYPE_STANDARD)
105
106/* USB Descriptor Length */
107#define DEVICE_DESCRIPTOR_LENGTH 0x12
108#define CONFIGURATION_DESCRIPTOR_LENGTH 0x09
109#define INTERFACE_DESCRIPTOR_LENGTH 0x09
110#define ENDPOINT_DESCRIPTOR_LENGTH 0x07
111#define HID_DESCRIPTOR_LENGTH 0x09
112
113
114#define USB_EP_TYPE_CTRL 0x00
115#define USB_EP_TYPE_ISOC 0x01
116#define USB_EP_TYPE_BULK 0x02
117#define USB_EP_TYPE_INTR 0x03
118
119#define USB_PID_SETUP 0
120#define USB_PID_DATA 1
121
122/* Class code */
123#define AUDIO_CLASS 0x01
124#define CDC_CLASS 0x02
125#define HID_CLASS 0x03
126#define PRT_CLASS 0x07
127#define MSC_CLASS 0x08
128#define HUB_CLASS 0x09
129#define DATA_INTERFACE_CLASS 0x0A
130#define BLUETOOTH_CLASS 0xE0
131
132/* usb speed */
133#define USB_DEVICE_SPEED_HIGH 0
134#define USB_DEVICE_SPEED_FULL 1
135#define USB_DEVICE_SPEED_LOW 2
136
137
138#define SETUP_PKT_LENGTH 8
139
140#define MAX_DEVICE_CONNECTED 4
141#ifndef MAX_EPS_PIPES
142#define MAX_EPS_PIPES 32
143#endif
144
145#define TUSBH_MAX_ERROR_COUNT 2
146#define TUSBH_STR_LENGTH 64
147
148typedef struct {
149 uint8_t bLength;
150 uint8_t bDescriptorType;
151 uint16_t bcdUSB;
152 uint8_t bDeviceClass;
153 uint8_t bDeviceSubClass;
154 uint8_t bDeviceProtocol;
155 uint8_t bMaxPacketSize;
156 uint16_t idVendor;
157 uint16_t idProduct;
158 uint16_t bcdDevice;
159 uint8_t iManufacturer;
160 uint8_t iProduct;
161 uint8_t iSerialNumber;
162 uint8_t bNumConfigurations;
163} DeviceDescriptor;
164
165typedef struct {
166 uint8_t bLength;
167 uint8_t bDescriptorType;
168 uint16_t wTotalLength;
169 uint8_t bNumInterfaces;
170 uint8_t bConfigurationValue;
171 uint8_t iConfiguration;
172 uint8_t bmAttributes;
173 uint8_t bMaxPower;
174} ConfigurationDescriptor;
175
176typedef struct {
177 uint8_t bLength;
178 uint8_t bDescriptorType;
179 uint8_t bInterfaceNumber;
180 uint8_t bAlternateSetting;
181 uint8_t bNumEndpoints;
182 uint8_t bInterfaceClass;
183 uint8_t bInterfaceSubClass;
184 uint8_t bInterfaceProtocol;
185 uint8_t iInterface;
186} InterfaceDescriptor;
187
188typedef struct {
189 uint8_t bLength;
190 uint8_t bDescriptorType;
191 uint8_t bEndpointAddress;
192 uint8_t bmAttributes;
193 uint16_t wMaxPacketSize;
194 uint8_t bInterval;
195} EndpointDescriptor;
196
197typedef struct {
198 uint8_t bDescLength;
199 uint8_t bDescriptorType;
200 uint8_t bNbrPorts;
201 uint8_t wHubCharacteristics[2];
202 uint8_t bPwrOn2PwrGood;
203 uint8_t bHubContrCurrent;
204 uint8_t DeviceRemovable;
205 uint8_t PortPweCtrlMak;
206} HubDescriptor;
207
208typedef struct {
209 uint8_t bmRequest;
210 uint8_t bRequest;
211 uint16_t wValue;
212 uint16_t wIndex;
213 uint16_t wLength;
214} UsbSetupRequest;
215
216typedef struct {
217 uint32_t baudrate;
218 uint8_t stop_bits; /* 0-1 Stop bit 1-1.5 Stop bits 2-2 Stop bits */
219 uint8_t parity; /* 0:None 1:Odd 2:Even 3:Mark 4:Space */
220 uint8_t data_bits;
221} Line_Coding_t;
222
223
224/*
225 * TUSBH ERROR CODE型
226 */
227typedef enum {
228 TUSBH_E_OK = 0,
229 TUSBH_E_BUSY,
230 TUSBH_E_BUSY_URB,
231 TUSBH_E_PAR,
232 TUSBH_E_OBJ,
233 TUSBH_E_ERR,
234 TUSBH_E_URB,
235 TUSBH_E_RTOS,
236 TUSBH_E_NOSPT,
237 TUSBH_E_TMOUT,
238 TUSBH_E_SYS,
239} TUSBH_ERCODE;
240
241/*
242 * TUSBD ERROR CODE型
243 */
244typedef enum {
245 TUSBD_E_OK = 0,
246 TUSBD_E_BUSY,
247 TUSBD_E_ERR
248} TUSBD_ERCODE;
249
250#ifdef __cplusplus
251}
252#endif
253
254#endif /* _TUSB_TYPES_H_ */
255
Note: See TracBrowser for help on using the repository browser.