Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to mount #458

Open
cocotop opened this issue Sep 12, 2024 · 1 comment
Open

Unable to mount #458

cocotop opened this issue Sep 12, 2024 · 1 comment
Labels
Bug Something isn't working

Comments

@cocotop
Copy link

cocotop commented Sep 12, 2024

Operating System

Windows 11

Arduino IDE version

1.8

Board

esp32s3

ArduinoCore version

1

TinyUSB Library version

3.3

Sketch as ATTACHED TXT

image

Compiled Log as ATTACHED TXT

image
#include <Adafruit_TinyUSB.h>

// 单一报告(无 ID)描述符
uint8_t const desc_hid_report[] = {
TUD_HID_REPORT_DESC_MOUSE()
};

// USB HID 对象
Adafruit_USBD_HID usb_hid;

void setup() {
// Manual begin() is required on core without built-in support e.g. mbed rp2040
if (!TinyUSBDevice.isInitialized()) {
TinyUSBDevice.begin(0);
}
Serial.begin(9600);
// Set up HID
usb_hid.setBootProtocol(HID_ITF_PROTOCOL_MOUSE);
usb_hid.setPollInterval(2);
usb_hid.setReportDescriptor(desc_hid_report, sizeof(desc_hid_report));
usb_hid.setStringDescriptor("TinyUSB Mouse");
usb_hid.begin();
// If already enumerated, additional class driverr begin() e.g msc, hid, midi won't take effect until re-enumeration
if (TinyUSBDevice.mounted()) {
TinyUSBDevice.detach();
delay(10);
TinyUSBDevice.attach();
}

Serial.println("Adafruit TinyUSB HID Mouse example");

}

void process_hid() {
// 如果 HID 准备好了
if (usb_hid.ready()) {
uint8_t const report_id = 0; // 无 ID
int8_t const delta = 5; // 移动步幅
usb_hid.mouseMove(report_id, delta, delta); // 模拟向右和向下移动
}
}

void loop() {
#ifdef TINYUSB_NEED_POLLING_TASK
TinyUSBDevice.task();
#endif

if (TinyUSBDevice.mounted()) {
    Serial.println("Device mounted successfully.");
    return;
} else {
    Serial.println("Device not mounted.");
}
// 每100毫秒移动一次鼠标
static uint32_t ms = 0;
if (millis() - ms > 100) { // 调整时间间隔来改变移动频率
    ms = millis();
    process_hid();
}

}

What happened ?

image

How to reproduce ?

image
Unable to mount

Debug Log

No response

Screenshots

image

@cocotop cocotop added the Bug Something isn't working label Sep 12, 2024
@manny4u67
Copy link

You will have to add this to your platformio.ini to enable OTG which is required for TinyUSB. @0cococ

Keep in mind that now you will need to hold boot and press reset to program the ESP32-S3

build_flags = 
	-DUSE_TINYUSB=1
	-DARDUINO_USB_MODE=0
	-DARDUINO_USB_CDC_ON_BOOT=1
lib_archive = no

More resources for you 👍
https://community.platformio.org/t/esp32-s3-tinyusb-config-not-working/34209/11
https://github.com/adafruit/Adafruit_TinyUSB_Arduino/blob/master/examples/HID/hid_boot_keyboard/hid_boot_keyboard.ino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants