summaryrefslogtreecommitdiff
path: root/demos/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2013-10-02 13:32:39 +0700
committerhathach <[email protected]>2013-10-02 13:32:39 +0700
commit1263dbb1221fc550737e560c415857829e8ecfd1 (patch)
treed2a5bfe2a942cd8295e3037108526d6c899e470d /demos/host
parent5c8389b9ae88d04b7d45330ad8b79ce0352b547b (diff)
enhacne msc demo, update IAR project file
Diffstat (limited to 'demos/host')
-rw-r--r--demos/host/host_os_none/host_os_none.ewp16
-rw-r--r--demos/host/src/cli.c2
-rw-r--r--demos/host/src/msc_app.c20
3 files changed, 33 insertions, 5 deletions
diff --git a/demos/host/host_os_none/host_os_none.ewp b/demos/host/host_os_none/host_os_none.ewp
index 31e345cc5..f47f439c6 100644
--- a/demos/host/host_os_none/host_os_none.ewp
+++ b/demos/host/host_os_none/host_os_none.ewp
@@ -300,6 +300,7 @@
<state>$PROJ_DIR$\..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\inc</state>
<state>$PROJ_DIR$\..\..\bsp</state>
<state>$PROJ_DIR$\..\..\..\tinyusb</state>
+ <state>$PROJ_DIR$\..\..\..\vendor\fatfs</state>
</option>
<option>
<name>CCStdIncCheck</name>
@@ -930,6 +931,9 @@
<name>$PROJ_DIR$\..\src\cdc_serial_app.c</name>
</file>
<file>
+ <name>$PROJ_DIR$\..\src\cli.c</name>
+ </file>
+ <file>
<name>$PROJ_DIR$\..\src\keyboard_app.c</name>
</file>
<file>
@@ -994,6 +998,18 @@
</group>
</group>
<group>
+ <name>fatfs</name>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\vendor\fatfs\ccsbcs.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\vendor\fatfs\diskio.c</name>
+ </file>
+ <file>
+ <name>$PROJ_DIR$\..\..\..\vendor\fatfs\ff.c</name>
+ </file>
+ </group>
+ <group>
<name>tinyusb</name>
<group>
<name>class</name>
diff --git a/demos/host/src/cli.c b/demos/host/src/cli.c
index ea83d7bdf..d507cc606 100644
--- a/demos/host/src/cli.c
+++ b/demos/host/src/cli.c
@@ -296,6 +296,8 @@ cli_error_t cli_cmd_list(char * p_para)
putchar('\n');
}
}
+
+// (void) f_closedir(&target_dir);
}
else
{
diff --git a/demos/host/src/msc_app.c b/demos/host/src/msc_app.c
index 8c1ff0dbe..2591e61a0 100644
--- a/demos/host/src/msc_app.c
+++ b/demos/host/src/msc_app.c
@@ -84,10 +84,8 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr)
printf("LBA 0-0x%X Block Size: %d\n", last_lba, block_size);
//------------- file system (only 1 LUN support) -------------//
- // TODO MSC refractor this hack
- // DSTATUS stat = disk_initialize(0);
uint8_t phy_disk = dev_addr-1;
- disk_state[phy_disk] = 0;
+ disk_initialize(phy_disk);
if ( disk_is_ready(phy_disk) )
{
@@ -118,7 +116,19 @@ void tusbh_msc_unmounted_cb(uint8_t dev_addr)
uint8_t phy_disk = dev_addr-1;
f_mount(phy_disk, NULL); // unmount disk
- disk_state[phy_disk] = STA_NOINIT;
+ disk_deinitialize(phy_disk);
+
+ if ( phy_disk == f_get_current_drive() )
+ { // active drive is unplugged --> change to other drive
+ for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++)
+ {
+ if ( disk_is_ready(i) )
+ {
+ f_chdrive(i);
+ cli_init(); // refractor, rename
+ }
+ }
+ }
}
void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes)
@@ -131,7 +141,7 @@ void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes)
//--------------------------------------------------------------------+
void msc_app_init(void)
{
-
+ diskio_init();
}
//------------- main task -------------//