How do I detect if a USB host is connected to my device?
Answer
In a self-powered system, it is generally desirable to be able to detect the presence of VBUS. VBUS indicates when a host device has been connected to or disconnected from the USB peripheral.
For EFM8 devices, the VBUS signal may be enabled on a port pin and configured to generate system interrupts if the state changes. The VBUS control bits are found in the USB0CF register. VBUSEN enables the VBUS pin as an input to the USB module, while the VBUSIE bit enables the associated interrupt. VBUSI will be set any time the state of VBUS changes, and firmware may then read the state of the VBUS pin and act accordingly.
For C8051 devices such as the C8051F320 and C8051F340, the VBSTAT bit in register REG0CN indicates the current logic level of the VBUS signal. It is possible to enable a VBUS interrupt that triggers when VBUS is connected.
VBUS Detect
Chinese version
http://community.silabs.com/t5/Silicon-Labs%E4%B8%AD%E6%96%87%E6%8A%80%E6%9C%AF%E8%AE%BA%E5%9D%9B/VBUS%E6%A3%80%E6%B5%8B/ta-p/178232