add Auto descriptor endpoint num config to support lpc17xx
CFG_TUD_DESC_*_EPNUM
This commit is contained in:
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
// defined by compiler flags for flexibility
|
// defined by compiler flags for flexibility
|
||||||
#ifndef CFG_TUSB_MCU
|
#ifndef CFG_TUSB_MCU
|
||||||
#error CFG_TUSB_MCU should be defined using compiler flags
|
#error CFG_TUSB_MCU must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX
|
#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX
|
||||||
@@ -93,12 +93,22 @@
|
|||||||
*/
|
*/
|
||||||
#define CFG_TUD_DESC_AUTO 1
|
#define CFG_TUD_DESC_AUTO 1
|
||||||
|
|
||||||
/* USB VID/PID if not defined, tinyusb to use default value
|
/* If USB VID/PID is not defined, tinyusb will use default value
|
||||||
* Note: different class combination e.g CDC and (CDC + MSC) should have different
|
* Note: different class combination e.g CDC and (CDC + MSC) should have different
|
||||||
* PID since Host OS will "remembered" device driver after the first plug */
|
* PID since Host OS will "remembered" device driver after the first plug */
|
||||||
// #define CFG_TUD_DESC_VID 0xCAFE
|
// #define CFG_TUD_DESC_VID 0xCAFE
|
||||||
// #define CFG_TUD_DESC_PID 0x0001
|
// #define CFG_TUD_DESC_PID 0x0001
|
||||||
|
|
||||||
|
// LPC175x_6x's endpoint type (bulk/interrupt/iso) are fixed by its number
|
||||||
|
// Therefor we need to force endpoint number to correct type on lpc17xx
|
||||||
|
#if CFG_TUSB_MCU == OPT_MCU_LPC175X_6X
|
||||||
|
#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 -------------//
|
//------------- CLASS -------------//
|
||||||
#define CFG_TUD_CDC 1
|
#define CFG_TUD_CDC 1
|
||||||
#define CFG_TUD_MSC 1
|
#define CFG_TUD_MSC 1
|
||||||
@@ -114,7 +124,6 @@
|
|||||||
#define CFG_TUD_HID_KEYBOARD_BOOT 1
|
#define CFG_TUD_HID_KEYBOARD_BOOT 1
|
||||||
#define CFG_TUD_HID_MOUSE_BOOT 1
|
#define CFG_TUD_HID_MOUSE_BOOT 1
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// CDC
|
// CDC
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
@@ -71,16 +71,6 @@ TU_VERIFY_STATIC(CFG_TUD_MSC_BUFSIZE < UINT16_MAX, "Size is not correct");
|
|||||||
#error CFG_TUD_MSC_PRODUCT_REV 4-byte string must be defined
|
#error CFG_TUD_MSC_PRODUCT_REV 4-byte string must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO highspeed device is 512
|
|
||||||
#ifndef CFG_TUD_MSC_EPSIZE
|
|
||||||
#if TUD_OPT_HIGH_SPEED
|
|
||||||
#define CFG_TUD_MSC_EPSIZE 512
|
|
||||||
#else
|
|
||||||
#define CFG_TUD_MSC_EPSIZE 64
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@@ -101,7 +101,8 @@ enum
|
|||||||
ITF_NUM_TOTAL
|
ITF_NUM_TOTAL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
ITF_STR_LANGUAGE = 0 ,
|
ITF_STR_LANGUAGE = 0 ,
|
||||||
ITF_STR_MANUFACTURER ,
|
ITF_STR_MANUFACTURER ,
|
||||||
ITF_STR_PRODUCT ,
|
ITF_STR_PRODUCT ,
|
||||||
@@ -133,23 +134,51 @@ enum {
|
|||||||
#define _EP_OUT(x) (x)
|
#define _EP_OUT(x) (x)
|
||||||
|
|
||||||
// CDC
|
// CDC
|
||||||
|
#ifdef CFG_TUD_DESC_CDC_EPNUM_NOTIF
|
||||||
|
#define EP_CDC_NOTIF _EP_IN (CFG_TUD_DESC_CDC_EPNUM_NOTIF)
|
||||||
|
#else
|
||||||
#define EP_CDC_NOTIF _EP_IN ( ITF_NUM_CDC+1 )
|
#define EP_CDC_NOTIF _EP_IN ( ITF_NUM_CDC+1 )
|
||||||
|
#endif
|
||||||
#define EP_CDC_NOTIF_SIZE 8
|
#define EP_CDC_NOTIF_SIZE 8
|
||||||
|
|
||||||
|
#ifdef CFG_TUD_DESC_CDC_EPNUM
|
||||||
|
#define EP_CDC_OUT _EP_OUT( CFG_TUD_DESC_CDC_EPNUM )
|
||||||
|
#define EP_CDC_IN _EP_IN ( CFG_TUD_DESC_CDC_EPNUM )
|
||||||
|
#else
|
||||||
#define EP_CDC_OUT _EP_OUT( ITF_NUM_CDC+2 )
|
#define EP_CDC_OUT _EP_OUT( ITF_NUM_CDC+2 )
|
||||||
#define EP_CDC_IN _EP_IN ( ITF_NUM_CDC+2 )
|
#define EP_CDC_IN _EP_IN ( ITF_NUM_CDC+2 )
|
||||||
|
#endif
|
||||||
|
|
||||||
// Mass Storage
|
// Mass Storage
|
||||||
|
#ifdef CFG_TUD_DESC_MSC_EPNUM
|
||||||
|
#define EP_MSC_OUT _EP_OUT( CFG_TUD_DESC_MSC_EPNUM )
|
||||||
|
#define EP_MSC_IN _EP_IN ( CFG_TUD_DESC_MSC_EPNUM )
|
||||||
|
#else
|
||||||
#define EP_MSC_OUT _EP_OUT( ITF_NUM_MSC+1 )
|
#define EP_MSC_OUT _EP_OUT( ITF_NUM_MSC+1 )
|
||||||
#define EP_MSC_IN _EP_IN ( ITF_NUM_MSC+1 )
|
#define EP_MSC_IN _EP_IN ( ITF_NUM_MSC+1 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TUD_OPT_HIGH_SPEED
|
||||||
|
#define EP_MSC_SIZE 512
|
||||||
|
#else
|
||||||
|
#define EP_MSC_SIZE 64
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// HID Keyboard with boot protocol
|
// HID Keyboard with boot protocol
|
||||||
|
#ifdef CFG_TUD_DESC_HID_KEYBOARD_EPNUM
|
||||||
|
#define EP_HID_KBD_BOOT _EP_IN ( CFG_TUD_DESC_HID_KEYBOARD_EPNUM )
|
||||||
|
#else
|
||||||
#define EP_HID_KBD_BOOT _EP_IN ( ITF_NUM_HID_BOOT_KBD+1 )
|
#define EP_HID_KBD_BOOT _EP_IN ( ITF_NUM_HID_BOOT_KBD+1 )
|
||||||
|
#endif
|
||||||
#define EP_HID_KBD_BOOT_SZ 8
|
#define EP_HID_KBD_BOOT_SZ 8
|
||||||
|
|
||||||
// HID Mouse with boot protocol
|
// HID Mouse with boot protocol
|
||||||
|
#ifdef CFG_TUD_DESC_HID_MOUSE_EPNUM
|
||||||
|
#define EP_HID_MSE_BOOT _EP_IN ( CFG_TUD_DESC_HID_MOUSE_EPNUM )
|
||||||
|
#else
|
||||||
#define EP_HID_MSE_BOOT _EP_IN ( ITF_NUM_HID_BOOT_MSE+1 )
|
#define EP_HID_MSE_BOOT _EP_IN ( ITF_NUM_HID_BOOT_MSE+1 )
|
||||||
|
#endif
|
||||||
#define EP_HID_MSE_BOOT_SZ 8
|
#define EP_HID_MSE_BOOT_SZ 8
|
||||||
|
|
||||||
// HID composite = keyboard + mouse + gamepad + etc ...
|
// HID composite = keyboard + mouse + gamepad + etc ...
|
||||||
@@ -466,7 +495,7 @@ desc_auto_cfg_t const _desc_auto_config_struct =
|
|||||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||||
.bEndpointAddress = EP_MSC_OUT,
|
.bEndpointAddress = EP_MSC_OUT,
|
||||||
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
||||||
.wMaxPacketSize = { .size = CFG_TUD_MSC_EPSIZE},
|
.wMaxPacketSize = { .size = EP_MSC_SIZE},
|
||||||
.bInterval = 1
|
.bInterval = 1
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -476,7 +505,7 @@ desc_auto_cfg_t const _desc_auto_config_struct =
|
|||||||
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
.bDescriptorType = TUSB_DESC_ENDPOINT,
|
||||||
.bEndpointAddress = EP_MSC_IN,
|
.bEndpointAddress = EP_MSC_IN,
|
||||||
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
.bmAttributes = { .xfer = TUSB_XFER_BULK },
|
||||||
.wMaxPacketSize = { .size = CFG_TUD_MSC_EPSIZE},
|
.wMaxPacketSize = { .size = EP_MSC_SIZE},
|
||||||
.bInterval = 1
|
.bInterval = 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -563,7 +592,6 @@ desc_auto_cfg_t const _desc_auto_config_struct =
|
|||||||
#endif // boot mouse
|
#endif // boot mouse
|
||||||
|
|
||||||
#if AUTO_DESC_HID_GENERIC
|
#if AUTO_DESC_HID_GENERIC
|
||||||
|
|
||||||
//------------- HID Generic Multiple report -------------//
|
//------------- HID Generic Multiple report -------------//
|
||||||
.hid_generic =
|
.hid_generic =
|
||||||
{
|
{
|
||||||
@@ -601,7 +629,6 @@ desc_auto_cfg_t const _desc_auto_config_struct =
|
|||||||
.bInterval = 0x0A
|
.bInterval = 0x0A
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // hid generic
|
#endif // hid generic
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user