Hi,
I've got a teensy 4.1 connected to an FPGA to handle all of the usb host protocol stuff. Right now, the system is working with a 4khz mouse and it is great. One minor source of annoyance is that the data logging on the fpga is now tied to how quickly (or not) the mouse is moving. Having a consistent update rate regardless of mouse movement would be great. Does the usb library allow this? I didn't see a clear path.
A shortened version of my arduino sketch:
void ProcessMouseData(){
uint32_t cur_buttons;
int16_t cur_x;
int16_t cur_y;
if (mouse.available()) { // <<<<========== Ideally, this should fire every on polling request answer, not just those with mouse position/click changes.
cur_buttons = mouse.getButtons();
cur_x = mouse.getMouseX();
cur_y = mouse.getMouseY();
mouse.mouseDataClear();
SendMouseDataToUART(cur_buttons, cur_x, cur_y); // This function just sends a few characters to translate usb poll response stream to a character stream on the uart
}
}
void setup(){
Serial.begin(UARTSPEED_HOST);
Serial2.begin(UARTSPEED_MOUSE);
myusb.begin();
}
void loop(){
myusb.Task();
ProcessMouseData();
watchForUSBDeviceChanges();
}
Thanks
I've got a teensy 4.1 connected to an FPGA to handle all of the usb host protocol stuff. Right now, the system is working with a 4khz mouse and it is great. One minor source of annoyance is that the data logging on the fpga is now tied to how quickly (or not) the mouse is moving. Having a consistent update rate regardless of mouse movement would be great. Does the usb library allow this? I didn't see a clear path.
A shortened version of my arduino sketch:
void ProcessMouseData(){
uint32_t cur_buttons;
int16_t cur_x;
int16_t cur_y;
if (mouse.available()) { // <<<<========== Ideally, this should fire every on polling request answer, not just those with mouse position/click changes.
cur_buttons = mouse.getButtons();
cur_x = mouse.getMouseX();
cur_y = mouse.getMouseY();
mouse.mouseDataClear();
SendMouseDataToUART(cur_buttons, cur_x, cur_y); // This function just sends a few characters to translate usb poll response stream to a character stream on the uart
}
}
void setup(){
Serial.begin(UARTSPEED_HOST);
Serial2.begin(UARTSPEED_MOUSE);
myusb.begin();
}
void loop(){
myusb.Task();
ProcessMouseData();
watchForUSBDeviceChanges();
}
Thanks