add tuh_hid_receive_report() for applicaiton to explicitly request report
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
@@ -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]);
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user