diff options
| author | sakumisu <[email protected]> | 2022-08-12 21:35:17 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2022-08-12 21:35:17 +0800 |
| commit | 628ee1f74df2ac62fdbf39a27c9bd0af1e64dda9 (patch) | |
| tree | efc23d27953fba5baca27a03fc12422a046e2edf | |
| parent | 88f710458c01c33760e3f9e672064ce2430b03ee (diff) | |
add mount callback for device, move tests in mount callback
| -rw-r--r-- | class/cdc/usbh_cdc_acm.c | 2 | ||||
| -rw-r--r-- | class/hid/usbh_hid.c | 2 | ||||
| -rw-r--r-- | class/msc/usbh_msc.c | 2 | ||||
| -rw-r--r-- | common/usb_hc.h | 4 | ||||
| -rw-r--r-- | core/usbh_core.c | 10 | ||||
| -rw-r--r-- | core/usbh_core.h | 16 | ||||
| -rw-r--r-- | demo/usb_host.c | 13 |
7 files changed, 32 insertions, 17 deletions
diff --git a/class/cdc/usbh_cdc_acm.c b/class/cdc/usbh_cdc_acm.c index 71d46699..5acd50d9 100644 --- a/class/cdc/usbh_cdc_acm.c +++ b/class/cdc/usbh_cdc_acm.c @@ -206,8 +206,6 @@ static int usbh_cdc_acm_connect(struct usbh_hubport *hport, uint8_t intf) USB_LOG_INFO("Register CDC ACM Class:%s\r\n", hport->config.intf[intf].devname); - extern int cdc_acm_test(); - cdc_acm_test(); return ret; } diff --git a/class/hid/usbh_hid.c b/class/hid/usbh_hid.c index 9323688a..e6082486 100644 --- a/class/hid/usbh_hid.c +++ b/class/hid/usbh_hid.c @@ -163,8 +163,6 @@ int usbh_hid_connect(struct usbh_hubport *hport, uint8_t intf) USB_LOG_INFO("Register HID Class:%s\r\n", hport->config.intf[intf].devname); - extern int hid_test(); - hid_test(); return 0; } diff --git a/class/msc/usbh_msc.c b/class/msc/usbh_msc.c index a1cc55a2..5db7a5a5 100644 --- a/class/msc/usbh_msc.c +++ b/class/msc/usbh_msc.c @@ -393,8 +393,6 @@ static int usbh_msc_connect(struct usbh_hubport *hport, uint8_t intf) USB_LOG_INFO("Register MSC Class:%s\r\n", hport->config.intf[intf].devname); - extern int msc_test(); - msc_test(); return ret; } diff --git a/common/usb_hc.h b/common/usb_hc.h index bc70d6b7..78575388 100644 --- a/common/usb_hc.h +++ b/common/usb_hc.h @@ -226,6 +226,10 @@ int usbh_ep_intr_async_transfer(usbh_epinfo_t ep, uint8_t *buffer, uint32_t bufl */ int usb_ep_cancel(usbh_epinfo_t ep); +/* usb hcd irq callback */ + +void usbh_event_notify_handler(uint8_t event, uint8_t rhport); + #ifdef __cplusplus } #endif diff --git a/core/usbh_core.c b/core/usbh_core.c index 2a61f0c6..e00a8fe2 100644 --- a/core/usbh_core.c +++ b/core/usbh_core.c @@ -660,6 +660,7 @@ static int usbh_enumerate(struct usbh_hubport *hport) } } + usbh_device_mount_done_callback(hport); errout: if (ret < 0) { usbh_hport_deactivate(hport); @@ -760,6 +761,7 @@ static void usbh_portchange_detect_thread(void *argument) } usbh_enumerate(hport); } else { + usbh_device_unmount_done_callback(hport); usbh_hport_deactivate(hport); for (uint8_t i = 0; i < hport->config.config_desc.bNumInterfaces; i++) { if (hport->config.intf[i].class_driver && hport->config.intf[i].class_driver->disconnect) { @@ -1027,3 +1029,11 @@ static const struct usbh_class_driver *usbh_find_class_driver(uint8_t class, uin } return NULL; } + +__WEAK void usbh_device_mount_done_callback(struct usbh_hubport *hport) +{ +} + +__WEAK void usbh_device_unmount_done_callback(struct usbh_hubport *hport) +{ +} diff --git a/core/usbh_core.h b/core/usbh_core.h index 05687250..b221f909 100644 --- a/core/usbh_core.h +++ b/core/usbh_core.h @@ -68,12 +68,12 @@ enum usbh_event_type { }; struct usbh_class_info { - uint8_t match_flags;/* Used for product specific matches; range is inclusive */ - uint8_t class; /* Base device class code */ - uint8_t subclass; /* Sub-class, depends on base class. Eg. */ - uint8_t protocol; /* Protocol, depends on base class. Eg. */ - uint16_t vid; /* Vendor ID (for vendor/product specific devices) */ - uint16_t pid; /* Product ID (for vendor/product specific devices) */ + uint8_t match_flags; /* Used for product specific matches; range is inclusive */ + uint8_t class; /* Base device class code */ + uint8_t subclass; /* Sub-class, depends on base class. Eg. */ + uint8_t protocol; /* Protocol, depends on base class. Eg. */ + uint16_t vid; /* Vendor ID (for vendor/product specific devices) */ + uint16_t pid; /* Product ID (for vendor/product specific devices) */ const struct usbh_class_driver *class_driver; }; @@ -130,12 +130,12 @@ typedef struct usbh_hub { struct usbh_hubport *parent; /* Parent hub port */ } usbh_hub_t; -void usbh_event_notify_handler(uint8_t event, uint8_t rhport); - int usbh_initialize(void); int lsusb(int argc, char **argv); struct usbh_hubport *usbh_find_hubport(uint8_t dev_addr); void *usbh_find_class_instance(const char *devname); +void usbh_device_mount_done_callback(struct usbh_hubport *hport); +void usbh_device_unmount_done_callback(struct usbh_hubport *hport); #ifdef __cplusplus } diff --git a/demo/usb_host.c b/demo/usb_host.c index cf31385a..999ea5e2 100644 --- a/demo/usb_host.c +++ b/demo/usb_host.c @@ -3,7 +3,7 @@ #include "usbh_hid.h" #include "usbh_msc.h" -USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t cdc_buffer[512]; +USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t cdc_buffer[512]; void usbh_cdc_acm_callback(void *arg, int nbytes) { @@ -73,7 +73,7 @@ int cdc_acm_test(void) #include "ff.h" #endif -USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t partition_table[512]; +USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t partition_table[512]; int msc_test(void) { @@ -143,7 +143,7 @@ int msc_test(void) return ret; } -USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t hid_buffer[128]; +USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t hid_buffer[128]; void usbh_hid_callback(void *arg, int nbytes) { @@ -180,4 +180,11 @@ int hid_test(void) USB_LOG_RAW("recv len:%d\r\n", ret); #endif return ret; +} + +void usbh_device_mount_done_callback(struct usbh_hubport *hport) +{ + cdc_acm_test(); + msc_test(); + hid_test(); }
\ No newline at end of file |
