usb.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Koen Zandberg <koen@bergzand.net>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for
6  * more details.
7  */
20 #ifndef USB_H
21 #define USB_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 #include "board.h"
28 
35 /* These can be overridden by boards that should come up with their board
36  * supplier VID/PID pair. Boards should only override this if the RIOT built-in
37  * peripherals are compatible with whatever is usually shipped with that pair
38  * */
39 #ifndef INTERNAL_PERIPHERAL_VID
40 
41 #define INTERNAL_PERIPHERAL_VID (0x1209)
42 #endif
43 #ifndef INTERNAL_PERIPHERAL_PID
44 
45 #define INTERNAL_PERIPHERAL_PID (0x7D00)
46 #endif
47 
48 #if !(defined(CONFIG_USB_VID) && defined(CONFIG_USB_PID))
49 #ifdef USB_H_USER_IS_RIOT_INTERNAL
50 #define CONFIG_USB_VID INTERNAL_PERIPHERAL_VID
51 #define CONFIG_USB_PID INTERNAL_PERIPHERAL_PID
52 #else
53 #error Please configure your vendor and product IDs. For development, you may \
54  set USB_VID=${USB_VID_TESTING} USB_PID=${USB_PID_TESTING}.
55 #endif
56 #endif
57 
64 #ifdef DOXYGEN
65 #define CONFIG_USB_VID
66 #endif
67 
74 #ifdef DOXYGEN
75 #define CONFIG_USB_PID
76 #endif
77 
81 #ifndef CONFIG_USB_MANUF_STR
82 #define CONFIG_USB_MANUF_STR "RIOT-os.org"
83 #endif
84 
88 #ifndef CONFIG_USB_PRODUCT_STR
89 #define CONFIG_USB_PRODUCT_STR "USB device"
90 #endif
91 
95 #ifndef CONFIG_USB_CONFIGURATION_STR
96 #define CONFIG_USB_CONFIGURATION_STR "USB config"
97 #endif
98 
108 #ifdef DOXYGEN
109 #define CONFIG_USB_SERIAL_STR "RIOT-12345"
110 #endif
111 
121 #if !defined(CONFIG_USB_SERIAL_STR) && !defined(CONFIG_USB_SERIAL_BYTE_LENGTH)
122 #define CONFIG_USB_SERIAL_BYTE_LENGTH 8
123 #endif
124 
131 #ifndef CONFIG_USB_PRODUCT_BCDVERSION
132 #define CONFIG_USB_PRODUCT_BCDVERSION 0x0100
133 #endif
134 
138 #ifndef CONFIG_USB_SPEC_BCDVERSION
139 #if defined(CONFIG_USB_SPEC_BCDVERSION_1_1)
140 #define CONFIG_USB_SPEC_BCDVERSION 0x0110
141 #elif defined(CONFIG_USB_SPEC_BCDVERSION_2_0)
142 #define CONFIG_USB_SPEC_BCDVERSION 0x0200
143 #else
144 #define CONFIG_USB_SPEC_BCDVERSION 0x0200
145 #endif
146 #endif
147 
151 #ifndef CONFIG_USB_SELF_POWERED
152 #define CONFIG_USB_SELF_POWERED (0)
153 #endif
154 
158 #ifndef CONFIG_USB_MAX_POWER
159 #define CONFIG_USB_MAX_POWER (100)
160 #endif
161 
165 #ifndef CONFIG_USB_DEFAULT_LANGID
166 #define CONFIG_USB_DEFAULT_LANGID 0x0409 /* EN-US */
167 #endif
168 
194 #ifdef DOXYGEN
195 #define USB_H_USER_IS_RIOT_INTERNAL
196 #endif
197 
202 typedef enum {
203  USB_VERSION_1x, /* USB 1.0 or 1.1 device */
204  USB_VERSION_20, /* USB 2.0 device */
205 } usb_version_t;
206 
210 typedef enum {
211  USB_SPEED_LOW, /* Low speed (1.5Mbit/s) */
212  USB_SPEED_FULL, /* Full speed (12Mbit/s) */
213  USB_SPEED_HIGH, /* High speed (480Mbit/s) */
214 } usb_speed_t;
215 
219 typedef enum {
225 } usb_ep_type_t;
226 
230 typedef enum {
233 } usb_ep_dir_t;
234 
235 #ifdef __cplusplus
236 }
237 #endif
238 
239 #endif /* USB_H */
240 
usb_ep_type_t
USB endpoint types.
Definition: usb.h:219
Bulk type.
Definition: usb.h:223
Host out, device in.
Definition: usb.h:231
Unused endpoint.
Definition: usb.h:220
Interrupt type.
Definition: usb.h:222
Isochronous type.
Definition: usb.h:224
usb_ep_dir_t
USB endpoint directions.
Definition: usb.h:230
Control type.
Definition: usb.h:221
usb_speed_t
USB speed definitions.
Definition: usb.h:210
usb_version_t
USB version definitions.
Definition: usb.h:202
Host in, device out.
Definition: usb.h:232