2015-04-09 16:32:04 +00:00
|
|
|
/*
|
|
|
|
Copyright 2011 Jun Wako <wakojun@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-03-28 02:02:25 +00:00
|
|
|
#pragma once
|
2015-04-09 16:32:04 +00:00
|
|
|
|
|
|
|
#include "host_driver.h"
|
2021-02-25 04:54:25 +00:00
|
|
|
#include <usbdrv/usbdrv.h>
|
2015-04-09 16:32:04 +00:00
|
|
|
|
2020-03-26 13:11:32 +00:00
|
|
|
typedef struct usbDescriptorHeader {
|
|
|
|
uchar bLength;
|
|
|
|
uchar bDescriptorType;
|
|
|
|
} __attribute__((packed)) usbDescriptorHeader_t;
|
|
|
|
|
2020-03-28 02:02:25 +00:00
|
|
|
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;
|
|
|
|
|
2020-03-26 13:11:32 +00:00
|
|
|
typedef struct usbStringDescriptor {
|
|
|
|
usbDescriptorHeader_t header;
|
|
|
|
int bString[];
|
|
|
|
} __attribute__((packed)) usbStringDescriptor_t;
|
|
|
|
|
2020-03-28 02:02:25 +00:00
|
|
|
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;
|
2021-01-11 08:46:30 +00:00
|
|
|
|
|
|
|
#ifndef KEYBOARD_SHARED_EP
|
|
|
|
usbInterfaceDescriptor_t keyboardInterface;
|
|
|
|
usbHIDDescriptor_t keyboardHID;
|
|
|
|
usbEndpointDescriptor_t keyboardINEndpoint;
|
|
|
|
#else
|
|
|
|
usbInterfaceDescriptor_t sharedInterface;
|
|
|
|
usbHIDDescriptor_t sharedHID;
|
|
|
|
usbEndpointDescriptor_t sharedINEndpoint;
|
|
|
|
#endif
|
2020-03-28 02:02:25 +00:00
|
|
|
|
2020-05-03 00:25:39 +00:00
|
|
|
#if defined(RAW_ENABLE)
|
2020-03-30 20:15:05 +00:00
|
|
|
usbInterfaceDescriptor_t rawInterface;
|
|
|
|
usbHIDDescriptor_t rawHID;
|
2020-04-05 22:57:28 +00:00
|
|
|
usbEndpointDescriptor_t rawINEndpoint;
|
|
|
|
usbEndpointDescriptor_t rawOUTEndpoint;
|
2020-03-28 02:02:25 +00:00
|
|
|
#endif
|
2020-05-03 00:25:39 +00:00
|
|
|
|
2022-03-18 21:37:23 +00:00
|
|
|
#if defined(XAP_ENABLE)
|
|
|
|
usbInterfaceDescriptor_t xapInterface;
|
|
|
|
usbHIDDescriptor_t xapHID;
|
|
|
|
usbEndpointDescriptor_t xapINEndpoint;
|
|
|
|
usbEndpointDescriptor_t xapOUTEndpoint;
|
|
|
|
#endif
|
|
|
|
|
2021-01-11 08:46:30 +00:00
|
|
|
#if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
|
|
|
|
usbInterfaceDescriptor_t sharedInterface;
|
|
|
|
usbHIDDescriptor_t sharedHID;
|
|
|
|
usbEndpointDescriptor_t sharedINEndpoint;
|
2020-05-14 00:24:18 +00:00
|
|
|
#endif
|
|
|
|
|
2020-05-03 00:25:39 +00:00
|
|
|
#if defined(CONSOLE_ENABLE)
|
|
|
|
usbInterfaceDescriptor_t consoleInterface;
|
|
|
|
usbHIDDescriptor_t consoleHID;
|
|
|
|
usbEndpointDescriptor_t consoleINEndpoint;
|
|
|
|
usbEndpointDescriptor_t consoleOUTEndpoint;
|
|
|
|
#endif
|
2020-03-28 02:02:25 +00:00
|
|
|
} __attribute__((packed)) usbConfigurationDescriptor_t;
|
|
|
|
|
2020-03-26 13:11:32 +00:00
|
|
|
#define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1))
|
|
|
|
|
2021-02-25 04:54:25 +00:00
|
|
|
extern bool vusb_suspended;
|
|
|
|
|
2015-04-09 16:32:04 +00:00
|
|
|
host_driver_t *vusb_driver(void);
|
2019-08-30 18:19:03 +00:00
|
|
|
void vusb_transfer_keyboard(void);
|