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.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. .can_upload = 0,
  57. .can_download = 1,
  58. .wDetachTimeOut = 0,
  59. .wTransferSize = USB_DFU_TRANSFER_SIZE,
  60. .bcdDFUVersion = { .maj = 1, .min = 1 }
  61. }
  62. },
  63. };
  64. static const struct usbd_config usbd_config_1 = {
  65. .init = init_usb_bootloader,
  66. .suspend = NULL,
  67. .resume = NULL,
  68. .desc = &usb_config_1.config,
  69. .function = {&dfu_function},
  70. };
  71. static const struct usb_desc_dev_t dfu_device_dev_desc = {
  72. .bLength = sizeof(struct usb_desc_dev_t),
  73. .bDescriptorType = USB_DESC_DEV,
  74. .bcdUSB = { .maj = 2 },
  75. .bDeviceClass = USB_DEV_CLASS_SEE_IFACE,
  76. .bDeviceSubClass = USB_DEV_SUBCLASS_SEE_IFACE,
  77. .bDeviceProtocol = USB_DEV_PROTO_SEE_IFACE,
  78. .bMaxPacketSize0 = EP0_BUFSIZE,
  79. .idVendor = VENDOR_ID,
  80. .idProduct = PRODUCT_ID,
  81. .bcdDevice = { .maj = MSB( BCD_VERSION ), .min = LSB( BCD_VERSION ) },
  82. .iManufacturer = 1,
  83. .iProduct = 2,
  84. .iSerialNumber = 3,
  85. .bNumConfigurations = 1,
  86. };
  87. struct usb_desc_string_t * const dfu_device_str_desc[] = {
  88. USB_DESC_STRING_LANG_ENUS,
  89. USB_DESC_STRING(STR_MANUFACTURER),
  90. USB_DESC_STRING(STR_PRODUCT),
  91. USB_DESC_STRING(STR_SERIAL),
  92. USB_DESC_STRING(STR_ALTNAME),
  93. NULL
  94. };
  95. const struct usbd_device dfu_device = {
  96. .dev_desc = &dfu_device_dev_desc,
  97. .string_descs = dfu_device_str_desc,
  98. .configs = {
  99. &usbd_config_1,
  100. NULL
  101. }
  102. };