2014-09-15 06:18 AM
Hi,
Im using the STM32F4 with the STM USB Stack and the demo VB project from
. Communication is working fine.Now I want to change the PID on the STM during runtime. Calling the HidD_GetHidGuid() from the PC,
still shows the old device path name, unless if I detach and attach the USB connector physically.Is there any possibility:
- to force the PC to reimport the HID Device Descriptor?
- generate 'something' in the STM32F4 USB Stack to force the PC to reconnect the USB device?Optionally I could disconnect from the VBUS, changing the special function of the PortA9 to input
pin and reassign it to VBUS, but I'm concerned that this could have a side effect, if the time betweendisconnect and connect is too short, or either too long.I would appreciate a software based solution, without modifying the I/O of the MCU.
cheers
#stm32f4-usb-hid-pid2014-09-15 07:08 AM
Hi
I do not know why you want to change the Product ID, changing it may cause miss match in device type (HID) and therefore driver However : ''generate 'something' in the STM32F4 USB Stack to force the PC to reconnect the USB device?'' // force a USB soft disconnect // USB_OTG_dev.regs.DREGS->DCTL |= 0x02; Setting and clearing the 0x02 bit will make the PC think the device has been unplugged/plugged in the USB2014-09-16 04:26 AM
Hi Mr Cat ;).
many thanks for the quick reply. USB_OTG_dev.regs.DREGS->DCTL |= 0x02;Delay(100ms);USB_OTG_dev.regs.DREGS->DCTL &= ~0x02;with some time delay inbetween works perfect.I have one Hardware where up to 2 can be connected at the same time to the PC.To distinguish both I need 2 USB handles, which I retrieve from the PID.The PID itself can be changed via USB and will be stored in a flash page of the processor. The processor itself needs to continue working, therefore a MCU reset is not possible, and to request the user to re-plugin the USB cable is inconvenient. Therefore I need this kind of device re-connect on the PC side.If you know an other option I'm open for that, as I have not jet so much experience with USB (just getting started vew months ago).cheers2014-09-16 04:52 AM
Hi
''I have one Hardware where up to 2 can be connected at the same time to the PC. To distinguish both I need 2 USB handles, which I retrieve from the PID.'' That is a PC Host issue and should not affect the STM32 target. For example, if you have 2/3/4/5 identical USB mice (mouse) and you plug them all in. Do you expect every mouse to change their PID just because there is another one? How does each mouse know another one has been plugged in? The PID of the STM32 target should not change. It is up to the PC (Host) to enumerate each identical USB device with a different 'handle' This handle is different to the PID. Again, think of the mouse example I gave. I am not a PC programmer, so I lack the expertise. The PID is used to identify the USB device type and help load the driver. If you change the PID, the PC Host will try to load a new driver2014-09-16 09:46 AM
> I have one Hardware where up to 2 can be connected at the same time to the PC.
> To distinguish both I need 2 USB handles, which I retrieve from the PID. Usually, the same model of devices share the same PID. Unique serial number on each device identifies the target device. The serial number on the libraries, \STM32_USB-Host-Device_Lib_V2.1.0\Project\USB_Device_Examples\HID\src\usbd_desc.c #define USBD_SERIALNUMBER_HS_STRING ''00000000011B'' #define USBD_SERIALNUMBER_FS_STRING ''00000000011C'' STM32Cube_FW_F4_V1.3.0 Unique serial number is generated for each chip, using Device IDs on the chip Refer to void Get_SerialNum(void) (usbd_desc.c) Windows application retrieves serial number using HidD_GetSerialNumberString() To pick up all of attached HID devices of the same VID/PID,
Jan Axelson’s generic_hid_vb_50
FrmMain.vb
Private Function FindTheHid() As Boolean
...
Do
...
If (MyHid.DeviceAttributes.VendorID = myVendorID) And _
(MyHid.DeviceAttributes.ProductID = myProductID) Then
...
myDeviceDetected = True ' <- here, don’t set this value to True
' And then, this loop picks up all of
' HID device of specified VID/PID
...
Loop Until (myDeviceDetected Or (memberIndex = devicePathName.Length))
Tsuneo
2018-06-10 08:42 AM
Hii.
I want to change USB VID and PID during runtime but inside STM32L062K8 firmware.
Can you help me?
Thanks