osal subtask rename
This commit is contained in:
parent
047bc5eeb1
commit
17a227ca90
|
@ -386,7 +386,7 @@ tusb_error_t sample_flow_control_subtask2(void)
|
||||||
statements[2]++;
|
statements[2]++;
|
||||||
|
|
||||||
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
osal_semaphore_wait(sem_hdl, OSAL_TIMEOUT_NORMAL, &error);
|
||||||
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error, flow_control_error_handler());
|
SUBTASK_ASSERT_STATUS_HDLR(error, flow_control_error_handler());
|
||||||
statements[3]++;
|
statements[3]++;
|
||||||
|
|
||||||
OSAL_SUBTASK_END
|
OSAL_SUBTASK_END
|
||||||
|
|
|
@ -221,12 +221,12 @@ tusb_error_t cdcd_control_request_subtask(uint8_t port, tusb_control_request_t c
|
||||||
|
|
||||||
if (CDC_REQUEST_GET_LINE_CODING == p_request->bRequest)
|
if (CDC_REQUEST_GET_LINE_CODING == p_request->bRequest)
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_INVOKED( usbd_control_xfer_substak(port, (tusb_dir_t) p_request->bmRequestType_bit.direction,
|
SUBTASK_INVOKE( usbd_control_xfer_substak(port, (tusb_dir_t) p_request->bmRequestType_bit.direction,
|
||||||
(uint8_t*) &cdcd_line_coding[port], min16_of(sizeof(cdc_line_coding_t), p_request->wLength)), err );
|
(uint8_t*) &cdcd_line_coding[port], min16_of(sizeof(cdc_line_coding_t), p_request->wLength)), err );
|
||||||
}
|
}
|
||||||
else if (CDC_REQUEST_SET_LINE_CODING == p_request->bRequest)
|
else if (CDC_REQUEST_SET_LINE_CODING == p_request->bRequest)
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_INVOKED( usbd_control_xfer_substak(port, (tusb_dir_t) p_request->bmRequestType_bit.direction,
|
SUBTASK_INVOKE( usbd_control_xfer_substak(port, (tusb_dir_t) p_request->bmRequestType_bit.direction,
|
||||||
(uint8_t*) &cdcd_line_coding[port], min16_of(sizeof(cdc_line_coding_t), p_request->wLength)), err );
|
(uint8_t*) &cdcd_line_coding[port], min16_of(sizeof(cdc_line_coding_t), p_request->wLength)), err );
|
||||||
// TODO notify application on xfer complete
|
// TODO notify application on xfer complete
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
|
||||||
|
|
||||||
//------------- Message Initialize -------------//
|
//------------- Message Initialize -------------//
|
||||||
memcpy(msg_payload, &msg_init, sizeof(rndis_msg_initialize_t));
|
memcpy(msg_payload, &msg_init, sizeof(rndis_msg_initialize_t));
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
send_message_get_response_subtask( dev_addr, p_cdc,
|
send_message_get_response_subtask( dev_addr, p_cdc,
|
||||||
msg_payload, sizeof(rndis_msg_initialize_t),
|
msg_payload, sizeof(rndis_msg_initialize_t),
|
||||||
msg_payload),
|
msg_payload),
|
||||||
|
@ -191,7 +191,7 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
|
||||||
memcpy(msg_payload, &msg_query_permanent_addr, sizeof(rndis_msg_query_t));
|
memcpy(msg_payload, &msg_query_permanent_addr, sizeof(rndis_msg_query_t));
|
||||||
memclr_(msg_payload + sizeof(rndis_msg_query_t), 6); // 6 bytes for MAC address
|
memclr_(msg_payload + sizeof(rndis_msg_query_t), 6); // 6 bytes for MAC address
|
||||||
|
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
send_message_get_response_subtask( dev_addr, p_cdc,
|
send_message_get_response_subtask( dev_addr, p_cdc,
|
||||||
msg_payload, sizeof(rndis_msg_query_t) + 6,
|
msg_payload, sizeof(rndis_msg_query_t) + 6,
|
||||||
msg_payload),
|
msg_payload),
|
||||||
|
@ -208,7 +208,7 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc)
|
||||||
memclr_(msg_payload + sizeof(rndis_msg_set_t), 4); // 4 bytes for filter flags
|
memclr_(msg_payload + sizeof(rndis_msg_set_t), 4); // 4 bytes for filter flags
|
||||||
((rndis_msg_set_t*) msg_payload)->oid_buffer[0] = (RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_MULTICAST | RNDIS_PACKET_TYPE_BROADCAST);
|
((rndis_msg_set_t*) msg_payload)->oid_buffer[0] = (RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_MULTICAST | RNDIS_PACKET_TYPE_BROADCAST);
|
||||||
|
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
send_message_get_response_subtask( dev_addr, p_cdc,
|
send_message_get_response_subtask( dev_addr, p_cdc,
|
||||||
msg_payload, sizeof(rndis_msg_set_t) + 4,
|
msg_payload, sizeof(rndis_msg_set_t) + 4,
|
||||||
msg_payload),
|
msg_payload),
|
||||||
|
@ -244,7 +244,7 @@ static tusb_error_t send_message_get_response_subtask( uint8_t dev_addr, cdch_da
|
||||||
OSAL_SUBTASK_BEGIN
|
OSAL_SUBTASK_BEGIN
|
||||||
|
|
||||||
//------------- Send RNDIS Control Message -------------//
|
//------------- Send RNDIS Control Message -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
||||||
CDC_REQUEST_SEND_ENCAPSULATED_COMMAND, 0, p_cdc->interface_number,
|
CDC_REQUEST_SEND_ENCAPSULATED_COMMAND, 0, p_cdc->interface_number,
|
||||||
mess_length, p_mess),
|
mess_length, p_mess),
|
||||||
|
@ -259,7 +259,7 @@ static tusb_error_t send_message_get_response_subtask( uint8_t dev_addr, cdch_da
|
||||||
SUBTASK_ASSERT(msg_notification[dev_addr-1][0] == 1);
|
SUBTASK_ASSERT(msg_notification[dev_addr-1][0] == 1);
|
||||||
|
|
||||||
//------------- Get RNDIS Message Initialize Complete -------------//
|
//------------- Get RNDIS Message Initialize Complete -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
||||||
CDC_REQUEST_GET_ENCAPSULATED_RESPONSE, 0, p_cdc->interface_number,
|
CDC_REQUEST_GET_ENCAPSULATED_RESPONSE, 0, p_cdc->interface_number,
|
||||||
RNDIS_MSG_PAYLOAD_MAX, p_response),
|
RNDIS_MSG_PAYLOAD_MAX, p_response),
|
||||||
|
|
|
@ -198,7 +198,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||||
OSAL_SUBTASK_BEGIN
|
OSAL_SUBTASK_BEGIN
|
||||||
|
|
||||||
//------------- SET IDLE (0) request -------------//
|
//------------- SET IDLE (0) request -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
||||||
HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
|
HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
@ -210,7 +210,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||||
//------------- Get Report Descriptor TODO HID parser -------------//
|
//------------- Get Report Descriptor TODO HID parser -------------//
|
||||||
if ( p_desc_hid->bNumDescriptors )
|
if ( p_desc_hid->bNumDescriptors )
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_INTERFACE),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_INTERFACE),
|
||||||
TUSB_REQ_GET_DESCRIPTOR, (p_desc_hid->bReportType << 8), 0,
|
TUSB_REQ_GET_DESCRIPTOR, (p_desc_hid->bReportType << 8), 0,
|
||||||
p_desc_hid->wReportLength, report_descriptor ),
|
p_desc_hid->wReportLength, report_descriptor ),
|
||||||
|
|
|
@ -139,7 +139,7 @@ tusb_error_t mscd_control_request_subtask(uint8_t port, tusb_control_request_t c
|
||||||
{
|
{
|
||||||
// Note: lpc11/13u need xfer data's address to be aligned 64 -> make use of scsi_data instead of using max_lun directly
|
// Note: lpc11/13u need xfer data's address to be aligned 64 -> make use of scsi_data instead of using max_lun directly
|
||||||
p_msc->scsi_data[0] = p_msc->max_lun;
|
p_msc->scsi_data[0] = p_msc->max_lun;
|
||||||
OSAL_SUBTASK_INVOKED( usbd_control_xfer_substak(port, TUSB_DIR_IN, p_msc->scsi_data, 1), err);
|
SUBTASK_INVOKE( usbd_control_xfer_substak(port, TUSB_DIR_IN, p_msc->scsi_data, 1), err);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
SUBTASK_RETURN(TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT);
|
SUBTASK_RETURN(TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT);
|
||||||
|
|
|
@ -327,7 +327,7 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||||
|
|
||||||
|
|
||||||
//------------- Get Max Lun -------------//
|
//------------- Get Max Lun -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
||||||
MSC_REQUEST_GET_MAX_LUN, 0, msch_data[dev_addr-1].interface_number,
|
MSC_REQUEST_GET_MAX_LUN, 0, msch_data[dev_addr-1].interface_number,
|
||||||
1, msch_buffer ),
|
1, msch_buffer ),
|
||||||
|
@ -339,7 +339,7 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
//------------- Reset -------------//
|
//------------- Reset -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_INTERFACE),
|
||||||
MSC_REQUEST_RESET, 0, msch_data[dev_addr-1].interface_number,
|
MSC_REQUEST_RESET, 0, msch_data[dev_addr-1].interface_number,
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
@ -365,7 +365,7 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||||
// Read Capacity --> Stalled --> Clear Stall --> Request Sense --> Read Capacity (2) to work
|
// Read Capacity --> Stalled --> Clear Stall --> Request Sense --> Read Capacity (2) to work
|
||||||
if ( hcd_pipe_is_stalled(msch_data[dev_addr-1].bulk_in) )
|
if ( hcd_pipe_is_stalled(msch_data[dev_addr-1].bulk_in) )
|
||||||
{ // clear stall TODO abstract clear stall function
|
{ // clear stall TODO abstract clear stall function
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_ENDPOINT),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_ENDPOINT),
|
||||||
TUSB_REQ_CLEAR_FEATURE, 0, hcd_pipe_get_endpoint_addr(msch_data[dev_addr-1].bulk_in),
|
TUSB_REQ_CLEAR_FEATURE, 0, hcd_pipe_get_endpoint_addr(msch_data[dev_addr-1].bulk_in),
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
|
|
@ -254,7 +254,7 @@ static tusb_error_t usbd_body_subtask(void)
|
||||||
|
|
||||||
if ( USBD_EVENTID_SETUP_RECEIVED == event.event_id )
|
if ( USBD_EVENTID_SETUP_RECEIVED == event.event_id )
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_INVOKED( usbd_control_request_subtask(event.port, &event.setup_received), error );
|
SUBTASK_INVOKE( usbd_control_request_subtask(event.port, &event.setup_received), error );
|
||||||
}else if (USBD_EVENTID_XFER_DONE == event.event_id)
|
}else if (USBD_EVENTID_XFER_DONE == event.event_id)
|
||||||
{
|
{
|
||||||
// Call class handling function, Class that endpoint not belong to should check and return
|
// Call class handling function, Class that endpoint not belong to should check and return
|
||||||
|
@ -329,7 +329,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t port, tusb_control_request_t c
|
||||||
|
|
||||||
if ( TUSB_ERROR_NONE == error )
|
if ( TUSB_ERROR_NONE == error )
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_INVOKED ( usbd_control_xfer_substak(port, (tusb_dir_t) p_request->bmRequestType_bit.direction, (uint8_t*) p_buffer, length ), error );
|
SUBTASK_INVOKE ( usbd_control_xfer_substak(port, (tusb_dir_t) p_request->bmRequestType_bit.direction, (uint8_t*) p_buffer, length ), error );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( TUSB_REQ_SET_ADDRESS == p_request->bRequest )
|
else if ( TUSB_REQ_SET_ADDRESS == p_request->bRequest )
|
||||||
|
@ -361,7 +361,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t port, tusb_control_request_t c
|
||||||
if ( (class_code > 0) && (class_code < USBD_CLASS_DRIVER_COUNT) &&
|
if ( (class_code > 0) && (class_code < USBD_CLASS_DRIVER_COUNT) &&
|
||||||
usbd_class_drivers[class_code].control_request_subtask )
|
usbd_class_drivers[class_code].control_request_subtask )
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_INVOKED( usbd_class_drivers[class_code].control_request_subtask(port, p_request), error );
|
SUBTASK_INVOKE( usbd_class_drivers[class_code].control_request_subtask(port, p_request), error );
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
error = TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
|
error = TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
|
||||||
|
|
|
@ -77,7 +77,7 @@ tusb_error_t hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port,
|
||||||
feature <= HUB_FEATURE_PORT_RESET_CHANGE);
|
feature <= HUB_FEATURE_PORT_RESET_CHANGE);
|
||||||
|
|
||||||
//------------- Clear Port Feature request -------------//
|
//------------- Clear Port Feature request -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
||||||
HUB_REQUEST_CLEAR_FEATURE, feature, hub_port,
|
HUB_REQUEST_CLEAR_FEATURE, feature, hub_port,
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
@ -86,7 +86,7 @@ tusb_error_t hub_port_clear_feature_subtask(uint8_t hub_addr, uint8_t hub_port,
|
||||||
SUBTASK_ASSERT_STATUS( error );
|
SUBTASK_ASSERT_STATUS( error );
|
||||||
|
|
||||||
//------------- Get Port Status to check if feature is cleared -------------//
|
//------------- Get Port Status to check if feature is cleared -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
||||||
HUB_REQUEST_GET_STATUS, 0, hub_port,
|
HUB_REQUEST_GET_STATUS, 0, hub_port,
|
||||||
4, hub_enum_buffer ),
|
4, hub_enum_buffer ),
|
||||||
|
@ -111,7 +111,7 @@ tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port)
|
||||||
OSAL_SUBTASK_BEGIN
|
OSAL_SUBTASK_BEGIN
|
||||||
|
|
||||||
//------------- Set Port Reset -------------//
|
//------------- Set Port Reset -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
||||||
HUB_REQUEST_SET_FEATURE, HUB_FEATURE_PORT_RESET, hub_port,
|
HUB_REQUEST_SET_FEATURE, HUB_FEATURE_PORT_RESET, hub_port,
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
@ -122,7 +122,7 @@ tusb_error_t hub_port_reset_subtask(uint8_t hub_addr, uint8_t hub_port)
|
||||||
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
|
||||||
|
|
||||||
//------------- Get Port Status to check if port is enabled, powered and reset_change -------------//
|
//------------- Get Port Status to check if port is enabled, powered and reset_change -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
usbh_control_xfer_subtask( hub_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
||||||
HUB_REQUEST_GET_STATUS, 0, hub_port,
|
HUB_REQUEST_GET_STATUS, 0, hub_port,
|
||||||
4, hub_enum_buffer ),
|
4, hub_enum_buffer ),
|
||||||
|
@ -179,7 +179,7 @@ tusb_error_t hub_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t cons
|
||||||
(*p_length) = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_descriptor_endpoint_t);
|
(*p_length) = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_descriptor_endpoint_t);
|
||||||
|
|
||||||
//------------- Get Hub Descriptor -------------//
|
//------------- Get Hub Descriptor -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_DEVICE),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_DEVICE),
|
||||||
HUB_REQUEST_GET_DESCRIPTOR, 0, 0,
|
HUB_REQUEST_GET_DESCRIPTOR, 0, 0,
|
||||||
sizeof(descriptor_hub_desc_t), hub_enum_buffer ),
|
sizeof(descriptor_hub_desc_t), hub_enum_buffer ),
|
||||||
|
@ -194,7 +194,7 @@ tusb_error_t hub_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t cons
|
||||||
static uint8_t i;
|
static uint8_t i;
|
||||||
for(i=1; i <= hub_data[dev_addr-1].port_number; i++)
|
for(i=1; i <= hub_data[dev_addr-1].port_number; i++)
|
||||||
{
|
{
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
||||||
HUB_REQUEST_SET_FEATURE, HUB_FEATURE_PORT_POWER, i,
|
HUB_REQUEST_SET_FEATURE, HUB_FEATURE_PORT_POWER, i,
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
|
|
@ -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);
|
||||||
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error, osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl));
|
SUBTASK_ASSERT_STATUS_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},
|
||||||
|
@ -210,7 +210,7 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType,
|
||||||
if (TUSB_EVENT_XFER_STALLED == usbh_devices[dev_addr].control.pipe_status) SUBTASK_RETURN(TUSB_ERROR_USBH_XFER_STALLED);
|
if (TUSB_EVENT_XFER_STALLED == usbh_devices[dev_addr].control.pipe_status) SUBTASK_RETURN(TUSB_ERROR_USBH_XFER_STALLED);
|
||||||
if (TUSB_EVENT_XFER_ERROR == usbh_devices[dev_addr].control.pipe_status) SUBTASK_RETURN(TUSB_ERROR_USBH_XFER_FAILED);
|
if (TUSB_EVENT_XFER_ERROR == usbh_devices[dev_addr].control.pipe_status) SUBTASK_RETURN(TUSB_ERROR_USBH_XFER_FAILED);
|
||||||
|
|
||||||
// SUBTASK_ASSERT_WITH_HANDLER(TUSB_ERROR_NONE == error &&
|
// SUBTASK_ASSERT_HDLR(TUSB_ERROR_NONE == error &&
|
||||||
// TUSB_EVENT_XFER_COMPLETE == usbh_devices[dev_addr].control.pipe_status,
|
// TUSB_EVENT_XFER_COMPLETE == usbh_devices[dev_addr].control.pipe_status,
|
||||||
// tuh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL) );
|
// tuh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL) );
|
||||||
|
|
||||||
|
@ -406,17 +406,17 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//------------- Get Port Status -------------//
|
//------------- Get Port Status -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( usbh_devices[0].hub_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
usbh_control_xfer_subtask( usbh_devices[0].hub_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_CLASS, TUSB_REQ_RCPT_OTHER),
|
||||||
HUB_REQUEST_GET_STATUS, 0, usbh_devices[0].hub_port,
|
HUB_REQUEST_GET_STATUS, 0, usbh_devices[0].hub_port,
|
||||||
4, enum_data_buffer ),
|
4, enum_data_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
// SUBTASK_ASSERT_STATUS( error );
|
// SUBTASK_ASSERT_STATUS( error );
|
||||||
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
SUBTASK_ASSERT_STATUS_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
||||||
|
|
||||||
// Acknowledge Port Connection Change
|
// Acknowledge Port Connection Change
|
||||||
OSAL_SUBTASK_INVOKED( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_CONNECTION_CHANGE), error );
|
SUBTASK_INVOKE( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_CONNECTION_CHANGE), 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 *) enum_data_buffer);
|
p_port_status = ((hub_port_status_response_t *) enum_data_buffer);
|
||||||
|
@ -432,14 +432,14 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Connection Event
|
{ // Connection Event
|
||||||
OSAL_SUBTASK_INVOKED ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
SUBTASK_INVOKE ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
||||||
// SUBTASK_ASSERT_STATUS( error );
|
// SUBTASK_ASSERT_STATUS( error );
|
||||||
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
SUBTASK_ASSERT_STATUS_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();
|
||||||
|
|
||||||
// Acknowledge Port Reset Change
|
// Acknowledge Port Reset Change
|
||||||
OSAL_SUBTASK_INVOKED( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_RESET_CHANGE), error );
|
SUBTASK_INVOKE( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_RESET_CHANGE), error );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -448,7 +448,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
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 -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( 0, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
usbh_control_xfer_subtask( 0, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
||||||
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_DEVICE << 8), 0,
|
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_DEVICE << 8), 0,
|
||||||
8, enum_data_buffer ),
|
8, enum_data_buffer ),
|
||||||
|
@ -465,12 +465,12 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
#if TUSB_CFG_HOST_HUB
|
#if TUSB_CFG_HOST_HUB
|
||||||
else
|
else
|
||||||
{ // connected via a hub
|
{ // connected via a hub
|
||||||
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
SUBTASK_ASSERT_STATUS_HDLR(error, hub_status_pipe_queue( usbh_devices[0].hub_addr) ); // TODO hub refractor
|
||||||
OSAL_SUBTASK_INVOKED ( hub_port_reset_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port), error );
|
SUBTASK_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 )
|
||||||
{ // Acknowledge Port Reset Change if Reset Successful
|
{ // Acknowledge Port Reset Change if Reset Successful
|
||||||
OSAL_SUBTASK_INVOKED( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_RESET_CHANGE), error );
|
SUBTASK_INVOKE( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_RESET_CHANGE), error );
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) hub_status_pipe_queue( usbh_devices[0].hub_addr ); // done with hub, waiting for next data on status pipe
|
(void) hub_status_pipe_queue( usbh_devices[0].hub_addr ); // done with hub, waiting for next data on status pipe
|
||||||
|
@ -481,7 +481,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
new_addr = get_new_address();
|
new_addr = get_new_address();
|
||||||
SUBTASK_ASSERT(new_addr <= TUSB_CFG_HOST_DEVICE_MAX); // TODO notify application we reach max devices
|
SUBTASK_ASSERT(new_addr <= TUSB_CFG_HOST_DEVICE_MAX); // TODO notify application we reach max devices
|
||||||
|
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( 0, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
usbh_control_xfer_subtask( 0, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
||||||
TUSB_REQ_SET_ADDRESS, new_addr, 0,
|
TUSB_REQ_SET_ADDRESS, new_addr, 0,
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
@ -503,7 +503,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
SUBTASK_ASSERT_STATUS ( usbh_pipe_control_open(new_addr, ((tusb_descriptor_device_t*) enum_data_buffer)->bMaxPacketSize0 ) );
|
SUBTASK_ASSERT_STATUS ( usbh_pipe_control_open(new_addr, ((tusb_descriptor_device_t*) enum_data_buffer)->bMaxPacketSize0 ) );
|
||||||
|
|
||||||
//------------- Get full device descriptor -------------//
|
//------------- Get full device descriptor -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
||||||
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_DEVICE << 8), 0,
|
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_DEVICE << 8), 0,
|
||||||
18, enum_data_buffer ),
|
18, enum_data_buffer ),
|
||||||
|
@ -520,18 +520,18 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
SUBTASK_ASSERT(configure_selected <= usbh_devices[new_addr].configure_count); // TODO notify application when invalid configuration
|
SUBTASK_ASSERT(configure_selected <= usbh_devices[new_addr].configure_count); // TODO notify application when invalid configuration
|
||||||
|
|
||||||
//------------- Get 9 bytes of configuration descriptor -------------//
|
//------------- Get 9 bytes of configuration descriptor -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
||||||
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_CONFIGURATION << 8) | (configure_selected - 1), 0,
|
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_CONFIGURATION << 8) | (configure_selected - 1), 0,
|
||||||
9, enum_data_buffer ),
|
9, enum_data_buffer ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
SUBTASK_ASSERT_STATUS(error);
|
SUBTASK_ASSERT_STATUS(error);
|
||||||
SUBTASK_ASSERT_WITH_HANDLER( TUSB_CFG_HOST_ENUM_BUFFER_SIZE >= ((tusb_descriptor_configuration_t*)enum_data_buffer)->wTotalLength,
|
SUBTASK_ASSERT_HDLR( TUSB_CFG_HOST_ENUM_BUFFER_SIZE >= ((tusb_descriptor_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) );
|
||||||
|
|
||||||
//------------- Get full configuration descriptor -------------//
|
//------------- Get full configuration descriptor -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_IN, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
||||||
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_CONFIGURATION << 8) | (configure_selected - 1), 0,
|
TUSB_REQ_GET_DESCRIPTOR, (TUSB_DESC_CONFIGURATION << 8) | (configure_selected - 1), 0,
|
||||||
TUSB_CFG_HOST_ENUM_BUFFER_SIZE, enum_data_buffer ),
|
TUSB_CFG_HOST_ENUM_BUFFER_SIZE, enum_data_buffer ),
|
||||||
|
@ -543,7 +543,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
usbh_devices[new_addr].interface_count = ((tusb_descriptor_configuration_t*) enum_data_buffer)->bNumInterfaces;
|
usbh_devices[new_addr].interface_count = ((tusb_descriptor_configuration_t*) enum_data_buffer)->bNumInterfaces;
|
||||||
|
|
||||||
//------------- Set Configure -------------//
|
//------------- Set Configure -------------//
|
||||||
OSAL_SUBTASK_INVOKED(
|
SUBTASK_INVOKE(
|
||||||
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_OUT, TUSB_REQ_TYPE_STANDARD, TUSB_REQ_RCPT_DEVICE),
|
||||||
TUSB_REQ_SET_CONFIGURATION, configure_selected, 0,
|
TUSB_REQ_SET_CONFIGURATION, configure_selected, 0,
|
||||||
0, NULL ),
|
0, NULL ),
|
||||||
|
@ -578,7 +578,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||||
static uint16_t length;
|
static uint16_t length;
|
||||||
length = 0;
|
length = 0;
|
||||||
|
|
||||||
OSAL_SUBTASK_INVOKED ( // parameters in task/sub_task must be static storage (static or global)
|
SUBTASK_INVOKE ( // parameters in task/sub_task must be static storage (static or global)
|
||||||
usbh_class_drivers[class_index].open_subtask( new_addr, (tusb_descriptor_interface_t*) p_desc, &length ),
|
usbh_class_drivers[class_index].open_subtask( new_addr, (tusb_descriptor_interface_t*) p_desc, &length ),
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
|
|
|
@ -75,14 +75,14 @@
|
||||||
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
||||||
|
|
||||||
#define SUBTASK_RETURN(error) return error;
|
#define SUBTASK_RETURN(error) return error;
|
||||||
#define OSAL_SUBTASK_INVOKED(subtask, status) status = subtask
|
#define SUBTASK_INVOKE(subtask, status) status = subtask
|
||||||
|
|
||||||
//------------- Sub Task Assert -------------//
|
//------------- Sub Task Assert -------------//
|
||||||
#define SUBTASK_ASSERT_STATUS(sts) VERIFY_STATUS(sts)
|
#define SUBTASK_ASSERT_STATUS(sts) VERIFY_STATUS(sts)
|
||||||
#define SUBTASK_ASSERT(condition) VERIFY(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
#define SUBTASK_ASSERT(condition) VERIFY(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||||
|
|
||||||
#define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) VERIFY_STATUS_HDLR(sts, func_call)
|
#define SUBTASK_ASSERT_STATUS_HDLR(sts, func_call) VERIFY_STATUS_HDLR(sts, func_call)
|
||||||
#define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) VERIFY_HDLR(condition, func_call)
|
#define SUBTASK_ASSERT_HDLR(condition, func_call) VERIFY_HDLR(condition, func_call)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -81,27 +81,25 @@ static inline osal_task_t osal_task_create(osal_func_t code, const char* name, u
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TASK_RESTART \
|
#define TASK_RESTART \
|
||||||
state = 0
|
_state = 0
|
||||||
|
|
||||||
#define OSAL_TASK_BEGIN \
|
#define OSAL_TASK_BEGIN \
|
||||||
ATTR_UNUSED static uint32_t timeout = 0;\
|
static uint16_t _state = 0; \
|
||||||
static uint16_t state = 0;\
|
ATTR_UNUSED static uint32_t _timeout = 0; \
|
||||||
(void) timeout; /* timemout can possible unsued */ \
|
(void) _timeout; \
|
||||||
switch(state) { \
|
switch(_state) { \
|
||||||
case 0: { \
|
case 0: {
|
||||||
|
|
||||||
#define OSAL_TASK_END \
|
#define OSAL_TASK_END \
|
||||||
default:\
|
default: TASK_RESTART; break; \
|
||||||
TASK_RESTART;\
|
|
||||||
}}\
|
}}\
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
#define osal_task_delay(msec) \
|
#define osal_task_delay(msec) \
|
||||||
do {\
|
do {\
|
||||||
timeout = osal_tick_get();\
|
_timeout = osal_tick_get();\
|
||||||
state = __LINE__; case __LINE__:\
|
_state = __LINE__; case __LINE__:\
|
||||||
if ( timeout + osal_tick_from_msec(msec) > osal_tick_get() ) \
|
if ( _timeout + osal_tick_from_msec(msec) > osal_tick_get() ) \
|
||||||
return TUSB_ERROR_OSAL_WAITING;\
|
return TUSB_ERROR_OSAL_WAITING;\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
|
@ -110,58 +108,28 @@ static inline osal_task_t osal_task_create(osal_func_t code, const char* name, u
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define OSAL_SUBTASK_BEGIN OSAL_TASK_BEGIN
|
#define OSAL_SUBTASK_BEGIN OSAL_TASK_BEGIN
|
||||||
#define OSAL_SUBTASK_END \
|
#define OSAL_SUBTASK_END \
|
||||||
default:\
|
default: TASK_RESTART; break; \
|
||||||
TASK_RESTART;\
|
|
||||||
}}\
|
}}\
|
||||||
return TUSB_ERROR_NONE;
|
return TUSB_ERROR_NONE;
|
||||||
|
|
||||||
#define OSAL_SUBTASK_INVOKED(subtask, status) \
|
#define SUBTASK_INVOKE(_subtask, _status) \
|
||||||
do {\
|
do {\
|
||||||
state = __LINE__; case __LINE__:\
|
_state = __LINE__; case __LINE__:\
|
||||||
{\
|
{\
|
||||||
status = subtask; /* invoke sub task */\
|
_status = _subtask; /* invoke sub task */\
|
||||||
if (TUSB_ERROR_OSAL_WAITING == status) /* sub task not finished -> continue waiting */\
|
if (TUSB_ERROR_OSAL_WAITING == _status) /* sub task not finished -> continue waiting */\
|
||||||
return TUSB_ERROR_OSAL_WAITING;\
|
return TUSB_ERROR_OSAL_WAITING;\
|
||||||
}\
|
}\
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
//------------- Sub Task Assert -------------//
|
//------------- Sub Task Assert -------------//
|
||||||
#define SUBTASK_RETURN(error) do { TASK_RESTART; return error; } while(0)
|
#define SUBTASK_RETURN(error) do { TASK_RESTART; return error; } while(0)
|
||||||
|
|
||||||
|
#define SUBTASK_ASSERT_STATUS(sts) VERIFY_STATUS_HDLR(sts, TASK_RESTART)
|
||||||
|
#define SUBTASK_ASSERT_STATUS_HDLR(sts, func_call) VERIFY_STATUS_HDLR(sts, func_call; TASK_RESTART )
|
||||||
|
|
||||||
|
#define SUBTASK_ASSERT(condition) VERIFY_HDLR(condition, TASK_RESTART)
|
||||||
|
#define SUBTASK_ASSERT_HDLR(condition, func_call) VERIFY_HDLR(condition, func_call; TASK_RESTART)
|
||||||
#define SUBTASK_ASSERT_STATUS(sts) VERIFY_STATUS_HDLR(sts, TASK_RESTART)
|
|
||||||
#define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) VERIFY_STATUS_HDLR(sts, func_call; TASK_RESTART )
|
|
||||||
|
|
||||||
#define SUBTASK_ASSERT(condition) VERIFY_HDLR(condition, TASK_RESTART)
|
|
||||||
// TODO remove assert with handler by catching error in enum main task
|
|
||||||
#define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) VERIFY_HDLR(condition, func_call; TASK_RESTART)
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call) \
|
|
||||||
do { func_call; TASK_RESTART; return error; } while(0)
|
|
||||||
|
|
||||||
#define SUBTASK_ASSERT_STATUS(sts) \
|
|
||||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, , tusb_error_t status = (tusb_error_t)(sts),\
|
|
||||||
TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
|
|
||||||
|
|
||||||
#define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
|
|
||||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
|
|
||||||
TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
|
|
||||||
|
|
||||||
// TODO allow to specify error return
|
|
||||||
#define SUBTASK_ASSERT(condition) \
|
|
||||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, , , \
|
|
||||||
(condition), TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
|
|
||||||
// TODO remove assert with handler by catching error in enum main task
|
|
||||||
#define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \
|
|
||||||
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
|
|
||||||
condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// QUEUE API
|
// QUEUE API
|
||||||
|
@ -196,10 +164,10 @@ static inline void osal_queue_flush(osal_queue_t const queue_hdl)
|
||||||
|
|
||||||
#define osal_queue_receive(queue_hdl, p_data, msec, p_error) \
|
#define osal_queue_receive(queue_hdl, p_data, msec, p_error) \
|
||||||
do {\
|
do {\
|
||||||
timeout = osal_tick_get();\
|
_timeout = osal_tick_get();\
|
||||||
state = __LINE__; case __LINE__:\
|
_state = __LINE__; case __LINE__:\
|
||||||
if( queue_hdl->count == 0 ) {\
|
if( queue_hdl->count == 0 ) {\
|
||||||
if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && ( timeout + osal_tick_from_msec(msec) <= osal_tick_get() )) /* time out */ \
|
if ( (msec != OSAL_TIMEOUT_WAIT_FOREVER) && ( _timeout + osal_tick_from_msec(msec) <= osal_tick_get() )) /* time out */ \
|
||||||
*(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\
|
*(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\
|
||||||
else\
|
else\
|
||||||
return TUSB_ERROR_OSAL_WAITING;\
|
return TUSB_ERROR_OSAL_WAITING;\
|
||||||
|
@ -250,10 +218,10 @@ static inline void osal_semaphore_reset(osal_semaphore_t sem_hdl)
|
||||||
|
|
||||||
#define osal_semaphore_wait(sem_hdl, msec, p_error) \
|
#define osal_semaphore_wait(sem_hdl, msec, p_error) \
|
||||||
do {\
|
do {\
|
||||||
timeout = osal_tick_get();\
|
_timeout = osal_tick_get();\
|
||||||
state = __LINE__; case __LINE__:\
|
_state = __LINE__; case __LINE__:\
|
||||||
if( sem_hdl->count == 0 ) {\
|
if( sem_hdl->count == 0 ) {\
|
||||||
if ( ( ((uint32_t) (msec)) != OSAL_TIMEOUT_WAIT_FOREVER) && (timeout + osal_tick_from_msec(msec) <= osal_tick_get()) ) /* time out */ \
|
if ( ( ((uint32_t) (msec)) != OSAL_TIMEOUT_WAIT_FOREVER) && (_timeout + osal_tick_from_msec(msec) <= osal_tick_get()) ) /* time out */ \
|
||||||
*(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\
|
*(p_error) = TUSB_ERROR_OSAL_TIMEOUT;\
|
||||||
else\
|
else\
|
||||||
return TUSB_ERROR_OSAL_WAITING;\
|
return TUSB_ERROR_OSAL_WAITING;\
|
||||||
|
|
Loading…
Reference in New Issue