add mount callback for device, move tests in mount callback
This commit is contained in:
@@ -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);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
USB_LOG_INFO("Register HID Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
|
||||||
extern int hid_test();
|
|
||||||
hid_test();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
USB_LOG_INFO("Register MSC Class:%s\r\n", hport->config.intf[intf].devname);
|
||||||
|
|
||||||
extern int msc_test();
|
|
||||||
msc_test();
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -660,6 +660,7 @@ static int usbh_enumerate(struct usbh_hubport *hport)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usbh_device_mount_done_callback(hport);
|
||||||
errout:
|
errout:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
usbh_hport_deactivate(hport);
|
usbh_hport_deactivate(hport);
|
||||||
@@ -760,6 +761,7 @@ static void usbh_portchange_detect_thread(void *argument)
|
|||||||
}
|
}
|
||||||
usbh_enumerate(hport);
|
usbh_enumerate(hport);
|
||||||
} else {
|
} else {
|
||||||
|
usbh_device_unmount_done_callback(hport);
|
||||||
usbh_hport_deactivate(hport);
|
usbh_hport_deactivate(hport);
|
||||||
for (uint8_t i = 0; i < hport->config.config_desc.bNumInterfaces; i++) {
|
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) {
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__WEAK void usbh_device_mount_done_callback(struct usbh_hubport *hport)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
__WEAK void usbh_device_unmount_done_callback(struct usbh_hubport *hport)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -68,12 +68,12 @@ enum usbh_event_type {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct usbh_class_info {
|
struct usbh_class_info {
|
||||||
uint8_t match_flags;/* Used for product specific matches; range is inclusive */
|
uint8_t match_flags; /* Used for product specific matches; range is inclusive */
|
||||||
uint8_t class; /* Base device class code */
|
uint8_t class; /* Base device class code */
|
||||||
uint8_t subclass; /* Sub-class, depends on base class. Eg. */
|
uint8_t subclass; /* Sub-class, depends on base class. Eg. */
|
||||||
uint8_t protocol; /* Protocol, 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 vid; /* Vendor ID (for vendor/product specific devices) */
|
||||||
uint16_t pid; /* Product ID (for vendor/product specific devices) */
|
uint16_t pid; /* Product ID (for vendor/product specific devices) */
|
||||||
const struct usbh_class_driver *class_driver;
|
const struct usbh_class_driver *class_driver;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -130,12 +130,12 @@ typedef struct usbh_hub {
|
|||||||
struct usbh_hubport *parent; /* Parent hub port */
|
struct usbh_hubport *parent; /* Parent hub port */
|
||||||
} usbh_hub_t;
|
} usbh_hub_t;
|
||||||
|
|
||||||
void usbh_event_notify_handler(uint8_t event, uint8_t rhport);
|
|
||||||
|
|
||||||
int usbh_initialize(void);
|
int usbh_initialize(void);
|
||||||
int lsusb(int argc, char **argv);
|
int lsusb(int argc, char **argv);
|
||||||
struct usbh_hubport *usbh_find_hubport(uint8_t dev_addr);
|
struct usbh_hubport *usbh_find_hubport(uint8_t dev_addr);
|
||||||
void *usbh_find_class_instance(const char *devname);
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include "usbh_hid.h"
|
#include "usbh_hid.h"
|
||||||
#include "usbh_msc.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)
|
void usbh_cdc_acm_callback(void *arg, int nbytes)
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ int cdc_acm_test(void)
|
|||||||
#include "ff.h"
|
#include "ff.h"
|
||||||
#endif
|
#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)
|
int msc_test(void)
|
||||||
{
|
{
|
||||||
@@ -143,7 +143,7 @@ int msc_test(void)
|
|||||||
return ret;
|
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)
|
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);
|
USB_LOG_RAW("recv len:%d\r\n", ret);
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void usbh_device_mount_done_callback(struct usbh_hubport *hport)
|
||||||
|
{
|
||||||
|
cdc_acm_test();
|
||||||
|
msc_test();
|
||||||
|
hid_test();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user