diff options
| author | sakumisu <[email protected]> | 2022-04-04 13:11:44 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-04-04 13:11:44 +0800 |
| commit | c1f6b86bcf21da700b93222a0ef9053a59c87c02 (patch) | |
| tree | 62c58ff236182103f7cb215243050a81e7560482 /core | |
| parent | f716b6d307eca556acdc0fc5dad24b57c2fd5109 (diff) | |
add class driver export macro control
Diffstat (limited to 'core')
| -rw-r--r-- | core/usbh_core.c | 36 |
1 files changed, 24 insertions, 12 deletions
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; |
