Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

dfu.desc.c 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // Originally Generated from MCHCK Toolkit
  2. /* Copyright (c) Jacob Alexander 2014-2016 <[email protected]>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. // ----- Local Includes -----
  18. #include "dfu.desc.h"
  19. // ----- Generated Includes -----
  20. #include <buildvars.h>
  21. // ----- Macros -----
  22. #define LSB(n) ((n) & 255)
  23. #define MSB(n) (((n) >> 8) & 255)
  24. // ----- Structs -----
  25. static const struct usb_config_1 usb_config_1 = {
  26. .config = {
  27. .bLength = sizeof(struct usb_desc_config_t),
  28. .bDescriptorType = USB_DESC_CONFIG,
  29. .wTotalLength = sizeof(struct usb_config_1),
  30. .bNumInterfaces = 1,
  31. .bConfigurationValue = 1,
  32. .iConfiguration = 0,
  33. .one = 1,
  34. .bMaxPower = 50
  35. },
  36. .usb_function_0 = {
  37. .iface = {
  38. .bLength = sizeof(struct usb_desc_iface_t),
  39. .bDescriptorType = USB_DESC_IFACE,
  40. .bInterfaceNumber = 0,
  41. .bAlternateSetting = 0,
  42. .bNumEndpoints = 0,
  43. .bInterfaceClass = USB_DEV_CLASS_APP,
  44. .bInterfaceSubClass = USB_DEV_SUBCLASS_APP_DFU,
  45. .bInterfaceProtocol = USB_DEV_PROTO_DFU_DFU,
  46. .iInterface = 4
  47. },
  48. .dfu = {
  49. .bLength = sizeof(struct dfu_desc_functional),
  50. .bDescriptorType = {
  51. .id = 0x1,
  52. .type_type = USB_DESC_TYPE_CLASS
  53. },
  54. .will_detach = 1,
  55. .manifestation_tolerant = 0,
  56. #if defined(_mk20dx128vlf5_) // Kiibohd-dfu / McHCK
  57. .can_upload = 0,
  58. #elif defined(_mk20dx256vlh7_) // Kiibohd-dfu
  59. .can_upload = 1,
  60. #endif
  61. .can_download = 1,
  62. .wDetachTimeOut = 0,
  63. .wTransferSize = USB_DFU_TRANSFER_SIZE,
  64. .bcdDFUVersion = { .maj = 1, .min = 1 }
  65. }
  66. },
  67. };
  68. static const struct usbd_config usbd_config_1 = {
  69. .init = init_usb_bootloader,
  70. .suspend = NULL,
  71. .resume = NULL,
  72. .desc = &usb_config_1.config,
  73. .function = {&dfu_function},
  74. };
  75. static const struct usb_desc_dev_t dfu_device_dev_desc = {
  76. .bLength = sizeof(struct usb_desc_dev_t),
  77. .bDescriptorType = USB_DESC_DEV,
  78. .bcdUSB = { .maj = 2 },
  79. .bDeviceClass = USB_DEV_CLASS_SEE_IFACE,
  80. .bDeviceSubClass = USB_DEV_SUBCLASS_SEE_IFACE,
  81. .bDeviceProtocol = USB_DEV_PROTO_SEE_IFACE,
  82. .bMaxPacketSize0 = EP0_BUFSIZE,
  83. .idVendor = VENDOR_ID,
  84. .idProduct = PRODUCT_ID,
  85. .bcdDevice = { .maj = MSB( BCD_VERSION ), .min = LSB( BCD_VERSION ) },
  86. .iManufacturer = 1,
  87. .iProduct = 2,
  88. .iSerialNumber = 3,
  89. .bNumConfigurations = 1,
  90. };
  91. struct usb_desc_string_t * const dfu_device_str_desc[] = {
  92. USB_DESC_STRING_LANG_ENUS,
  93. USB_DESC_STRING(STR_MANUFACTURER),
  94. USB_DESC_STRING(STR_PRODUCT),
  95. USB_DESC_STRING(STR_SERIAL),
  96. USB_DESC_STRING(STR_ALTNAME),
  97. NULL
  98. };
  99. const struct usbd_device dfu_device = {
  100. .dev_desc = &dfu_device_dev_desc,
  101. .string_descs = dfu_device_str_desc,
  102. .configs = {
  103. &usbd_config_1,
  104. NULL
  105. }
  106. };