summaryrefslogtreecommitdiff
path: root/src/class
diff options
context:
space:
mode:
Diffstat (limited to 'src/class')
-rw-r--r--src/class/cdc/cdc_host.c12
-rw-r--r--src/class/cdc/cdc_host.h17
2 files changed, 23 insertions, 6 deletions
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index ee824cb4e..aa3a7e1e5 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -239,6 +239,8 @@ bool cdch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it
bool cdch_set_config(uint8_t dev_addr, uint8_t itf_num)
{
(void) dev_addr; (void) itf_num;
+
+ if (tuh_cdc_mount_cb) tuh_cdc_mount_cb(dev_addr);
return true;
}
@@ -254,6 +256,16 @@ void cdch_close(uint8_t dev_addr)
TU_VERIFY(dev_addr <= CFG_TUH_DEVICE_MAX, );
cdch_data_t * p_cdc = get_itf(dev_addr);
+
+ // Invoke application callback
+ if (tuh_cdc_umount_cb)
+ {
+ if (p_cdc->ep_out || p_cdc->ep_in || p_cdc->ep_notif)
+ {
+ tuh_cdc_umount_cb(dev_addr);
+ }
+ }
+
tu_memclr(p_cdc, sizeof(cdch_data_t));
}
diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h
index 33dbd2efb..c3b601b34 100644
--- a/src/class/cdc/cdc_host.h
+++ b/src/class/cdc/cdc_host.h
@@ -34,13 +34,18 @@
#endif
//--------------------------------------------------------------------+
-// CDC APPLICATION PUBLIC API
+// Application API
//--------------------------------------------------------------------+
-/** \ingroup ClassDriver_CDC Communication Device Class (CDC)
- * \addtogroup CDC_Serial Serial
- * @{
- * \defgroup CDC_Serial_Host Host
- * @{ */
+
+
+//------------- Application Callback -------------//
+
+// Invoked when a device with CDC interface is mounted
+TU_ATTR_WEAK void tuh_cdc_mount_cb(uint8_t dev_addr);
+
+// Invoked when a device with CDC interface is unmounted
+TU_ATTR_WEAK void tuh_cdc_umount_cb(uint8_t dev_addr);
+
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_xfer_cb_t complete_cb);