refractor usbd-dcd callback, add bus event isr

This commit is contained in:
hathach
2013-11-21 12:47:55 +07:00
parent d94efa60d6
commit 6887e5e642
15 changed files with 169 additions and 83 deletions

View File

@@ -194,7 +194,7 @@ tusb_error_t cdcd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_int
return TUSB_ERROR_NONE;
}
void cdcd_bus_reset(uint8_t coreid)
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));

View File

@@ -63,11 +63,13 @@ bool tusbd_cdc_is_busy(uint8_t coreid, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN
tusb_error_t tusbd_cdc_send(uint8_t coreid, void * p_data, uint32_t length, bool is_notify);
tusb_error_t tusbd_cdc_receive(uint8_t coreid, void * p_buffer, uint32_t length, bool is_notify);
//------------- Callback -------------//
//--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
void tusbd_cdc_mounted_cb(uint8_t coreid);
void tusbd_cdc_unmounted_cb(uint8_t coreid);
void tusbd_cdc_xfer_isr(uint8_t coreid, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes);
void tusbd_cdc_line_coding_changed_cb(uint8_t coreid, cdc_line_coding_t* p_line_coding);
//void tusbd_cdc_line_coding_changed_cb(uint8_t coreid, cdc_line_coding_t* p_line_coding);
//--------------------------------------------------------------------+
// USBD-CLASS DRIVER API
@@ -76,9 +78,9 @@ void tusbd_cdc_line_coding_changed_cb(uint8_t coreid, cdc_line_coding_t* p_line_
void cdcd_init(void);
tusb_error_t cdcd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length);
void cdcd_bus_reset(uint8_t coreid);
tusb_error_t cdcd_control_request(uint8_t coreid, tusb_control_request_t const * p_request);
void cdcd_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes);
void cdcd_close(uint8_t coreid);
#endif

View File

@@ -124,7 +124,7 @@ void hidd_init(void)
// TODO not implemented yet
}
void hidd_bus_reset(uint8_t coreid)
void hidd_close(uint8_t coreid)
{
// TODO not implemented yet
}
@@ -148,6 +148,8 @@ tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const *
uint8_t const desc_type = u16_high_u8(p_request->wValue);
uint8_t const desc_index = u16_low_u8 (p_request->wValue);
(void) desc_index;
ASSERT ( p_request->bRequest == TUSB_REQUEST_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT,
TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT);
@@ -170,6 +172,9 @@ tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const *
hid_request_report_type_t report_type = u16_high_u8(p_request->wValue);
uint8_t report_id = u16_low_u8(p_request->wValue);
(void) report_id;
(void) report_type;
dcd_pipe_control_xfer(coreid, TUSB_DIR_HOST_TO_DEV, &set_report, p_request->wLength);
}
break;

View File

@@ -49,13 +49,21 @@
//--------------------------------------------------------------------+
// KEYBOARD Application API
// KEYBOARD APPLICATION API
//--------------------------------------------------------------------+
/** \addtogroup ClassDriver_HID_Keyboard Keyboard
* @{ */
/** \defgroup Keyboard_Device Device
* @{ */
/** \brief Check if the interface is configured and ready to use
* \param[in] coreid USB Controller ID
* \retval true if the interface is configured
* \retval false if the interface is not configured (e.g device is not attached)
* \note This function should be call frequently or before any xfer attempt to check if device is still attached
*/
bool tusbd_hid_keyboard_is_configured(uint8_t coreid);
/** \brief Check if the interface is currently busy or not
* \param[in] coreid USB Controller ID
* \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to host
@@ -77,7 +85,9 @@ bool tusbd_hid_keyboard_is_busy(uint8_t coreid);
*/
tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const *p_report);
//------------- Application Callback -------------//
//--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
/** \brief Callback function that is invoked when an transferring event occurred
* \param[in] coreid USB Controller ID
* \param[in] event an value from \ref tusb_event_t
@@ -88,6 +98,8 @@ tusb_error_t tusbd_hid_keyboard_send(uint8_t coreid, hid_keyboard_report_t const
* \note Application should schedule the next report by calling \ref tusbh_hid_keyboard_get_report within this callback
*/
void tusbd_hid_keyboard_isr(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes);
void tusbd_hid_keyboard_mounted_cb(uint8_t coreid);
void tusbd_hid_keyboard_unmounted_cb(uint8_t coreid);
/** @} */
/** @} */
@@ -100,6 +112,14 @@ void tusbd_hid_keyboard_isr(uint8_t coreid, tusb_event_t event, uint32_t xferred
/** \defgroup Mouse_Device Device
* @{ */
/** \brief Check if the interface is configured and ready to use
* \param[in] coreid USB Controller ID
* \retval true if the interface is configured
* \retval false if the interface is not configured (e.g device is not attached)
* \note This function should be call frequently or before any xfer attempt to check if device is still attached
*/
bool tusbd_hid_mouse_is_configured(uint8_t coreid);
/** \brief Check if the interface is currently busy or not
* \param[in] coreid USB Controller ID
* \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to host
@@ -121,7 +141,12 @@ bool tusbd_hid_mouse_is_busy(uint8_t coreid);
*/
tusb_error_t tusbd_hid_mouse_send(uint8_t coreid, hid_mouse_report_t const *p_report);
//--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
void tusbd_hid_mouse_isr(uint8_t coreid, tusb_event_t event, uint32_t xferred_bytes);
void tusbd_hid_mouse_mounted_cb(uint8_t coreid);
void tusbd_hid_mouse_unmounted_cb(uint8_t coreid);
/** @} */
/** @} */
@@ -134,10 +159,10 @@ void tusbd_hid_mouse_isr(uint8_t coreid, tusb_event_t event, uint32_t xferred_by
#ifdef _TINY_USB_SOURCE_FILE_
void hidd_init(void);
void hidd_bus_reset(uint8_t coreid);
tusb_error_t hidd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length);
tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * p_request);
void hidd_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes);
void hidd_close(uint8_t coreid);
#endif

View File

@@ -75,7 +75,7 @@ void mscd_init(void)
// TODO not implemented
}
void mscd_bus_reset(uint8_t coreid)
void mscd_close(uint8_t coreid)
{
// TODO not implemented yet
}

View File

@@ -50,6 +50,20 @@
//--------------------------------------------------------------------+
// APPLICATION API
//--------------------------------------------------------------------+
/** \brief Check if the interface is configured and ready to use
* \param[in] coreid USB Controller ID
* \retval true if the interface is configured
* \retval false if the interface is not configured (e.g device is not attached)
* \note This function should be call frequently or before any xfer attempt to check if device is still attached
*/
bool tusbd_msc_is_configured(uint8_t coreid);
//--------------------------------------------------------------------+
// APPLICATION CALLBACK API
//--------------------------------------------------------------------+
void tusbd_msc_mounted_cb(uint8_t coreid);
void tusbd_msc_unmounted_cb(uint8_t coreid);
// p_length [in,out] allocated/maximum length, application update with actual length
msc_csw_status_t tusbd_msc_scsi_received_isr (uint8_t coreid, uint8_t lun, uint8_t scsi_cmd[16], void ** pp_buffer, uint16_t* p_length);
@@ -62,10 +76,10 @@ tusb_error_t tusbh_msc_write10(uint8_t dev_addr, uint8_t lun, void const * p_buf
#ifdef _TINY_USB_SOURCE_FILE_
void mscd_init(void);
void mscd_bus_reset(uint8_t coreid);
tusb_error_t mscd_open(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length);
tusb_error_t mscd_control_request(uint8_t coreid, tusb_control_request_t const * p_request);
void mscd_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes);
void mscd_close(uint8_t coreid);
#endif