I want to ask about how can I get mouse data over STM32F 407. I don't want to send it to PC. My microcontroller should be USB HOST and the mouse only communicate the microcontroller. I've searched a lot but I only found sample projects for HID and in the projects Microcontroller was pretending like a mouse and sends data to the PC.
While not exactly for F4-Discovery, there are examples for F446E EVAL that should get you going. These can be found in the "MCU Package for STM32F4 Series" (at the moment of writing version 1.24.1) within STM32Cube tool from ST. Once you download the package, go to the location of your package respoitory folder. The examples can be found under: STM32Cube/Repository/STM32Cube_FW_F4_V1.24.1/Projects/STM32446E_EVAL/Applications/USB_Host. For USB Host HID which you ask for there are two separate sample projects: HID_RTOS (USB Host processing etc. done using FreeRTOS tasks) and HID_Standalone (done using one loop inside main.c
).
As for the F407 discovery - the User Manual mentions that the USB-micro connector (CN5 on the board) supports full OTG. You'll obviously need an external USB-micro OTG adapter to physically connect your mouse to the board, but no hardware modifications should be needed.
When it comes to adapting the EVAL example for F4-discovery - by looking at things you may be able to actually have it working with surprisingly little work. The EVAL example uses the display it has onboard, so you'll obviously need to cut out any code related to that, plus possibly look into external clock configuration. After that it should be a matter of just using the USB FS (undefine USE_USB_HS
) - luckily even though both MCUs come in different packaing, the USB FS pins are the same for both, so the initialization for that doesn't change.