add TUSB_CFG_OS_TASK_PRIO to mandatory option for using an RTOS

using plain char for error enum character
increase freeRTOS configMAX_PRIORITIES to 16
house keeping & clean up compiler warning
This commit is contained in:
hathach 2013-04-25 11:00:56 +07:00
parent d4a2600ecc
commit e9dbce5f1b
13 changed files with 34 additions and 17 deletions

View File

@ -465,6 +465,7 @@
<option id="com.crt.advproject.gcc.thumb.1149795974" name="Thumb mode" superClass="com.crt.advproject.gcc.thumb" value="true" valueType="boolean"/>
<option id="gnu.c.compiler.option.preprocessor.def.symbols.510918973" name="Defined symbols (-D)" superClass="gnu.c.compiler.option.preprocessor.def.symbols" valueType="definedSymbols">
<listOptionValue builtIn="false" value="__REDLIB__"/>
<listOptionValue builtIn="false" value="TUSB_CFG_OS_TASK_PRIO=(configMAX_PRIORITIES-5)"/>
<listOptionValue builtIn="false" value="__USE_CMSIS=CMSISv2p10_LPC43xx_DriverLib"/>
<listOptionValue builtIn="false" value="CORE_M4"/>
<listOptionValue builtIn="false" value="MCU=MCU_LPC43XX"/>

View File

@ -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

View File

@ -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)
{

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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;

View File

@ -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)
{

View File

@ -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

View File

@ -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

View File

@ -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 )