2014-08-15 17:53:43 +00:00
|
|
|
// Originally Generated from MCHCK Toolkit
|
2016-02-21 22:19:52 +00:00
|
|
|
/* Copyright (c) Jacob Alexander 2014-2016 <haata@kiibohd.com>
|
2014-08-15 17:53:43 +00:00
|
|
|
*
|
|
|
|
* 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 3 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// ----- Local Includes -----
|
|
|
|
|
|
|
|
#include "dfu.desc.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----- Generated Includes -----
|
|
|
|
|
|
|
|
#include <buildvars.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-23 23:16:16 +00:00
|
|
|
// ----- Macros -----
|
|
|
|
|
|
|
|
#define LSB(n) ((n) & 255)
|
|
|
|
#define MSB(n) (((n) >> 8) & 255)
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-15 17:53:43 +00:00
|
|
|
// ----- Structs -----
|
|
|
|
|
|
|
|
static const struct usb_config_1 usb_config_1 = {
|
|
|
|
.config = {
|
|
|
|
.bLength = sizeof(struct usb_desc_config_t),
|
|
|
|
.bDescriptorType = USB_DESC_CONFIG,
|
|
|
|
.wTotalLength = sizeof(struct usb_config_1),
|
|
|
|
.bNumInterfaces = 1,
|
|
|
|
.bConfigurationValue = 1,
|
|
|
|
.iConfiguration = 0,
|
|
|
|
.one = 1,
|
2016-02-21 22:19:52 +00:00
|
|
|
.bMaxPower = 50
|
2014-08-15 17:53:43 +00:00
|
|
|
},
|
|
|
|
.usb_function_0 = {
|
|
|
|
.iface = {
|
|
|
|
.bLength = sizeof(struct usb_desc_iface_t),
|
|
|
|
.bDescriptorType = USB_DESC_IFACE,
|
|
|
|
.bInterfaceNumber = 0,
|
|
|
|
.bAlternateSetting = 0,
|
|
|
|
.bNumEndpoints = 0,
|
|
|
|
.bInterfaceClass = USB_DEV_CLASS_APP,
|
|
|
|
.bInterfaceSubClass = USB_DEV_SUBCLASS_APP_DFU,
|
|
|
|
.bInterfaceProtocol = USB_DEV_PROTO_DFU_DFU,
|
2015-03-08 23:59:34 +00:00
|
|
|
.iInterface = 4
|
2014-08-15 17:53:43 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
.dfu = {
|
|
|
|
.bLength = sizeof(struct dfu_desc_functional),
|
|
|
|
.bDescriptorType = {
|
|
|
|
.id = 0x1,
|
|
|
|
.type_type = USB_DESC_TYPE_CLASS
|
|
|
|
},
|
|
|
|
.will_detach = 1,
|
|
|
|
.manifestation_tolerant = 0,
|
2016-07-24 06:46:37 +00:00
|
|
|
#if defined(_mk20dx128vlf5_) // Kiibohd-dfu / McHCK
|
2015-05-26 00:23:18 +00:00
|
|
|
.can_upload = 0,
|
2016-07-24 06:46:37 +00:00
|
|
|
#elif defined(_mk20dx256vlh7_) // Kiibohd-dfu
|
|
|
|
.can_upload = 1,
|
|
|
|
#endif
|
2014-08-15 17:53:43 +00:00
|
|
|
.can_download = 1,
|
|
|
|
.wDetachTimeOut = 0,
|
|
|
|
.wTransferSize = USB_DFU_TRANSFER_SIZE,
|
|
|
|
.bcdDFUVersion = { .maj = 1, .min = 1 }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usbd_config usbd_config_1 = {
|
|
|
|
.init = init_usb_bootloader,
|
|
|
|
.suspend = NULL,
|
|
|
|
.resume = NULL,
|
|
|
|
.desc = &usb_config_1.config,
|
|
|
|
.function = {&dfu_function},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct usb_desc_dev_t dfu_device_dev_desc = {
|
|
|
|
.bLength = sizeof(struct usb_desc_dev_t),
|
|
|
|
.bDescriptorType = USB_DESC_DEV,
|
|
|
|
.bcdUSB = { .maj = 2 },
|
|
|
|
.bDeviceClass = USB_DEV_CLASS_SEE_IFACE,
|
|
|
|
.bDeviceSubClass = USB_DEV_SUBCLASS_SEE_IFACE,
|
|
|
|
.bDeviceProtocol = USB_DEV_PROTO_SEE_IFACE,
|
|
|
|
.bMaxPacketSize0 = EP0_BUFSIZE,
|
|
|
|
.idVendor = VENDOR_ID,
|
|
|
|
.idProduct = PRODUCT_ID,
|
2016-07-23 23:16:16 +00:00
|
|
|
.bcdDevice = { .maj = MSB( BCD_VERSION ), .min = LSB( BCD_VERSION ) },
|
2014-08-15 17:53:43 +00:00
|
|
|
.iManufacturer = 1,
|
|
|
|
.iProduct = 2,
|
|
|
|
.iSerialNumber = 3,
|
|
|
|
.bNumConfigurations = 1,
|
|
|
|
};
|
|
|
|
|
2016-07-23 23:16:16 +00:00
|
|
|
struct usb_desc_string_t * const dfu_device_str_desc[] = {
|
2014-08-15 17:53:43 +00:00
|
|
|
USB_DESC_STRING_LANG_ENUS,
|
|
|
|
USB_DESC_STRING(STR_MANUFACTURER),
|
|
|
|
USB_DESC_STRING(STR_PRODUCT),
|
|
|
|
USB_DESC_STRING(STR_SERIAL),
|
2015-03-08 23:59:34 +00:00
|
|
|
USB_DESC_STRING(STR_ALTNAME),
|
2014-08-15 17:53:43 +00:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct usbd_device dfu_device = {
|
|
|
|
.dev_desc = &dfu_device_dev_desc,
|
|
|
|
.string_descs = dfu_device_str_desc,
|
|
|
|
.configs = {
|
|
|
|
&usbd_config_1,
|
|
|
|
NULL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|