#include <USBHost_t36.h>
USBHost usb_host;
USBHIDParser hid1(usb_host);
USBHIDParser hid2(usb_host);
USBHub hub(usb_host);
MouseController mouse_in(usb_host);
void setup() {
// USB IN
while (!Serial && millis() < 4000) ;
Serial.begin(115200);
Serial.println("Test mouse reads");
usb_host.begin();
}
void loop() {
elapsedMicros em = 0;
uint32_t count_mouse_reads = 0;
while (count_mouse_reads < 1000) {
usb_host.Task();
if (mouse_in.available())
{
#if 0
// Proxy Mouse
Serial.print("Mouse: buttons = ");
Serial.print(mouse_in.getButtons());
Serial.print(", mouseX = ");
Serial.print(mouse_in.getMouseX());
Serial.print(", mouseY = ");
Serial.print(mouse_in.getMouseY());
Serial.print(", wheel = ");
Serial.print(mouse_in.getWheel());
Serial.print(", wheelH = ");
Serial.print(mouse_in.getWheelH());
Serial.println();
#endif
count_mouse_reads++;
mouse_in.mouseDataClear();
}
}
Serial.println((uint32_t)em);
delay(250);
}
Test mouse reads
76819003
2036999
2043999
2042999
USB HID Device Info Program
This Sketch shows information about plugged in HID devices
*** You can control the output by simple character input to Serial ***
R - Turns on or off showing the raw data
C - Toggles showing changed data only on or off
<anything else> - toggles showing the Hid formatted breakdown of the data
USB2 PLL running
reset waited 6
USBHS_ASYNCLISTADDR = 0
USBHS_PERIODICLISTBASE = 2000C000
periodictable = 2000C000
port change: 10001803
connect
begin reset
port change: 10001005
port enabled
end recovery
new_Device: 12 Mbit/sec
new_Pipe
enumeration:
enumeration:
enumeration:
Device Descriptor:
12 01 10 01 00 00 00 08 8A 25 36 00 09 01 01 02 00 01
VendorID = 258A, ProductID = 0036, Version = 0109
Class/Subclass/Protocol = 0 / 0 / 0
Number of Configurations = 1
enumeration:
enumeration:
Manufacturer: SINOWEALTH
enumeration:
Product: Wired Gaming Mouse
enumeration:
Config data length = 59
enumeration:
Configuration Descriptor:
09 02 3B 00 02 01 00 A0 F0
NumInterfaces = 2
ConfigurationValue = 1
09 04 00 00 01 03 01 02 00
Interface = 0
Number of endpoints = 1
Class/Subclass/Protocol = 3(HID) / 1(Boot) / 2(Mouse)
09 21 11 01 00 01 22 47 00
HID, 1 report descriptor
07 05 81 03 08 00 01
Endpoint = 1 IN
Type = Interrupt
Max Size = 8
Polling Interval = 1
09 04 01 00 01 03 01 01 00
Interface = 1
Number of endpoints = 1
Class/Subclass/Protocol = 3(HID) / 1(Boot) / 1(Keyboard)
09 21 11 01 00 01 22 D5 00
HID, 1 report descriptor
07 05 82 03 08 00 01
Endpoint = 2 IN
Type = Interrupt
Max Size = 8
Polling Interval = 1
enumeration:
USBHub memory usage = 960
USBHub claim_device this=20007300
USBHub memory usage = 960
USBHub claim_device this=200076C0
USBDeviceInfo claim this=20006CA8
****************************************
** Device Level **
vid=258A
pid=36
bDeviceClass = 0
bDeviceSubClass = 0
bDeviceProtocol = 0
09 04 00 00 01 03 01 02 00 09 21 11 01 00 01 22 47 00 07 05 81 03 08 00 01 09 04 01 00 01 03 01
01 00 09 21 11 01 00 01 22 D5 00 07 05 82 03 08 00 01
HIDParser claim this=20006020
HIDParser claim this=20006660
HIDParser claim this=2000ACE0
HIDParser claim this=20004920
HIDParser claim this=20006CC0
Descriptor 4 = INTERFACE
USBDeviceInfo claim this=20006CA8
****************************************
** Interface Level **
09 04 00 00 01 03 01 02 00 09 21 11 01 00 01 22 47 00 07 05 81 03 08 00 01 09 04 01 00 01 03 01
01 00 09 21 11 01 00 01 22 D5 00 07 05 82 03 08 00 01
bInterfaceNumber = 0
number end points = 1
bInterfaceClass = 3
bInterfaceSubClass = 1
HID (BOOT)
bInterfaceProtocol = 2
report descriptor size = 71
endpoint = 81
attributes = 3 Interrupt
size = 8
interval = 1
HIDParser claim this=20006020
bInterfaceNumber = 0
bInterfaceClass = 3
bInterfaceSubClass = 1
bInterfaceProtocol = 2
HID Parser Claim: 09 04 00 00 01 03 01 02 00 09 21 11 01 00 01 22 47 00 07 05 81 03 08 00 01 09 04 01 00 01 03 01 01 00 09 21 11 01 00 01 22 D5 00 07 05 82 03 08 00 01
report descriptor size = 71
Single endpoint HID:
endpoint = 81
size = 8
interval = 1
new_Pipe
USBHost.
I tried to do the triangle mouse movement while mouse.available(), that worked with 1000hz.
Just when reading values from USBHost and passing them over, I get 500hz.
#include <USBHost_t36.h>
USBHost usb_host;
USBHIDParser hid1(usb_host);
USBHIDParser hid2(usb_host);
USBHub hub(usb_host);
MouseController mouse_in(usb_host);
void setup() {
// USB IN
while (!Serial && millis() < 4000) ;
Serial.begin(115200);
Serial.println("Test mouse reads");
usb_host.begin();
}
void loop() {
elapsedMicros em = 0;
uint32_t count_mouse_reads = 0;
while (count_mouse_reads < 1000) {
usb_host.Task();
if (mouse_in.available())
{
#if 0
// Proxy Mouse
Serial.print("Mouse: buttons = ");
Serial.print(mouse_in.getButtons());
Serial.print(", mouseX = ");
Serial.print(mouse_in.getMouseX());
Serial.print(", mouseY = ");
Serial.print(mouse_in.getMouseY());
Serial.print(", wheel = ");
Serial.print(mouse_in.getWheel());
Serial.print(", wheelH = ");
Serial.print(mouse_in.getWheelH());
Serial.println();
#endif
count_mouse_reads++;
mouse_in.mouseDataClear();
}
}
uint32_t delta_time = em;
Serial.print(delta_time);
Serial.print(" ");
Serial.println((1000000.0 / (float)delta_time) * 1000.0, 2);
delay(250);
}
Test mouse reads
2830003 353.36
1085998 920.81
1106998 903.34
1099998 909.09
1075998 929.37
1079998 925.93
1077998 927.65
1037998 963.39
1033998 967.12
1002998 997.01
1010998 989.12
1016998 983.29
1019998 980.39
Will try in a few minutes! That sounds promising.
Thank you for all your efforts.
Edit: Works perfectly fine!
Mind sharing some code?
I only see attachReceive on raw usb HID.
USB1_PORTSC1 |= USB_PORTSC1_PFSC; // force 12 Mbit/sec
//USBHS_PORTSC1 |= USBHS_PORTSC_PFSC; // force 12 Mbit/sec