Content originally posted in LPCWare by Daniel Widyanto on Sun Oct 28 20:36:00 MST 2012
Hi Linas,
The SoftConnect pin is attached to the USB device peripheral.
When you insert this code:
<code>
void usb_connect(void) {
LPC_USB->USBDevIntClr = 0x10; /* Clear CCEMPTY */
LPC_USB->USBCmdCode = 0x00FE0500; /* CMD_CODE=0xFE, CMD_PHASE=0x05(Command) */
while (!(LPC_USB->USBDevIntSt & 0x10)); /* Wait for CCEMPTY */
LPC_USB->USBDevIntClr = 0x10; /* Clear CCEMPTY */
LPC_USB->USBCmdCode = 0x00010100; /* CMD_WDATA=0x01(CON=1), CMD_PHASE=0x01(Write) */
while (!(LPC_USB->USBDevIntSt & 0x10)); /* Wait for CCEMPTY */
}
</code>
the SoftConnect pin will turn LOW, activating the pull-up to D+, and start the LPC17xx USB device enumeration (if USB host is attached).
Alternatively, you can use this code
<code>
void usb_connect(void) {
LPC_GPIOx->FIOPIN &= ~(1 << your_softconnect_pin);
}
</code>
to turn LOW any GPIO that you use to activate the pull up to D+.
Or the least implementation is to pull up the D+ line permanently.
But, I'd recommend to have at least SoftConnect, since the USB Host may have very fast response (eg. start enumerating the USB device after 2ms attachment), and you are not sure whether your device is ready to receive that within 2ms (assuming you need to init other peripherals on the board as well).
Also, Softconnect is better than GPIO, since most of USB stack for LPC17xx is using SoftConnect pin instead of GPIO.