This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to distinguish USB is connected to PC or power adaptor?

Hello All,

I'm using the keil USB middleware on LPC4357. The usb is configured as MSC SD card device.

I want to implement that

1. SD card can be access by file system functions when not connected to anything 2. SD card can be access by file system functions when connected to a power adaptor 3. SD card should be a MSC device in PC when connected to PC.

I already implement the first and third points by checking the presence of vbus.

If vbus is present, call USBD_Initialize(), USBD_Connect() to initialize the USB, and if vbus is not present, call USBD_Uninitialize(), USBD_Disconnect() to uninitialize the USB, and re initialize file system.

About this implementation, I also have a question. At first, I use the USBD_MSC0_SetMediaOwnerFS() and USBD_MSC0_SetMediaOwnerUSB() functions to do this, but I don't know why it indroduce a big delay. I dropped this way.

So, the last question is how to implement point 2

These two function USBD_Initialize(), USBD_Connect() return zero(OK) no matter what the USB is connected to the PC or adaptor