move main work in usbh_enumeration_task to its body subtask for task_assert style
This commit is contained in:
		| @@ -249,7 +249,21 @@ void usbh_device_unplugged_isr(uint8_t hostid) | ||||
| //--------------------------------------------------------------------+ | ||||
| // ENUMERATION TASK | ||||
| //--------------------------------------------------------------------+ | ||||
| tusb_error_t enumeration_body_subtask(void); | ||||
|  | ||||
| // To enable the TASK_ASSERT style (quick return on false condition) in a real RTOS, a task must act as a wrapper | ||||
| // and is used mainly to call subtasks. Within a subtask return statement can be called freely, the task with | ||||
| // forever loop cannot have any return at all. | ||||
| OSAL_TASK_FUNCTION(usbh_enumeration_task) | ||||
| { | ||||
|   OSAL_TASK_LOOP_BEGIN | ||||
|  | ||||
|   enumeration_body_subtask(); | ||||
|  | ||||
|   OSAL_TASK_LOOP_END | ||||
| } | ||||
|  | ||||
| tusb_error_t enumeration_body_subtask(void) | ||||
| { | ||||
|   tusb_error_t error; | ||||
|   usbh_enumerate_t enum_entry; | ||||
| @@ -259,7 +273,7 @@ OSAL_TASK_FUNCTION(usbh_enumeration_task) | ||||
|   static uint8_t configure_selected = 1; // TODO move | ||||
|   static uint8_t *p_desc = NULL; // TODO move | ||||
|  | ||||
|   OSAL_TASK_LOOP_BEGIN | ||||
|   OSAL_SUBTASK_BEGIN | ||||
|  | ||||
|   osal_queue_receive(enum_queue_hdl, &enum_entry, OSAL_TIMEOUT_WAIT_FOREVER, &error); | ||||
|  | ||||
| @@ -444,7 +458,7 @@ OSAL_TASK_FUNCTION(usbh_enumeration_task) | ||||
|  | ||||
|   tusbh_device_mount_succeed_cb(new_addr); | ||||
|  | ||||
|   OSAL_TASK_LOOP_END | ||||
|   OSAL_SUBTASK_END | ||||
| } | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
|   | ||||
| @@ -96,34 +96,12 @@ tusb_error_t osal_task_create(osal_task_t *task); | ||||
| #define OSAL_TASK_LOOP_END | ||||
|  | ||||
| //------------- Sub Task -------------// | ||||
| #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask) TASK_ASSERT_STATUS(subtask) | ||||
|  | ||||
| #define TASK_RESTART | ||||
| #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask) SUBTASK_ASSERT_STATUS(subtask) | ||||
|  | ||||
| #define OSAL_SUBTASK_BEGIN | ||||
| #define OSAL_SUBTASK_END \ | ||||
|   return TUSB_ERROR_NONE; | ||||
|  | ||||
| //------------- Task Assert -------------// | ||||
| #define _TASK_ASSERT_ERROR_HANDLER(error, func_call)\ | ||||
|     func_call; TASK_RESTART; return error | ||||
|  | ||||
| #define TASK_ASSERT_STATUS(sts) \ | ||||
|     ASSERT_DEFINE_WITH_HANDLER(_TASK_ASSERT_ERROR_HANDLER, , tusb_error_t status = (tusb_error_t)(sts),\ | ||||
|                                TUSB_ERROR_NONE == status, (void) 0, "%s", TUSB_ErrorStr[status]) | ||||
|  | ||||
| #define TASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \ | ||||
|     ASSERT_DEFINE_WITH_HANDLER(_TASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\ | ||||
|                                TUSB_ERROR_NONE == status, (void) 0, "%s", TUSB_ErrorStr[status]) | ||||
|  | ||||
| #define TASK_ASSERT(condition) \ | ||||
|     ASSERT_DEFINE_WITH_HANDLER(_TASK_ASSERT_ERROR_HANDLER, , ,\ | ||||
|                                condition, (void) 0, "%s", "evaluated to false") | ||||
|  | ||||
| #define TASK_ASSERT_WITH_HANDLER(condition, func_call) \ | ||||
|     ASSERT_DEFINE_WITH_HANDLER(_TASK_ASSERT_ERROR_HANDLER, func_call, ,\ | ||||
|                                condition, (void) 0, "%s", "evaluated to false") | ||||
|  | ||||
| //------------- Sub Task Assert (like Task but return error) -------------// | ||||
| #define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\ | ||||
|     func_call; return error | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 hathach
					hathach