Replies: 1 comment
-
Please use English so everyone can understand, also ESP's wrapper layer is not covered by this repo. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Operating System
Others
Board
ESP32S3
Firmware
const uint8_t hid_report_descriptor[] = {
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(HID_ITF_PROTOCOL_KEYBOARD)),
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(HID_ITF_PROTOCOL_MOUSE)),
0x05, 0x0d, /* USAGE_PAGE (Digitizer) /
0x09, 0x04, / USAGE (Touch Screen) /
0xa1, 0x01, / COLLECTION (Application) /
0x85, HID_ITF_PROTOCOL_ABSMOUSE, / REPORT_ID */
};
What happened ?
#include "tinyusb.h"
enum
{
ITF_NUM_HID,
ITF_NUM_CDC,
};
#define LSB(v) ((v) & 0xFF)
#define MSB(v) (((v) >> 8) & 0xFF)
#define ITF_NUM_TOTAL 3
#define TUSB_DESC_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN + TUD_CDC_DESC_LEN)
#define EPNUM_CDC_NOTIF 0x81
#define EPNUM_CDC_OUT 0x02
#define EPNUM_CDC_IN 0x82
#define EPNUM_HID 0x83
const uint8_t hid_report_descriptor[] = {
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(HID_ITF_PROTOCOL_KEYBOARD)),
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(HID_ITF_PROTOCOL_MOUSE)),
0x05, 0x0d, /* USAGE_PAGE (Digitizer) /
0x09, 0x04, / USAGE (Touch Screen) /
0xa1, 0x01, / COLLECTION (Application) /
0x85, HID_ITF_PROTOCOL_ABSMOUSE, / REPORT_ID */
};
const size_t hid_report_descriptor_size = sizeof(hid_report_descriptor);
// Invoked when received GET HID REPORT DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
uint8_t const *tud_hid_descriptor_report_cb(uint8_t instance)
{
// We use only one interface and one HID report descriptor, so we can ignore parameter 'instance'
return hid_report_descriptor;
}
/**
This is a simple configuration descriptor that defines 1 configuration and 1 HID interface
*/
static const uint8_t configuration_descriptor[] = {
// Configuration number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, TUSB_DESC_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 200),
// Interface number, string index, boot protocol, report descriptor len, EP In address, size & polling interval
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 5, HID_ITF_PROTOCOL_NONE, sizeof(hid_report_descriptor), EPNUM_HID, CFG_TUD_HID_EP_BUFSIZE, 10),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_NUM_CDC, 4, EPNUM_CDC_NOTIF, 8, EPNUM_CDC_OUT, EPNUM_CDC_IN, 64),
};
const char *string_descriptor[] = {
// array of pointer to string descriptors
(char[]){0x09, 0x04}, // 0: is supported language is English (0x0409)
CONFIG_TINYUSB_DESC_MANUFACTURER_STRING, // 1: Manufacturer
CONFIG_TINYUSB_DESC_PRODUCT_STRING, // 2: Product
CONFIG_TINYUSB_DESC_SERIAL_STRING, // 3: Serials, should use chip ID
CONFIG_TINYUSB_DESC_CDC_STRING, // 4: CDC Interface
CONFIG_DESC_HID_STRING, // 5: HID Interface
};
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
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)
{
(void)instance;
(void)report_id;
(void)report_type;
(void)buffer;
(void)reqlen;
return 0;
}
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
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)
{
}
const tinyusb_config_t tusb_cfg = {
.device_descriptor = NULL,
.string_descriptor = string_descriptor,
.string_descriptor_count = sizeof(string_descriptor) / sizeof(string_descriptor[0]),
.external_phy = false,
.configuration_descriptor = configuration_descriptor,
};
How to reproduce ?
I deleted the definition of the mouse, the touch screen works fine, plus the mouse, the touch screen doesn't work, is there something wrong with it?
Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)
I (27) boot: ESP-IDF v5.3.1 2nd stage bootloader
I (27) boot: compile time Sep 14 2024 15:54:57
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.1
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode : DIO
I (43) boot.esp32s3: SPI Flash Size : 2MB
I (48) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (57) boot: ## Label Usage Type ST Offset Length
I (64) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (72) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (79) boot: 2 factory factory app 00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c020020 size=0bfd0h ( 49104) map
I (108) esp_image: segment 1: paddr=0001bff8 vaddr=3fc92500 size=02af4h ( 10996) load
I (111) esp_image: segment 2: paddr=0001eaf4 vaddr=40374000 size=01524h ( 5412) load
I (117) esp_image: segment 3: paddr=00020020 vaddr=42000020 size=1cca4h (117924) map
I (146) esp_image: segment 4: paddr=0003cccc vaddr=40375524 size=0cee0h ( 52960) load
I (163) boot: Loaded app from partition at offset 0x10000
I (164) boot: Disabling RNG early entropy source...
I (176) cpu_start: Multicore app
I (185) cpu_start: Pro cpu start user code
I (185) cpu_start: cpu freq: 160000000 Hz
I (185) app_init: Application information:
I (188) app_init: Project name: hello_world
I (193) app_init: App version: 1
I (197) app_init: Compile time: Sep 14 2024 15:53:32
I (203) app_init: ELF file SHA256: 740cab92b...
I (209) app_init: ESP-IDF: v5.3.1
I (213) efuse_init: Min chip rev: v0.0
I (218) efuse_init: Max chip rev: v0.99
I (223) efuse_init: Chip rev: v0.1
I (228) heap_init: Initializing. RAM available for dynamic allocation:
I (235) heap_init: At 3FC96418 len 000532F8 (332 KiB): RAM
I (241) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (247) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (253) heap_init: At 600FE100 len 00001EE8 (7 KiB): RTCRAM
I (261) spi_flash: detected chip: gd
I (264) spi_flash: flash io: dio
W (268) spi_flash: Detected size(16384k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (281) sleep: Configure to isolate all GPIO pins in sleep state
I (288) sleep: Enable automatic switching of GPIO sleep configuration
I (295) main_task: Started on CPU0
I (305) main_task: Calling app_main()
I (305) app: USB initialization
W (305) tusb_desc: No Device descriptor provided, using default.
I (365) tusb_desc:
┌─────────────────────────────────┐
│ USB Device Descriptor Summary │
├───────────────────┬─────────────┤
│bDeviceClass │ 239 │
├───────────────────┼─────────────┤
│bDeviceSubClass │ 2 │
├───────────────────┼─────────────┤
│bDeviceProtocol │ 1 │
├───────────────────┼─────────────┤
│bMaxPacketSize0 │ 64 │
├───────────────────┼─────────────┤
│idVendor │ 0x303a │
├───────────────────┼─────────────┤
│idProduct │ 0x4009 │
├───────────────────┼─────────────┤
│bcdDevice │ 0x100 │
├───────────────────┼─────────────┤
│iManufacturer │ 0x1 │
├───────────────────┼─────────────┤
│iProduct │ 0x2 │
├───────────────────┼─────────────┤
│iSerialNumber │ 0x3 │
├───────────────────┼─────────────┤
│bNumConfigurations │ 0x1 │
└───────────────────┴─────────────┘
I (525) TinyUSB: TinyUSB Driver installed
I (525) app: USB initialization DONE
Screenshots
No response
I have checked existing issues, dicussion and documentation
Beta Was this translation helpful? Give feedback.
All reactions