diff --git a/demos/host/host_freertos/.cproject b/demos/host/host_freertos/.cproject index da8f3f998..d93e4bdb6 100644 --- a/demos/host/host_freertos/.cproject +++ b/demos/host/host_freertos/.cproject @@ -465,6 +465,7 @@ + diff --git a/demos/host/src/keyboard_app.c b/demos/host/src/keyboard_app.c index 889bb0c48..7269d4eba 100644 --- a/demos/host/src/keyboard_app.c +++ b/demos/host/src/keyboard_app.c @@ -40,6 +40,8 @@ //--------------------------------------------------------------------+ #include "keyboard_app.h" +#if TUSB_CFG_HOST_HID_KEYBOARD + //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ @@ -48,11 +50,12 @@ //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -static tusb_keyboard_report_t usb_keyboard_report TUSB_CFG_ATTR_USBRAM; - +//OSAL_TASK_DEF(keyboard_task_def, keyboard_app_task, 128, ) OSAL_QUEUE_DEF(queue_kbd_report, QUEUE_KEYBOARD_REPORT_DEPTH, tusb_keyboard_report_t); static osal_queue_handle_t q_kbd_report_hdl; +static tusb_keyboard_report_t usb_keyboard_report TUSB_CFG_ATTR_USBRAM; + // only convert a-z (case insensitive) + 0-9 static inline uint8_t keycode_to_ascii(uint8_t keycode) ATTR_CONST ATTR_ALWAYS_INLINE; @@ -91,6 +94,9 @@ void tusbh_hid_keyboard_isr(uint8_t dev_addr, uint8_t instance_num, tusb_event_t //--------------------------------------------------------------------+ void keyboard_app_init(void) { + memclr_(&usb_keyboard_report, sizeof(tusb_keyboard_report_t)); + +// ASSERT( osal_task_create() ) q_kbd_report_hdl = osal_queue_create(&queue_kbd_report); // TODO keyboard_app_task create @@ -134,3 +140,5 @@ static inline uint8_t keycode_to_ascii(uint8_t keycode) ( KEYBOARD_KEYCODE_1 <= keycode && keycode < KEYBOARD_KEYCODE_0) ? ( (keycode - KEYBOARD_KEYCODE_1) + '1' ) : ( KEYBOARD_KEYCODE_0 == keycode) ? '0' : 'x'; } + +#endif diff --git a/demos/host/src/main.c b/demos/host/src/main.c index ad7d2c8a5..2c925eb1c 100644 --- a/demos/host/src/main.c +++ b/demos/host/src/main.c @@ -28,8 +28,13 @@ int main(void) tusb_init(); //------------- application task init -------------// +#if TUSB_CFG_HOST_HID_KEYBOARD keyboard_app_init(); +#endif + +#if TUSB_CFG_HOST_HID_MOUSE mouse_app_init(); +#endif while (1) { diff --git a/demos/host/src/mouse_app.c b/demos/host/src/mouse_app.c index 4d81941ab..acafe8d14 100644 --- a/demos/host/src/mouse_app.c +++ b/demos/host/src/mouse_app.c @@ -40,6 +40,8 @@ //--------------------------------------------------------------------+ #include "mouse_app.h" +#if TUSB_CFG_HOST_HID_MOUSE + //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ @@ -118,3 +120,5 @@ OSAL_TASK_FUNCTION( mouse_app_task ) (void* p_task_para) OSAL_TASK_LOOP_END } + +#endif diff --git a/demos/host/src/tusb_config.h b/demos/host/src/tusb_config.h index d6f3c55ef..47cab3e81 100644 --- a/demos/host/src/tusb_config.h +++ b/demos/host/src/tusb_config.h @@ -93,6 +93,7 @@ #define TUSB_CFG_DEBUG 3 //#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build +//#define TUSB_CFG_OS_TASK_PRIO #define TUSB_CFG_OS_TICKS_PER_SECOND 1000 diff --git a/tinyusb/common/errors.c b/tinyusb/common/errors.c index 2de115697..6c53bd007 100644 --- a/tinyusb/common/errors.c +++ b/tinyusb/common/errors.c @@ -35,12 +35,11 @@ * This file is part of the tinyUSB stack. */ -#include "primitive_types.h" #include "errors.h" #if TUSB_CFG_DEBUG == 3 -uint8_t const* const TUSB_ErrorStr[] = +char const* const TUSB_ErrorStr[] = { ERROR_TABLE(ERROR_STRING) 0 diff --git a/tinyusb/common/errors.h b/tinyusb/common/errors.h index 0392865e1..cf10a63fa 100644 --- a/tinyusb/common/errors.h +++ b/tinyusb/common/errors.h @@ -49,7 +49,6 @@ #ifndef _TUSB_ERRORS_H_ #define _TUSB_ERRORS_H_ -#include "primitive_types.h" #include "tusb_option.h" #ifdef __cplusplus @@ -87,7 +86,7 @@ typedef enum { #if TUSB_CFG_DEBUG == 3 /// Enum to String for debugging purposes. Only available if \ref TUSB_CFG_DEBUG > 0 -extern uint8_t const* const TUSB_ErrorStr[]; +extern char const* const TUSB_ErrorStr[]; #endif #ifdef __cplusplus diff --git a/tinyusb/hal/hal.h b/tinyusb/hal/hal.h index a79ea4a16..4916aea08 100644 --- a/tinyusb/hal/hal.h +++ b/tinyusb/hal/hal.h @@ -52,6 +52,7 @@ #define _TUSB_HAL_H_ #include "tusb_option.h" +#include "common/primitive_types.h" #include "common/errors.h" #include "common/compiler/compiler.h" diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 55f3eb771..54f9e7dce 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -89,7 +89,7 @@ static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1] TUSB_CFG_ATTR_USBRAM; // including zero-address //------------- Enumeration Task Data -------------// -OSAL_TASK_DEF(enum_task, usbh_enumeration_task, 128, OSAL_PRIO_HIGH); +OSAL_TASK_DEF(enum_task, usbh_enumeration_task, 128, TUSB_CFG_OS_TASK_PRIO); OSAL_QUEUE_DEF(enum_queue, ENUM_QUEUE_DEPTH, uint32_t); osal_queue_handle_t enum_queue_hdl; STATIC_ uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM; diff --git a/tinyusb/osal/osal_common.h b/tinyusb/osal/osal_common.h index eda859145..6a9965fea 100644 --- a/tinyusb/osal/osal_common.h +++ b/tinyusb/osal/osal_common.h @@ -64,12 +64,6 @@ enum OSAL_TIMEOUT_WAIT_FOREVER = 0x0EEEEEEE }; -typedef enum { - OSAL_PRIO_LOW, - OSAL_PRIO_NORMAL, - OSAL_PRIO_HIGH -}osal_prio_t; - static inline uint32_t osal_tick_from_msec(uint32_t msec) ATTR_CONST ATTR_ALWAYS_INLINE; static inline uint32_t osal_tick_from_msec(uint32_t msec) { diff --git a/tinyusb/osal/osal_freeRTOS.h b/tinyusb/osal/osal_freeRTOS.h index d92cb374c..cd92812cb 100644 --- a/tinyusb/osal/osal_freeRTOS.h +++ b/tinyusb/osal/osal_freeRTOS.h @@ -75,7 +75,7 @@ extern "C" { void task_func typedef struct { - signed portCHAR const * name; + char const * name; pdTASK_CODE code; unsigned portSHORT stack_depth; unsigned portBASE_TYPE prio; @@ -92,7 +92,7 @@ typedef struct { static inline tusb_error_t osal_task_create(osal_task_t *task) ATTR_ALWAYS_INLINE; static inline tusb_error_t osal_task_create(osal_task_t *task) { - return pdPASS == xTaskCreate(task->code, task->name, task->stack_depth, NULL, task->prio, NULL) ? + return pdPASS == xTaskCreate(task->code, (signed portCHAR const *) task->name, task->stack_depth, NULL, task->prio, NULL) ? TUSB_ERROR_NONE : TUSB_ERROR_OSAL_TASK_CREATE_FAILED; } @@ -104,7 +104,8 @@ static inline tusb_error_t osal_task_create(osal_task_t *task) //------------- Sub Task -------------// #define OSAL_SUBTASK_BEGIN // TODO refractor move -#define OSAL_SUBTASK_END +#define OSAL_SUBTASK_END \ + return TUSB_ERROR_NONE; #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \ status = subtask diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h index 4d20b3049..7773351d2 100644 --- a/tinyusb/tusb_option.h +++ b/tinyusb/tusb_option.h @@ -114,6 +114,10 @@ #ifndef TUSB_CFG_OS_TICKS_PER_SECOND #error TUSB_CFG_OS_TICKS_PER_SECOND is required to use with OS_NONE #endif +#else + #ifndef TUSB_CFG_OS_TASK_PRIO + #error TUSB_CFG_OS_TASK_PRIO need to be defined (hint: use the highest if possible) + #endif #endif #ifndef TUSB_CFG_CONFIGURATION_MAX diff --git a/vendor/freertos/FreeRTOSConfig.h b/vendor/freertos/FreeRTOSConfig.h index 6737e9242..ebf0b06d4 100644 --- a/vendor/freertos/FreeRTOSConfig.h +++ b/vendor/freertos/FreeRTOSConfig.h @@ -68,7 +68,7 @@ #define configUSE_PREEMPTION 1 #define configUSE_IDLE_HOOK 1 -#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 8 ) +#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 16 ) #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( ( unsigned long ) SystemCoreClock ) #define configTICK_RATE_HZ ( ( portTickType ) 1000 )