36 lines
752 B
C
36 lines
752 B
C
#include <usb/usb.h>
|
|
#include <hwo/utils.h>
|
|
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
struct {
|
|
struct usb_descriptor_header header;
|
|
uint16_t lang;
|
|
} LANG =
|
|
{
|
|
header: { 4, DT_STRING },
|
|
lang: 0x0407
|
|
};
|
|
|
|
void* usb_get_descriptor(uint8_t dType,uint8_t index,uint16_t *size)
|
|
{
|
|
switch (dType)
|
|
{
|
|
case DT_DEVICE:
|
|
*size = usb_device.descriptor->descriptor.bLength;
|
|
return &usb_device.descriptor->descriptor;
|
|
case DT_CONFIGURATION:
|
|
*size = usb_device.descriptor->configurations[index]->size;
|
|
return usb_device.descriptor->configurations[index]->descriptor;
|
|
case DT_STRING:
|
|
*size = usb_device.descriptor->strings[index]->bLength;
|
|
return usb_device.descriptor->strings[index];
|
|
default:
|
|
*size = 0;
|
|
return NULL;
|
|
};
|
|
};
|
|
|
|
|