1 // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <string.h> 18 #include "usb_descriptors.h" 19 20 21 /* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug. 22 * Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC. 23 * 24 * Auto ProductID layout's Bitmap: 25 * [MSB] HID | MSC | CDC [LSB] 26 */ 27 #define EPNUM_MSC 0x03 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 //------------- HID Report Descriptor -------------// 33 #if CFG_TUD_HID 34 enum { 35 REPORT_ID_KEYBOARD = 1, 36 REPORT_ID_MOUSE 37 }; 38 #endif 39 40 //------------- Configuration Descriptor -------------// 41 enum { 42 # if CFG_TUD_CDC 43 ITF_NUM_CDC = 0, 44 ITF_NUM_CDC_DATA, 45 # endif 46 47 # if CFG_TUD_MSC 48 ITF_NUM_MSC, 49 # endif 50 51 # if CFG_TUD_HID 52 ITF_NUM_HID, 53 # endif 54 55 ITF_NUM_TOTAL 56 }; 57 58 enum { 59 TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN + CFG_TUD_CDC * TUD_CDC_DESC_LEN + CFG_TUD_MSC * TUD_MSC_DESC_LEN + 60 CFG_TUD_HID * TUD_HID_DESC_LEN 61 }; 62 63 bool tusb_desc_set; 64 void tusb_set_descriptor(tusb_desc_device_t *desc, const char **str_desc); 65 tusb_desc_device_t *tusb_get_active_desc(void); 66 char **tusb_get_active_str_desc(void); 67 void tusb_clear_descriptor(void); 68 69 #ifdef __cplusplus 70 } 71 #endif 72