We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hy, i'm starting to program on stm32f407 and I have some problem using USB.
I manage to make simple application with wizard. But now, i want to make for example an HID Application with more than one endpoint. For example, i want ARM to send data to PC as a keyboard and mouse.
How can i make multiple endpoint and more complex HID report descriptor.
I use keil 4.54 and rl-arm library.
Thanks for your help. I found help and manual not clear on this point.
Thanks for this answer.
So I create a nex .h file to declare my own descriptor. Where do i include this file ?
Maybe, you have a link for example ?
Thank you in advance.
You should specify these arrays in a .c file that you should add to your project and it should automatically replace other arrays as they are defined as __weak
To make keyboard + mouse HID device, multi-TLC (Top-Level Collection) is much easier than HID + HID composite device. Just replacing the report descriptor to this one, you'll get keyboard + mouse HID device
You may apply RL-USB APIs without any change. For example, usbd_hid_get_report() is called with rid (Report ID) = 1 for keyboard, rid = 2 for mouse.
const U8 USBD_HID_ReportDescriptor[] = { // Keyboard Top-Level Collection (TLC) 0x85, 0x01, // REPORT_ID (1) 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x06, // USAGE (Keyboard) 0xa1, 0x01, // COLLECTION (Application) 0x05, 0x07, // USAGE_PAGE (Keyboard) 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x75, 0x01, // REPORT_SIZE (1) 0x95, 0x08, // REPORT_COUNT (8) 0x81, 0x02, // INPUT (Data,Var,Abs) 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x08, // REPORT_SIZE (8) 0x81, 0x03, // INPUT (Cnst,Var,Abs) 0x95, 0x05, // REPORT_COUNT (5) 0x75, 0x01, // REPORT_SIZE (1) 0x05, 0x08, // USAGE_PAGE (LEDs) 0x19, 0x01, // USAGE_MINIMUM (Num Lock) 0x29, 0x05, // USAGE_MAXIMUM (Kana) 0x91, 0x02, // OUTPUT (Data,Var,Abs) 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x03, // REPORT_SIZE (3) 0x91, 0x03, // OUTPUT (Cnst,Var,Abs) 0x95, 0x06, // REPORT_COUNT (6) 0x75, 0x08, // REPORT_SIZE (8) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x65, // LOGICAL_MAXIMUM (101) 0x05, 0x07, // USAGE_PAGE (Keyboard) 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) 0x81, 0x00, // INPUT (Data,Ary,Abs) 0xc0, // END_COLLECTION // Mouse TLC 0x85, 0x02, // REPORT_ID (2) 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x01, // USAGE (Pointer) 0xa1, 0x00, // COLLECTION (Physical) 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x03, // USAGE_MAXIMUM (Button 3) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x95, 0x03, // REPORT_COUNT (3) 0x75, 0x01, // REPORT_SIZE (1) 0x81, 0x02, // INPUT (Data,Var,Abs) 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x05, // REPORT_SIZE (5) 0x81, 0x03, // INPUT (Cnst,Var,Abs) 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x02, // REPORT_COUNT (2) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xc0, // END_COLLECTION 0xc0 // END_COLLECTION };
These macros are tuned for this change.
usb_config.c #define USBD_HID_INREPORT_NUM 2 #define USBD_HID_OUTREPORT_NUM 1 #define USBD_HID_INREPORT_MAX_SZ 9 #define USBD_HID_OUTREPORT_MAX_SZ 2
Tsuneo
Thanks for your advice,
As soon as i put Report Id inside my descriptor, in a software as USBlyser, the HID report descriptor was not recognized and the device can not start.
Have you an idea about the problem.
Now your problem is probably that Windows host does not have appropriate driver for the device that you created it automatically loads drivers for devices with single in or out descriptor but your descriptor does not apply to no standard HID device so Windows do not have driver for it in that case you have to provide Windows driver for your custom device.
If you would run the example once on your PC, the USB configuration of the example should be recorded on Windows registry. When you modify descriptors, Windows could be confused by seeing different USB configuration on your device. Windows try to assign previous device driver and fail.
Windows manages devices using their Vendor/Product ID (VID/PID). When you change device configuration, a) Assign another VID/PID to your device OR b) Uninstall the device instance from Windows.
This utility gives easy way to find / uninstall target device instace of the VID/PID USBDeview www.nirsoft.net/.../usb_devices_view.html