mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-23 00:40:12 +00:00
add api for hcd: hcd_pipe_is_idle
add api for usbh: tusbh_device_get_mounted_class_flag implement api for custom class - is mounted - read
This commit is contained in:
parent
3924764dff
commit
5c564df8c1
@ -61,6 +61,17 @@ typedef struct {
|
||||
//--------------------------------------------------------------------+
|
||||
// USBH-CLASS DRIVER API
|
||||
//--------------------------------------------------------------------+
|
||||
STATIC_ INLINE_ bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id);
|
||||
STATIC_ INLINE_ bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id)
|
||||
{
|
||||
(void) vendor_id; // TODO check this later
|
||||
(void) product_id;
|
||||
return (tusbh_device_get_mounted_class_flag(dev_addr) & BIT_(TUSB_CLASS_MAPPED_INDEX_END-1) ) != 0;
|
||||
}
|
||||
|
||||
tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length);
|
||||
tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length);
|
||||
|
||||
#ifdef _TINY_USB_SOURCE_FILE_
|
||||
|
||||
void cush_init(void);
|
||||
|
@ -56,8 +56,35 @@
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
custom_interface_info_t custom_interface[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
// APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length)
|
||||
{
|
||||
if ( !tusbh_custom_is_mounted(dev_addr, vendor_id, product_id) )
|
||||
{
|
||||
return TUSB_ERROR_DEVICE_NOT_READY;
|
||||
}
|
||||
|
||||
ASSERT( p_buffer != NULL && length != 0, TUSB_ERROR_INVALID_PARA);
|
||||
if ( hcd_pipe_is_idle(custom_interface[dev_addr-1].pipe_in) )
|
||||
{
|
||||
return TUSB_ERROR_INTERFACE_IS_BUSY;
|
||||
}
|
||||
|
||||
(void) hcd_pipe_xfer( custom_interface[dev_addr-1].pipe_in, p_buffer, length, false);
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void const * p_data, uint16_t length)
|
||||
{
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBH-CLASS API
|
||||
//--------------------------------------------------------------------+
|
||||
void cush_init(void)
|
||||
{
|
||||
|
@ -95,11 +95,11 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int
|
||||
tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid)
|
||||
{
|
||||
//------------- parameters validation -------------//
|
||||
// TODO change to use is configured function
|
||||
ASSERT_INT(TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
|
||||
ASSERT_PTR(report, TUSB_ERROR_INVALID_PARA);
|
||||
ASSERT(TUSB_INTERFACE_STATUS_BUSY != p_hid->status, TUSB_ERROR_INTERFACE_IS_BUSY);
|
||||
|
||||
// TODO abstract to use hidh service
|
||||
ASSERT_STATUS( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
|
||||
|
||||
p_hid->status = TUSB_INTERFACE_STATUS_BUSY;
|
||||
|
@ -444,6 +444,12 @@ tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl)
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl)
|
||||
{
|
||||
ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle( pipe_hdl );
|
||||
return (p_qhd->p_qtd_list_head == NULL);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// EHCI Interrupt Handler
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -96,6 +96,7 @@ tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
||||
pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc, uint8_t class_code) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) ATTR_WARN_UNUSED_RESULT;
|
||||
bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl);
|
||||
|
||||
#if 0
|
||||
tusb_error_t hcd_pipe_cancel()ATTR_WARN_UNUSED_RESULT;
|
||||
|
@ -130,6 +130,11 @@ tusb_device_state_t tusbh_device_get_state (uint8_t const dev_addr)
|
||||
return usbh_devices[dev_addr].state;
|
||||
}
|
||||
|
||||
uint32_t tusbh_device_get_mounted_class_flag(uint8_t dev_addr)
|
||||
{
|
||||
return tusbh_device_is_configured(dev_addr) ? usbh_devices[dev_addr].flag_supported_class : 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// CLASS-USBD API (don't require to verify parameters)
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -86,13 +86,14 @@ typedef struct {
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_error_t tusbh_configuration_set (uint8_t dev_addr, uint8_t configure_number) ATTR_WARN_UNUSED_RESULT;
|
||||
//tusb_error_t tusbh_configuration_set (uint8_t dev_addr, uint8_t configure_number) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_device_state_t tusbh_device_get_state (uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT ATTR_PURE;
|
||||
static inline bool tusbh_device_is_configured(uint8_t dev_addr) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT ATTR_PURE;
|
||||
static inline bool tusbh_device_is_configured(uint8_t dev_addr)
|
||||
{
|
||||
return tusbh_device_get_state(dev_addr) == TUSB_DEVICE_STATE_CONFIGURED;
|
||||
}
|
||||
uint32_t tusbh_device_get_mounted_class_flag(uint8_t dev_addr);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION CALLBACK
|
||||
@ -106,6 +107,7 @@ void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_de
|
||||
//--------------------------------------------------------------------+
|
||||
#ifdef _TINY_USB_SOURCE_FILE_
|
||||
|
||||
|
||||
OSAL_TASK_FUNCTION (usbh_enumeration_task) (void* p_task_para);
|
||||
tusb_error_t usbh_init(void);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user