remove auto descriptor and its option CFG_TUD_DESC_AUTO

This commit is contained in:
hathach
2019-04-18 23:59:21 +07:00
parent 307ba23046
commit 23bcf1cc7a
9 changed files with 32 additions and 583 deletions

View File

@@ -94,7 +94,6 @@ LIB_SOURCE += \
hw/bsp/$(BOARD)/board_$(BOARD).c \
src/common/tusb_fifo.c \
src/device/usbd.c \
src/device/usbd_auto_desc.c \
src/device/usbd_control.c \
src/class/msc/msc_device.c \
src/class/cdc/cdc_device.c \

View File

@@ -69,25 +69,6 @@
//--------------------------------------------------------------------
#define CFG_TUD_ENDOINT0_SIZE 64
/*------------- Descriptors -------------*/
/* Enable auto generated descriptor, tinyusb will try its best to create
* descriptor ( device, configuration, hid ) that matches enabled CFG_* in this file
*
* Note: All CFG_TUD_DESC_* are relevant only if CFG_TUD_DESC_AUTO is enabled
*/
#define CFG_TUD_DESC_AUTO 0
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// Therefore we need to force endpoint number to correct type on lpc17xx
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
#define CFG_TUD_DESC_CDC_EPNUM_NOTIF 1
#define CFG_TUD_DESC_CDC_EPNUM 2
#define CFG_TUD_DESC_MSC_EPNUM 5
#define CFG_TUD_DESC_HID_KEYBOARD_EPNUM 4
#define CFG_TUD_DESC_HID_MOUSE_EPNUM 7
#endif
//------------- CLASS -------------//
#define CFG_TUD_CDC 1
#define CFG_TUD_MSC 1
@@ -126,10 +107,9 @@
// HID
//--------------------------------------------------------------------
/* Use the HID_ASCII_TO_KEYCODE lookup if CFG_TUD_HID_KEYBOARD is enabled.
* This will occupies 256 bytes of ROM. It will also enable the use of 2 extra APIs
/* Use the HID_ASCII_TO_KEYCODE lookup
* This will occupies 256 bytes of ROM. It will also enable the use of extra APIs
* - tud_hid_keyboard_send_char()
* - tud_hid_keyboard_send_string()
*/
#define CFG_TUD_HID_ASCII_TO_KEYCODE_LOOKUP 1

View File

@@ -81,27 +81,39 @@ uint8_t const desc_hid_report[] =
};
//------------- Configuration Descriptor -------------//
enum {
#if CFG_TUD_CDC
ITF_NUM_CDC = 0,
ITF_NUM_CDC_DATA,
#endif
enum
{
#if CFG_TUD_CDC
ITF_NUM_CDC = 0,
ITF_NUM_CDC_DATA,
#endif
#if CFG_TUD_MSC
ITF_NUM_MSC,
#endif
#if CFG_TUD_MSC
ITF_NUM_MSC,
#endif
#if CFG_TUD_HID
ITF_NUM_HID,
#endif
#if CFG_TUD_HID
ITF_NUM_HID,
#endif
ITF_NUM_TOTAL
ITF_NUM_TOTAL
};
enum {
enum
{
CONFIG_DESC_LEN = sizeof(tusb_desc_configuration_t) + CFG_TUD_CDC*TUD_CDC_DESC_LEN + CFG_TUD_MSC*TUD_MSC_DESC_LEN + CFG_TUD_HID*TUD_HID_DESC_LEN
};
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X || CFG_TUSB_MCU == OPT_MCU_LPC177X_8X || CFG_TUSB_MCU == OPT_MCU_LPC40XX
// LPC 17xx and 40xx endpoint type (bulk/interrupt/iso) are fixed by its number
// 0 control, 1 In, 2 Bulk, 3 Iso, 4 In etc ...
// Note: since CDC EP ( 1 & 2), HID (4) are spot-on, thus we only need to force
// endpoint number for MSC to 5
#define EPNUM_MSC 0x05
#else
#define EPNUM_MSC 0x03
#endif
uint8_t const desc_configuration[] =
{
// Config: self-powered with remote wakeup support, max power up to 100 mA
@@ -112,7 +124,7 @@ uint8_t const desc_configuration[] =
#endif
#if CFG_TUD_MSC
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, 0x03, 0x83, 64), // highspeed 512
TUD_MSC_DESCRIPTOR(ITF_NUM_MSC, 5, EPNUM_MSC, 0x80 | EPNUM_MSC, 64), // highspeed 512
#endif
#if CFG_TUD_HID
@@ -147,7 +159,6 @@ uint16_t const * const string_desc_arr [] =
};
// tud_desc_set is required by tinyusb stack
// since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr
tud_desc_set_t tud_desc_set =
{
.device = &desc_device,