Skip to main content
Graduate II
October 27, 2024
Solved

PROGRaming use of 2do usb in nucleo.h7

  • October 27, 2024
  • 3 replies
  • 1271 views

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

 

    This topic has been closed for replies.
    Best answer by FBL

    Hi @yogui_ricardo 

    You need HID class instead of CDC to interface a mouse. Here is a working example to start with on eval board  STM32CubeH7/Projects/STM32H743I-EVAL/Applications/USB_Device/HID_Standalone at master · STMicroelectronics/STM32CubeH7 · GitHub You need to refer to schematics as well.

    3 replies

    Graduate
    October 27, 2024

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

    Graduate II
    October 28, 2024

    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

    }

    FBLAnswer
    Technical Moderator
    October 28, 2024

    Hi @yogui_ricardo 

    You need HID class instead of CDC to interface a mouse. Here is a working example to start with on eval board  STM32CubeH7/Projects/STM32H743I-EVAL/Applications/USB_Device/HID_Standalone at master · STMicroelectronics/STM32CubeH7 · GitHub You need to refer to schematics as well.