mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-23 00:40:12 +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
|
// BLINKING TASK
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
uint8_t custom_read_buffer[4*1024] TUSB_CFG_ATTR_USBRAM;
|
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)
|
void custom_class_loopback_task (void* p_task_para)
|
||||||
{
|
{
|
||||||
if( tusbh_custom_is_mounted(1, 0, 0) ) // hardcode addr = 1, ignore vendor/product ID
|
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));
|
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];
|
custom_interface_info_t custom_interface[TUSB_CFG_HOST_DEVICE_MAX];
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
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)
|
||||||
// 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) )
|
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);
|
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) )
|
if ( !hcd_pipe_is_idle(custom_interface[dev_addr-1].pipe_in) )
|
||||||
{
|
{
|
||||||
return TUSB_ERROR_INTERFACE_IS_BUSY;
|
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)
|
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;
|
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)
|
void async_advance_isr(ehci_qhd_t * const async_head)
|
||||||
{
|
{
|
||||||
// TODO do we need to close addr0
|
// 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->is_removing = 0;
|
||||||
async_head->p_qtd_list_head = async_head->p_qtd_list_tail = NULL;
|
async_head->p_qtd_list_head = async_head->p_qtd_list_tail = NULL;
|
||||||
@ -469,7 +469,7 @@ void async_advance_isr(ehci_qhd_t * const async_head)
|
|||||||
{
|
{
|
||||||
// check if control endpoint is removing
|
// check if control endpoint is removing
|
||||||
ehci_qhd_t *p_control_qhd = &ehci_data.device[relative_dev_addr].control.qhd;
|
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->is_removing = 0;
|
||||||
p_control_qhd->used = 0;
|
p_control_qhd->used = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user