mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
change osal_task_create signature
This commit is contained in:
parent
a789fad4b7
commit
329fdc026c
@ -63,7 +63,7 @@ static uint32_t led_blink_interval_ms = 1000; // default is 1 second
|
||||
void led_blinking_init(void)
|
||||
{
|
||||
led_blink_interval_ms = 1000;
|
||||
osal_task_create(led_blinking_task, "blinky", 128, NULL, LED_BLINKING_APP_TASK_PRIO, NULL);
|
||||
osal_task_create(led_blinking_task, "blinky", 128, NULL, LED_BLINKING_APP_TASK_PRIO);
|
||||
}
|
||||
|
||||
void led_blinking_set_interval(uint32_t ms)
|
||||
|
@ -116,7 +116,7 @@ void cdcd_serial_app_init(void)
|
||||
sem_hdl = osal_semaphore_create(1, 0);
|
||||
ASSERT_PTR( sem_hdl, VOID_RETURN);
|
||||
|
||||
osal_task_create(cdcd_serial_app_task, "cdc", 128, NULL, CDC_SERIAL_APP_TASK_PRIO, NULL);
|
||||
osal_task_create(cdcd_serial_app_task, "cdc", 128, NULL, CDC_SERIAL_APP_TASK_PRIO);
|
||||
}
|
||||
|
||||
tusb_error_t cdcd_serial_subtask(void);
|
||||
|
@ -106,7 +106,7 @@ void tusbd_hid_keyboard_set_report_cb(uint8_t coreid, hid_request_report_type_t
|
||||
//--------------------------------------------------------------------+
|
||||
void keyboard_device_app_init(void)
|
||||
{
|
||||
osal_task_create(keyboard_device_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO, NULL);
|
||||
osal_task_create(keyboard_device_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO);
|
||||
}
|
||||
|
||||
tusb_error_t keyboard_device_subtask(void);
|
||||
|
@ -95,7 +95,7 @@ void tusbd_hid_mouse_set_report_cb(uint8_t coreid, hid_request_report_type_t rep
|
||||
//--------------------------------------------------------------------+
|
||||
void mouse_device_app_init(void)
|
||||
{
|
||||
osal_task_create(mouse_device_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO, NULL);
|
||||
osal_task_create(mouse_device_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO);
|
||||
}
|
||||
|
||||
void mouse_device_subtask(void);
|
||||
|
@ -115,7 +115,7 @@ void cdc_serial_host_app_init(void)
|
||||
sem_hdl = osal_semaphore_create(1, 0);
|
||||
ASSERT_PTR( sem_hdl, VOID_RETURN);
|
||||
|
||||
VERIFY( osal_task_create(cdc_serial_host_app_task, "cdc", 128, NULL, CDC_SERIAL_APP_TASK_PRIO, NULL), );
|
||||
VERIFY( osal_task_create(cdc_serial_host_app_task, "cdc", 128, NULL, CDC_SERIAL_APP_TASK_PRIO), );
|
||||
}
|
||||
|
||||
//------------- main task -------------//
|
||||
|
@ -105,7 +105,7 @@ void keyboard_host_app_init(void)
|
||||
queue_kbd_hdl = osal_queue_create( QUEUE_KEYBOARD_REPORT_DEPTH, sizeof(hid_keyboard_report_t) );
|
||||
ASSERT_PTR( queue_kbd_hdl, VOID_RETURN );
|
||||
|
||||
VERIFY( osal_task_create(keyboard_host_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO, NULL), );
|
||||
VERIFY( osal_task_create(keyboard_host_app_task, "kbd", 128, NULL, KEYBOARD_APP_TASK_PRIO), );
|
||||
}
|
||||
|
||||
//------------- main task -------------//
|
||||
|
@ -106,7 +106,7 @@ void mouse_host_app_init(void)
|
||||
queue_mouse_hdl = osal_queue_create( QUEUE_MOUSE_REPORT_DEPTH, sizeof(hid_mouse_report_t) );
|
||||
ASSERT_PTR( queue_mouse_hdl, VOID_RETURN);
|
||||
|
||||
VERIFY( osal_task_create(mouse_host_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO, NULL), );
|
||||
VERIFY( osal_task_create(mouse_host_app_task, "mouse", 128, NULL, MOUSE_APP_TASK_PRIO), );
|
||||
}
|
||||
|
||||
//------------- main task -------------//
|
||||
|
@ -141,7 +141,7 @@ void tuh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes)
|
||||
//--------------------------------------------------------------------+
|
||||
void msc_host_app_init(void)
|
||||
{
|
||||
osal_task_create( msc_host_app_task, "msc", 512, NULL, MSC_APP_TASK_PRIO, NULL);
|
||||
osal_task_create( msc_host_app_task, "msc", 512, NULL, MSC_APP_TASK_PRIO);
|
||||
diskio_init();
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,7 @@ tusb_error_t usbd_init (void)
|
||||
usbd_control_xfer_sem_hdl = osal_semaphore_create(1, 0);
|
||||
ASSERT_PTR(usbd_queue_hdl, TUSB_ERROR_OSAL_SEMAPHORE_FAILED);
|
||||
|
||||
osal_task_t usbd_hdl;
|
||||
osal_task_create(usbd_task, "usbd", TUC_DEVICE_STACKSIZE, NULL, TUSB_CFG_OS_TASK_PRIO, &usbd_hdl);
|
||||
osal_task_create(usbd_task, "usbd", TUC_DEVICE_STACKSIZE, NULL, TUSB_CFG_OS_TASK_PRIO);
|
||||
|
||||
|
||||
//------------- Descriptor Check -------------//
|
||||
|
@ -150,7 +150,7 @@ tusb_error_t usbh_init(void)
|
||||
enum_queue_hdl = osal_queue_create( ENUM_QUEUE_DEPTH, sizeof(uint32_t) );
|
||||
ASSERT_PTR(enum_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
|
||||
|
||||
osal_task_create(usbh_enumeration_task, "usbh", 200, NULL, TUSB_CFG_OS_TASK_PRIO, NULL);
|
||||
osal_task_create(usbh_enumeration_task, "usbh", 200, NULL, TUSB_CFG_OS_TASK_PRIO);
|
||||
|
||||
//------------- Semaphore, Mutex for Control Pipe -------------//
|
||||
for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) // including address zero
|
||||
|
@ -56,13 +56,7 @@
|
||||
#include "tusb_option.h"
|
||||
#include "common/common.h"
|
||||
|
||||
#ifndef _TEST_
|
||||
|
||||
/*------------- Task -------------*/
|
||||
typedef void (*osal_func_t)(void *param);
|
||||
typedef void* osal_task_t;
|
||||
|
||||
static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl);
|
||||
|
||||
/*------------- Queue -------------*/
|
||||
|
||||
@ -103,97 +97,6 @@ static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t
|
||||
condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
|
||||
#endif
|
||||
|
||||
//------------- OSAL API for cmock -------------//
|
||||
#else
|
||||
|
||||
#include "osal_common.h"
|
||||
|
||||
//------------- Tick -------------//
|
||||
uint32_t osal_tick_get(void);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TASK API
|
||||
//--------------------------------------------------------------------+
|
||||
typedef uint32_t osal_task_t;
|
||||
tusb_error_t osal_task_create(osal_task_t *task);
|
||||
|
||||
void osal_task_delay(uint32_t msec);
|
||||
|
||||
#define OSAL_TASK_LOOP_BEGIN
|
||||
#define OSAL_TASK_LOOP_END
|
||||
|
||||
#define SUBTASK_EXIT(error) return error;
|
||||
|
||||
//------------- Sub Task -------------//
|
||||
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) status = subtask
|
||||
|
||||
#define OSAL_SUBTASK_BEGIN
|
||||
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
||||
|
||||
//------------- Sub Task Assert -------------//
|
||||
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call) func_call; return error
|
||||
|
||||
#define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
|
||||
|
||||
#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])
|
||||
|
||||
#define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
||||
|
||||
#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")
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Semaphore API
|
||||
//--------------------------------------------------------------------+
|
||||
typedef volatile uint8_t osal_semaphore_t;
|
||||
typedef osal_semaphore_t * osal_semaphore_handle_t;
|
||||
|
||||
osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem);
|
||||
void osal_semaphore_wait(osal_semaphore_handle_t sem_hdl, uint32_t msec, tusb_error_t *p_error);
|
||||
tusb_error_t osal_semaphore_post(osal_semaphore_handle_t sem_hdl);
|
||||
void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// MUTEX API (priority inheritance)
|
||||
//--------------------------------------------------------------------+
|
||||
#define OSAL_MUTEX_DEF(name) osal_mutex_t name
|
||||
#define OSAL_MUTEX_REF(name) &name
|
||||
|
||||
typedef osal_semaphore_t osal_mutex_t;
|
||||
typedef osal_semaphore_handle_t osal_mutex_handle_t;
|
||||
|
||||
osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex);
|
||||
void osal_mutex_wait(osal_mutex_handle_t mutex_hdl, uint32_t msec, tusb_error_t *p_error);
|
||||
tusb_error_t osal_mutex_release(osal_mutex_handle_t mutex_hdl);
|
||||
void osal_mutex_reset(osal_mutex_handle_t mutex_hdl);
|
||||
//--------------------------------------------------------------------+
|
||||
// QUEUE API
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct{
|
||||
uint32_t * const buffer ; ///< buffer pointer
|
||||
uint8_t const depth ; ///< buffer size
|
||||
volatile uint8_t count ; ///< bytes in fifo
|
||||
volatile uint8_t wr_idx ; ///< write pointer
|
||||
volatile uint8_t rd_idx ; ///< read pointer
|
||||
} osal_queue_t;
|
||||
|
||||
typedef osal_queue_t * osal_queue_handle_t;
|
||||
|
||||
|
||||
osal_queue_handle_t osal_queue_create (osal_queue_t *p_queue);
|
||||
void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error);
|
||||
tusb_error_t osal_queue_send (osal_queue_handle_t const queue_hdl, const void * data);
|
||||
void osal_queue_flush(osal_queue_handle_t const queue_hdl);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// TICK API
|
||||
//--------------------------------------------------------------------+
|
||||
uint32_t osal_tick_get(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -64,9 +64,14 @@ extern "C" {
|
||||
//--------------------------------------------------------------------+
|
||||
// TASK API
|
||||
//--------------------------------------------------------------------+
|
||||
static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl)
|
||||
typedef void (*osal_func_t)(void *param);
|
||||
typedef void* osal_task_t;
|
||||
|
||||
static inline osal_task_t osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio)
|
||||
{
|
||||
return xTaskCreate(code, (const signed char*) name, stack_size, param, prio, task_hdl);
|
||||
osal_task_t task_hdl;
|
||||
xTaskCreate(code, (const signed char*) name, stack_size, param, prio, &task_hdl);
|
||||
return task_hdl;
|
||||
}
|
||||
|
||||
static inline void osal_task_delay(uint32_t msec)
|
||||
|
@ -70,10 +70,13 @@ uint32_t tusb_tick_get(void);
|
||||
// OSAL_TASK_LOOP_ENG
|
||||
// }
|
||||
//--------------------------------------------------------------------+
|
||||
static inline bool osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio, osal_task_t* task_hdl)
|
||||
typedef void (*osal_func_t)(void *param);
|
||||
typedef void* osal_task_t;
|
||||
|
||||
static inline osal_task_t osal_task_create(osal_func_t code, const char* name, uint32_t stack_size, void* param, uint32_t prio)
|
||||
{
|
||||
(void) code; (void) name; (void) stack_size; (void) param; (void) prio; (void) task_hdl;
|
||||
return true;
|
||||
(void) code; (void) name; (void) stack_size; (void) param; (void) prio;
|
||||
return (osal_task_t) 1;
|
||||
}
|
||||
|
||||
#define TASK_RESTART \
|
||||
|
Loading…
x
Reference in New Issue
Block a user