Content originally posted in LPCWare by Daniel Widyanto on Wed Nov 07 23:27:22 MST 2012
If you are thinking to implement similar USB OTG scheme, yes it's possible to switch the USB port role (host -> device, device -> host) on the fly.
In fact, this is the default implementation for USB OTG in LPC17xx. When USB cable ID pin is low, the OTG transceiver will interrupt the MCU, then the MCU is configuring itself for Host function (Refer to OTGStCtrl, PORT_FUNC bit, and restart the OHCI registers). Otherwise, the MCU will configure the port as USB device. See Fig 40 and Fig 41 UM10360 LPC17xx User Manual for the clarification.
If you don't use the OTG transceiver, then you need to figure out how to connect / disconnect the D+ pull up.