summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2020-09-04 10:46:48 +0700
committerGitHub <[email protected]>2020-09-04 10:46:48 +0700
commited7a0de3abd12b7fefaeb2fc97607ae7d73d5419 (patch)
tree15e3453593465f5879a75fee50e2dbb765d7c6a9 /examples
parentf10b8145afb6d7b78fbf31b525951b4137e1d774 (diff)
parenta8e538efe7d11291e32e016fad5910ebaf9eac43 (diff)
Merge pull request #505 from hathach/update-host
Update host
Diffstat (limited to 'examples')
-rw-r--r--examples/host/cdc_msc_hid/.only.MCU_LPC175X_6X0
-rw-r--r--examples/host/cdc_msc_hid/.only.MCU_LPC177X_8X0
-rw-r--r--examples/host/cdc_msc_hid/.only.MCU_LPC18XX0
-rw-r--r--examples/host/cdc_msc_hid/.only.MCU_LPC40XX0
-rw-r--r--examples/host/cdc_msc_hid/.only.MCU_LPC43XX0
-rw-r--r--examples/host/cdc_msc_hid/Makefile26
-rw-r--r--examples/host/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject23
-rw-r--r--examples/host/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject26
-rw-r--r--examples/host/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject24
-rw-r--r--examples/host/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject19
-rw-r--r--examples/host/cdc_msc_hid/src/main.c101
-rw-r--r--examples/host/cdc_msc_hid/src/msc_app.c36
-rw-r--r--examples/host/cdc_msc_hid/src/tusb_config.h27
-rw-r--r--examples/make.mk1
14 files changed, 196 insertions, 87 deletions
diff --git a/examples/host/cdc_msc_hid/.only.MCU_LPC175X_6X b/examples/host/cdc_msc_hid/.only.MCU_LPC175X_6X
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/examples/host/cdc_msc_hid/.only.MCU_LPC175X_6X
diff --git a/examples/host/cdc_msc_hid/.only.MCU_LPC177X_8X b/examples/host/cdc_msc_hid/.only.MCU_LPC177X_8X
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/examples/host/cdc_msc_hid/.only.MCU_LPC177X_8X
diff --git a/examples/host/cdc_msc_hid/.only.MCU_LPC18XX b/examples/host/cdc_msc_hid/.only.MCU_LPC18XX
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/examples/host/cdc_msc_hid/.only.MCU_LPC18XX
diff --git a/examples/host/cdc_msc_hid/.only.MCU_LPC40XX b/examples/host/cdc_msc_hid/.only.MCU_LPC40XX
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/examples/host/cdc_msc_hid/.only.MCU_LPC40XX
diff --git a/examples/host/cdc_msc_hid/.only.MCU_LPC43XX b/examples/host/cdc_msc_hid/.only.MCU_LPC43XX
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/examples/host/cdc_msc_hid/.only.MCU_LPC43XX
diff --git a/examples/host/cdc_msc_hid/Makefile b/examples/host/cdc_msc_hid/Makefile
new file mode 100644
index 000000000..35de0a9a0
--- /dev/null
+++ b/examples/host/cdc_msc_hid/Makefile
@@ -0,0 +1,26 @@
+include ../../../tools/top.mk
+include ../../make.mk
+
+INC += \
+ src \
+ $(TOP)/hw \
+
+# Example source
+EXAMPLE_SOURCE += $(wildcard src/*.c)
+SRC_C += $(addprefix $(CURRENT_PATH)/, $(EXAMPLE_SOURCE))
+
+CFLAGS += -Wno-error=cast-align
+
+# TinyUSB Host Stack source
+SRC_C += \
+ src/class/cdc/cdc_host.c \
+ src/class/hid/hid_host.c \
+ src/class/msc/msc_host.c \
+ src/host/usbh.c \
+ src/host/hub.c \
+ src/host/ehci/ehci.c \
+ src/host/ohci/ohci.c \
+ src/portable/nxp/lpc18_43/hcd_lpc18_43.c \
+ src/portable/nxp/lpc17_40/hcd_lpc17_40.c
+
+include ../../rules.mk
diff --git a/examples/host/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject b/examples/host/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject
index ba5a9cea7..8a2c36390 100644
--- a/examples/host/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject
+++ b/examples/host/cdc_msc_hid/ses/lpc175x_6x/lpc175x_6x.emProject
@@ -19,8 +19,8 @@
arm_target_device_name="LPC1769"
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="Yes"
- c_preprocessor_definitions="LPC175x_6x;__LPC1700_FAMILY;__LPC176x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;CORE_M3;BOARD_LPCXPRESSO1769;CFG_TUSB_MCU=OPT_MCU_LPC175X_6X"
- c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/inc"
+ c_preprocessor_definitions="LPC175x_6x;__LPC1700_FAMILY;__LPC176x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;CORE_M3;BOARD_LPCXPRESSO1769;CFG_TUSB_MCU=OPT_MCU_LPC175X_6X;CFG_TUSB_DEBUG=2;LOGGER_RTT"
+ c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/inc;$(rootDir)/lib/SEGGER_RTT/RTT"
debug_register_definition_file="LPC176x5x_Registers.xml"
debug_target_connection="J-Link"
gcc_enable_all_warnings="Yes"
@@ -101,12 +101,19 @@
<file file_name="LPC176x5x_Vectors.s" />
<file file_name="thumb_crt0.s" />
</folder>
- <folder
- Name="segger_rtt"
- exclude=""
- filter="*.c;*.h"
- path="../../../../../lib/segger_rtt"
- recurse="No" />
+ <folder Name="lib">
+ <folder Name="SEGGER_RTT">
+ <folder Name="RTT">
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT.c" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT.h" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT_Conf.h" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT_printf.c" />
+ </folder>
+ <folder Name="Syscalls">
+ <file file_name="../../../../../lib/SEGGER_RTT/Syscalls/SEGGER_RTT_Syscalls_SES.c" />
+ </folder>
+ </folder>
+ </folder>
</project>
<configuration Name="LPCXpresso 1769" />
</solution>
diff --git a/examples/host/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject b/examples/host/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject
index 2dd7de552..2b5538957 100644
--- a/examples/host/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject
+++ b/examples/host/cdc_msc_hid/ses/lpc18xx/lpc18xx.emProject
@@ -17,8 +17,8 @@
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="LPC1857"
arm_target_interface_type="SWD"
- c_preprocessor_definitions="LPC18xx;__LPC1800_FAMILY;__LPC185x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;CORE_M3;BOARD_MCB1800;CFG_TUSB_MCU=OPT_MCU_LPC18XX;CFG_TUSB_MEM_SECTION= __attribute__((section(&quot;.bss2&quot;)))"
- c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)//inc;$(lpcDir)//inc/config_18xx"
+ c_preprocessor_definitions="LPC18xx;__LPC1800_FAMILY;__LPC185x_SUBFAMILY;ARM_MATH_CM3;FLASH_PLACEMENT=1;CORE_M3;BOARD_MCB1800;CFG_TUSB_MCU=OPT_MCU_LPC18XX;CFG_TUSB_MEM_SECTION= __attribute__((section(&quot;.bss2&quot;)));CFG_TUSB_DEBUG=2"
+ c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)//inc;$(lpcDir)//inc/config_18xx;$(rootDir)/lib/SEGGER_RTT/RTT"
debug_register_definition_file="$(ProjectDir)/LPC18xx_Registers.xml"
debug_target_connection="J-Link"
gcc_entry_point="Reset_Handler"
@@ -53,6 +53,7 @@
<folder Name="mcb1800">
<file file_name="../../../../../hw/bsp/mcb1800/mcb1800.c" />
</folder>
+ <file file_name="../../../../../hw/bsp/board.c" />
</folder>
<folder Name="mcu">
<folder Name="nxp">
@@ -102,12 +103,6 @@
</folder>
</folder>
<folder
- Name="segger_rtt"
- exclude=""
- filter="*.c;*.h"
- path="../../../../../lib/segger_rtt"
- recurse="No" />
- <folder
Name="src"
exclude=""
filter="*.c;*.h"
@@ -119,6 +114,21 @@
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
+ <folder Name="lib">
+ <folder Name="SEGGER_RTT">
+ <folder Name="RTT">
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT.c" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT_printf.c" />
+ </folder>
+ <folder Name="Syscalls">
+ <file file_name="../../../../../lib/SEGGER_RTT/Syscalls/SEGGER_RTT_Syscalls_SES.c" />
+ </folder>
+ </folder>
+ </folder>
+ <configuration
+ Name="MCB1800"
+ arm_target_interface_type="JTAG"
+ speed="12000" />
</project>
<configuration
Name="MCB1800"
diff --git a/examples/host/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject b/examples/host/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject
index bfb7922a3..68995f1a5 100644
--- a/examples/host/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject
+++ b/examples/host/cdc_msc_hid/ses/lpc40xx/lpc40xx.emProject
@@ -18,8 +18,8 @@
arm_target_debug_interface_type="ADIv5"
arm_target_device_name="LPC4088"
arm_target_interface_type="SWD"
- c_preprocessor_definitions="CORE_M4;__LPC4000_FAMILY;__LPC408x_SUBFAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_EA4088QS;CFG_TUSB_MCU=OPT_MCU_LPC40XX;CFG_TUSB_MEM_SECTION= __attribute__((section(&quot;.bss2&quot;)))"
- c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/inc"
+ c_preprocessor_definitions="CORE_M4;__LPC4000_FAMILY;__LPC408x_SUBFAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_EA4088QS;CFG_TUSB_MCU=OPT_MCU_LPC40XX;CFG_TUSB_MEM_SECTION= __attribute__((section(&quot;.bss2&quot;)));CFG_TUSB_DEBUG=2;LOGGER_RTT"
+ c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/inc;$(rootDir)/lib/SEGGER_RTT/RTT"
debug_register_definition_file="$(ProjectDir)/LPC408x_7x_Registers.xml"
debug_target_connection="J-Link"
gcc_enable_all_warnings="Yes"
@@ -55,6 +55,7 @@
<folder Name="ea4088qs">
<file file_name="../../../../../hw/bsp/ea4088qs/ea4088qs.c" />
</folder>
+ <file file_name="../../../../../hw/bsp/board.c" />
</folder>
<folder Name="mcu">
<folder Name="nxp">
@@ -92,12 +93,6 @@
</folder>
</folder>
<folder
- Name="segger_rtt"
- exclude=""
- filter="*.c;*.h"
- path="../../../../../lib/segger_rtt"
- recurse="No" />
- <folder
Name="src"
exclude=""
filter="*.c;*.h"
@@ -109,6 +104,19 @@
filter="*.c;*.h"
path="../../../../../src"
recurse="Yes" />
+ <folder Name="lib">
+ <folder Name="SEGGER_RTT">
+ <folder Name="RTT">
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT.c" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT.h" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT_Conf.h" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT_printf.c" />
+ </folder>
+ <folder Name="Syscalls">
+ <file file_name="../../../../../lib/SEGGER_RTT/Syscalls/SEGGER_RTT_Syscalls_SES.c" />
+ </folder>
+ </folder>
+ </folder>
</project>
<configuration
Name="EA4088 QuickStart"
diff --git a/examples/host/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject b/examples/host/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject
index 3b93c623c..2d99ae6c8 100644
--- a/examples/host/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject
+++ b/examples/host/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject
@@ -20,7 +20,7 @@
arm_target_interface_type="SWD"
build_treat_warnings_as_errors="No"
c_preprocessor_definitions="CORE_M4;__LPC4300_FAMILY;__LPC435x_SUBFAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_EA4357;CFG_TUSB_MCU=OPT_MCU_LPC43XX;CFG_TUSB_MEM_SECTION= __attribute__((section(&quot;.bss2&quot;)))"
- c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)//inc;$(lpcDir)//inc/config_43xx"
+ c_user_include_directories="../../src;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)//inc;$(rootDir)/lib/SEGGER_RTT/RTT;$(lpcDir)//inc/config_43xx"
debug_register_definition_file="LPC43xx_Registers.xml"
debug_target_connection="J-Link"
gcc_enable_all_warnings="Yes"
@@ -122,11 +122,16 @@
<file file_name="LPC43xx_Vectors.s" />
<file file_name="thumb_crt0.s" />
</folder>
- <folder
- Name="segger_rtt"
- exclude=""
- filter="*.c;*.h"
- path="../../../../../lib/segger_rtt"
- recurse="No" />
+ <folder Name="lib">
+ <folder Name="SEGGER_RTT">
+ <folder Name="RTT">
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT.c" />
+ <file file_name="../../../../../lib/SEGGER_RTT/RTT/SEGGER_RTT_printf.c" />
+ </folder>
+ <folder Name="Syscalls">
+ <file file_name="../../../../../lib/SEGGER_RTT/Syscalls/SEGGER_RTT_Syscalls_SES.c" />
+ </folder>
+ </folder>
+ </folder>
</project>
</solution>
diff --git a/examples/host/cdc_msc_hid/src/main.c b/examples/host/cdc_msc_hid/src/main.c
index 0fbbd4534..4200cc5e0 100644
--- a/examples/host/cdc_msc_hid/src/main.c
+++ b/examples/host/cdc_msc_hid/src/main.c
@@ -58,7 +58,7 @@ int main(void)
cdc_task();
#endif
-#if CFG_TUD_HID
+#if CFG_TUH_HID_KEYBOARD || CFG_TUH_HID_MOUSE
hid_task();
#endif
}
@@ -75,7 +75,7 @@ CFG_TUSB_MEM_SECTION static char serial_in_buffer[64] = { 0 };
void tuh_mount_cb(uint8_t dev_addr)
{
// application set-up
- printf("\na CDC device (address %d) is mounted\n", dev_addr);
+ printf("A device with address %d is mounted\r\n", dev_addr);
tuh_cdc_receive(dev_addr, serial_in_buffer, sizeof(serial_in_buffer), true); // schedule first transfer
}
@@ -83,7 +83,7 @@ void tuh_mount_cb(uint8_t dev_addr)
void tuh_umount_cb(uint8_t dev_addr)
{
// application tear-down
- printf("\na CDC device (address %d) is unmounted \n", dev_addr);
+ printf("A device with address %d is unmounted \r\n", dev_addr);
}
// invoked ISR context
@@ -110,27 +110,83 @@ void cdc_task(void)
// USB HID
//--------------------------------------------------------------------+
#if CFG_TUH_HID_KEYBOARD
-void hid_task(void)
+
+uint8_t const keycode2ascii[128][2] = { HID_KEYCODE_TO_ASCII };
+
+// look up new key in previous keys
+static inline bool find_key_in_report(hid_keyboard_report_t const *p_report, uint8_t keycode)
{
+ for(uint8_t i=0; i<6; i++)
+ {
+ if (p_report->keycode[i] == keycode) return true;
+ }
+
+ return false;
+}
+
+static inline void process_kbd_report(hid_keyboard_report_t const *p_new_report)
+{
+ static hid_keyboard_report_t prev_report = { 0, 0, {0} }; // previous report to check key released
+
+ //------------- example code ignore control (non-printable) key affects -------------//
+ for(uint8_t i=0; i<6; i++)
+ {
+ if ( p_new_report->keycode[i] )
+ {
+ if ( find_key_in_report(&prev_report, p_new_report->keycode[i]) )
+ {
+ // exist in previous report means the current key is holding
+ }else
+ {
+ // not existed in previous report means the current key is pressed
+ bool const is_shift = p_new_report->modifier & (KEYBOARD_MODIFIER_LEFTSHIFT | KEYBOARD_MODIFIER_RIGHTSHIFT);
+ uint8_t ch = keycode2ascii[p_new_report->keycode[i]][is_shift ? 1 : 0];
+ putchar(ch);
+ if ( ch == '\r' ) putchar('\n'); // added new line for enter key
+
+ fflush(stdout); // flush right away, else nanolib will wait for newline
+ }
+ }
+ // TODO example skips key released
+ }
+
+ prev_report = *p_new_report;
+}
+CFG_TUSB_MEM_SECTION static hid_keyboard_report_t usb_keyboard_report;
+
+void hid_task(void)
+{
+ uint8_t const addr = 1;
+ if ( tuh_hid_keyboard_is_mounted(addr) )
+ {
+ if ( !tuh_hid_keyboard_is_busy(addr) )
+ {
+ process_kbd_report(&usb_keyboard_report);
+ tuh_hid_keyboard_get_report(addr, &usb_keyboard_report);
+ }
+ }
}
void tuh_hid_keyboard_mounted_cb(uint8_t dev_addr)
{
// application set-up
- printf("\na Keyboard device (address %d) is mounted\n", dev_addr);
+ printf("A Keyboard device (address %d) is mounted\r\n", dev_addr);
+
+ tuh_hid_keyboard_get_report(dev_addr, &usb_keyboard_report);
}
void tuh_hid_keyboard_unmounted_cb(uint8_t dev_addr)
{
// application tear-down
- printf("\na Keyboard device (address %d) is unmounted\n", dev_addr);
+ printf("A Keyboard device (address %d) is unmounted\r\n", dev_addr);
}
// invoked ISR context
void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event)
{
-
+ (void) dev_addr;
+ (void) event;
}
#endif
@@ -139,18 +195,20 @@ void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event)
void tuh_hid_mouse_mounted_cb(uint8_t dev_addr)
{
// application set-up
- printf("\na Mouse device (address %d) is mounted\n", dev_addr);
+ printf("A Mouse device (address %d) is mounted\r\n", dev_addr);
}
void tuh_hid_mouse_unmounted_cb(uint8_t dev_addr)
{
// application tear-down
- printf("\na Mouse device (address %d) is unmounted\n", dev_addr);
+ printf("A Mouse device (address %d) is unmounted\r\n", dev_addr);
}
// invoked ISR context
void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event)
{
+ (void) dev_addr;
+ (void) event;
}
#endif
@@ -187,16 +245,23 @@ void print_greeting(void)
[OPT_OS_FREERTOS] = "FreeRTOS",
};
- printf("\n--------------------------------------------------------------------\n");
- printf("- Host example\n");
- printf("- if you find any bugs or get any questions, feel free to file an\n");
- printf("- issue at https://github.com/hathach/tinyusb\n");
- printf("--------------------------------------------------------------------\n\n");
+ printf("--------------------------------------------------------------------\r\n");
+ printf("- Host example\r\n");
+ printf("- if you find any bugs or get any questions, feel free to file an\r\n");
+ printf("- issue at https://github.com/hathach/tinyusb\r\n");
+ printf("--------------------------------------------------------------------\r\n\r\n");
+
+ printf("This Host demo is configured to support:\r\n");
+ printf(" - RTOS = %s\r\n", rtos_name[CFG_TUSB_OS]);
+
+#if CFG_TUH_CDC
+ printf(" - Communication Device Class\r\n");
+#endif
+
+#if CFG_TUH_MSC
+ printf(" - Mass Storage\r\n");
+#endif
- printf("This Host demo is configured to support:");
- printf(" - RTOS = %s\n", rtos_name[CFG_TUSB_OS]);
-// if (CFG_TUH_CDC ) puts(" - Communication Device Class");
-// if (CFG_TUH_MSC ) puts(" - Mass Storage");
// if (CFG_TUH_HID_KEYBOARD ) puts(" - HID Keyboard");
// if (CFG_TUH_HID_MOUSE ) puts(" - HID Mouse");
}
diff --git a/examples/host/cdc_msc_hid/src/msc_app.c b/examples/host/cdc_msc_hid/src/msc_app.c
index 20ac88744..62bd961c1 100644
--- a/examples/host/cdc_msc_hid/src/msc_app.c
+++ b/examples/host/cdc_msc_hid/src/msc_app.c
@@ -35,23 +35,24 @@
//------------- IMPLEMENTATION -------------//
void tuh_msc_mounted_cb(uint8_t dev_addr)
{
- puts("\na MassStorage device is mounted");
+ printf("A MassStorage device is mounted\r\n");
-// //------------- Disk Information -------------//
-// // SCSI VendorID[8] & ProductID[16] from Inquiry Command
-// uint8_t const* p_vendor = tuh_msc_get_vendor_name(dev_addr);
-// uint8_t const* p_product = tuh_msc_get_product_name(dev_addr);
-//
-// for(uint8_t i=0; i<8; i++) putchar(p_vendor[i]);
-//
-// putchar(' ');
-// for(uint8_t i=0; i<16; i++) putchar(p_product[i]);
-// putchar('\n');
-//
-// uint32_t last_lba, block_size;
-// tuh_msc_get_capacity(dev_addr, &last_lba, &block_size);
-// printf("Disk Size: %d MB\n", (last_lba+1)/ ((1024*1024)/block_size) );
-// printf("LBA 0-0x%X Block Size: %d\n", last_lba, block_size);
+ //------------- Disk Information -------------//
+ // SCSI VendorID[8] & ProductID[16] from Inquiry Command
+ uint8_t const* p_vendor = tuh_msc_get_vendor_name(dev_addr);
+ uint8_t const* p_product = tuh_msc_get_product_name(dev_addr);
+
+ for(uint8_t i=0; i<8; i++) putchar(p_vendor[i]);
+
+ putchar(' ');
+ for(uint8_t i=0; i<16; i++) putchar(p_product[i]);
+ putchar('\n');
+
+ uint32_t last_lba = 0;
+ uint32_t block_size = 0;
+ tuh_msc_get_capacity(dev_addr, &last_lba, &block_size);
+ printf("Disk Size: %ld MB\r\n", (last_lba+1)/ ((1024*1024)/block_size) );
+ printf("LBA 0-0x%lX Block Size: %ld\r\n", last_lba, block_size);
//
// //------------- file system (only 1 LUN support) -------------//
// uint8_t phy_disk = dev_addr-1;
@@ -81,7 +82,8 @@ void tuh_msc_mounted_cb(uint8_t dev_addr)
void tuh_msc_unmounted_cb(uint8_t dev_addr)
{
- puts("\na MassStorage device is unmounted");
+ (void) dev_addr;
+ printf("A MassStorage device is unmounted\r\n");
// uint8_t phy_disk = dev_addr-1;
//
diff --git a/examples/host/cdc_msc_hid/src/tusb_config.h b/examples/host/cdc_msc_hid/src/tusb_config.h
index aa259dafd..6604623b1 100644
--- a/examples/host/cdc_msc_hid/src/tusb_config.h
+++ b/examples/host/cdc_msc_hid/src/tusb_config.h
@@ -40,9 +40,9 @@
#endif
#if CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX
-#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST | OPT_MODE_HIGH_SPEED)
+ #define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST | OPT_MODE_HIGH_SPEED)
#else
-#define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST
+ #define CFG_TUSB_RHPORT0_MODE OPT_MODE_HOST
#endif
#define CFG_TUSB_OS OPT_OS_NONE
@@ -69,29 +69,16 @@
// CONFIGURATION
//--------------------------------------------------------------------
-#define CFG_TUH_HUB 1
+#define CFG_TUH_HUB 0
#define CFG_TUH_CDC 1
-#define CFG_TUH_HID_KEYBOARD 0
-#define CFG_TUH_HID_MOUSE 0
+#define CFG_TUH_HID_KEYBOARD 1
+#define CFG_TUH_HID_MOUSE 1
#define CFG_TUSB_HOST_HID_GENERIC 0 // (not yet supported)
-#define CFG_TUH_MSC 0
+#define CFG_TUH_MSC 1
+#define CFG_TUH_VENDOR 0
#define CFG_TUSB_HOST_DEVICE_MAX (CFG_TUH_HUB ? 5 : 1) // normal hub has 4 ports
-//------------- CLASS -------------//
-#define CFG_TUD_CDC 0
-#define CFG_TUD_MSC 0
-#define CFG_TUD_HID 0
-#define CFG_TUD_VENDOR 0
-
-// CDC FIFO size of TX and RX
-#define CFG_TUD_CDC_RX_BUFSIZE 64
-#define CFG_TUD_CDC_TX_BUFSIZE 64
-
-// MSC Buffer size of Device Mass storage
-#define CFG_TUD_MSC_BUFSIZE 512
-
-
#ifdef __cplusplus
}
#endif
diff --git a/examples/make.mk b/examples/make.mk
index b7917987e..6743044fd 100644
--- a/examples/make.mk
+++ b/examples/make.mk
@@ -84,7 +84,6 @@ ifeq ($(LOGGER),rtt)
RTT_SRC = lib/SEGGER_RTT
CFLAGS += -DLOGGER_RTT -DSEGGER_RTT_MODE_DEFAULT=SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL
INC += $(TOP)/$(RTT_SRC)/RTT
- SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT_printf.c
SRC_C += $(RTT_SRC)/RTT/SEGGER_RTT.c
else ifeq ($(LOGGER),swo)
CFLAGS += -DLOGGER_SWO