2023-06-21 12:39 PM
Hi, I have a generic PlayStation 2 USB gamepad, which has a resonator instead of a crystal, yes it is probably not as faithful to the frequency, but it works on the computer, and it works on the Arduino UNO and the Arduino Mega2560, that is, it works with the MAX3421E.
Arduino code here.
Added the definition to generate more data:
// Patch printf so we can use it.
#define LOAD_UHS_PRINTF_HELPER
#define DEBUG_PRINTF_EXTRA_HUGE 1 // <------------------ From 0 to 1
#define DEBUG_PRINTF_EXTRA_HUGE_USB_HID 1
#define DEBUG_PRINTF_EXTRA_HUGE_UHS_HOST 1 // <------------------ Added
Output data via Arduino Mega2560 UART:
16:01:49.283 ->
16:01:49.283 -> HID RAW demo Begin.
16:01:50.345 ->
16:01:50.345 ->
16:01:50.345 ->
16:01:50.345 -> Configuring: parent = 0, port = 1, speed = 0
16:01:50.544 ->
16:01:50.544 ->
16:01:50.544 -> Configuring PktSize 0x40, rcode: 0x00, retries 0,
16:01:50.544 -> ep entry for interface 0 ep 0 max packet size = 64
16:01:50.544 -> ctrlReq2: left: 64, read:64, nbytes 64
16:01:50.544 -> RESULT: 0x00 0x00 0x08 0x0040000001000680
16:01:50.577 -> ctrlReq3: acceptBuffer sz 8 nbytes 64 left 56
16:01:50.577 ->
ep entry for interface 0 ep 0 max packet size = 64
16:01:50.677 -> 0 retries.
16:01:50.677 -> DevDescr 2nd poll, bMaxPacketSize0:8
16:01:50.677 -> ep entry for interface 12 ep 0 max packet size = 8
16:01:50.677 -> ctrlReq2: left: 18, read:18, nbytes 18
16:01:50.677 -> RESULT: 0x00 0x01 0x12 0x0012000001000680
16:01:50.743 -> ep entry for interface 0 ep 0 max packet size = 64
16:01:51.042 -> 0 retries.
16:01:51.042 -> configs: 1
16:01:51.042 -> ep entry for interface 0 ep 0 max packet size = 64
16:01:51.042 -> ctrlReq2: left: 9, read:9, nbytes 9
16:01:51.042 -> RESULT: 0x00 0x01 0x08 0x0009000002000680
16:01:51.042 -> ctrlReq2: left: 1, read:9, nbytes 9
16:01:51.042 -> RESULT: 0x00 0x01 0x01 0x0009000002000680
16:01:51.042 -> CONFIGURATION: 0, bNumInterfaces 1, wTotalLength 41
16:01:51.075 -> ep entry for interface 0 ep 0 max packet size = 64
16:01:51.075 -> bLength: 9 bDescriptorType: 02
16:01:51.075 -> eating 8
16:01:51.075 -> bLength: 9 bDescriptorType: 04
16:01:51.075 -> INTERFACE DESCRIPTOR FOUND
16:01:51.075 -> Getting 2 endpoints
16:01:51.075 -> bLength: 9 bDescriptorType: 21
16:01:51.075 -> eating 7
16:01:51.075 -> bLength: 7 bDescriptorType: 05
16:01:51.075 -> ENDPOINT DESCRIPTOR: 0
16:01:51.075 -> ENDPOINT DESCRIPTOR OK
16:01:51.075 -> eating 0
16:01:51.075 -> bLength: 7 bDescriptorType: 05
16:01:51.075 -> ENDPOINT DESCRIPTOR: 1
16:01:51.108 -> ENDPOINT DESCRIPTOR OK
16:01:51.108 -> eating 0
16:01:51.108 -> eating 1
16:01:51.108 -> ENDPOINT DESCRIPTORS FILLED
16:01:51.108 -> TestInterface VID:0079 PID:0006 Class:00 Subclass:00 Protocol 00
16:01:51.108 -> Interface data: Class:03 Subclass:00 Protocol 00, number of endpoints 2
16:01:51.108 -> Parent: 00, bAddress: 01
16:01:51.108 -> Driver 1 supports this interface
16:01:51.108 -> Driver 1 can be used for this interface
16:01:51.108 -> USB_INTERFACE END OF STREAM
16:01:51.108 -> ep entry for interface 0 ep 0 max packet size = 8
16:01:51.142 -> ctrlReq2: left: 9, read:9, nbytes 9
16:01:51.142 -> RESULT: 0x00 0x01 0x09 0x0009000002000680
16:01:51.142 -> CONFIGURATION: 1, bNumInterfaces 1, wTotalLength 41
16:01:51.142 -> Best configuration is 1, enumerating interfaces.
16:01:51.142 -> ep entry for interface 0 ep 0 max packet size = 8
16:01:51.142 -> bLength: 9 bDescriptorType: 02
16:01:51.142 -> eating 8
16:01:51.142 -> bLength: 9 bDescriptorType: 04
16:01:51.142 -> INTERFACE DESCRIPTOR FOUND
16:01:51.142 -> Getting 2 endpoints
16:01:51.142 -> bLength: 9 bDescriptorType: 21
16:01:51.175 -> eating 7
16:01:51.175 -> bLength: 7 bDescriptorType: 05
16:01:51.175 -> ENDPOINT DESCRIPTOR: 0
16:01:51.175 -> ENDPOINT DESCRIPTOR OK
16:01:51.175 -> eating 0
16:01:51.175 -> bLength: 7 bDescriptorType: 05
16:01:51.175 -> ENDPOINT DESCRIPTOR: 1
16:01:51.175 -> ENDPOINT DESCRIPTOR OK
16:01:51.175 -> eating 0
16:01:51.175 -> eating 1
16:01:51.175 -> ENDPOINT DESCRIPTORS FILLED
16:01:51.175 -> AttemptConfig: parent = 0, port = 1
16:01:51.175 -> Driver 1 supports this interface
16:01:51.175 -> Interface Configured
16:01:51.175 -> ep entry for interface 0 ep 0 max packet size = 8
16:01:51.208 -> Driver 0 @ 00 Skipped
16:01:51.208 -> Driver 1 @ 01 Initialize
16:01:51.208 -> HID START, A 01 I 01 O 01
16:01:51.208 -> HID driver type 0 started, Subclass 00, Protocol 00
16:01:51.208 -> Total endpoints = (3)1
16:01:51.208 -> Driver 2 @ 00 Skipped
16:01:51.208 -> Driver 3 no driver at this index.
16:01:51.208 -> Driver 4 no driver at this index.
16:01:51.208 -> Driver 5 no driver at this index.
16:01:51.208 -> Driver 6 no driver at this index.
16:01:51.208 -> Driver 7 no driver at this index.
16:01:51.208 -> Driver 8 no driver at this index.
16:01:51.241 -> Driver 9 no driver at this index.
16:01:51.241 -> Driver 10 no driver at this index.
16:01:51.241 -> Driver 11 no driver at this index.
16:01:51.241 -> Driver 12 no driver at this index.
16:01:51.241 -> Driver 13 no driver at this index.
16:01:51.241 -> Driver 14 no driver at this index.
16:01:51.241 -> Driver 15 no driver at this index.
16:01:51.241 -> ep entry for interface 0 ep 1 max packet size = 8
16:01:51.241 -> RAW input 8 bytes interface 0, Subclass 00, Protocol 00 Data: 00 00 7b 7f 7f 9f 00 c0
16:01:51.274 -> ep entry for interface 0 ep 1 max packet size = 8
16:01:51.274 -> RAW input 8 bytes interface 0, Subclass 00, Protocol 00 Data: 7f 7f 7a 7f 7f 0f 00 c0
16:01:51.274 -> ep entry for interface 0 ep 1 max packet size = 8
16:01:51.274 -> RAW input 8 bytes interface 0, Subclass 00, Protocol 00 Data: 7f 7f 7a 7f 7f 0f 00 c0
16:01:51.308 -> ep entry for interface 0 ep 1 max packet size = 8
16:01:51.308 -> RAW input 8 bytes interface 0, Subclass 00, Protocol 00 Data: 7f 7f 7b 7f 7f 0f 00 c0
16:01:51.308 -> ep entry for interface 0 ep 1 max packet size = 8
16:01:51.308 -> RAW input 8 bytes interface 0, Subclass 00, Protocol 00 Data: 7f 7f 7a 7f 7f 0f 00 c0
16:01:51.341 -> ep entry for interface 0 ep 1 max packet size = 8
16:01:51.341 -> RAW input 8 bytes interface 0, Subclass 00, Protocol 00 Data: 7f 7f 7b 7f 7f 0f 00 c0
STM32CubeIDE project here
Output data via STM32F407VGT6 UART (Attempt 1):
App start
MCU-ID 10076413
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Recovering USB module
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
Manufacturer : DragonRise Inc.
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
Manufacturer :
Product : Generic USB Joystick
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
USBH_HID_InterfaceInit
Interface 0, cannot find the HID_BOOT_CODE, skip
Interface 0, try to find the HID_CUSTOM_BOOT_CODE
Switching to Interface (#0)
Class : 3h
SubClass : 0h
Protocol : 0h
Custom device found!
max_ep: 2
Interface 0, endpoint #0: address 0x81, attributes 0x03
Interface 0, endpoint #1: address 0x01, attributes 0x03
Switching to Interface (#0)
HID class started.
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
USBH_HID_InterfaceInit
Interface 0, cannot find the HID_BOOT_CODE, skip
Interface 0, try to find the HID_CUSTOM_BOOT_CODE
Switching to Interface (#0)
Class : 3h
SubClass : 0h
Protocol : 0h
Custom device found!
max_ep: 2
Interface 0, endpoint #0: address 0x81, attributes 0x03
Interface 0, endpoint #1: address 0x01, attributes 0x03
Switching to Interface (#0)
HID class started.
Dump HID Report Descriptor start
wItemLength 101
0x81 0x02 0xC0 0xA1 0x02 0x75 0x08 0x95 0x07 0x46 0xFF 0x00 0x26 0xFF 0x00 0x09 0x02 0x91 0x02 0xC0 0xC0 0xFF 0x75 0x01 0x09 0x31 0x09 0x32 0x09 0x32 0x09 0x35 0x81 0x02 0x75 0x04 0x95 0x01 0x25 0x07 0x95 0x08 0x25 0x01 0x45 0x01 0x09 0x01 0x81 0x02 0xC0 0xA1 0x02 0x75 0x08 0x95 0x07 0x46 0xFF 0x00 0x26 0xFF 0x00 0x09 0x02 0x91 0x02 0xC0 0xC0 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Dump HID Report Descriptor end
Output data via STM32F407VGT6 UART (Attempt 2):
App start
MCU-ID 10076413
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
ERROR: Control error: Get Device configuration descriptor request failed
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
VID: 0209h
PID: 0029h
Address (#1) assigned.
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
ERROR: Control error: Get Device configuration descriptor request failed
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
Recovering USB module
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
Manufacturer : DragonRise Inc.
Product : Generic USB Joystick
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
USBH_HID_InterfaceInit
Interface 0, cannot find the HID_BOOT_CODE, skip
Interface 0, try to find the HID_CUSTOM_BOOT_CODE
Switching to Interface (#0)
Class : 3h
SubClass : 0h
Protocol : 0h
Custom device found!
max_ep: 2
Interface 0, endpoint #0: address 0x81, attributes 0x03
Interface 0, endpoint #1: address 0x01, attributes 0x03
Switching to Interface (#0)
HID class started.
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
USBH_HID_InterfaceInit
Interface 0, cannot find the HID_BOOT_CODE, skip
Interface 0, try to find the HID_CUSTOM_BOOT_CODE
Switching to Interface (#0)
Class : 3h
SubClass : 0h
Protocol : 0h
Custom device found!
max_ep: 2
Interface 0, endpoint #0: address 0x81, attributes 0x03
Interface 0, endpoint #1: address 0x01, attributes 0x03
Switching to Interface (#0)
HID class started.
Dump HID Report Descriptor start
wItemLength 101
0x42 0x65 0x00 0x75 0x01 0x95 0x0C 0x25 0x01 0x45 0x01 0x05 0x09 0x19 0x01 0x29 0x0C 0x81 0x02 0x06 0x00 0xFF 0x75 0x01 0x95 0x08 0x25 0x01 0x45 0x01 0x09 0x01 0x81 0x02 0xC0 0xA1 0x02 0x75 0x08 0x95 0x07 0x46 0xFF 0x00 0x26 0xFF 0x00 0x09 0x02 0x91 0x02 0xC0 0xC0 0x95 0x0C 0x25 0x01 0x45 0x01 0x05 0x09 0x19 0x01 0x29 0x0C 0x81 0x02 0x06 0x00 0xFF 0x75 0x01 0x95 0x08 0x25 0x01 0x45 0x01 0x09 0x01 0x81 0x02 0xC0 0xA1 0x02 0x75 0x08 0x95 0x07 0x46 0xFF 0x00 0x26 0xFF 0x00 0x09 0x02 0x91 0x02 0xC0 0xC0
Dump HID Report Descriptor end
Output data via STM32F407VGT6 UART (Attempt 3):
App start
MCU-ID 10076413
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
Recovering USB module
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
ERROR: Control error: Get Device configuration descriptor request failed
USB Device Connected
USB Device Reset Completed
ERROR: Control error: Device not responding
USB Device Connected
USB Device Reset Completed
VID: 0079h
PID: 0006h
Address (#1) assigned.
Manufacturer : DragonRise Inc.
Product : Generic USB Joystick
Serial Number : N/A
Enumeration done.
This device has only 1 configuration.
Default configuration set.
USBH_HID_InterfaceInit
Interface 0, cannot find the HID_BOOT_CODE, skip
Interface 0, try to find the HID_CUSTOM_BOOT_CODE
Switching to Interface (#0)
Class : 3h
SubClass : 0h
Protocol : 0h
Custom device found!
max_ep: 2
Interface 0, endpoint #0: address 0x81, attributes 0x03
Interface 0, endpoint #1: address 0x01, attributes 0x03
Switching to Interface (#0)
HID class started.
Dump HID Report Descriptor start
wItemLength 101
0x47 0x65 0x6E 0x65 0x72 0x69 0x63 0x20 0x20 0x20 0x55 0x53 0x42 0x20 0x20 0x4A 0x6F 0x79 0x73 0x74 0x69 0x63 0x6B 0x20 0x20 0x00 0x42 0x00 0x20 0x00 0x20 0x00 0x4A 0x00 0x6F 0x00 0x79 0x00 0x73 0x00 0x74 0x00 0x69 0x00 0x63 0x00 0x6B 0x00 0x20 0x00 0x20 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Dump HID Report Descriptor end
As can be seen, the HID Report Descriptor data is not the same:
Is STM32 not checking packets for errors?
"
USB packets contain error checking mechanisms, including a CRC bit to ensure data validity and a toggle bit in the PID packet to ensure correct data sequencing. Sometimes during USB data transmission, even these can become compromised if there an error in this mechanism, causing individual USB transactions to be dropped or causing reduced throughput.
For instance, if the data packet is corrupt and the CRC is invalid, the receiver will send a NAK bit to the transceiver, informing of an erroneous data packet. Transceivers will then resend the data multiple times, but this can in turn cause data packets to drop as the receiver may consider this to be duplicate data.
One example of an incorrect sequence includes incorrect data bit toggling. In a normal data transaction, the data PID will toggle between DATA0 and DATA1 consecutively, however, if there are issues with this, data retransmission can occur where the toggle bit does not update correctly, causing a repetition of the same toggle bit. In these cases, sequential DATA0s or Data1s are not passed to the application because the receiver will ignore packets that are repeating. This will cause data to not be passed to the application.
"
[Source]
2023-06-21 01:23 PM
From APPLICATION NOTE 3782 - Frequently Asked Questions about the MAX3421E:
"
What does "Smart SIE" mean?
SIE stands for Serial Interface Engine. The SIE converts signals received and sent by the USB
transceiver into packets. An ordinary SIE does basic signal housekeeping, such as:
CRC generation and error checking
Bit stuffing
Clock regeneration
Sending and checking handshake packets
A smart SIE delves deeper into the USB protocol, handling higherlevel protocol issues so the
programmer does not need to bother with them.
"
2023-06-23 02:07 AM