summaryrefslogtreecommitdiff
path: root/demos/host/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2014-03-06 11:27:22 +0700
committerhathach <[email protected]>2014-03-06 11:37:37 +0700
commitdcc58a7afcd6f02458a5edaca33a5b63418d641f (patch)
treea5ed07d5132d411aee3d643e1287b367a9b14884 /demos/host/src
parentde7437852bb0cea3357aac86b87fc91831a7cc86 (diff)
refractor app_os_prio.h
Diffstat (limited to 'demos/host/src')
-rw-r--r--demos/host/src/app_os_prio.h82
-rw-r--r--demos/host/src/cdc_serial_app.c3
-rw-r--r--demos/host/src/keyboard_app.c3
-rw-r--r--demos/host/src/main.c3
-rw-r--r--demos/host/src/mouse_app.c4
-rw-r--r--demos/host/src/msc_app.c3
-rw-r--r--demos/host/src/rndis_app.c3
7 files changed, 82 insertions, 19 deletions
diff --git a/demos/host/src/app_os_prio.h b/demos/host/src/app_os_prio.h
new file mode 100644
index 000000000..99be2de0c
--- /dev/null
+++ b/demos/host/src/app_os_prio.h
@@ -0,0 +1,82 @@
+/**************************************************************************/
+/*!
+ @file app_os_prio.h
+ @author hathach (tinyusb.org)
+
+ @section LICENSE
+
+ Software License Agreement (BSD License)
+
+ Copyright (c) 2013, hathach (tinyusb.org)
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the copyright holders nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ This file is part of the tinyusb stack.
+*/
+/**************************************************************************/
+
+/** \ingroup TBD
+ * \defgroup TBD
+ * \brief TBD
+ *
+ * @{
+ */
+
+#ifndef _TUSB_APP_OS_PRIO_H_
+#define _TUSB_APP_OS_PRIO_H_
+
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include "tusb.h"
+
+#if TUSB_CFG_OS == TUSB_OS_NONE
+ #define LOWER_PRIO(x) 0 // does not matter
+#elif TUSB_CFG_OS == TUSB_OS_FREERTOS
+ #define LOWER_PRIO(x) ((x)-1) // freeRTOS lower number --> lower priority
+#elif TUSB_CFG_OS == TUSB_OS_CMSIS_RTX
+ #define LOWER_PRIO(x) ((x)-1) // CMSIS-RTOS lower number --> lower priority
+#else
+ #error Priority is not configured for this RTOS
+#endif
+
+enum {
+ STANDARD_APP_TASK_PRIO = LOWER_PRIO(TUSB_CFG_OS_TASK_PRIO), // Application Task is lower than usb system task
+ LED_BLINKING_APP_TASK_PRIO = LOWER_PRIO(STANDARD_APP_TASK_PRIO), // Blinking task is lower than normal task
+
+ KEYBOARD_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO,
+ MOUSE_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO,
+ CDC_SERIAL_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO,
+ MSC_APP_TASK_PRIO = STANDARD_APP_TASK_PRIO
+};
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* _TUSB_APP_OS_PRIO_H_ */
+
+/** @} */
diff --git a/demos/host/src/cdc_serial_app.c b/demos/host/src/cdc_serial_app.c
index 6afcd0eed..db97bd87c 100644
--- a/demos/host/src/cdc_serial_app.c
+++ b/demos/host/src/cdc_serial_app.c
@@ -37,10 +37,7 @@
/**************************************************************************/
#include "cdc_serial_app.h"
-
-#if TUSB_CFG_OS != TUSB_OS_NONE
#include "app_os_prio.h"
-#endif
#if TUSB_CFG_HOST_CDC
diff --git a/demos/host/src/keyboard_app.c b/demos/host/src/keyboard_app.c
index 68437195b..907ae8c2e 100644
--- a/demos/host/src/keyboard_app.c
+++ b/demos/host/src/keyboard_app.c
@@ -40,10 +40,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "keyboard_app.h"
-
-#if TUSB_CFG_OS != TUSB_OS_NONE
#include "app_os_prio.h"
-#endif
#if TUSB_CFG_HOST_HID_KEYBOARD
diff --git a/demos/host/src/main.c b/demos/host/src/main.c
index ef44f6b5e..5f7001202 100644
--- a/demos/host/src/main.c
+++ b/demos/host/src/main.c
@@ -46,10 +46,7 @@
#include "boards/board.h"
#include "tusb.h"
-#if TUSB_CFG_OS != TUSB_OS_NONE
#include "app_os_prio.h"
-#endif
-
#include "mouse_app.h"
#include "keyboard_app.h"
#include "msc_app.h"
diff --git a/demos/host/src/mouse_app.c b/demos/host/src/mouse_app.c
index 59798691b..60b91f4d2 100644
--- a/demos/host/src/mouse_app.c
+++ b/demos/host/src/mouse_app.c
@@ -40,11 +40,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "mouse_app.h"
-
-#if TUSB_CFG_OS != TUSB_OS_NONE
#include "app_os_prio.h"
-#endif
-
#if TUSB_CFG_HOST_HID_MOUSE
diff --git a/demos/host/src/msc_app.c b/demos/host/src/msc_app.c
index 520bfa5b1..b7e909cee 100644
--- a/demos/host/src/msc_app.c
+++ b/demos/host/src/msc_app.c
@@ -40,10 +40,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "msc_app.h"
-
-#if TUSB_CFG_OS != TUSB_OS_NONE
#include "app_os_prio.h"
-#endif
#if TUSB_CFG_HOST_MSC
diff --git a/demos/host/src/rndis_app.c b/demos/host/src/rndis_app.c
index f77df8b9a..8371d6985 100644
--- a/demos/host/src/rndis_app.c
+++ b/demos/host/src/rndis_app.c
@@ -37,10 +37,7 @@
/**************************************************************************/
#include "rndis_app.h"
-
-#if TUSB_CFG_OS != TUSB_OS_NONE
#include "app_os_prio.h"
-#endif
#if TUSB_CFG_HOST_CDC && TUSB_CFG_HOST_CDC_RNDIS