mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-21 21:41:09 +00:00
add custom bulk out test
This commit is contained in:
parent
fe53297b17
commit
2cc5df9b00
@ -112,12 +112,18 @@ int main(void)
|
||||
// BLINKING TASK
|
||||
//--------------------------------------------------------------------+
|
||||
uint8_t custom_read_buffer[4*1024] TUSB_CFG_ATTR_USBRAM;
|
||||
uint8_t custom_write_buffer[4*1024] TUSB_CFG_ATTR_USBRAM;
|
||||
uint32_t custom_write_buffer[1024] TUSB_CFG_ATTR_USBRAM;
|
||||
void custom_class_loopback_task (void* p_task_para)
|
||||
{
|
||||
if( tusbh_custom_is_mounted(1, 0, 0) ) // hardcode addr = 1, ignore vendor/product ID
|
||||
{
|
||||
tusbh_custom_read(1, 0, 0, custom_read_buffer, sizeof(custom_read_buffer));
|
||||
|
||||
static uint32_t magic_number = 1;
|
||||
custom_write_buffer[0] = magic_number;
|
||||
tusbh_custom_write(1, 0, 0, custom_write_buffer, sizeof(custom_write_buffer));
|
||||
|
||||
magic_number += 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
custom_interface_info_t custom_interface[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// 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)
|
||||
static tusb_error_t cush_validate_paras(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) )
|
||||
{
|
||||
@ -68,6 +65,16 @@ tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t pr
|
||||
}
|
||||
|
||||
ASSERT( p_buffer != NULL && length != 0, TUSB_ERROR_INVALID_PARA);
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API (need to check parameters)
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length)
|
||||
{
|
||||
ASSERT_STATUS( cush_validate_paras(dev_addr, vendor_id, product_id, p_buffer, length) );
|
||||
|
||||
if ( !hcd_pipe_is_idle(custom_interface[dev_addr-1].pipe_in) )
|
||||
{
|
||||
return TUSB_ERROR_INTERFACE_IS_BUSY;
|
||||
@ -80,6 +87,15 @@ tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t pr
|
||||
|
||||
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)
|
||||
{
|
||||
ASSERT_STATUS( cush_validate_paras(dev_addr, vendor_id, product_id, p_data, length) );
|
||||
|
||||
if ( !hcd_pipe_is_idle(custom_interface[dev_addr-1].pipe_out) )
|
||||
{
|
||||
return TUSB_ERROR_INTERFACE_IS_BUSY;
|
||||
}
|
||||
|
||||
(void) hcd_pipe_xfer( custom_interface[dev_addr-1].pipe_out, p_data, length, true);
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl)
|
||||
void async_advance_isr(ehci_qhd_t * const async_head)
|
||||
{
|
||||
// TODO do we need to close addr0
|
||||
if(async_head->is_removing) // closing control pipe of addr0
|
||||
if (async_head->is_removing) // closing control pipe of addr0
|
||||
{
|
||||
async_head->is_removing = 0;
|
||||
async_head->p_qtd_list_head = async_head->p_qtd_list_tail = NULL;
|
||||
@ -469,17 +469,17 @@ void async_advance_isr(ehci_qhd_t * const async_head)
|
||||
{
|
||||
// check if control endpoint is removing
|
||||
ehci_qhd_t *p_control_qhd = &ehci_data.device[relative_dev_addr].control.qhd;
|
||||
if( p_control_qhd->is_removing )
|
||||
if ( p_control_qhd->is_removing )
|
||||
{
|
||||
p_control_qhd->is_removing = 0;
|
||||
p_control_qhd->used = 0;
|
||||
p_control_qhd->is_removing = 0;
|
||||
p_control_qhd->used = 0;
|
||||
|
||||
// Host Controller has cleaned up its cached data for this device, set state to unplug
|
||||
usbh_devices[relative_dev_addr+1].state = TUSB_DEVICE_STATE_UNPLUG;
|
||||
|
||||
for (uint8_t i=0; i<EHCI_MAX_QHD; i++) // free all qhd
|
||||
{
|
||||
ehci_data.device[relative_dev_addr].qhd[i].used = 0;
|
||||
ehci_data.device[relative_dev_addr].qhd[i].used = 0;
|
||||
ehci_data.device[relative_dev_addr].qhd[i].is_removing = 0;
|
||||
}
|
||||
for (uint8_t i=0; i<EHCI_MAX_QTD; i++) // free all qtd
|
||||
|
Loading…
x
Reference in New Issue
Block a user