@@ -63,5 +63,52 @@ void mp_usbd_hex_str(char *out_str, const uint8_t *bytes, size_t bytes_len) {
6363 }
6464 out_str [hex_len ] = 0 ;
6565}
66+ #if CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32P4
67+ const uint8_t hid_report_descriptor [] = {
68+ TUD_HID_REPORT_DESC_KEYBOARD (HID_REPORT_ID (HID_ITF_PROTOCOL_KEYBOARD )),
69+ TUD_HID_REPORT_DESC_MOUSE (HID_REPORT_ID (HID_ITF_PROTOCOL_MOUSE ))
70+ };
6671
72+ /**
73+ * @brief String descriptor
74+ */
75+ const char * hid_string_descriptor [5 ] = {
76+ // array of pointer to string descriptors
77+ (char []){0x09 , 0x04 }, // 0: is supported language is English (0x0409)
78+ "TinyUSB" , // 1: Manufacturer
79+ "TinyUSB Device" , // 2: Product
80+ "123456" , // 3: Serials, should use chip ID
81+ "Example HID interface" , // 4: HID
82+ };
83+
84+ /********* TinyUSB HID callbacks ***************/
85+
86+ // Invoked when received GET HID REPORT DESCRIPTOR request
87+ // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
88+ uint8_t const * tud_hid_descriptor_report_cb (uint8_t instance )
89+ {
90+ // We use only one interface and one HID report descriptor, so we can ignore parameter 'instance'
91+ return hid_report_descriptor ;
92+ }
93+
94+ // Invoked when received GET_REPORT control request
95+ // Application must fill buffer report's content and return its length.
96+ // Return zero will cause the stack to STALL request
97+ uint16_t tud_hid_get_report_cb (uint8_t instance , uint8_t report_id , hid_report_type_t report_type , uint8_t * buffer , uint16_t reqlen )
98+ {
99+ (void ) instance ;
100+ (void ) report_id ;
101+ (void ) report_type ;
102+ (void ) buffer ;
103+ (void ) reqlen ;
104+
105+ return 0 ;
106+ }
107+
108+ // Invoked when received SET_REPORT control request or
109+ // received data on OUT endpoint ( Report ID = 0, Type = 0 )
110+ void tud_hid_set_report_cb (uint8_t instance , uint8_t report_id , hid_report_type_t report_type , uint8_t const * buffer , uint16_t bufsize )
111+ {
112+ }
113+ #endif
67114#endif // MICROPY_HW_ENABLE_USBDEV
0 commit comments