summaryrefslogtreecommitdiff
path: root/demos/host/src
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-09-30 15:16:23 +0700
committerhathach <[email protected]>2013-09-30 15:16:23 +0700
commit3cc169f2fd3159ecad494eb6223bbed6cc8135d6 (patch)
tree8a29e735e2f450857f6180c442695cad78b3fd7c /demos/host/src
parentcb600ed9887224b6e0b4904f66442eef2900fd2d (diff)
able to mount one device on the hub
Diffstat (limited to 'demos/host/src')
-rw-r--r--demos/host/src/msc_app.c23
-rw-r--r--demos/host/src/tusb_config.h4
2 files changed, 19 insertions, 8 deletions
diff --git a/demos/host/src/msc_app.c b/demos/host/src/msc_app.c
index 5c3881826..e5101cafa 100644
--- a/demos/host/src/msc_app.c
+++ b/demos/host/src/msc_app.c
@@ -85,11 +85,12 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
//------------- file system (only 1 LUN support) -------------//
// DSTATUS stat = disk_initialize(0);
- disk_state = 0;
+ uint8_t phy_disk = dev_addr-1;
+ disk_state[phy_disk] = 0;
- if ( disk_is_ready(0) )
+ if ( disk_is_ready(phy_disk) )
{
- if ( f_mount(0, &fatfs[dev_addr-1]) != FR_OK ) // TODO multiple volume
+ if ( f_mount(phy_disk, &fatfs[phy_disk]) != FR_OK ) // TODO multiple volume
{
puts("mount failed");
return;
@@ -102,7 +103,7 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
puts("- THE AUTHOR HAS NO RESPONSIBILITY WITH YOUR DEVICE NOR ITS DATA -");
puts("---------------------------------------------------------------------");
- f_chdrive(dev_addr-1); // change to newly mounted drive
+ f_chdrive(phy_disk); // change to newly mounted drive
f_chdir("/"); // root as current dir
cli_init();
@@ -112,7 +113,7 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
void tusbh_msc_unmounted_isr(uint8_t dev_addr)
{
// unmount disk
- disk_state = STA_NOINIT;
+ disk_state[dev_addr-1] = STA_NOINIT;
puts("--");
}
@@ -136,7 +137,17 @@ OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para)
osal_task_delay(10);
- if ( disk_is_ready(0) )
+ bool is_any_disk_mounted = false;
+ for(uint8_t phy_disk=0; phy_disk < TUSB_CFG_HOST_DEVICE_MAX; phy_disk++)
+ {
+ if ( disk_is_ready(phy_disk) )
+ {
+ is_any_disk_mounted = true;
+ break;
+ }
+ }
+
+ if ( is_any_disk_mounted )
{
int ch = getchar();
if ( ch > 0 )
diff --git a/demos/host/src/tusb_config.h b/demos/host/src/tusb_config.h
index 711802fab..3b69dffad 100644
--- a/demos/host/src/tusb_config.h
+++ b/demos/host/src/tusb_config.h
@@ -65,14 +65,14 @@
//--------------------------------------------------------------------+
// HOST CONFIGURATION
//--------------------------------------------------------------------+
-#define TUSB_CFG_HOST_DEVICE_MAX 1
+#define TUSB_CFG_HOST_DEVICE_MAX 3
#define TUSB_CFG_CONFIGURATION_MAX 1
//------------- USBD -------------//
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
//------------- CLASS -------------//
-#define TUSB_CFG_HOST_HUB 0
+#define TUSB_CFG_HOST_HUB 1
#define TUSB_CFG_HOST_HID_KEYBOARD 1
#define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_HID_GENERIC 0