Przeglądaj źródła

add class driver export macro control

sakumisu 3 lat temu
rodzic
commit
c1f6b86bcf
5 zmienionych plików z 24 dodań i 20 usunięć
  1. 0 2
      class/cdc/usbh_cdc_acm.h
  2. 0 3
      class/hid/usbh_hid.h
  3. 0 1
      class/hub/usbh_hub.h
  4. 0 2
      class/msc/usbh_msc.h
  5. 24 12
      core/usbh_core.c

+ 0 - 2
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

+ 0 - 3
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

+ 0 - 1
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

+ 0 - 2
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);
 

+ 24 - 12
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;