EmbeddedRelated.com
Forums

USB Driver for lpc2378

Started by pete...@esysr.com October 7, 2008
I am just getting started on using the USB interface on the lpc2378.
Can anyone provide some example source code for a USB client COM
implementation. Ultimately I will be implementing a HID and possibly
Mass Storage client with the lpc2378.

Ideally the source code would be ported to CrossWorks Tasking Library but
I am willing to port to run with CTL.

Pete

An Engineer's Guide to the LPC2100 Series

lpcusb should do the trick even comes with all the examples
you are mentioning.

http://sourceforge.net/projects/lpcusb

--Ray

p...@esysr.com wrote:
>
> I am just getting started on using the USB interface on the lpc2378.
> Can anyone provide some example source code for a USB client COM
> implementation. Ultimately I will be implementing a HID and possibly
> Mass Storage client with the lpc2378.
>
> Ideally the source code would be ported to CrossWorks Tasking Library but
> I am willing to port to run with CTL.
>
> Pete
>
>

Thanks! That is just what I am looking for :)

> lpcusb should do the trick even comes with all the examples
> you are mentioning.

I'm working on a project with an LPC2468. I tried the LPCUSB code.
It sends through the setup packets correctly and the Win32 driver
pickups the configuration. But then the communication never ends. I
have a USB bus analyzer on it and there is a constant never ending
stream of INs/OUTs/SOF etc that keeps going forever. More
interesting, I can see where the host sets the USB address for the
device, but then after that many INs/OUTs have different adr values
being sent back and forth.

I'm starting to get the feeling that while the USB sections of the
2148 and 2468 appear mostly the same, there must be some small
differences. Has anyone ever got the LPCUSB code to actually work on
a LPC23XX/LPC24XX part?

Still looking for USB device code examples that actually work on
these LPC23/24. I'm testing some of the Keil example USB code right
now, but so far no success either. Different problems here, trying
to see if I can resolve these issues.

Thanks, Chris.

I ported this to the LPC2366 - works fine. I have a few kludges in it, but
the differences are all in the init code.

Let me know if this helps

#ifdef __IOLPC2148_H

// configure P0.23 for Vbus sense

PINSEL1 = ( PINSEL1 & ~( 3 << 14 ) ) | ( 1 << 14 ); // P0.23

IODIR0 &= ~( 1 << 23 );

// configure P0.31 for CONNECT

PINSEL1 = ( PINSEL1 & ~( 3 << 30 ) ) | ( 2 << 30 ); // P0.31

// enable PUSB

PCONP |= ( 1 << 31 );

// initialise PLL

PLL1CON = 1; // enable PLL

PLL1CFG = ( 1 << 5 ) | 3; // P = 2, M = 4

PLL1FEED = 0xAA;

PLL1FEED = 0x55;

while( ( PLL1STAT &(1 << 10)) == 0 );

PLL1CON = 3; // enable and connect

PLL1FEED = 0xAA;

PLL1FEED = 0x55;

#endif

#ifdef __IOLPC2368_H

PINSEL1_bit.P0_29 = 1; // Set up D+, D-

PINSEL1_bit.P0_30 = 1;

PINSEL3_bit.P1_18 = 1; // UP Connect

// PORTSET (2, 1 << 9); // And clear connect request

PORTCLR(2, 1 << 9); // And clear connect request

PORTDIRSET(2, 1 << 9); // Set 2.9 as output

PORTCLR(2, 1 << 9); // And set connect request

PORTDIRCLR(VBus); // VBus is GPIO In

// Turn on power to peripheral

PCONP |= ( unsigned int )( 1 << 31 );

USBCLKCTRL_bit.DEV_CLK_EN = 1;

USBCLKCTRL_bit.AHB_CLK_EN = 1;

#endif

From: l... [mailto:l...] On Behalf Of
sig5534
Sent: Sunday, October 12, 2008 10:54 AM
To: l...
Subject: [lpc2000] Re: USB Driver for lpc2378

> lpcusb should do the trick even comes with all the examples
> you are mentioning.

I'm working on a project with an LPC2468. I tried the LPCUSB code.
It sends through the setup packets correctly and the Win32 driver
pickups the configuration. But then the communication never ends. I
have a USB bus analyzer on it and there is a constant never ending
stream of INs/OUTs/SOF etc that keeps going forever. More
interesting, I can see where the host sets the USB address for the
device, but then after that many INs/OUTs have different adr values
being sent back and forth.

I'm starting to get the feeling that while the USB sections of the
2148 and 2468 appear mostly the same, there must be some small
differences. Has anyone ever got the LPCUSB code to actually work on
a LPC23XX/LPC24XX part?

Still looking for USB device code examples that actually work on
these LPC23/24. I'm testing some of the Keil example USB code right
now, but so far no success either. Different problems here, trying
to see if I can resolve these issues.

Thanks, Chris.


It's not a matter of init code, or pin selects. The LPCUSB code does the startup enumeration just fine on my LPC2468, and it turns on the configured LED, but then the problems start. Perhaps there is something different in how the code is compiling for me, I am using GCC. Some of these various USB code sets are written for different compilers and I often run into attributes and sometimes data structures specific to a compiler that do not port directly. They have to be re-written, and there is always the potential for some small bug or change to cause problems. Still working on it ....

Chris.

On Mon, Oct 13, 2008 at 1:53 AM, sig5534 wrote:
>
> Still looking for USB device code examples that actually work on
> these LPC23/24. I'm testing some of the Keil example USB code right
> now, but so far no success either. Different problems here, trying
> to see if I can resolve these issues.

I have access to two LPC2468 kits. One is IAR LPC-2468 Kick Starter
board and it seems to work quite well with the provided 32K code size
limited edition of IAR Embedded Workbench (V5.11). It comes with
quite some USB examples (USB mouse, USB audio, USB mass
storage device and USB virtual com port).

The other is Hitex LPC-Stick which works fine (the provided HiTop 5.20
IDE works under XP only, not Vista). It is using Hitex's GCC compiler.
It comes with some USB examples as well (HID device and USB mass
storage host).

I am now also trying out jcwren's example on the Olimex LPC-P2148
demo board. I am interested in the port of lpcusb to LPC-2468 as well.

Regards,
Xiaofan