summaryrefslogtreecommitdiff
path: root/demos/host/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-09-20 23:53:48 +0700
committerhathach <[email protected]>2013-09-20 23:53:48 +0700
commitf8f398a6813567306acd2e9dcfae199c3ecbad3a (patch)
tree2a0acf048ae44a4ee439c3928a8f74f91ea30bf5 /demos/host/src
parent52ae0afeb6dc781b82e6e71b864a02184eaf62bf (diff)
start to add msc host, fix dangerous problem with unstable device when plugged --> 200 ms delay. 50ms delay after each port reset
Diffstat (limited to 'demos/host/src')
-rw-r--r--demos/host/src/cdc_serial_app.c9
-rw-r--r--demos/host/src/keyboard_app.c9
-rw-r--r--demos/host/src/main.c19
-rw-r--r--demos/host/src/mouse_app.c9
-rw-r--r--demos/host/src/msc_app.c90
-rw-r--r--demos/host/src/rndis_app.c15
-rw-r--r--demos/host/src/tusb_config.h2
7 files changed, 139 insertions, 14 deletions
diff --git a/demos/host/src/cdc_serial_app.c b/demos/host/src/cdc_serial_app.c
index e44cfd924..a6616964b 100644
--- a/demos/host/src/cdc_serial_app.c
+++ b/demos/host/src/cdc_serial_app.c
@@ -135,5 +135,14 @@ OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para)
OSAL_TASK_LOOP_END
}
+#else
+
+// dummy implementation to remove #ifdef in main.c
+void cdc_serial_app_init(void) { }
+OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para)
+{
+ OSAL_TASK_LOOP_BEGIN
+ OSAL_TASK_LOOP_END
+}
#endif
diff --git a/demos/host/src/keyboard_app.c b/demos/host/src/keyboard_app.c
index 404a27c41..b0f92a2c7 100644
--- a/demos/host/src/keyboard_app.c
+++ b/demos/host/src/keyboard_app.c
@@ -178,4 +178,13 @@ static inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode)
hid_keycode_to_ascii_tbl [modifier & (KEYBOARD_MODIFIER_LEFTSHIFT | KEYBOARD_MODIFIER_RIGHTSHIFT) ? 1 : 0] [keycode];
}
+#else
+
+// dummy implementation to remove #ifdef in main.c
+void keyboard_app_init(void) { }
+OSAL_TASK_FUNCTION( keyboard_app_task ) (void* p_task_para)
+{
+ OSAL_TASK_LOOP_BEGIN
+ OSAL_TASK_LOOP_END
+}
#endif
diff --git a/demos/host/src/main.c b/demos/host/src/main.c
index ca26e633f..66df55d7a 100644
--- a/demos/host/src/main.c
+++ b/demos/host/src/main.c
@@ -55,7 +55,7 @@
#include "cdc_serial_app.h"
#include "rndis_app.h"
-#if defined(__CODE_RED)
+#if defined(__CODE_RED) // TODO to be removed
#include <cr_section_macros.h>
#include <NXP/crp.h>
// Variable to store CRP value in. Will be placed automatically
@@ -104,10 +104,13 @@ void os_none_start_scheduler(void)
while (1)
{
tusb_task_runner();
+ led_blinking_task(NULL);
+
keyboard_app_task(NULL);
mouse_app_task(NULL);
+ msc_app_task(NULL);
cdc_serial_app_task(NULL);
- led_blinking_task(NULL);
+ rndis_app_task(NULL);
}
}
#endif
@@ -123,21 +126,11 @@ int main(void)
//------------- application task init -------------//
(void) osal_task_create( OSAL_TASK_REF(led_blinking_task) );
-#if TUSB_CFG_HOST_HID_KEYBOARD
keyboard_app_init();
-#endif
-
-#if TUSB_CFG_HOST_HID_MOUSE
mouse_app_init();
-#endif
-
-#if TUSB_CFG_HOST_CDC
+ msc_app_init();
cdc_serial_app_init();
-
- #if TUSB_CFG_HOST_CDC_RNDIS
rndis_app_init();
- #endif
-#endif
//------------- start OS scheduler (never return) -------------//
#if TUSB_CFG_OS == TUSB_OS_FREERTOS
diff --git a/demos/host/src/mouse_app.c b/demos/host/src/mouse_app.c
index 3469fc4ab..32596e9e2 100644
--- a/demos/host/src/mouse_app.c
+++ b/demos/host/src/mouse_app.c
@@ -156,5 +156,14 @@ static inline void process_mouse_report(tusb_mouse_report_t const * p_report)
}
+#else
+
+// dummy implementation to remove #ifdef in main.c
+void mouse_app_init(void) { }
+OSAL_TASK_FUNCTION( mouse_app_task ) (void* p_task_para)
+{
+ OSAL_TASK_LOOP_BEGIN
+ OSAL_TASK_LOOP_END
+}
#endif
diff --git a/demos/host/src/msc_app.c b/demos/host/src/msc_app.c
new file mode 100644
index 000000000..54de0d0cf
--- /dev/null
+++ b/demos/host/src/msc_app.c
@@ -0,0 +1,90 @@
+/**************************************************************************/
+/*!
+ @file msc_app.c
+ @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.
+*/
+/**************************************************************************/
+
+//--------------------------------------------------------------------+
+// INCLUDE
+//--------------------------------------------------------------------+
+#include "mouse_app.h"
+
+#if TUSB_CFG_OS != TUSB_OS_NONE
+#include "app_os_prio.h"
+#endif
+
+#if TUSB_CFG_HOST_MSC
+
+//--------------------------------------------------------------------+
+// MACRO CONSTANT TYPEDEF
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// INTERNAL OBJECT & FUNCTION DECLARATION
+//--------------------------------------------------------------------+
+
+//--------------------------------------------------------------------+
+// tinyusb callback (ISR context)
+//--------------------------------------------------------------------+
+void tusbh_msc_mounted_cb(uint8_t dev_addr)
+{
+ printf("an msc device is mounted\n");
+}
+
+//--------------------------------------------------------------------+
+// IMPLEMENTATION
+//--------------------------------------------------------------------+
+void msc_app_init(void)
+{
+
+}
+
+//------------- main task -------------//
+OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para)
+{
+
+}
+
+#else
+// dummy implementation to remove #ifdef in main.c
+void msc_app_init(void) { }
+OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para)
+{
+ OSAL_TASK_LOOP_BEGIN
+ OSAL_TASK_LOOP_END
+}
+
+
+#endif
diff --git a/demos/host/src/rndis_app.c b/demos/host/src/rndis_app.c
index cb9c9ba0d..d0027ea97 100644
--- a/demos/host/src/rndis_app.c
+++ b/demos/host/src/rndis_app.c
@@ -69,5 +69,20 @@ void rndis_app_init(void)
}
+OSAL_TASK_FUNCTION( rndis_app_task ) (void* p_task_para)
+{
+ OSAL_TASK_LOOP_BEGIN
+ OSAL_TASK_LOOP_END
+}
+
+#else
+
+// dummy implementation to remove #ifdef in main.c
+void rndis_app_init(void) { }
+OSAL_TASK_FUNCTION( rndis_app_task ) (void* p_task_para)
+{
+ OSAL_TASK_LOOP_BEGIN
+ OSAL_TASK_LOOP_END
+}
#endif
diff --git a/demos/host/src/tusb_config.h b/demos/host/src/tusb_config.h
index 215a77cbc..30891fcbb 100644
--- a/demos/host/src/tusb_config.h
+++ b/demos/host/src/tusb_config.h
@@ -76,7 +76,7 @@
#define TUSB_CFG_HOST_HID_KEYBOARD 1
#define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_HID_GENERIC 0
-#define TUSB_CFG_HOST_MSC 0
+#define TUSB_CFG_HOST_MSC 1
#define TUSB_CFG_HOST_CDC 1
#define TUSB_CFG_HOST_CDC_RNDIS 1