Enabling both host ports?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Enabling both host ports?

1,260 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdupre on Wed Nov 27 17:34:39 MST 2013
I've got the LPCOpen Mass Storage Demo working ion the EA LPC1788 dev board.
The Demo code appears to be hard-coded for using port 1 (i.e. the pins on p0.20 and p0.30)

I'd like to switch it to use port 2 (i.e. on p0.31 and the dedicated USB_D-2 pin).
In the end, I'd like both ports working at the same time, but I think I should start by making port 2 work.

I've changed the hardware initialization to configure the USB2 pins and set stctrl, but it appears there is a lot more to it than that.

Can someone give me a hint?  How do you differentiate io & interrupts on the two physical IO ports?

Labels (1)
0 Kudos
Reply
4 Replies

1,082 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdupre on Fri Dec 06 13:43:00 MST 2013
I can't recommend anything , as I am slogging through it now.  I can say that I was able to get port2 to operate as host by adding a few things like this:

#if (ENABLE_USB2 == 0 )
HCD_STATUS HcdGetDeviceSpeed(uint8_t HostID, HCD_USB_SPEED *DeviceSpeed)
{
if ( USB_REG(HostID)->RhPortStatus1 & HC_RH_PORT_STATUS_CurrentConnectStatus) {/* If device is connected */
*DeviceSpeed =
( USB_REG(HostID)->RhPortStatus1 & HC_RH_PORT_STATUS_LowSpeedDeviceAttached) ? LOW_SPEED : FULL_SPEED;
return HCD_STATUS_OK;
}
else {
return HCD_STATUS_DEVICE_DISCONNECTED;
}
}
#else
HCD_STATUS HcdGetDeviceSpeed(uint8_t HostID, HCD_USB_SPEED *DeviceSpeed)
{
if ( USB_REG(HostID)->RhPortStatus2 & HC_RH_PORT_STATUS_CurrentConnectStatus) {/* If device is connected */
*DeviceSpeed =
( USB_REG(HostID)->RhPortStatus2 & HC_RH_PORT_STATUS_LowSpeedDeviceAttached) ? LOW_SPEED : FULL_SPEED;
return HCD_STATUS_OK;
}
else {
return HCD_STATUS_DEVICE_DISCONNECTED;
}
}
#endif


Just search the sample code for all references to USB_REG(HostID)->RhPortStatus1

I have not attempted to get both ports working simultaneously, as this solves my imediate problem.
0 Kudos
Reply

1,082 Views
skrcek
Contributor I

I would like use USB port 2 as host on LPC1788. Unfortunaly i found there are exist examples only for port1.

I made following changes in original code:

   - pin muxing to port2 in HAL_USBInit.

   - change USB function to USB_REG(HostID)->StCtrl = 0x00 in HciInitDriver

   - replacing USB_REG(HostID)->RhPortStatus1 to USB_REG(HostID)->RhPortStatus2 in all project

but code still not working.

Could  you give me some advice how to properly change lpcusblib library?

Thank you in advance.

0 Kudos
Reply

1,082 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by sipel_tp on Fri Dec 06 08:38:38 MST 2013
Thank you for your response.

I need to use a virtual serial device on usb PORT2 and usb host on PORT1 and the library does not support both because the microcontroller has only one core for both PORTS like you said.

Do I need to rewrite a new library on my own or it could be done doing only some minor changes?
I couldn't make the library work without defining USB_HOST_ONLY or USB_DEVICE_ONLY and they are mutually exclusive

What would you recommend?

Thank you very much again.
0 Kudos
Reply

1,082 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jdupre on Tue Dec 03 14:25:04 MST 2013
To answer my own question:

You'll need to take a look at the OHCI specification (http://www.scaramanga.co.uk/stuff/qemu-usb/hcir1_0a.pdf)
Note how multiple HcRhPortStatus registers appear at the end of the OHCI register space.

The bigger hurdle is that the LPCOpen USB Host "library" does not take into account the secondary USB port on the LPC17xx.  Not at all.  Take a look for the references to USB_REG(HostID)->RhPortStatus1 to see how it works for port 1.  You'll need to add or modify a bunch of functions to reference USB_REG(HostID)->RhPortStatus2.

It appears that  the LPC17xx is the only chip with USB host capabilities that has more than one physical port per USB core.  Other chips like the 18xx and 43xx have only one port per core, so switching ports is just an issue of changing core number when referencing the register addresses.  ("Host ID" in the example above.)
0 Kudos
Reply