From d438000b99a5dbd5357d042fa48d0d87f180f032 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 22 Jun 2018 16:01:55 +0700 Subject: [PATCH] clean up --- src/device/usbd.c | 8 ++++++-- src/device/usbd_pvt.h | 2 +- src/osal/osal.h | 1 + src/osal/osal_freeRTOS.h | 2 +- src/osal/osal_none.h | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/device/usbd.c b/src/device/usbd.c index 4332c2925..0f6cebc6c 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -182,7 +182,7 @@ typedef struct ATTR_ALIGNED(4) // USBD_EVT_FUNC_CALL struct { - void (*func)(void*); + osal_task_func_t func; void* param; }func_call; }; @@ -308,6 +308,10 @@ static tusb_error_t usbd_main_st(void) } } } + else if ( USBD_EVT_FUNC_CALL == event.event_id ) + { + if ( event.func_call.func ) event.func_call.func(event.func_call.param); + } else { STASK_ASSERT(false); @@ -631,7 +635,7 @@ tusb_error_t usbd_open_edpt_pair(uint8_t rhport, tusb_desc_endpoint_t const* p_d return TUSB_ERROR_NONE; } -void usbd_defer_func(void (*func)(void*), void* param, bool isr ) +void usbd_defer_func(osal_task_func_t func, void* param, bool isr ) { usbd_task_event_t event = { diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index 4632fc52b..8189d5811 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -76,7 +76,7 @@ tusb_error_t usbd_open_edpt_pair(uint8_t rhport, tusb_desc_endpoint_t const* p_d /*------------------------------------------------------------------*/ /* Other Helpers *------------------------------------------------------------------*/ -void usbd_defer_func( void (*func)(void*), void* param, bool isr ); +void usbd_defer_func( osal_task_func_t func, void* param, bool isr ); #ifdef __cplusplus diff --git a/src/osal/osal.h b/src/osal/osal.h index 669159607..7a8e6ecbf 100644 --- a/src/osal/osal.h +++ b/src/osal/osal.h @@ -58,6 +58,7 @@ enum #define OSAL_TIMEOUT_CONTROL_XFER OSAL_TIMEOUT_WAIT_FOREVER +typedef void (*osal_task_func_t)( void * ); #if CFG_TUSB_OS == OPT_OS_NONE #include "osal_none.h" diff --git a/src/osal/osal_freeRTOS.h b/src/osal/osal_freeRTOS.h index 6e6535da3..b14ed3100 100644 --- a/src/osal/osal_freeRTOS.h +++ b/src/osal/osal_freeRTOS.h @@ -71,7 +71,7 @@ static inline bool in_isr(void) typedef struct { - void (*func)(void *param); + osal_task_func_t func; uint16_t prio; uint16_t stack_sz; diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h index 0e29d110e..9bdb047b4 100644 --- a/src/osal/osal_none.h +++ b/src/osal/osal_none.h @@ -68,7 +68,7 @@ #define OSAL_TASK_DEF(_name, _str, _func, _prio, _stack_sz) osal_task_def_t _name; typedef uint8_t osal_task_def_t; -typedef void* osal_task_t; +typedef void* osal_task_t; static inline osal_task_t osal_task_create(osal_task_def_t* taskdef) {