mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-05 22:20:10 +00:00
assert clean up
This commit is contained in:
parent
c50da4962e
commit
1d33d4e072
tinyusb
@ -234,7 +234,7 @@ tusb_error_t hidd_control_request_st(uint8_t rhport, tusb_control_request_t cons
|
|||||||
// return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; // TODO test STALL control out endpoint (with mouse+keyboard)
|
// return TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT; // TODO test STALL control out endpoint (with mouse+keyboard)
|
||||||
// wValue = Report Type | Report ID
|
// wValue = Report Type | Report ID
|
||||||
STASK_INVOKE( usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, m_hid_buffer, p_request->wLength), err );
|
STASK_INVOKE( usbd_control_xfer_st(rhport, p_request->bmRequestType_bit.direction, m_hid_buffer, p_request->wLength), err );
|
||||||
STASK_ASSERT_STATUS(err);
|
STASK_ASSERT_ERR(err);
|
||||||
|
|
||||||
p_driver->set_report_cb(rhport, u16_high_u8(p_request->wValue), m_hid_buffer, p_request->wLength);
|
p_driver->set_report_cb(rhport, u16_high_u8(p_request->wValue), m_hid_buffer, p_request->wLength);
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_
|
|||||||
#if TUSB_CFG_HOST_HID_KEYBOARD
|
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||||
if ( HID_PROTOCOL_KEYBOARD == p_interface_desc->bInterfaceProtocol)
|
if ( HID_PROTOCOL_KEYBOARD == p_interface_desc->bInterfaceProtocol)
|
||||||
{
|
{
|
||||||
STASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboardh_data[dev_addr-1]) );
|
STASK_ASSERT_ERR ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboardh_data[dev_addr-1]) );
|
||||||
tuh_hid_keyboard_mounted_cb(dev_addr);
|
tuh_hid_keyboard_mounted_cb(dev_addr);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@ -233,7 +233,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_
|
|||||||
#if TUSB_CFG_HOST_HID_MOUSE
|
#if TUSB_CFG_HOST_HID_MOUSE
|
||||||
if ( HID_PROTOCOL_MOUSE == p_interface_desc->bInterfaceProtocol)
|
if ( HID_PROTOCOL_MOUSE == p_interface_desc->bInterfaceProtocol)
|
||||||
{
|
{
|
||||||
STASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouseh_data[dev_addr-1]) );
|
STASK_ASSERT_ERR ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouseh_data[dev_addr-1]) );
|
||||||
tuh_hid_mouse_mounted_cb(dev_addr);
|
tuh_hid_mouse_mounted_cb(dev_addr);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
@ -351,7 +351,7 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_
|
|||||||
//------------- SCSI Inquiry -------------//
|
//------------- SCSI Inquiry -------------//
|
||||||
tusbh_msc_inquiry(dev_addr, 0, msch_buffer);
|
tusbh_msc_inquiry(dev_addr, 0, msch_buffer);
|
||||||
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
memcpy(msch_data[dev_addr-1].vendor_id , ((scsi_inquiry_data_t*) msch_buffer)->vendor_id , 8);
|
memcpy(msch_data[dev_addr-1].vendor_id , ((scsi_inquiry_data_t*) msch_buffer)->vendor_id , 8);
|
||||||
memcpy(msch_data[dev_addr-1].product_id, ((scsi_inquiry_data_t*) msch_buffer)->product_id, 16);
|
memcpy(msch_data[dev_addr-1].product_id, ((scsi_inquiry_data_t*) msch_buffer)->product_id, 16);
|
||||||
@ -359,7 +359,7 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_
|
|||||||
//------------- SCSI Read Capacity 10 -------------//
|
//------------- SCSI Read Capacity 10 -------------//
|
||||||
tusbh_msc_read_capacity10(dev_addr, 0, msch_buffer);
|
tusbh_msc_read_capacity10(dev_addr, 0, msch_buffer);
|
||||||
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
// NOTE: my toshiba thumb-drive stall the first Read Capacity and require the sequence
|
// NOTE: my toshiba thumb-drive stall the first Read Capacity and require the sequence
|
||||||
// Read Capacity --> Stalled --> Clear Stall --> Request Sense --> Read Capacity (2) to work
|
// Read Capacity --> Stalled --> Clear Stall --> Request Sense --> Read Capacity (2) to work
|
||||||
@ -371,21 +371,21 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_
|
|||||||
0, NULL ),
|
0, NULL ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
hcd_pipe_clear_stall(msch_data[dev_addr-1].bulk_in);
|
hcd_pipe_clear_stall(msch_data[dev_addr-1].bulk_in);
|
||||||
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error); // wait for SCSI status
|
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error); // wait for SCSI status
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
//------------- SCSI Request Sense -------------//
|
//------------- SCSI Request Sense -------------//
|
||||||
(void) tuh_msc_request_sense(dev_addr, 0, msch_buffer);
|
(void) tuh_msc_request_sense(dev_addr, 0, msch_buffer);
|
||||||
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
//------------- Re-read SCSI Read Capactity -------------//
|
//------------- Re-read SCSI Read Capactity -------------//
|
||||||
tusbh_msc_read_capacity10(dev_addr, 0, msch_buffer);
|
tusbh_msc_read_capacity10(dev_addr, 0, msch_buffer);
|
||||||
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
osal_semaphore_wait(msch_sem_hdl, SCSI_XFER_TIMEOUT, &error);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
msch_data[dev_addr-1].last_lba = __be2n( ((scsi_read_capacity10_data_t*)msch_buffer)->last_lba );
|
msch_data[dev_addr-1].last_lba = __be2n( ((scsi_read_capacity10_data_t*)msch_buffer)->last_lba );
|
||||||
|
@ -81,10 +81,6 @@ extern "C"
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// tusb_error_t Status Assert TODO use ASSERT_DEFINE
|
// tusb_error_t Status Assert TODO use ASSERT_DEFINE
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define ASSERT_STATUS_MESSAGE(sts, message) \
|
|
||||||
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
|
|
||||||
TUSB_ERROR_NONE == status, status, "%s: %s", tusb_strerr[status], message)
|
|
||||||
|
|
||||||
#define ASSERT_STATUS(sts) \
|
#define ASSERT_STATUS(sts) \
|
||||||
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
|
ASSERT_DEFINE(tusb_error_t status = (tusb_error_t)(sts),\
|
||||||
TUSB_ERROR_NONE == status, status, "%s", tusb_strerr[status])
|
TUSB_ERROR_NONE == status, status, "%s", tusb_strerr[status])
|
||||||
|
@ -257,7 +257,7 @@ static tusb_error_t usbd_main_stk(void)
|
|||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
osal_queue_receive(usbd_queue_hdl, &event, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
osal_queue_receive(usbd_queue_hdl, &event, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
#else
|
#else
|
||||||
enum { ROUTINE_INTERVAL_MS = 10 };
|
enum { ROUTINE_INTERVAL_MS = 10 };
|
||||||
osal_queue_receive(usbd_queue_hdl, &event, ROUTINE_INTERVAL_MS, &error);
|
osal_queue_receive(usbd_queue_hdl, &event, ROUTINE_INTERVAL_MS, &error);
|
||||||
@ -322,7 +322,7 @@ tusb_error_t usbd_control_xfer_st(uint8_t rhport, tusb_dir_t dir, uint8_t * buff
|
|||||||
dcd_control_xfer(rhport, dir, buffer, length);
|
dcd_control_xfer(rhport, dir, buffer, length);
|
||||||
osal_semaphore_wait( usbd_control_xfer_sem_hdl, 100, &error );
|
osal_semaphore_wait( usbd_control_xfer_sem_hdl, 100, &error );
|
||||||
|
|
||||||
STASK_ASSERT_STATUS( error );
|
STASK_ASSERT_ERR( error );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status opposite direction with Zero Length
|
// Status opposite direction with Zero Length
|
||||||
@ -458,7 +458,7 @@ static tusb_error_t proc_set_config_req(uint8_t rhport, uint8_t config_number)
|
|||||||
usbd_devices[rhport].interface2class[p_desc_interface->bInterfaceNumber] = class_index;
|
usbd_devices[rhport].interface2class[p_desc_interface->bInterfaceNumber] = class_index;
|
||||||
|
|
||||||
uint16_t length=0;
|
uint16_t length=0;
|
||||||
ASSERT_STATUS( usbd_class_drivers[class_index].open( rhport, p_desc_interface, &length ) );
|
ASSERT_ERR( usbd_class_drivers[class_index].open( rhport, p_desc_interface, &length ) );
|
||||||
|
|
||||||
TU_ASSERT( length >= sizeof(tusb_desc_interface_t), TUSB_ERROR_FAILED );
|
TU_ASSERT( length >= sizeof(tusb_desc_interface_t), TUSB_ERROR_FAILED );
|
||||||
p_desc += length;
|
p_desc += length;
|
||||||
|
@ -83,7 +83,7 @@ tusb_error_t hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port,
|
|||||||
0, NULL ),
|
0, NULL ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS( error );
|
STASK_ASSERT_ERR( error );
|
||||||
|
|
||||||
//------------- Get Port Status to check if feature is cleared -------------//
|
//------------- Get Port Status to check if feature is cleared -------------//
|
||||||
STASK_INVOKE(
|
STASK_INVOKE(
|
||||||
@ -92,7 +92,7 @@ tusb_error_t hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port,
|
|||||||
4, hub_enum_buffer ),
|
4, hub_enum_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS( error );
|
STASK_ASSERT_ERR( error );
|
||||||
|
|
||||||
//------------- Check if feature is cleared -------------//
|
//------------- Check if feature is cleared -------------//
|
||||||
hub_port_status_response_t * p_port_status;
|
hub_port_status_response_t * p_port_status;
|
||||||
@ -117,7 +117,7 @@ tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port)
|
|||||||
0, NULL ),
|
0, NULL ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS( error );
|
STASK_ASSERT_ERR( error );
|
||||||
|
|
||||||
osal_task_delay(RESET_DELAY); // TODO Hub wait for Status Endpoint on Reset Change
|
osal_task_delay(RESET_DELAY); // TODO Hub wait for Status Endpoint on Reset Change
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port)
|
|||||||
4, hub_enum_buffer ),
|
4, hub_enum_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS( error );
|
STASK_ASSERT_ERR( error );
|
||||||
|
|
||||||
hub_port_status_response_t * p_port_status;
|
hub_port_status_response_t * p_port_status;
|
||||||
p_port_status = (hub_port_status_response_t *) hub_enum_buffer;
|
p_port_status = (hub_port_status_response_t *) hub_enum_buffer;
|
||||||
@ -185,7 +185,7 @@ tusb_error_t hub_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_i
|
|||||||
sizeof(descriptor_hub_desc_t), hub_enum_buffer ),
|
sizeof(descriptor_hub_desc_t), hub_enum_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
// only care about this field in hub descriptor
|
// only care about this field in hub descriptor
|
||||||
hub_data[dev_addr-1].port_number = ((descriptor_hub_desc_t*) hub_enum_buffer)->bNbrPorts;
|
hub_data[dev_addr-1].port_number = ((descriptor_hub_desc_t*) hub_enum_buffer)->bNbrPorts;
|
||||||
@ -203,7 +203,7 @@ tusb_error_t hub_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------- Queue the initial Status endpoint transfer -------------//
|
//------------- Queue the initial Status endpoint transfer -------------//
|
||||||
STASK_ASSERT_STATUS ( hcd_pipe_xfer(hub_data[dev_addr-1].pipe_status, &hub_data[dev_addr-1].status_change, 1, true) );
|
STASK_ASSERT_ERR ( hcd_pipe_xfer(hub_data[dev_addr-1].pipe_status, &hub_data[dev_addr-1].status_change, 1, true) );
|
||||||
|
|
||||||
OSAL_SUBTASK_END
|
OSAL_SUBTASK_END
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType,
|
|||||||
OSAL_SUBTASK_BEGIN
|
OSAL_SUBTASK_BEGIN
|
||||||
|
|
||||||
osal_mutex_wait(usbh_devices[dev_addr].control.mutex_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
osal_mutex_wait(usbh_devices[dev_addr].control.mutex_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
||||||
STASK_ASSERT_STATUS_HDLR(error, osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl));
|
STASK_ASSERT_ERR_HDLR(error, osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl));
|
||||||
|
|
||||||
usbh_devices[dev_addr].control.request = (tusb_control_request_t) {
|
usbh_devices[dev_addr].control.request = (tusb_control_request_t) {
|
||||||
{.bmRequestType = bmRequestType},
|
{.bmRequestType = bmRequestType},
|
||||||
@ -206,7 +206,7 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType,
|
|||||||
if ( TUSB_ERROR_NONE == error ) osal_semaphore_wait(usbh_devices[dev_addr].control.sem_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
if ( TUSB_ERROR_NONE == error ) osal_semaphore_wait(usbh_devices[dev_addr].control.sem_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
||||||
osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl);
|
osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl);
|
||||||
|
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
if (TUSB_EVENT_XFER_STALLED == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_STALLED);
|
if (TUSB_EVENT_XFER_STALLED == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_STALLED);
|
||||||
if (TUSB_EVENT_XFER_ERROR == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_FAILED);
|
if (TUSB_EVENT_XFER_ERROR == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_FAILED);
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
OSAL_SUBTASK_BEGIN
|
OSAL_SUBTASK_BEGIN
|
||||||
|
|
||||||
osal_queue_receive(enum_queue_hdl, &enum_entry, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
osal_queue_receive(enum_queue_hdl, &enum_entry, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
usbh_devices[0].core_id = enum_entry.core_id; // TODO refractor integrate to device_pool
|
usbh_devices[0].core_id = enum_entry.core_id; // TODO refractor integrate to device_pool
|
||||||
usbh_devices[0].hub_addr = enum_entry.hub_addr;
|
usbh_devices[0].hub_addr = enum_entry.hub_addr;
|
||||||
@ -412,8 +412,8 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
4, enum_data_buffer ),
|
4, enum_data_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
// STASK_ASSERT_STATUS( error );
|
// STASK_ASSERT_ERR( error );
|
||||||
STASK_ASSERT_STATUS_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
STASK_ASSERT_ERR_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
||||||
|
|
||||||
// Acknowledge Port Connection Change
|
// Acknowledge Port Connection Change
|
||||||
STASK_INVOKE( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_CONNECTION_CHANGE), error );
|
STASK_INVOKE( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_CONNECTION_CHANGE), error );
|
||||||
@ -433,8 +433,8 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
else
|
else
|
||||||
{ // Connection Event
|
{ // Connection Event
|
||||||
STASK_INVOKE ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
STASK_INVOKE ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
||||||
// STASK_ASSERT_STATUS( error );
|
// STASK_ASSERT_ERR( error );
|
||||||
STASK_ASSERT_STATUS_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
STASK_ASSERT_ERR_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
||||||
|
|
||||||
usbh_devices[0].speed = hub_port_get_speed();
|
usbh_devices[0].speed = hub_port_get_speed();
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STASK_ASSERT_STATUS( usbh_pipe_control_open(0, 8) );
|
STASK_ASSERT_ERR( usbh_pipe_control_open(0, 8) );
|
||||||
usbh_devices[0].state = TUSB_DEVICE_STATE_ADDRESSED;
|
usbh_devices[0].state = TUSB_DEVICE_STATE_ADDRESSED;
|
||||||
|
|
||||||
//------------- Get first 8 bytes of device descriptor to get Control Endpoint Size -------------//
|
//------------- Get first 8 bytes of device descriptor to get Control Endpoint Size -------------//
|
||||||
@ -458,14 +458,14 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
//------------- Reset device again before Set Address -------------//
|
//------------- Reset device again before Set Address -------------//
|
||||||
if (usbh_devices[0].hub_addr == 0)
|
if (usbh_devices[0].hub_addr == 0)
|
||||||
{ // connected directly to roothub
|
{ // connected directly to roothub
|
||||||
STASK_ASSERT_STATUS(error); // TODO some slow device is observed to fail the very fist controller xfer, can try more times
|
STASK_ASSERT_ERR(error); // TODO some slow device is observed to fail the very fist controller xfer, can try more times
|
||||||
hcd_port_reset( usbh_devices[0].core_id ); // reset port after 8 byte descriptor
|
hcd_port_reset( usbh_devices[0].core_id ); // reset port after 8 byte descriptor
|
||||||
osal_task_delay(RESET_DELAY);
|
osal_task_delay(RESET_DELAY);
|
||||||
}
|
}
|
||||||
#if TUSB_CFG_HOST_HUB
|
#if TUSB_CFG_HOST_HUB
|
||||||
else
|
else
|
||||||
{ // connected via a hub
|
{ // connected via a hub
|
||||||
STASK_ASSERT_STATUS_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
STASK_ASSERT_ERR_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
||||||
STASK_INVOKE ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
STASK_INVOKE ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
||||||
|
|
||||||
if ( TUSB_ERROR_NONE == error )
|
if ( TUSB_ERROR_NONE == error )
|
||||||
@ -487,7 +487,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
0, NULL ),
|
0, NULL ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
//------------- update port info & close control pipe of addr0 -------------//
|
//------------- update port info & close control pipe of addr0 -------------//
|
||||||
usbh_devices[new_addr].core_id = usbh_devices[0].core_id;
|
usbh_devices[new_addr].core_id = usbh_devices[0].core_id;
|
||||||
@ -500,7 +500,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
|
usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
|
||||||
|
|
||||||
// open control pipe for new address
|
// open control pipe for new address
|
||||||
STASK_ASSERT_STATUS ( usbh_pipe_control_open(new_addr, ((tusb_desc_device_t*) enum_data_buffer)->bMaxPacketSize0 ) );
|
STASK_ASSERT_ERR ( usbh_pipe_control_open(new_addr, ((tusb_desc_device_t*) enum_data_buffer)->bMaxPacketSize0 ) );
|
||||||
|
|
||||||
//------------- Get full device descriptor -------------//
|
//------------- Get full device descriptor -------------//
|
||||||
STASK_INVOKE(
|
STASK_INVOKE(
|
||||||
@ -509,7 +509,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
18, enum_data_buffer ),
|
18, enum_data_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
// update device info TODO alignment issue
|
// update device info TODO alignment issue
|
||||||
usbh_devices[new_addr].vendor_id = ((tusb_desc_device_t*) enum_data_buffer)->idVendor;
|
usbh_devices[new_addr].vendor_id = ((tusb_desc_device_t*) enum_data_buffer)->idVendor;
|
||||||
@ -526,7 +526,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
9, enum_data_buffer ),
|
9, enum_data_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
STASK_ASSERT_HDLR( TUSB_CFG_HOST_ENUM_BUFFER_SIZE >= ((tusb_desc_configuration_t*)enum_data_buffer)->wTotalLength,
|
STASK_ASSERT_HDLR( TUSB_CFG_HOST_ENUM_BUFFER_SIZE >= ((tusb_desc_configuration_t*)enum_data_buffer)->wTotalLength,
|
||||||
tuh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_CONFIG_DESC_TOO_LONG, NULL) );
|
tuh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_CONFIG_DESC_TOO_LONG, NULL) );
|
||||||
|
|
||||||
@ -537,7 +537,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
TUSB_CFG_HOST_ENUM_BUFFER_SIZE, enum_data_buffer ),
|
TUSB_CFG_HOST_ENUM_BUFFER_SIZE, enum_data_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
// update configuration info
|
// update configuration info
|
||||||
usbh_devices[new_addr].interface_count = ((tusb_desc_configuration_t*) enum_data_buffer)->bNumInterfaces;
|
usbh_devices[new_addr].interface_count = ((tusb_desc_configuration_t*) enum_data_buffer)->bNumInterfaces;
|
||||||
@ -549,7 +549,7 @@ tusb_error_t enumeration_body_subtask(void)
|
|||||||
0, NULL ),
|
0, NULL ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
STASK_ASSERT_STATUS(error);
|
STASK_ASSERT_ERR(error);
|
||||||
|
|
||||||
usbh_devices[new_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
|
usbh_devices[new_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
|
||||||
|
|
||||||
|
@ -78,11 +78,11 @@
|
|||||||
#define STASK_INVOKE(_subtask, _status) (_status) = _subtask
|
#define STASK_INVOKE(_subtask, _status) (_status) = _subtask
|
||||||
|
|
||||||
//------------- Sub Task Assert -------------//
|
//------------- Sub Task Assert -------------//
|
||||||
#define STASK_ASSERT_STATUS(sts) VERIFY_STATUS(sts)
|
#define STASK_ASSERT_ERR(_err) VERIFY_STATUS(_err)
|
||||||
#define STASK_ASSERT(condition) VERIFY(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
#define STASK_ASSERT_ERR_HDLR(_err, _func) VERIFY_STATUS_HDLR(_err, _func)
|
||||||
|
|
||||||
#define STASK_ASSERT_STATUS_HDLR(sts, func_call) VERIFY_STATUS_HDLR(sts, func_call)
|
#define STASK_ASSERT(_cond) VERIFY(_cond, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||||
#define STASK_ASSERT_HDLR(condition, func_call) VERIFY_HDLR(condition, func_call)
|
#define STASK_ASSERT_HDLR(_cond, _func) VERIFY_HDLR(_cond, _func)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -125,11 +125,11 @@ static inline osal_task_t osal_task_create(osal_func_t code, const char* name, u
|
|||||||
//------------- Sub Task Assert -------------//
|
//------------- Sub Task Assert -------------//
|
||||||
#define STASK_RETURN(error) do { TASK_RESTART; return error; } while(0)
|
#define STASK_RETURN(error) do { TASK_RESTART; return error; } while(0)
|
||||||
|
|
||||||
#define STASK_ASSERT_STATUS(sts) VERIFY_STATUS_HDLR(sts, TASK_RESTART)
|
#define STASK_ASSERT_ERR(_err) VERIFY_STATUS_HDLR(_err, TASK_RESTART)
|
||||||
#define STASK_ASSERT_STATUS_HDLR(sts, func_call) VERIFY_STATUS_HDLR(sts, func_call; TASK_RESTART )
|
#define STASK_ASSERT_ERR_HDLR(_err, _func) VERIFY_STATUS_HDLR(_err, _func; TASK_RESTART )
|
||||||
|
|
||||||
#define STASK_ASSERT(condition) VERIFY_HDLR(condition, TASK_RESTART)
|
#define STASK_ASSERT(_cond) VERIFY_HDLR(_cond, TASK_RESTART)
|
||||||
#define STASK_ASSERT_HDLR(condition, func_call) VERIFY_HDLR(condition, func_call; TASK_RESTART)
|
#define STASK_ASSERT_HDLR(_cond, _func) VERIFY_HDLR(_cond, _func; TASK_RESTART)
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// QUEUE API
|
// QUEUE API
|
||||||
|
@ -316,10 +316,10 @@ static tusb_error_t pipe_control_xfer(uint8_t ep_id, uint8_t* p_buffer, uint16_t
|
|||||||
|
|
||||||
if (ep_id)
|
if (ep_id)
|
||||||
{
|
{
|
||||||
ASSERT_STATUS ( pipe_control_write(p_buffer, packet_len) );
|
ASSERT_ERR ( pipe_control_write(p_buffer, packet_len) );
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
ASSERT_STATUS ( pipe_control_read(p_buffer, packet_len) );
|
ASSERT_ERR ( pipe_control_read(p_buffer, packet_len) );
|
||||||
}
|
}
|
||||||
|
|
||||||
dcd_data.control_dma.remaining_bytes -= packet_len;
|
dcd_data.control_dma.remaining_bytes -= packet_len;
|
||||||
|
@ -46,11 +46,11 @@ tusb_error_t tusb_init(void)
|
|||||||
VERIFY( tusb_hal_init(), TUSB_ERROR_FAILED ) ; // hardware init
|
VERIFY( tusb_hal_init(), TUSB_ERROR_FAILED ) ; // hardware init
|
||||||
|
|
||||||
#if MODE_HOST_SUPPORTED
|
#if MODE_HOST_SUPPORTED
|
||||||
ASSERT_STATUS( usbh_init() ); // host stack init
|
ASSERT_ERR( usbh_init() ); // host stack init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MODE_DEVICE_SUPPORTED
|
#if MODE_DEVICE_SUPPORTED
|
||||||
ASSERT_STATUS ( usbd_init() ); // device stack init
|
ASSERT_ERR ( usbd_init() ); // device stack init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user