2024-10-27 12:08 PM
I want to use the second USB of my nucleo-h753zi board, in a program that checks and graphs the movements and clicks of the mouse that enters through the USB port, but I only see the stlink, there is the init = MX_USB_DEVICE_Init (void); I used the power in "ext" and in "chgr" but without result. What am I missing or what am I doing wrong? Thanks
2024-10-27 02:16 PM
Middleware - USB device - select a proper class (CDC?) and write some code to handle the transfers.
2024-10-27 07:42 PM
yes;That is contemplated:
void SendMessageToPC(char* message) {
CDC_Transmit_FS((uint8_t*)message, strlen(message));
}
void SendMovementData(int x, int y, uint8_t buttons) {
char buffer[50]; // Buffer para el mensaje
// Formatear el mensaje
sprintf(buffer, "Mov: X=%d, Y=%d, Buttons=%d\r\n", x, y, buttons);
// Enviar el mensaje al PC
CDC_Transmit_FS((uint8_t*)buffer, strlen(buffer));
}
void ProcessMovement() {
HID_ReportTypeDef report = {0, 0, 0}; // Inicializa el reporte
report.buttons = 1; // Emular clic en el botón 1
report.x = 5; // Desplazamiento en X
report.y = 0; // Desplazamiento en Y
USBD_HID_SendReport(&hUsbDeviceFS, (uint8_t*)&report, sizeof(report));
// Envía la información de movimiento por USB Serial
SendMovementData(report.x, report.y, report.buttons);
HAL_Delay(10); // Pausa para evitar sobrecarga de reportes
}