summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-08-23 11:00:21 +0700
committerhathach <[email protected]>2021-08-23 11:00:21 +0700
commit800f85329ea21bdefc778c246c8098dea12fb402 (patch)
treee5ea27b16de88a577a45c03521d579100e41acd0 /examples
parent58477b71f2989bc24480cb6e90dfd61506ec0ccd (diff)
add tuh_hid_receive_report() for applicaiton to explicitly request report
Diffstat (limited to 'examples')
-rw-r--r--examples/host/cdc_msc_hid/src/hid_app.c13
-rw-r--r--examples/host/cdc_msc_hid/src/main.c29
-rw-r--r--examples/host/cdc_msc_hid/src/tusb_config.h6
3 files changed, 18 insertions, 30 deletions
diff --git a/examples/host/cdc_msc_hid/src/hid_app.c b/examples/host/cdc_msc_hid/src/hid_app.c
index 5e3ac6a72..11437c2b4 100644
--- a/examples/host/cdc_msc_hid/src/hid_app.c
+++ b/examples/host/cdc_msc_hid/src/hid_app.c
@@ -80,6 +80,13 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
hid_info[instance].report_count = tuh_hid_parse_report_descriptor(hid_info[instance].report_info, MAX_REPORT, desc_report, desc_len);
printf("HID has %u reports \r\n", hid_info[instance].report_count);
}
+
+ // request to receive report
+ // tuh_hid_report_received_cb() will be invoked when report is available
+ if ( !tuh_hid_receive_report(dev_addr, instance) )
+ {
+ printf("Error: cannot request to receive report\r\n");
+ }
}
// Invoked when device with hid interface is un-mounted
@@ -110,6 +117,12 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
process_generic_report(dev_addr, instance, report, len);
break;
}
+
+ // continue to request to receive report
+ if ( !tuh_hid_receive_report(dev_addr, instance) )
+ {
+ printf("Error: cannot request to receive report\r\n");
+ }
}
//--------------------------------------------------------------------+
diff --git a/examples/host/cdc_msc_hid/src/main.c b/examples/host/cdc_msc_hid/src/main.c
index 7ae814e38..a14be05ea 100644
--- a/examples/host/cdc_msc_hid/src/main.c
+++ b/examples/host/cdc_msc_hid/src/main.c
@@ -33,7 +33,6 @@
//--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF PROTYPES
//--------------------------------------------------------------------+
-void print_greeting(void);
void led_blinking_task(void);
extern void cdc_task(void);
@@ -43,7 +42,8 @@ extern void hid_app_task(void);
int main(void)
{
board_init();
- print_greeting();
+
+ printf("TinyUSB Host CDC MSC HID Example\r\n");
tusb_init();
@@ -126,28 +126,3 @@ void led_blinking_task(void)
board_led_write(led_state);
led_state = 1 - led_state; // toggle
}
-
-//--------------------------------------------------------------------+
-// HELPER FUNCTION
-//--------------------------------------------------------------------+
-void print_greeting(void)
-{
- char const * const rtos_name[] =
- {
- [OPT_OS_NONE] = "None",
- [OPT_OS_FREERTOS] = "FreeRTOS",
- [OPT_OS_MYNEWT] = "Mynewt OS",
- [OPT_OS_CUSTOM] = "Custom OS implemnted by application",
- [OPT_OS_PICO] = "Raspberry Pi Pico SDK",
- [OPT_OS_RTTHREAD] = "RT-Thread"
- };
-
- printf("----------------------------------------------------\r\n");
- printf("TinyUSB Host Example\r\n");
- printf("If you find any bugs or problems, feel free to open\r\n");
- printf("an 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]);
-}
diff --git a/examples/host/cdc_msc_hid/src/tusb_config.h b/examples/host/cdc_msc_hid/src/tusb_config.h
index b574acf9b..80f07f446 100644
--- a/examples/host/cdc_msc_hid/src/tusb_config.h
+++ b/examples/host/cdc_msc_hid/src/tusb_config.h
@@ -76,15 +76,15 @@
#define CFG_TUH_HUB 1
#define CFG_TUH_CDC 1
-#define CFG_TUH_HID 4
+#define CFG_TUH_HID 4 // typical keyboard + mouse device can have 3-4 HID interfaces
#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
//------------- HID -------------//
-
-#define CFG_TUH_HID_EP_BUFSIZE 64
+#define CFG_TUH_HID_EPIN_BUFSIZE 64
+#define CFG_TUH_HID_EPOUT_BUFSIZE 64
#ifdef __cplusplus
}