diff options
| author | hathach <[email protected]> | 2014-03-31 11:59:43 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2014-03-31 11:59:43 +0700 |
| commit | 6682720b2aecb777d8f8aceedbd49aaff4fbbc27 (patch) | |
| tree | 9fcb36a06d168b31b0027affdcb8265560b33a79 /tinyusb | |
| parent | 0bb2cc64b0e1248bfc8e564755a0850b5e5ad762 (diff) | |
implement & document all the device class _mounted_cb & _unmounted_cb callbacks
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/class/cdc_device.c | 2 | ||||
| -rw-r--r-- | tinyusb/class/cdc_device.h | 9 | ||||
| -rw-r--r-- | tinyusb/class/hid_device.h | 20 | ||||
| -rw-r--r-- | tinyusb/class/msc_device.c | 3 | ||||
| -rw-r--r-- | tinyusb/class/msc_device.h | 12 |
5 files changed, 43 insertions, 3 deletions
diff --git a/tinyusb/class/cdc_device.c b/tinyusb/class/cdc_device.c index 405095402..0d3120061 100644 --- a/tinyusb/class/cdc_device.c +++ b/tinyusb/class/cdc_device.c @@ -180,6 +180,8 @@ void cdcd_close(uint8_t coreid) {
// no need to close opened pipe, dcd bus reset will put controller's endpoints to default state
memclr_(&cdcd_data[coreid], sizeof(cdcd_data_t));
+
+ tusbd_cdc_unmounted_cb(coreid);
}
tusb_error_t cdcd_control_request_subtask(uint8_t coreid, tusb_control_request_t const * p_request)
diff --git a/tinyusb/class/cdc_device.h b/tinyusb/class/cdc_device.h index dd4fd5e6d..c88b578c9 100644 --- a/tinyusb/class/cdc_device.h +++ b/tinyusb/class/cdc_device.h @@ -98,7 +98,16 @@ tusb_error_t tusbd_cdc_receive(uint8_t coreid, void * p_buffer, uint32_t length, //--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
+/** \brief Callback function that will be invoked when this interface is mounted (configured) by USB host
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b set-up interface-related data
+ */
void tusbd_cdc_mounted_cb(uint8_t coreid);
+
+/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b tear-down interface-related data
+ */
void tusbd_cdc_unmounted_cb(uint8_t coreid);
/** \brief Callback function that is invoked when an completion (error or success) of an USB transfer previously submitted
diff --git a/tinyusb/class/hid_device.h b/tinyusb/class/hid_device.h index c04d4ceac..e3a4b309d 100644 --- a/tinyusb/class/hid_device.h +++ b/tinyusb/class/hid_device.h @@ -80,7 +80,17 @@ tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const //--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
+
+/** \brief Callback function that will be invoked when this interface is mounted (configured) by USB host
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b set-up interface-related data
+ */
void tusbd_hid_keyboard_mounted_cb(uint8_t coreid);
+
+/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b tear-down interface-related data
+ */
void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid);
/** \brief Callback function that is invoked when an transferring event occurred
@@ -155,8 +165,16 @@ tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_re //--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
-
+/** \brief Callback function that will be invoked when this interface is mounted (configured) by USB host
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b set-up interface-related data
+ */
void tusbd_hid_mouse_mounted_cb(uint8_t coreid);
+
+/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b tear-down interface-related data
+ */
void tusbd_hid_mouse_unmounted_cb(uint8_t coreid);
/** \brief Callback function that is invoked when an transferring event occurred
diff --git a/tinyusb/class/msc_device.c b/tinyusb/class/msc_device.c index 99c082cf5..091faabb6 100644 --- a/tinyusb/class/msc_device.c +++ b/tinyusb/class/msc_device.c @@ -82,6 +82,7 @@ void mscd_init(void) void mscd_close(uint8_t coreid)
{
memclr_(&mscd_data, sizeof(mscd_interface_t));
+ tusbd_msc_unmounted_cb(coreid);
}
tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length)
@@ -111,6 +112,8 @@ tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int (*p_length) += sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t);
+ tusbd_msc_mounted_cb(coreid);
+
//------------- Queue Endpoint OUT for Command Block Wrapper -------------//
ASSERT_STATUS( dcd_pipe_xfer(p_msc->edpt_out, (uint8_t*) &p_msc->cbw, sizeof(msc_cmd_block_wrapper_t), true) );
diff --git a/tinyusb/class/msc_device.h b/tinyusb/class/msc_device.h index a50e507f5..41ba6a67f 100644 --- a/tinyusb/class/msc_device.h +++ b/tinyusb/class/msc_device.h @@ -50,7 +50,7 @@ /** \addtogroup ClassDriver_MSC
* @{
* \defgroup MSC_Device Device
- * @{ */
+ * @{ */
//--------------------------------------------------------------------+
// APPLICATION API
@@ -59,9 +59,17 @@ //--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
+/** \brief Callback function that will be invoked when this interface is mounted (configured) by USB host
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b set-up interface-related data
+ */
void tusbd_msc_mounted_cb(uint8_t coreid);
-void tusbd_msc_unmounted_cb(uint8_t coreid);
+/** \brief Callback function that will be invoked when this interface is unmounted (bus reset/unplugged)
+ * \param[in] coreid USB Controller ID of the interface
+ * \note This callback should be used by Application to \b tear-down interface-related data
+ */
+void tusbd_msc_unmounted_cb(uint8_t coreid);
/** \brief Callback that is invoked when tinyusb stack received \ref SCSI_CMD_READ_10 command from host
* \param[in] coreid USB Controller ID
|
