Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 9d0b268

Browse files
committed
Add Binary Object Store (BOS) descriptor support.
1 parent b06923b commit 9d0b268

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

firmware/library/include/fx2usb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ struct usb_descriptor_set {
160160
usb_configuration_set_c *configs;
161161
uint8_t string_count;
162162
usb_ascii_string_c *strings;
163+
uint8_t capability_count;
164+
usb_desc_generic_c *capabilities;
163165
};
164166

165167
typedef __code const struct usb_descriptor_set

firmware/library/include/usb.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ enum usb_descriptor {
5454
USB_DESC_DEVICE_QUALIFIER = 6,
5555
USB_DESC_OTHER_SPEED_CONFIGURATION = 7,
5656
USB_DESC_INTERFACE_POWER = 8,
57+
USB_DESC_BINARY_OBJECT_STORE = 15,
58+
USB_DESC_DEVICE_CAPABILITY = 16,
59+
};
60+
61+
enum usb_device_capability {
62+
USB_DEV_CAP_PLATFORM = 5,
5763
};
5864

5965
enum usb_feature {
@@ -232,4 +238,14 @@ struct usb_desc_string {
232238
typedef __code const struct usb_desc_string
233239
usb_desc_string_c;
234240

241+
struct usb_desc_binary_object_store {
242+
uint8_t bLength;
243+
uint8_t bDescriptorType;
244+
uint16_t wTotalLength;
245+
uint8_t bNumDeviceCaps;
246+
};
247+
248+
typedef __code const struct usb_desc_binary_object_store
249+
usb_binary_object_store_c;
250+
235251
#endif

firmware/library/usb.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ void usb_serve_descriptor(usb_descriptor_set_c *set,
210210
*buf++ = 0;
211211
scratch[0] += 2;
212212
}
213+
} else if(type == USB_DESC_BINARY_OBJECT_STORE && index == 0) {
214+
__xdata struct usb_desc_binary_object_store *bos_desc =
215+
(__xdata struct usb_desc_binary_object_store *)buf;
216+
bos_desc->bLength = sizeof(struct usb_desc_binary_object_store);
217+
bos_desc->bDescriptorType = USB_DESC_BINARY_OBJECT_STORE;
218+
// bos_desc->wTotalLength filled in later
219+
bos_desc->bNumDeviceCaps = set->capability_count;
220+
buf += bos_desc->bLength;
221+
for(uint8_t i = 0; i < bos_desc->bNumDeviceCaps; i++) {
222+
APPEND(&set->capabilities[i]);
223+
}
224+
bos_desc->wTotalLength = (uint16_t)(buf - scratch);
225+
SETUP_EP0_IN_DATA(scratch, bos_desc->wTotalLength);
226+
return;
213227
} else {
214228
STALL_EP0();
215229
return;

0 commit comments

Comments
 (0)