Hi
Our system has a USB device port and SD card slot, the SD card is optional, so there are 2 cases:
1. Connect the USB to PC, it needs to be a HID device. 2. Insert SD card, then connect USB to PC, it needs to be a HID+MSC composite device.
I am using RL_USB, this means I need 2 usb configuration: one for single HID device, the other for composite HID+MSC device, firmware needs to detect if sd card is inserted to decide which configuration to enable. However, it seems I can only config the usb class in compile time, and not able to change it in runtime??
Am I right? What's the general solution for this requirement? I am using RL_USB library.
Thanks.
You may always expose HID + MSC configuration to host. The MSC interface returns NOT READY - MEDIUM NOT PRESENT sense data while no SD card is inserted. I believe Keil SD reader example implements this response.
Tsuneo
In this way (use CheckMedia), if sd card not inserted, windows still display an disk icon "Removable Disk", if you double click the disk, you get a message: please insert a disk into drive.
What I would like is that windows DO NOT display that disk icon until sd card is inserted! is this possible?
PS: My home pc has a built-in sd slot, windows always display "Removable Disk" icon, no matter sd card is present or not.
If I use a USB-SD converter, connect the usb to pc, windows always display "Removable Disk" icon, no matter sd card is present or not.
Don't know if this is the general solution.
If you get your device to disconnect and reconnect, you cn have it enumerate as a disk only when it has a SD card inserted.
> Don't know if this is the general solution.
It's the Windows way.
As of configuration change using soft-detach, Windows WRONGLY assume single configuration for each USB device, though USB spec allows multi-configurations. To switch configuration on Windows, soft-detach / attach is used as the last resort. In this case, you have to assign different VID/PID (at least, PID) to the new configuration, because Windows ASSume single configuration for each VID/PID.
Yes, I want this solution: use 2 configurations, and use soft-reset to select different configuration, but problem is: does RL_USB library support this? I can't see any usbd_xxx functions to change configuration in runtime, seems I can only make one configuration in the USB_Config.c source file, then compile to one single static configuration!
I guess I must change RL_USB source code instead of using the RL_USB.Lib of CM3? But the source code is not provided in MDK4.20, I must copy these source code from early version of RL_ARM? Don't know if there is license problem.
> does RL_USB library support this?
No. You have to rewrite the library source code.
On the config switch scheme, HID connection is disturbed, every time SD card is inserted/removed. I don't think it's a decent implementation.