tusb_descriptors.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**************************************************************************/
  2. /*!
  3. @file tusb_descriptors.h
  4. @author hathach (tinyusb.org)
  5. @section LICENSE
  6. Software License Agreement (BSD License)
  7. Copyright (c) 2013, hathach (tinyusb.org)
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. 1. Redistributions of source code must retain the above copyright
  12. notice, this list of conditions and the following disclaimer.
  13. 2. Redistributions in binary form must reproduce the above copyright
  14. notice, this list of conditions and the following disclaimer in the
  15. documentation and/or other materials provided with the distribution.
  16. 3. Neither the name of the copyright holders nor the
  17. names of its contributors may be used to endorse or promote products
  18. derived from this software without specific prior written permission.
  19. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
  20. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
  23. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
  26. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. This file is part of the tinyusb stack.
  30. */
  31. /**************************************************************************/
  32. #ifndef _TUSB_DESCRIPTORS_H_
  33. #define _TUSB_DESCRIPTORS_H_
  34. #include "tusb.h"
  35. //--------------------------------------------------------------------+
  36. // Descriptors Value (calculated by enabled Classes)
  37. //--------------------------------------------------------------------+
  38. #define CFG_VENDORID 0xCAFE
  39. //#define CFG_PRODUCTID 0x4567 // use auto product id to prevent conflict with pc's driver
  40. // each combination of interfaces need to have a unique productid, as windows will bind & remember device driver after the first plug.
  41. // Auto ProductID layout's Bitmap: (MSB) MassStorage | Generic | Mouse | Key | CDC (LSB)
  42. #ifndef CFG_PRODUCTID
  43. #define PRODUCTID_BITMAP(interface, n) ( (TUSB_CFG_DEVICE_##interface) << (n) )
  44. #define CFG_PRODUCTID (0x4000 | ( PRODUCTID_BITMAP(CDC, 0) | PRODUCTID_BITMAP(HID_KEYBOARD, 1) | \
  45. PRODUCTID_BITMAP(HID_MOUSE, 2) | PRODUCTID_BITMAP(HID_GENERIC, 3) | \
  46. PRODUCTID_BITMAP(MSC, 4) ) )
  47. #endif
  48. #define ITF_NUM_CDC 0
  49. #define ITF_TOTAL 2
  50. //--------------------------------------------------------------------+
  51. // Endpoints Address & Max Packet Size
  52. //--------------------------------------------------------------------+
  53. #define EDPT_IN(x) (0x80 | (x))
  54. #define EDPT_OUT(x) (x)
  55. #define CDC_EDPT_NOTIF EDPT_IN (1)
  56. #define CDC_EDPT_NOTIFICATION_PACKETSIZE 64
  57. #define CDC_EDPT_OUT EDPT_OUT(2)
  58. #define CDC_EDPT_IN EDPT_IN (2)
  59. #define CDC_EDPT_SIZE 64
  60. //--------------------------------------------------------------------+
  61. // CONFIGURATION DESCRIPTOR
  62. //--------------------------------------------------------------------+
  63. typedef struct ATTR_PACKED
  64. {
  65. tusb_desc_configuration_t configuration;
  66. //------------- CDC -------------//
  67. tusb_desc_interface_assoc_t cdc_iad;
  68. //CDC Control Interface
  69. tusb_desc_interface_t cdc_comm_interface;
  70. cdc_desc_func_header_t cdc_header;
  71. cdc_desc_func_call_management_t cdc_call;
  72. cdc_desc_func_acm_t cdc_acm;
  73. cdc_desc_func_union_t cdc_union;
  74. tusb_desc_endpoint_t cdc_endpoint_notification;
  75. //CDC Data Interface
  76. tusb_desc_interface_t cdc_data_interface;
  77. tusb_desc_endpoint_t cdc_endpoint_out;
  78. tusb_desc_endpoint_t cdc_endpoint_in;
  79. } app_descriptor_configuration_t;
  80. #endif