Open FFBoard
Open source force feedback firmware
Loading...
Searching...
No Matches
usb_descriptors.cpp
Go to the documentation of this file.
1/*
2 * usb_descriptors.c
3 *
4 * Created on: 16.02.2021
5 * Author: Yannick
6 */
7#include "tusb.h"
8#include "usb_descriptors.h"
9#include "usbd.h"
10#include "main.h"
11#include "usb_hid_ffb_desc.h"
12
13//--------------------------------------------------------------------+
14// Device Descriptors
15//--------------------------------------------------------------------+
16#define USBD_VID 0x1209
17#define USBD_PID 0xFFB0
19{
20 .bLength = sizeof(tusb_desc_device_t),
21 .bDescriptorType = TUSB_DESC_DEVICE,
22 .bcdUSB = 0x0200,
23
24 // As required by USB Specs IAD's subclass must be common class (2) and protocol must be IAD (1)
25 .bDeviceClass = TUSB_CLASS_UNSPECIFIED,
26 .bDeviceSubClass = MISC_SUBCLASS_COMMON,
27 .bDeviceProtocol = MISC_PROTOCOL_IAD,
28 .bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
29
30 .idVendor = USBD_VID,
31 .idProduct = USBD_PID,
32 .bcdDevice = 0x0100,
33
34 .iManufacturer = 0x01,
35 .iProduct = 0x02,
36 .iSerialNumber = 0x03,
37
38 .bNumConfigurations = 0x01
39};
40
41
42/*--------------------------------------------------------------------
43 * Configuration descriptors
44 * String index starts at 4 (interfaces field)
45----------------------------------------------------------------------*/
46
47const uint8_t usb_cdc_conf[] =
48{
49 // Config number, interface count, string index, total length, attribute, power in mA
50 TUD_CONFIG_DESCRIPTOR(1, 2, 0, (TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN), TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP | TUSB_DESC_CONFIG_ATT_SELF_POWERED, 100),
51
52 // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
53 TUD_CDC_DESCRIPTOR(0, 4, 0x82, 8, 0x01, 0x81, 64),
54};
55
56
57// Composite CDC and HID
58#ifdef AXIS1_FFB_HID_DESC
59 const uint8_t usb_cdc_hid_conf_1axis[] ={USB_CONF_DESC_HID_CDC(USB_HID_1FFB_REPORT_DESC_SIZE,64)};
60#endif
61
62#ifdef AXIS1_FFB_HID_DESC_32B
63 const uint8_t usb_cdc_hid_conf_1axis_32b[] ={USB_CONF_DESC_HID_CDC(USB_HID_1FFB_REPORT_DESC_32B_SIZE,64)};
64#if TUD_OPT_HIGH_SPEED
65 const uint8_t usb_cdc_hid_conf_1axis_32b_hs[] ={USB_CONF_DESC_HID_CDC(USB_HID_1FFB_REPORT_DESC_32B_SIZE,512)};
66#endif
67#endif
68
69// Composite CDC and HID
70#ifdef AXIS2_FFB_HID_DESC
71 const uint8_t usb_cdc_hid_conf_2axis[] ={USB_CONF_DESC_HID_CDC(USB_HID_2FFB_REPORT_DESC_SIZE,64)};
72#endif
73
74#ifdef AXIS2_FFB_HID_DESC_32B
75 const uint8_t usb_cdc_hid_conf_2axis_32b[] ={USB_CONF_DESC_HID_CDC(USB_HID_2FFB_REPORT_DESC_32B_SIZE,64)};
76#endif
77
78// Composite CDC and HID
79#ifdef FFB_HID_DESC_GAMEPAD
80 const uint8_t usb_cdc_hid_conf_gamepad[] ={USB_CONF_DESC_HID_CDC(USB_HID_GAMEPAD_REPORT_DESC_SIZE,64)};
81#endif
82
83// Composite CDC and MIDI
84uint8_t const usb_cdc_midi_conf[] =
85{
86 // Config number, interface count, string index, total length, attribute, power in mA
87 TUD_CONFIG_DESCRIPTOR(1, 4, 0, TUD_CONFIG_DESC_LEN + TUD_CDC_DESC_LEN + TUD_MIDI_DESC_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP | TUSB_DESC_CONFIG_ATT_SELF_POWERED, 100),
88 // 1st CDC: Interface number, string index, EP notification address and size, EP data address (out, in) and size.
89 TUD_CDC_DESCRIPTOR(0, 4, 0x82, 8, 0x01, 0x81, 64),
90 // Interface number, string index, EP Out & EP In address, EP size
91 TUD_MIDI_DESCRIPTOR(2, 6, 0x02, 0x83, 64)
92};
93
94//--------------------------------------------------------------------+
95// String Descriptors
96//--------------------------------------------------------------------+
97
98// Default ffboard names
100 .langId = 0x0409,
101 .manufacturer = "Open FFBoard",
102 .product = "FFBoard " HW_TYPE,
103 // Interfaces start at index 4
104 .interfaces = {"FFBoard CDC", "FFBoard HID","FFBoard MIDI"}
105};
106
107
@ MISC_SUBCLASS_COMMON
Definition tusb_types.h:186
@ TUSB_CLASS_UNSPECIFIED
Definition tusb_types.h:159
TU_ATTR_PACKED_BEGIN TU_ATTR_BIT_FIELD_ORDER_BEGIN struct TU_ATTR_PACKED tusb_desc_device_t
USB Device Descriptor.
@ MISC_PROTOCOL_IAD
Definition tusb_types.h:190
@ TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP
Definition tusb_types.h:218
@ TUSB_DESC_CONFIG_ATT_SELF_POWERED
Definition tusb_types.h:219
@ TUSB_DESC_DEVICE
Definition tusb_types.h:93
const uint8_t usb_cdc_hid_conf_1axis_32b_hs[]
const uint8_t usb_cdc_hid_conf_1axis_32b[]
const uint8_t usb_cdc_conf[]
const uint8_t usb_cdc_hid_conf_2axis[]
const uint8_t usb_cdc_hid_conf_gamepad[]
const uint8_t usb_cdc_midi_conf[]
const tusb_desc_device_t usb_devdesc_ffboard_composite
struct usb_string_desc usb_string_desc_t
const uint8_t usb_cdc_hid_conf_2axis_32b[]
const usb_string_desc_t usb_ffboard_strings_default
const uint8_t usb_cdc_hid_conf_1axis[]