Loading...
Searching...
No Matches
usb.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Koen Zandberg <koen@bergzand.net>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include "board.h"
25
31
32/* These can be overridden by boards that should come up with their board
33 * supplier VID/PID pair. Boards should only override this if the RIOT built-in
34 * peripherals are compatible with whatever is usually shipped with that pair
35 * */
36#ifndef INTERNAL_PERIPHERAL_VID
38#define INTERNAL_PERIPHERAL_VID (0x1209)
39#endif
40#ifndef INTERNAL_PERIPHERAL_PID
42#define INTERNAL_PERIPHERAL_PID (0x7D00)
43#endif
44
45#if !(defined(CONFIG_USB_VID) && defined(CONFIG_USB_PID))
46#ifdef USB_H_USER_IS_RIOT_INTERNAL
47#define CONFIG_USB_VID INTERNAL_PERIPHERAL_VID
48#define CONFIG_USB_PID INTERNAL_PERIPHERAL_PID
49#else
50#error Please configure your vendor and product IDs. For development, you may \
51 set USB_VID=${USB_VID_TESTING} USB_PID=${USB_PID_TESTING}.
52#endif
53#else
54#if CONFIG_USB_VID == INTERNAL_PERIPHERAL_VID && \
55 CONFIG_USB_PID == INTERNAL_PERIPHERAL_PID
56#error Please configure your vendor and product IDs differently than the \
57 INTERNAL_PERIPHERAL_* settings. For development, you may set \
58 USB_VID=${USB_VID_TESTING} \
59 USB_PID=${USB_PID_TESTING}.
60#endif
61#endif /* !(defined(CONFIG_USB_VID) && defined(CONFIG_USB_PID)) */
62
69#ifdef DOXYGEN
70#define CONFIG_USB_VID
71#endif
72
79#ifdef DOXYGEN
80#define CONFIG_USB_PID
81#endif
82
86#ifndef CONFIG_USB_MANUF_STR
87#define CONFIG_USB_MANUF_STR "RIOT-os.org"
88#endif
89
93#ifndef CONFIG_USB_PRODUCT_STR
94#define CONFIG_USB_PRODUCT_STR RIOT_BOARD
95#endif
96
100#ifndef CONFIG_USB_CONFIGURATION_STR
101#define CONFIG_USB_CONFIGURATION_STR "USB config"
102#endif
103
113#ifdef DOXYGEN
114#define CONFIG_USB_SERIAL_STR "RIOT-12345"
115#endif
116
126#if !defined(CONFIG_USB_SERIAL_STR) && !defined(CONFIG_USB_SERIAL_BYTE_LENGTH)
127#define CONFIG_USB_SERIAL_BYTE_LENGTH 8
128#endif
129
136#ifndef CONFIG_USB_PRODUCT_BCDVERSION
137#define CONFIG_USB_PRODUCT_BCDVERSION 0x0100
138#endif
139
143#ifndef CONFIG_USB_SPEC_BCDVERSION
144#if defined(CONFIG_USB_SPEC_BCDVERSION_1_1)
145#define CONFIG_USB_SPEC_BCDVERSION 0x0110
146#elif defined(CONFIG_USB_SPEC_BCDVERSION_2_0)
147#define CONFIG_USB_SPEC_BCDVERSION 0x0200
148#else
149#define CONFIG_USB_SPEC_BCDVERSION 0x0200
150#endif
151#endif
152
156#ifndef CONFIG_USB_SELF_POWERED
157#define CONFIG_USB_SELF_POWERED (0)
158#endif
159
163#ifndef CONFIG_USB_REM_WAKEUP
164#define CONFIG_USB_REM_WAKEUP (0)
165#endif
166
170#ifndef CONFIG_USB_MAX_POWER
171#define CONFIG_USB_MAX_POWER (100)
172#endif
173
177#ifndef CONFIG_USB_DEFAULT_LANGID
178#define CONFIG_USB_DEFAULT_LANGID 0x0409 /* EN-US */
179#endif
181
206#ifdef DOXYGEN
207#define USB_H_USER_IS_RIOT_INTERNAL
208#endif
210
214typedef enum {
215 USB_VERSION_1x, /* USB 1.0 or 1.1 device */
216 USB_VERSION_20, /* USB 2.0 device */
218
222typedef enum {
223 USB_SPEED_LOW, /* Low speed (1.5Mbit/s) */
224 USB_SPEED_FULL, /* Full speed (12Mbit/s) */
225 USB_SPEED_HIGH, /* High speed (480Mbit/s) */
227
238
246
250#define USB_ENDPOINT_INTERRUPT_FS_MAX_SIZE (64)
251
255#define USB_ENDPOINT_INTERRUPT_HS_MAX_SIZE (1024)
256
260#define USB_ENDPOINT_BULK_FS_MAX_SIZE (64)
261
265#define USB_ENDPOINT_BULK_HS_MAX_SIZE (512)
266
267#ifdef __cplusplus
268}
269#endif
270
usb_version_t
USB version definitions.
Definition usb.h:214
usb_ep_dir_t
USB endpoint directions.
Definition usb.h:242
usb_ep_type_t
USB endpoint types.
Definition usb.h:231
usb_speed_t
USB speed definitions.
Definition usb.h:222
@ USB_EP_DIR_OUT
Host out, device in.
Definition usb.h:243
@ USB_EP_DIR_IN
Host in, device out.
Definition usb.h:244
@ USB_EP_TYPE_NONE
Unused endpoint.
Definition usb.h:232
@ USB_EP_TYPE_CONTROL
Control type.
Definition usb.h:233
@ USB_EP_TYPE_BULK
Bulk type.
Definition usb.h:235
@ USB_EP_TYPE_INTERRUPT
Interrupt type.
Definition usb.h:234
@ USB_EP_TYPE_ISOCHRONOUS
Isochronous type.
Definition usb.h:236