Merge branch 'master' into hid_joystick
This commit is contained in:
commit
a80ea8b7cc
284 changed files with 9404 additions and 2408 deletions
|
@ -206,10 +206,17 @@ void main_subtask_usb_extra_device(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef RAW_ENABLE
|
||||
void main_subtask_raw(void) { udi_hid_raw_receive_report(); }
|
||||
#endif
|
||||
|
||||
void main_subtasks(void) {
|
||||
main_subtask_usb_state();
|
||||
main_subtask_power_check();
|
||||
main_subtask_usb_extra_device();
|
||||
#ifdef RAW_ENABLE
|
||||
main_subtask_raw();
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
|
|
@ -146,6 +146,7 @@
|
|||
#ifdef RAW
|
||||
# define UDI_HID_RAW_ENABLE_EXT() main_raw_enable()
|
||||
# define UDI_HID_RAW_DISABLE_EXT() main_raw_disable()
|
||||
# define UDI_HID_RAW_RECEIVE(buffer, len) main_raw_receive(buffer, len)
|
||||
#endif
|
||||
|
||||
//@}
|
||||
|
|
|
@ -18,6 +18,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "samd51j18a.h"
|
||||
#include "conf_usb.h"
|
||||
#include "udd.h"
|
||||
#ifdef RAW
|
||||
# include "raw_hid.h"
|
||||
#endif
|
||||
|
||||
uint8_t keyboard_protocol = 1;
|
||||
|
||||
|
@ -89,4 +92,6 @@ bool main_raw_enable(void) {
|
|||
}
|
||||
|
||||
void main_raw_disable(void) { main_b_raw_enable = false; }
|
||||
|
||||
void main_raw_receive(uint8_t *buffer, uint8_t len) { raw_hid_receive(buffer, len); }
|
||||
#endif
|
||||
|
|
|
@ -640,6 +640,9 @@ static bool udi_hid_raw_b_report_trans_ongoing;
|
|||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_raw_report_trans[UDI_HID_RAW_REPORT_SIZE];
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
static uint8_t udi_hid_raw_report_recv[UDI_HID_RAW_REPORT_SIZE];
|
||||
|
||||
COMPILER_WORD_ALIGNED
|
||||
UDC_DESC_STORAGE udi_hid_raw_report_desc_t udi_hid_raw_report_desc = {{
|
||||
0x06, 0x60, 0xFF, // Usage Page (Vendor Defined)
|
||||
|
@ -663,6 +666,7 @@ static bool udi_hid_raw_setreport(void);
|
|||
static void udi_hid_raw_setreport_valid(void);
|
||||
|
||||
static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep);
|
||||
static void udi_hid_raw_report_rcvd(udd_ep_status_t status, iram_size_t nb_rcvd, udd_ep_id_t ep);
|
||||
|
||||
bool udi_hid_raw_enable(void) {
|
||||
// Initialize internal values
|
||||
|
@ -719,7 +723,30 @@ static void udi_hid_raw_report_sent(udd_ep_status_t status, iram_size_t nb_sent,
|
|||
|
||||
static void udi_hid_raw_setreport_valid(void) {}
|
||||
|
||||
#endif // RAW
|
||||
void raw_hid_send(uint8_t *data, uint8_t length) {
|
||||
if (main_b_raw_enable && !udi_hid_raw_b_report_trans_ongoing && length == UDI_HID_RAW_REPORT_SIZE) {
|
||||
memcpy(udi_hid_raw_report, data, UDI_HID_RAW_REPORT_SIZE);
|
||||
udi_hid_raw_send_report();
|
||||
}
|
||||
}
|
||||
|
||||
bool udi_hid_raw_receive_report(void) {
|
||||
if (!main_b_raw_enable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return udd_ep_run(UDI_HID_RAW_EP_OUT | USB_EP_DIR_OUT, false, udi_hid_raw_report_recv, UDI_HID_RAW_REPORT_SIZE, udi_hid_raw_report_rcvd);
|
||||
}
|
||||
|
||||
static void udi_hid_raw_report_rcvd(udd_ep_status_t status, iram_size_t nb_rcvd, udd_ep_id_t ep) {
|
||||
UNUSED(ep);
|
||||
|
||||
if (status == UDD_EP_TRANSFER_OK && nb_rcvd == UDI_HID_RAW_REPORT_SIZE) {
|
||||
UDI_HID_RAW_RECEIVE(udi_hid_raw_report_recv, UDI_HID_RAW_REPORT_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
#endif //RAW
|
||||
|
||||
//********************************************************************************************
|
||||
// CON
|
||||
|
|
|
@ -111,6 +111,7 @@ bool udi_hid_mou_send_report(void);
|
|||
#ifdef RAW
|
||||
extern UDC_DESC_STORAGE udi_api_t udi_api_hid_raw;
|
||||
bool udi_hid_raw_send_report(void);
|
||||
bool udi_hid_raw_receive_report(void);
|
||||
#endif // RAW
|
||||
|
||||
//@}
|
||||
|
|
|
@ -97,6 +97,7 @@ void main_mou_disable(void);
|
|||
extern volatile bool main_b_raw_enable;
|
||||
bool main_raw_enable(void);
|
||||
void main_raw_disable(void);
|
||||
void main_raw_receive(uint8_t *buffer, uint8_t len);
|
||||
#endif // RAW
|
||||
|
||||
#endif // _MAIN_H_
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
#include "timer.h"
|
||||
#include "uart.h"
|
||||
#include "debug.h"
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
# include "sleep_led.h"
|
||||
#endif
|
||||
|
||||
#define UART_BAUD_RATE 115200
|
||||
|
||||
|
@ -59,6 +62,9 @@ int main(void) {
|
|||
initForUsbConnectivity();
|
||||
|
||||
keyboard_init();
|
||||
#ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_init();
|
||||
#endif
|
||||
|
||||
debug("main loop\n");
|
||||
while (1) {
|
||||
|
@ -67,10 +73,16 @@ int main(void) {
|
|||
suspended = false;
|
||||
usbSofCount = 0;
|
||||
last_timer = timer_read();
|
||||
# ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_disable();
|
||||
# endif
|
||||
} else {
|
||||
// Suspend when no SOF in 3ms-10ms(7.1.7.4 Suspending of USB1.1)
|
||||
if (timer_elapsed(last_timer) > 5) {
|
||||
suspended = true;
|
||||
# ifdef SLEEP_LED_ENABLE
|
||||
sleep_led_enable();
|
||||
# endif
|
||||
/*
|
||||
uart_putchar('S');
|
||||
_delay_ms(1);
|
||||
|
|
|
@ -335,6 +335,10 @@ const PROGMEM uchar mouse_extra_hid_report[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifndef SERIAL_NUMBER
|
||||
# define SERIAL_NUMBER 0
|
||||
#endif
|
||||
|
||||
#ifndef USB_MAX_POWER_CONSUMPTION
|
||||
# define USB_MAX_POWER_CONSUMPTION 500
|
||||
#endif
|
||||
|
@ -344,101 +348,175 @@ const PROGMEM uchar mouse_extra_hid_report[] = {
|
|||
# define USB_POLLING_INTERVAL_MS 1
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
const PROGMEM usbStringDescriptor_t usbStringDescriptorZero = {
|
||||
.header = {
|
||||
.bLength = USB_STRING_LEN(1),
|
||||
.bDescriptorType = USBDESCR_STRING
|
||||
},
|
||||
.bString = {0x0409} // US English
|
||||
};
|
||||
|
||||
const PROGMEM usbStringDescriptor_t usbStringDescriptorManufacturer = {
|
||||
.header = {
|
||||
.bLength = USB_STRING_LEN(sizeof(STR(MANUFACTURER)) - 1),
|
||||
.bDescriptorType = USBDESCR_STRING
|
||||
},
|
||||
.bString = LSTR(MANUFACTURER)
|
||||
};
|
||||
|
||||
const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = {
|
||||
.header = {
|
||||
.bLength = USB_STRING_LEN(sizeof(STR(PRODUCT)) - 1),
|
||||
.bDescriptorType = USBDESCR_STRING
|
||||
},
|
||||
.bString = LSTR(PRODUCT)
|
||||
};
|
||||
|
||||
const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = {
|
||||
.header = {
|
||||
.bLength = USB_STRING_LEN(sizeof(STR(SERIAL_NUMBER)) - 1),
|
||||
.bDescriptorType = USBDESCR_STRING
|
||||
},
|
||||
.bString = LSTR(SERIAL_NUMBER)
|
||||
};
|
||||
|
||||
#if USB_CFG_DESCR_PROPS_DEVICE
|
||||
/*
|
||||
* Descriptor for compite device: Keyboard + Mouse
|
||||
*
|
||||
* contains: device, interface, HID and endpoint descriptors
|
||||
* Device descriptor
|
||||
*/
|
||||
#if USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
const PROGMEM char usbDescriptorConfiguration[] = {
|
||||
/* USB configuration descriptor */
|
||||
9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
|
||||
USBDESCR_CONFIG, /* descriptor type */
|
||||
# if defined (MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
59, // 9 + (9 + 9 + 7) + (9 + 9 + 7)
|
||||
#else
|
||||
34, // 9 + (9 + 9 + 7)
|
||||
# endif
|
||||
0,
|
||||
// 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT3 + 9, 0,
|
||||
/* total length of data returned (including inlined descriptors) */
|
||||
# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
2, /* number of interfaces in this configuration */
|
||||
# else
|
||||
1,
|
||||
const PROGMEM usbDeviceDescriptor_t usbDeviceDescriptor = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbDeviceDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_DEVICE
|
||||
},
|
||||
.bcdUSB = 0x0110,
|
||||
.bDeviceClass = USB_CFG_DEVICE_CLASS,
|
||||
.bDeviceSubClass = USB_CFG_DEVICE_SUBCLASS,
|
||||
.bDeviceProtocol = 0x00,
|
||||
.bMaxPacketSize0 = 8,
|
||||
.idVendor = VENDOR_ID,
|
||||
.idProduct = PRODUCT_ID,
|
||||
.bcdDevice = DEVICE_VER,
|
||||
.iManufacturer = 0x01,
|
||||
.iProduct = 0x02,
|
||||
.iSerialNumber = 0x03,
|
||||
.bNumConfigurations = 1
|
||||
};
|
||||
#endif
|
||||
1, /* index of this configuration */
|
||||
0, /* configuration name string index */
|
||||
# if USB_CFG_IS_SELF_POWERED
|
||||
(1 << 7) | USBATTR_SELFPOWER, /* attributes */
|
||||
|
||||
#if USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
/*
|
||||
* Configuration descriptors
|
||||
*/
|
||||
const PROGMEM usbConfigurationDescriptor_t usbConfigurationDescriptor = {
|
||||
.header = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbConfigurationDescriptorHeader_t),
|
||||
.bDescriptorType = USBDESCR_CONFIG
|
||||
},
|
||||
.wTotalLength = sizeof(usbConfigurationDescriptor_t),
|
||||
# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
.bNumInterfaces = 2,
|
||||
# else
|
||||
(1 << 7), /* attributes */
|
||||
.bNumInterfaces = 1,
|
||||
# endif
|
||||
USB_MAX_POWER_CONSUMPTION / 2, /* max USB current in 2mA units */
|
||||
.bConfigurationValue = 0x01,
|
||||
.iConfiguration = 0x00,
|
||||
# if USB_CFG_IS_SELF_POWERED
|
||||
.bmAttributes = (1 << 7) | USBATTR_SELFPOWER,
|
||||
# else
|
||||
.bmAttributes = (1 << 7),
|
||||
# endif
|
||||
.bMaxPower = USB_MAX_POWER_CONSUMPTION / 2
|
||||
},
|
||||
|
||||
/*
|
||||
* Keyboard interface
|
||||
* Keyboard
|
||||
*/
|
||||
/* Interface descriptor */
|
||||
9, /* sizeof(usbDescrInterface): length of descriptor in bytes */
|
||||
USBDESCR_INTERFACE, /* descriptor type */
|
||||
0, /* index of this interface */
|
||||
0, /* alternate setting for this interface */
|
||||
USB_CFG_HAVE_INTRIN_ENDPOINT, /* endpoints excl 0: number of endpoint descriptors to follow */
|
||||
USB_CFG_INTERFACE_CLASS, USB_CFG_INTERFACE_SUBCLASS, USB_CFG_INTERFACE_PROTOCOL, 0, /* string index for interface */
|
||||
/* HID descriptor */
|
||||
9, /* sizeof(usbDescrHID): length of descriptor in bytes */
|
||||
USBDESCR_HID, /* descriptor type: HID */
|
||||
0x01, 0x01, /* BCD representation of HID version */
|
||||
0x00, /* target country code */
|
||||
0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */
|
||||
0x22, /* descriptor type: report */
|
||||
sizeof(keyboard_hid_report), 0, /* total length of report descriptor */
|
||||
/* Endpoint descriptor */
|
||||
# if USB_CFG_HAVE_INTRIN_ENDPOINT /* endpoint descriptor for endpoint 1 */
|
||||
7, /* sizeof(usbDescrEndpoint) */
|
||||
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
|
||||
(char)0x81, /* IN endpoint number 1 */
|
||||
0x03, /* attrib: Interrupt endpoint */
|
||||
8, 0, /* maximum packet size */
|
||||
USB_POLLING_INTERVAL_MS, /* in ms */
|
||||
.keyboardInterface = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbInterfaceDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_INTERFACE
|
||||
},
|
||||
.bInterfaceNumber = 0,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = USB_CFG_HAVE_INTRIN_ENDPOINT,
|
||||
.bInterfaceClass = USB_CFG_INTERFACE_CLASS,
|
||||
.bInterfaceSubClass = USB_CFG_INTERFACE_SUBCLASS,
|
||||
.bInterfaceProtocol = USB_CFG_INTERFACE_PROTOCOL,
|
||||
.iInterface = 0x00
|
||||
},
|
||||
.keyboardHID = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbHIDDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_HID
|
||||
},
|
||||
.bcdHID = 0x0101,
|
||||
.bCountryCode = 0x00,
|
||||
.bNumDescriptors = 1,
|
||||
.bDescriptorType = USBDESCR_HID_REPORT,
|
||||
.wDescriptorLength = sizeof(keyboard_hid_report)
|
||||
},
|
||||
# ifdef USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
.keyboardINEndpoint = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbEndpointDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_ENDPOINT
|
||||
},
|
||||
.bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | 1),
|
||||
.bmAttributes = 0x03,
|
||||
.wMaxPacketSize = 8,
|
||||
.bInterval = USB_POLLING_INTERVAL_MS
|
||||
},
|
||||
# endif
|
||||
|
||||
# if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
/*
|
||||
* Mouse/extrakeys interface
|
||||
* Mouse/Extrakeys
|
||||
*/
|
||||
/* Interface descriptor */
|
||||
9, /* sizeof(usbDescrInterface): length of descriptor in bytes */
|
||||
USBDESCR_INTERFACE, /* descriptor type */
|
||||
1, /* index of this interface */
|
||||
0, /* alternate setting for this interface */
|
||||
USB_CFG_HAVE_INTRIN_ENDPOINT3, /* endpoints excl 0: number of endpoint descriptors to follow */
|
||||
0x03, /* CLASS: HID */
|
||||
0, /* SUBCLASS: none */
|
||||
0, /* PROTOCOL: none */
|
||||
0, /* string index for interface */
|
||||
/* HID descriptor */
|
||||
9, /* sizeof(usbDescrHID): length of descriptor in bytes */
|
||||
USBDESCR_HID, /* descriptor type: HID */
|
||||
0x01, 0x01, /* BCD representation of HID version */
|
||||
0x00, /* target country code */
|
||||
0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */
|
||||
0x22, /* descriptor type: report */
|
||||
sizeof(mouse_extra_hid_report), 0, /* total length of report descriptor */
|
||||
# if USB_CFG_HAVE_INTRIN_ENDPOINT3 /* endpoint descriptor for endpoint 3 */
|
||||
/* Endpoint descriptor */
|
||||
7, /* sizeof(usbDescrEndpoint) */
|
||||
USBDESCR_ENDPOINT, /* descriptor type = endpoint */
|
||||
(char)(0x80 | USB_CFG_EP3_NUMBER), /* IN endpoint number 3 */
|
||||
0x03, /* attrib: Interrupt endpoint */
|
||||
8, 0, /* maximum packet size */
|
||||
USB_POLLING_INTERVAL_MS, /* in ms */
|
||||
.mouseExtraInterface = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbInterfaceDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_INTERFACE
|
||||
},
|
||||
.bInterfaceNumber = 1,
|
||||
.bAlternateSetting = 0x00,
|
||||
.bNumEndpoints = USB_CFG_HAVE_INTRIN_ENDPOINT3,
|
||||
.bInterfaceClass = 0x03,
|
||||
.bInterfaceSubClass = 0x00,
|
||||
.bInterfaceProtocol = 0x00,
|
||||
.iInterface = 0x00
|
||||
},
|
||||
.mouseExtraHID = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbHIDDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_HID
|
||||
},
|
||||
.bcdHID = 0x0101,
|
||||
.bCountryCode = 0x00,
|
||||
.bNumDescriptors = 1,
|
||||
.bDescriptorType = USBDESCR_HID_REPORT,
|
||||
.wDescriptorLength = sizeof(mouse_extra_hid_report)
|
||||
},
|
||||
# if USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
.mouseExtraINEndpoint = {
|
||||
.header = {
|
||||
.bLength = sizeof(usbEndpointDescriptor_t),
|
||||
.bDescriptorType = USBDESCR_ENDPOINT
|
||||
},
|
||||
.bEndpointAddress = (USBRQ_DIR_DEVICE_TO_HOST | USB_CFG_EP3_NUMBER),
|
||||
.bmAttributes = 0x03,
|
||||
.wMaxPacketSize = 8,
|
||||
.bInterval = USB_POLLING_INTERVAL_MS
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
};
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
|
||||
usbMsgLen_t len = 0;
|
||||
|
||||
|
@ -451,22 +529,48 @@ USB_PUBLIC usbMsgLen_t usbFunctionDescriptor(struct usbRequest *rq) {
|
|||
debug_hex16(rq->wLength.word); debug("\n");
|
||||
*/
|
||||
switch (rq->wValue.bytes[1]) {
|
||||
#if USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
case USBDESCR_CONFIG:
|
||||
usbMsgPtr = (unsigned char *)usbDescriptorConfiguration;
|
||||
len = sizeof(usbDescriptorConfiguration);
|
||||
#if USB_CFG_DESCR_PROPS_DEVICE
|
||||
case USBDESCR_DEVICE:
|
||||
usbMsgPtr = (unsigned char *)&usbDeviceDescriptor;
|
||||
len = sizeof(usbDeviceDescriptor_t);
|
||||
break;
|
||||
#endif
|
||||
#if USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
case USBDESCR_CONFIG:
|
||||
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor;
|
||||
len = sizeof(usbConfigurationDescriptor_t);
|
||||
break;
|
||||
#endif
|
||||
case USBDESCR_STRING:
|
||||
switch (rq->wValue.bytes[0]) {
|
||||
case 0:
|
||||
usbMsgPtr = (unsigned char *)&usbStringDescriptorZero;
|
||||
len = usbStringDescriptorZero.header.bLength;
|
||||
break;
|
||||
case 1: // iManufacturer
|
||||
usbMsgPtr = (unsigned char *)&usbStringDescriptorManufacturer;
|
||||
len = usbStringDescriptorManufacturer.header.bLength;
|
||||
break;
|
||||
case 2: // iProduct
|
||||
usbMsgPtr = (unsigned char *)&usbStringDescriptorProduct;
|
||||
len = usbStringDescriptorProduct.header.bLength;
|
||||
break;
|
||||
case 3: // iSerialNumber
|
||||
usbMsgPtr = (unsigned char *)&usbStringDescriptorSerial;
|
||||
len = usbStringDescriptorSerial.header.bLength;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case USBDESCR_HID:
|
||||
switch (rq->wValue.bytes[0]) {
|
||||
case 0:
|
||||
usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + 9);
|
||||
len = 9;
|
||||
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.keyboardHID;
|
||||
len = sizeof(usbHIDDescriptor_t);
|
||||
break;
|
||||
#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
case 1:
|
||||
usbMsgPtr = (unsigned char *)(usbDescriptorConfiguration + 9 + (9 + 9 + 7) + 9);
|
||||
len = 9;
|
||||
usbMsgPtr = (unsigned char *)&usbConfigurationDescriptor.mouseExtraHID;
|
||||
len = sizeof(usbHIDDescriptor_t);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -15,12 +15,92 @@ You should have received a copy of the GNU General Public License
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef VUSB_H
|
||||
#define VUSB_H
|
||||
#pragma once
|
||||
|
||||
#include "host_driver.h"
|
||||
|
||||
typedef struct usbDescriptorHeader {
|
||||
uchar bLength;
|
||||
uchar bDescriptorType;
|
||||
} __attribute__((packed)) usbDescriptorHeader_t;
|
||||
|
||||
typedef struct usbDeviceDescriptor {
|
||||
usbDescriptorHeader_t header;
|
||||
unsigned bcdUSB;
|
||||
uchar bDeviceClass;
|
||||
uchar bDeviceSubClass;
|
||||
uchar bDeviceProtocol;
|
||||
uchar bMaxPacketSize0;
|
||||
unsigned idVendor;
|
||||
unsigned idProduct;
|
||||
unsigned bcdDevice;
|
||||
uchar iManufacturer;
|
||||
uchar iProduct;
|
||||
uchar iSerialNumber;
|
||||
uchar bNumConfigurations;
|
||||
} __attribute__((packed)) usbDeviceDescriptor_t;
|
||||
|
||||
typedef struct usbConfigurationDescriptorHeader {
|
||||
usbDescriptorHeader_t header;
|
||||
unsigned wTotalLength;
|
||||
uchar bNumInterfaces;
|
||||
uchar bConfigurationValue;
|
||||
uchar iConfiguration;
|
||||
uchar bmAttributes;
|
||||
uchar bMaxPower;
|
||||
} __attribute__((packed)) usbConfigurationDescriptorHeader_t;
|
||||
|
||||
typedef struct usbStringDescriptor {
|
||||
usbDescriptorHeader_t header;
|
||||
int bString[];
|
||||
} __attribute__((packed)) usbStringDescriptor_t;
|
||||
|
||||
typedef struct usbInterfaceDescriptor {
|
||||
usbDescriptorHeader_t header;
|
||||
uchar bInterfaceNumber;
|
||||
uchar bAlternateSetting;
|
||||
uchar bNumEndpoints;
|
||||
uchar bInterfaceClass;
|
||||
uchar bInterfaceSubClass;
|
||||
uchar bInterfaceProtocol;
|
||||
uchar iInterface;
|
||||
} __attribute__((packed)) usbInterfaceDescriptor_t;
|
||||
|
||||
typedef struct usbEndpointDescriptor {
|
||||
usbDescriptorHeader_t header;
|
||||
uchar bEndpointAddress;
|
||||
uchar bmAttributes;
|
||||
unsigned wMaxPacketSize;
|
||||
uchar bInterval;
|
||||
} __attribute__((packed)) usbEndpointDescriptor_t;
|
||||
|
||||
typedef struct usbHIDDescriptor {
|
||||
usbDescriptorHeader_t header;
|
||||
unsigned bcdHID;
|
||||
uchar bCountryCode;
|
||||
uchar bNumDescriptors;
|
||||
uchar bDescriptorType;
|
||||
unsigned wDescriptorLength;
|
||||
} __attribute__((packed)) usbHIDDescriptor_t;
|
||||
|
||||
typedef struct usbConfigurationDescriptor {
|
||||
usbConfigurationDescriptorHeader_t header;
|
||||
usbInterfaceDescriptor_t keyboardInterface;
|
||||
usbHIDDescriptor_t keyboardHID;
|
||||
#ifdef USB_CFG_HAVE_INTRIN_ENDPOINT
|
||||
usbEndpointDescriptor_t keyboardINEndpoint;
|
||||
#endif
|
||||
|
||||
#if defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)
|
||||
usbInterfaceDescriptor_t mouseExtraInterface;
|
||||
usbHIDDescriptor_t mouseExtraHID;
|
||||
# ifdef USB_CFG_HAVE_INTRIN_ENDPOINT3
|
||||
usbEndpointDescriptor_t mouseExtraINEndpoint;
|
||||
# endif
|
||||
#endif
|
||||
} __attribute__((packed)) usbConfigurationDescriptor_t;
|
||||
|
||||
#define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1))
|
||||
|
||||
host_driver_t *vusb_driver(void);
|
||||
void vusb_transfer_keyboard(void);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue