Ok.
I really need a USB code running in gcc and a don't have children but
want to someday.
So, I'' post all my findings here, and what i got. Hopefully somebody
will try this, do some more progress and share it back here.
As far as I know the main problem porting keil USBMEM to gcc is the
__pack attribute.
I know keil code is not that complete, but once it is up and running
will be easier to work in robustness.
Since I don't know if there is some problem in posting the whole code,
i'm telling what i've changed.
hopefully i did not forget any changes, but if so, ask.
//----------------------------------------------------------------------------------------------------------
*makefile*
be sure that your compiler flags include:
-fpack-struct
//----------------------------------------------------------------------------------------------------------
*diskimg.c*
replace :
const unsigned char DiskImage[MSC_ImageSize] __at MSC_ImageStart = {
with:
const unsigned char DiskImage[MSC_ImageSize] = {
i haven't analised the MSC doe yet, but so far i thing this is harmless
//----------------------------------------------------------------------------------------------------------
*usbhw.h*
add this line:
#define __irq __attribute__((interrupt))
//----------------------------------------------------------------------------------------------------------
*mscuser.c
*replace:
BYTE Memory[MSC_MemorySize] __at MSC_MemoryStart; // MSC RAM
with:
BYTE Memory[MSC_MemorySize]; // MSC RAM
*
*//----------------------------------------------------------------------------------------------------------
*usbcore.c*
replace:
(BYTE *)pD += ((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength;
with:
pD = (USB_COMMON_DESCRIPTOR*)(((BYTE *)pD) +
((USB_CONFIGURATION_DESCRIPTOR *)pD)->wTotalLength);
and
replace:
(BYTE *)pD += pD->bLength;
with:
pD = (USB_COMMON_DESCRIPTOR*)(((BYTE *)pD) + pD->bLength);
both appears twice in the file
I'm in this point now, but i think this generates good code.
//----------------------------------------------------------------------------------------------------------
*usbhw.c*
replace:
*((__packed DWORD *)pData) = RX_DATA;
pData += 4;
with:
DWORD w;
w = RX_DATA;
*pData++ = (w )&0xff;
*pData++ = (w>>8 )&0xff;
*pData++ = (w>>16)&0xff;
*pData++ = (w>>24)&0xff;
and
replace:
TX_DATA = *((__packed DWORD *)pData);
pData += 4;
with:
DWORD x;
x = (*pData++);
x |= (*pData++)<<8;
x |= (*pData++)<<16;
x |= (*pData++)<<24;
TX_DATA = x;
//----------------------------------------------------------------------------------------------------------
*usbuser.c*
replace:
#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
with:
#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? (void*)USB_EndPoint##n
: NULL)
and
replace:
const void (* USB_P_EP[16]) (DWORD event)=
with:
const void (* const USB_P_EP[16]) (DWORD event)=
//----------------------------------------------------------------------------------------------------------
*usbuser.h*
replace:
extern const void (* USB_P_EP[16]) (DWORD event)=
with:
extern const void (* const USB_P_EP[16]) (DWORD event)=
//----------------------------------------------------------------------------------------------------------
Mauricio
[Non-text portions of this message have been removed]Message
Re: [lpc2000] Re: Digest Number 944
2006-01-28 by Mauricio Scaff
Attachments
- No local attachments were found for this message.