*This content has been reposted with the approval of the original author.
IntroductionThere is a USB library for the F407 series on the Geehy official website, its name is APM32F4xx_OTG_SDK, and I downloaded the V1.1 version. It contains host and device routines in addition to the USB driver. There are three types of routines: mouse, virtual serial port, and USB flash drive. I'll share with you some of my experience in the process of using it. In this time, we will mainly talk about HID device routines, ie. mouse.
The hardware I used is the APM32F407IG MINI Board of Geehy, which provides a full-speed USB port (Type B). After opening the HID routine in the Device_Examples directory and successfully compiling and downloading it, and connecting the USB cable to the board, the computer's device manager appears with the device shown below:
When a new mouse device appears, then the routine's enumeration works fine. In this routine, the left and right mouse movements are controlled using KEY1 and KEY2. There are also two IOs, PC8, and PC9, that can control the up-and-down movement of the cursor. If the mouse can be controlled freely, the routine is working properly.
Parameter configurationI. Selection of different targets of the project
As shown in the figure below, there are three targets in a Keil project, USBD_HID_FS for full speed, using the pins PA11 and PA12; USBD_HID_HS1 for high-speed, using the ULPI interface, with many pins configured, which is due to the need for an external high-speed PHY; USBD_HID_HS2 for high-speed, because the embedded high-speed PHY, so the communication pins are mainly PB14 and PB15. When I used it before, it was directly connected with 0 Ω resistors from PB14 and PB15 pins respectively, and then it can be used directly connected to the USB port, but the quality of the wiring needs to be ensured.
There is only full speed on the MINI board, so here I am mainly demonstrating full speed as well.
II. Descriptor configuration
In general, the descriptors of the routines can be left unmodified if you just want to control the mouse. The following is a brief description of how to modify a few descriptors.
If you want to adjust the device version number or vendor ID and product ID, you can modify the device descriptor, the specific method is as follows:
Configuration descriptor is the most content of all descriptors, it also contains interface descriptor, endpoint descriptor, and other information. The specific usage is as follows:
If you want to modify the information expressed in the string, you can modify the corresponding string descriptor, for example, the product string descriptor:
III. After we get the routine, how should we use it?
The routine is used for demonstration, the main purpose is to let people know how this driver should be used, and the most important part of the whole SDK should be the driver. We need to understand what is necessary for the routines and what can be modified or removed according to our needs. For example, the following figure is the main function of the routine, and the contents of the operation are all here, except for the interrupt.
Comments
Please log in or sign up to comment.