cancel
Showing results for 
Search instead for 
Did you mean: 

PROGRaming use of 2do usb in nucleo.h7

yogui_ricardo
Associate II

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

 

yogui_ricardo_0-1730055814190.png

 

2 REPLIES 2
gbm
Lead III

Middleware - USB device - select a proper class (CDC?) and write some code to handle the transfers.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
yogui_ricardo
Associate II

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

}