View previous topic :: View next topic |
Author |
Message |
robo_z
Joined: 11 Dec 2014 Posts: 5
|
[Help] USB HID With 2 Interfaces - Dual Game Pad |
Posted: Sun Feb 23, 2020 9:49 am |
|
|
Hi Everyone
I'm trying to implement a dual game pad with a PIC18F4550 with 2 interfaces, not only one with report IDs. I need create a Game pad with 2 interfaces, same as ex_usb_kbmouse.c & usb_desc_kbmouse.h files of examples.
This is my descriptor (Only recognize one game pad):
Code: |
#define USB_CONFIG_PID 0x0020
#define USB_CONFIG_VID 0x0461
#define USB_CONFIG_BUS_POWER 500 //100mA
#define USB_CONFIG_VERSION 0x0100 //01.00
#define USB_CONFIG_HID_TX_SIZE 64 //Bytes
#define USB_CONFIG_HID_RX_SIZE 0 //Bytes
#define USB_CONFIG_HID_TX_POLL 10 //for full speed devices, valid range is 1-255 & for slow speed devices, valid range is 10-255
#define USB_CONFIG_HID_RX_POLL 1
#define USB_HID_DEVICE TRUE
#define USB_HID_ENDPOINT 2
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP1 for IN bulk/interrupt transfers
#define USB_EP1_TX_SIZE USB_CONFIG_HID_TX_SIZE
#define USB_EP1_RX_SIZE USB_CONFIG_HID_RX_SIZE
//#define USB_HID_ENDPOINT 1
#define USB_EP2_TX_ENABLE USB_ENABLE_INTERRUPT //turn on EP2 for IN bulk/interrupt transfers
#define USB_EP2_TX_SIZE USB_CONFIG_HID_TX_SIZE
#define USB_EP2_RX_SIZE USB_CONFIG_HID_RX_SIZE
...
|
Thanks for you help.
Last edited by robo_z on Wed Mar 11, 2020 8:37 am; edited 7 times in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Sun Feb 23, 2020 12:55 pm |
|
|
OK.
First
#define USB_HID_ENDPOINT 1
is overridden by the second line:
#define USB_HID_ENDPOINT 2
A #define is processed sequentially before compilation.
You can't have two defines like this.
You are not posting the rest of the descriptors. The class descriptors. The
config descriptor, the endpoint descriptors etc..
Nor the #define USB_MAX_NUM_INTERFACES setting.
Also you are looking at the wrong example. Look at ex_usb_multihid, and
ex_usb_multhid2. You will see that the two devices are one descriptor.
Only one configuration, and one size. Two report ID's in the single
descriptor. |
|
|
robo_z
Joined: 11 Dec 2014 Posts: 5
|
|
Posted: Mon Feb 24, 2020 3:15 am |
|
|
Ttelmah wrote: | OK.
First
#define USB_HID_ENDPOINT 1
is overridden by the second line:
#define USB_HID_ENDPOINT 2
...
descriptor. |
Thank you very much for your help
I have corrected and added the rest of the code, so you can have a better idea.
I will review those examples that you recommend. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19540
|
|
Posted: Mon Feb 24, 2020 7:13 am |
|
|
As I said, look at the example of how to do two HID devices. The format
is very different from what you are posting.... |
|
|
|