summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-05-12 19:27:34 +0700
committerhathach <[email protected]>2021-05-18 12:58:24 +0700
commit510beef9f8f78689424ee8f62d3883b89fe794fa (patch)
treec20daa78178244870494a7b96bf38eab88ae173e /src/class
parente0dbb489aed9d9e7f081c379400dcb74600ede6a (diff)
make tuh_msc_mount_cb() tuh_msc_unmount_cb() as weak callback
Diffstat (limited to 'src/class')
-rw-r--r--src/class/msc/msc_host.c9
-rw-r--r--src/class/msc/msc_host.h4
2 files changed, 8 insertions, 5 deletions
diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c
index 3e8573df0..4869c8c03 100644
--- a/src/class/msc/msc_host.c
+++ b/src/class/msc/msc_host.c
@@ -287,7 +287,7 @@ bool tuh_msc_reset(uint8_t dev_addr)
#endif
//--------------------------------------------------------------------+
-// CLASS-USBH API (don't require to verify parameters)
+// CLASS-USBH API
//--------------------------------------------------------------------+
void msch_init(void)
{
@@ -298,7 +298,9 @@ void msch_close(uint8_t dev_addr)
{
msch_interface_t* p_msc = get_itf(dev_addr);
tu_memclr(p_msc, sizeof(msch_interface_t));
- tuh_msc_unmount_cb(dev_addr); // invoke Application Callback
+
+ // invoke Application Callback
+ if (tuh_msc_unmount_cb) tuh_msc_unmount_cb(dev_addr);
}
bool msch_xfer_cb(uint8_t dev_addr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes)
@@ -471,8 +473,9 @@ static bool config_read_capacity_complete(uint8_t dev_addr, msc_cbw_t const* cbw
// Mark enumeration is complete
p_msc->mounted = true;
- tuh_msc_mount_cb(dev_addr);
+ if (tuh_msc_mount_cb) tuh_msc_mount_cb(dev_addr);
+ // notify usbh that driver enumeration is complete
usbh_driver_set_config_complete(dev_addr, p_msc->itf_num);
return true;
diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h
index d99f1204a..7ebc9b5a8 100644
--- a/src/class/msc/msc_host.h
+++ b/src/class/msc/msc_host.h
@@ -106,10 +106,10 @@ bool tuh_msc_read_capacity(uint8_t dev_addr, uint8_t lun, scsi_read_capacity10_r
//------------- Application Callback -------------//
// Invoked when a device with MassStorage interface is mounted
-void tuh_msc_mount_cb(uint8_t dev_addr);
+TU_ATTR_WEAK void tuh_msc_mount_cb(uint8_t dev_addr);
// Invoked when a device with MassStorage interface is unmounted
-void tuh_msc_unmount_cb(uint8_t dev_addr);
+TU_ATTR_WEAK void tuh_msc_unmount_cb(uint8_t dev_addr);
//--------------------------------------------------------------------+
// Internal Class Driver API