aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/os/hal/include/usbh/defs.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/os/hal/include/usbh/defs.h')
-rw-r--r--lib/chibios-contrib/os/hal/include/usbh/defs.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/hal/include/usbh/defs.h b/lib/chibios-contrib/os/hal/include/usbh/defs.h
new file mode 100644
index 000000000..9fed388fe
--- /dev/null
+++ b/lib/chibios-contrib/os/hal/include/usbh/defs.h
@@ -0,0 +1,159 @@
1/*
2 ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio
3 Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail)
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16*/
17
18#ifndef USBH_DEFS_H_
19#define USBH_DEFS_H_
20
21#include "hal.h"
22
23#if HAL_USE_USBH
24
25#include "osal.h"
26
27#ifdef __IAR_SYSTEMS_ICC__
28#define PACKED_STRUCT PACKED_VAR struct
29#else
30#define PACKED_STRUCT struct PACKED_VAR
31#endif
32
33typedef PACKED_STRUCT {
34 uint8_t bLength;
35 uint8_t bDescriptorType;
36 uint16_t bcdUSB;
37 uint8_t bDeviceClass;
38 uint8_t bDeviceSubClass;
39 uint8_t bDeviceProtocol;
40 uint8_t bMaxPacketSize0;
41 uint16_t idVendor;
42 uint16_t idProduct;
43 uint16_t bcdDevice;
44 uint8_t iManufacturer;
45 uint8_t iProduct;
46 uint8_t iSerialNumber;
47 uint8_t bNumConfigurations;
48} usbh_device_descriptor_t;
49#define USBH_DT_DEVICE 0x01
50#define USBH_DT_DEVICE_SIZE 18
51
52typedef PACKED_STRUCT {
53 uint8_t bLength;
54 uint8_t bDescriptorType;
55 uint16_t wTotalLength;
56 uint8_t bNumInterfaces;
57 uint8_t bConfigurationValue;
58 uint8_t iConfiguration;
59 uint8_t bmAttributes;
60 uint8_t bMaxPower;
61} usbh_config_descriptor_t;
62#define USBH_DT_CONFIG 0x02
63#define USBH_DT_CONFIG_SIZE 9
64
65typedef PACKED_STRUCT {
66 uint8_t bLength;
67 uint8_t bDescriptorType;
68 uint16_t wData[1];
69} usbh_string_descriptor_t;
70#define USBH_DT_STRING 0x03
71#define USBH_DT_STRING_SIZE 2
72
73typedef PACKED_STRUCT {
74 uint8_t bLength;
75 uint8_t bDescriptorType;
76 uint8_t bInterfaceNumber;
77 uint8_t bAlternateSetting;
78 uint8_t bNumEndpoints;
79 uint8_t bInterfaceClass;
80 uint8_t bInterfaceSubClass;
81 uint8_t bInterfaceProtocol;
82 uint8_t iInterface;
83} usbh_interface_descriptor_t;
84#define USBH_DT_INTERFACE 0x04
85#define USBH_DT_INTERFACE_SIZE 9
86
87typedef PACKED_STRUCT {
88 uint8_t bLength;
89 uint8_t bDescriptorType;
90 uint8_t bEndpointAddress;
91 uint8_t bmAttributes;
92 uint16_t wMaxPacketSize;
93 uint8_t bInterval;
94} usbh_endpoint_descriptor_t;
95#define USBH_DT_ENDPOINT 0x05
96#define USBH_DT_ENDPOINT_SIZE 7
97
98typedef PACKED_STRUCT {
99 uint8_t bLength;
100 uint8_t bDescriptorType;
101 uint8_t bFirstInterface;
102 uint8_t bInterfaceCount;
103 uint8_t bFunctionClass;
104 uint8_t bFunctionSubClass;
105 uint8_t bFunctionProtocol;
106 uint8_t iFunction;
107} usbh_ia_descriptor_t;
108#define USBH_DT_INTERFACE_ASSOCIATION 0x0b
109#define USBH_DT_INTERFACE_ASSOCIATION_SIZE 8
110
111typedef PACKED_STRUCT {
112 uint8_t bDescLength;
113 uint8_t bDescriptorType;
114 uint8_t bNbrPorts;
115 uint16_t wHubCharacteristics;
116 uint8_t bPwrOn2PwrGood;
117 uint8_t bHubContrCurrent;
118 uint32_t DeviceRemovable;
119} usbh_hub_descriptor_t;
120#define USBH_DT_HUB 0x29
121#define USBH_DT_HUB_SIZE (7 + 4)
122
123typedef PACKED_STRUCT {
124 uint8_t bmRequestType;
125 uint8_t bRequest;
126 uint16_t wValue;
127 uint16_t wIndex;
128 uint16_t wLength;
129} usbh_control_request_t;
130
131
132#define USBH_REQ_GET_STATUS 0x00
133#define USBH_REQ_CLEAR_FEATURE 0x01
134#define USBH_REQ_SET_FEATURE 0x03
135#define USBH_REQ_SET_ADDRESS 0x05
136#define USBH_REQ_GET_DESCRIPTOR 0x06
137#define USBH_REQ_SET_DESCRIPTOR 0x07
138#define USBH_REQ_GET_CONFIGURATION 0x08
139#define USBH_REQ_SET_CONFIGURATION 0x09
140#define USBH_REQ_GET_INTERFACE 0x0A
141#define USBH_REQ_SET_INTERFACE 0x0B
142#define USBH_REQ_SYNCH_FRAME 0x0C
143
144#define USBH_REQTYPE_DIR_IN 0x80
145#define USBH_REQTYPE_DIR_OUT 0x00
146
147#define USBH_REQTYPE_TYPE_STANDARD 0x00
148#define USBH_REQTYPE_TYPE_CLASS 0x20
149#define USBH_REQTYPE_TYPE_VENDOR 0x40
150
151#define USBH_REQTYPE_RECIP_DEVICE 0x00
152#define USBH_REQTYPE_RECIP_INTERFACE 0x01
153#define USBH_REQTYPE_RECIP_ENDPOINT 0x02
154#define USBH_REQTYPE_RECIP_OTHER 0x03
155
156#endif
157
158
159#endif /* USBH_DEFS_H_ */