mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-15 03:40:19 +00:00
more clean up
This commit is contained in:
parent
9bf083d449
commit
65a076f198
@ -121,11 +121,20 @@ void cdcd_serial_app_init(void)
|
||||
osal_task_create(cdcd_serial_app_task, "cdc", 128, NULL, CDC_SERIAL_APP_TASK_PRIO, NULL);
|
||||
}
|
||||
|
||||
tusb_error_t cdcd_serial_subtask(void);
|
||||
|
||||
void cdcd_serial_app_task(void* param)
|
||||
{
|
||||
(void) param;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
cdcd_serial_subtask();
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
|
||||
tusb_error_t cdcd_serial_subtask(void)
|
||||
{
|
||||
OSAL_SUBTASK_BEGIN
|
||||
|
||||
tusb_error_t error;
|
||||
|
||||
@ -153,7 +162,7 @@ void cdcd_serial_app_task(void* param)
|
||||
tusbd_cdc_receive(0, serial_rx_buffer, SERIAL_BUFFER_SIZE, true);
|
||||
}
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
OSAL_SUBTASK_END
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -109,11 +109,20 @@ void keyboard_device_app_init(void)
|
||||
osal_task_create(keyboard_device_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO, NULL);
|
||||
}
|
||||
|
||||
tusb_error_t keyboard_device_subtask(void);
|
||||
|
||||
void keyboard_device_app_task(void* param)
|
||||
{
|
||||
(void) param;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
keyboard_device_subtask();
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
|
||||
tusb_error_t keyboard_device_subtask(void)
|
||||
{
|
||||
OSAL_SUBTASK_BEGIN
|
||||
|
||||
osal_task_delay(50);
|
||||
|
||||
@ -136,8 +145,7 @@ void keyboard_device_app_task(void* param)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
OSAL_SUBTASK_END
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -98,11 +98,19 @@ void mouse_device_app_init(void)
|
||||
osal_task_create(mouse_device_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO, NULL);
|
||||
}
|
||||
|
||||
void mouse_device_subtask(void);
|
||||
|
||||
void mouse_device_app_task(void * param)
|
||||
{
|
||||
(void) para;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
mouse_device_subtask();
|
||||
OSAL_TASK_LOOP_END
|
||||
}
|
||||
|
||||
void mouse_device_subtask(void)
|
||||
{
|
||||
OSAL_SUBTASK_BEGIN
|
||||
|
||||
osal_task_delay(20);
|
||||
|
||||
@ -143,7 +151,7 @@ void mouse_device_app_task(void * param)
|
||||
}
|
||||
}
|
||||
|
||||
OSAL_TASK_LOOP_END
|
||||
OSAL_SUBTASK_END
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -109,7 +109,6 @@ TUSB_CFG_ATTR_USBRAM usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]
|
||||
|
||||
//------------- Enumeration Task Data -------------/
|
||||
enum { ENUM_QUEUE_DEPTH = 16 };
|
||||
OSAL_TASK_DEF(usbh_enumeration_task, 200, TUSB_CFG_OS_TASK_PRIO);
|
||||
OSAL_QUEUE_DEF(enum_queue_def, ENUM_QUEUE_DEPTH, uint32_t);
|
||||
|
||||
STATIC_VAR osal_queue_handle_t enum_queue_hdl;
|
||||
@ -147,7 +146,8 @@ tusb_error_t usbh_init(void)
|
||||
//------------- Enumeration & Reporter Task init -------------//
|
||||
enum_queue_hdl = osal_queue_create( OSAL_QUEUE_REF(enum_queue_def) );
|
||||
ASSERT_PTR(enum_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
|
||||
ASSERT_STATUS( osal_task_create( OSAL_TASK_REF(usbh_enumeration_task) ));
|
||||
|
||||
osal_task_create(usbh_enumeration_task, "usbh", 200, NULL, TUSB_CFG_OS_TASK_PRIO, NULL);
|
||||
|
||||
//------------- Semaphore, Mutex for Control Pipe -------------//
|
||||
for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) // including address zero
|
||||
@ -344,9 +344,9 @@ static 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, p_task_para)
|
||||
void usbh_enumeration_task(void* param)
|
||||
{
|
||||
(void) p_task_para; // suppress compiler warnings
|
||||
(void) param;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
|
@ -89,7 +89,7 @@ static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t
|
||||
default:\
|
||||
TASK_RESTART;\
|
||||
}}\
|
||||
return /*TUSB_ERROR_NONE*/;
|
||||
return;
|
||||
|
||||
|
||||
#define osal_task_delay(msec) \
|
||||
@ -114,7 +114,11 @@ static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t
|
||||
}while(0)
|
||||
|
||||
#define OSAL_SUBTASK_BEGIN OSAL_TASK_LOOP_BEGIN
|
||||
#define OSAL_SUBTASK_END OSAL_TASK_LOOP_END
|
||||
#define OSAL_SUBTASK_END \
|
||||
default:\
|
||||
TASK_RESTART;\
|
||||
}}\
|
||||
return TUSB_ERROR_NONE;
|
||||
|
||||
//------------- Sub Task Assert -------------//
|
||||
#define SUBTASK_EXIT(error) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user