2019-03-07 10:56 PM
Hi.
If power is applied while USB is plugged in, it is possible to read and write data with USB MSC and Fatfs.
I am looking for a way for USB to be detected when I plug in USB while STM32 is running.
Even if I look for a way, I found only STM32 device.
If you know how, please let me know.
Thank you.
2019-03-08 07:15 AM
I don't quite understand your question, but if you are talking about detecting when devices are attached to OTG module in HOST mode, this is indicated by PCDET bit in OTG_HPRT - see Host detection of a peripheral connection in the OTG chapter in RM.
Whether the attached device is MSC, then of course results from subsequent enumeration process.
JW
2019-03-10 07:41 PM
I looked up what you said. You have seen that the PCDET bit in OTG_FS_HPRT tells you the control and status of the host port. However, I need help with usage. I do not know how to use the OTG_FS_HPRT register.
When I try to use a register in main.c I get an error that it is not defined.
How should I use the OTG-related registers in the RM in STM32?
2019-03-10 07:49 PM
Perhaps review a working example?
STM32Cube_FW_F7_V1.14.0\Projects\STM32756G_EVAL\Applications\USB_Host\MSC_Standalone\readme.txt
2019-03-11 01:04 PM
If you have already some USB stack in place, then that stack takes care of the registers etc. Your application then should rely on the states and/or callbacks provided by that stack - see the documentation accompanying the stack.
JW
2019-03-12 07:09 PM
I understand that USBH_UserProcess will call back the usb state and change the Appli_state.
In the STM32Cube_FW_F4_V1.24.0 \Projects \STM32F4-Discovery\Applications\FatFs\FatFs_USBDisk example I have found that USBH_UserProcess is called every time a USB device is plugged in or unplugged.
However, in my code generated by CubeMx, USBH_UserProcess is only called at the start of the program.
How do I behave like an example?
2019-03-13 05:46 AM
Find, what's the difference between the example and the generated code. Find, where is the callback called in the example and find out why isn't it called at the same place in the generated code.
I don't use Cube nor CubeMX.
JW