diff --git a/class/cdc/usbh_cdc_acm.h b/class/cdc/usbh_cdc_acm.h index 6e5c8a10..50117462 100644 --- a/class/cdc/usbh_cdc_acm.h +++ b/class/cdc/usbh_cdc_acm.h @@ -41,8 +41,6 @@ struct usbh_cdc_acm { #endif }; -extern const struct usbh_class_info cdc_acm_class_info; - #ifdef __cplusplus extern "C" { #endif diff --git a/class/hid/usbh_hid.h b/class/hid/usbh_hid.h index 6c03b75e..cc65641e 100644 --- a/class/hid/usbh_hid.h +++ b/class/hid/usbh_hid.h @@ -34,9 +34,6 @@ struct usbh_hid { usbh_epinfo_t intout; /* INTR OUT endpoint */ }; -extern const struct usbh_class_info hid_keyboard_class_info; -extern const struct usbh_class_info hid_mouse_class_info; - #ifdef __cplusplus extern "C" { #endif diff --git a/class/hub/usbh_hub.h b/class/hub/usbh_hub.h index 152eb376..fd4d04f3 100644 --- a/class/hub/usbh_hub.h +++ b/class/hub/usbh_hub.h @@ -29,7 +29,6 @@ /* Maximum size of an interrupt IN transfer */ #define USBH_HUB_INTIN_BUFSIZE ((USBH_HUB_MAX_PORTS + 8) >> 3) -extern const struct usbh_class_info hub_class_info; extern usb_slist_t hub_class_head; #ifdef __cplusplus diff --git a/class/msc/usbh_msc.h b/class/msc/usbh_msc.h index 1cd26015..066ddf33 100644 --- a/class/msc/usbh_msc.h +++ b/class/msc/usbh_msc.h @@ -38,8 +38,6 @@ struct usbh_msc { uint16_t blocksize; /* Block size of USB mass storage device */ }; -extern const struct usbh_class_info msc_class_info; - int usbh_msc_scsi_write10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors); int usbh_msc_scsi_read10(struct usbh_msc *msc_class, uint32_t start_sector, const uint8_t *buffer, uint32_t nsectors); diff --git a/core/usbh_core.c b/core/usbh_core.c index 23468456..93cd1bf3 100644 --- a/core/usbh_core.c +++ b/core/usbh_core.c @@ -21,13 +21,27 @@ * */ #include "usbh_core.h" -#include "usbh_cdc_acm.h" -#include "usbh_hid.h" -#include "usbh_msc.h" struct usbh_class_info *usbh_class_info_table_begin = NULL; struct usbh_class_info *usbh_class_info_table_end = NULL; +#ifdef CONFIG_USBHOST_CLASS_DRIVER_EXPORT_DISBALE +extern const struct usbh_class_info cdc_acm_class_info; +extern const struct usbh_class_info hid_keyboard_class_info; +extern const struct usbh_class_info hid_mouse_class_info; +extern const struct usbh_class_info msc_class_info; +extern const struct usbh_class_info hub_class_info; +const struct usbh_class_info *class_info_table[] = { + &cdc_acm_class_info, + &hid_keyboard_class_info, + &hid_mouse_class_info, + &msc_class_info, +#ifdef CONFIG_USBHOST_HUB + &hub_class_info, +#endif +}; +#endif + static const char *speed_table[] = { "error speed", "low speed", "full speed", "high speed" }; static const struct usbh_class_driver *usbh_find_class_driver(uint8_t class, uint8_t subcalss, uint8_t protocol, uint16_t vid, uint16_t pid); @@ -813,7 +827,8 @@ int usbh_initialize(void) memset(&usbh_core_cfg, 0, sizeof(struct usbh_core_priv)); -#ifdef __ARMCC_VERSION /* ARM C Compiler */ +#ifndef CONFIG_USBHOST_CLASS_DRIVER_EXPORT_DISBALE +#ifdef __ARMCC_VERSION /* ARM C Compiler */ extern const int usbh_class_info$$Base; extern const int usbh_class_info$$Limit; usbh_class_info_table_begin = (struct usbh_class_info *)&usbh_class_info$$Base; @@ -824,6 +839,11 @@ int usbh_initialize(void) usbh_class_info_table_begin = (struct usbh_class_info *)&_usbh_class_info_start; usbh_class_info_table_end = (struct usbh_class_info *)&_usbh_class_info_end; #endif +#else + usbh_class_info_table_begin = (struct usbh_class_info *)class_info_table[0]; + usbh_class_info_table_end = (struct usbh_class_info *)(class_info_table[0] + (sizeof(class_info_table) / sizeof(class_info_table[0]))); +#endif + #ifdef CONFIG_USBHOST_HUB usbh_workq_initialize(); #endif @@ -989,14 +1009,6 @@ void *usbh_find_class_instance(const char *devname) return NULL; } -const struct usbh_class_info *class_info_table[] = { - &cdc_acm_class_info, - &hid_keyboard_class_info, - &hid_mouse_class_info, - &msc_class_info, - &hub_class_info, -}; - static const struct usbh_class_driver *usbh_find_class_driver(uint8_t class, uint8_t subclass, uint8_t protocol, uint16_t vid, uint16_t pid) { struct usbh_class_info *index = NULL;