Converting keil code to crossworks
Hi, I've been trying to compile the USBHID & USBCDC code from the keil example bundle to work with the LPC1343 cpu and have had some troubles getting the code modified to compile with crossworks. Maybe someone can give me some pointers...
The first things I had to do was modify the includes on top of the files for processor defines so I removed the "#include <lpc13xx.h>" and added:
#include <CMSIS/LPC13xx.h>
#include <LPC1000.h>
#include <liblpc1000.h>
Basically I have two main problems that puzzle me, first this code:
if ( LPC_GPIO0->DATA & (1<<1) ) { /* Check if PBINT is pressed */
durring compile gives me this error:
‘LPC_GPIO_TypeDef’ has no member named ‘DATA’
and looking throught the"CMSIS/LPC13xx.h" file i found the typedef and got it to compile without errors like this:
if ( LPC_GPIO0->u1.s1.DATA & (1<<1) ) { /* Check if PBINT is pressed */
but I'm wondering if this is correct or maybe I just found a bad work around to the problem??
and my next problem is this code:
typedef __packed union {
which give me the error:
expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘union’
and in this case I found the if I remove the "__packed" it compiles ok, but obviously I'm removing something that is needed... So searching around I found a post in the forum where Paul talks about packing structures to only take up the amount of ram really needed using "__attribute__ ((packed))" and applying his principale i modified the above to this:
typedef union {
uint16_t W;
struct {
uint8_t L;
uint8_t H;
} __attribute__ ((packed)) WB;
} __attribute__ ((packed)) WORD_BYTE;
and now it compiles ok.. But I have some doubs if the "__packed" for keil is the same as what paul is talking about??
Thanks for the help.
-
The LPC13xx.h header file in the latest release of the LPC1000 CPU support package (1.7) should now be compatible with your original code.
See http://www.rowleydownload.co.uk/documentation/arm_2_0/gnu/gcc/Type-Attributes.html and http://www.rowleydownload.co.uk/documentation/arm_2_0/gnu/gcc/Variable-Attributes.html for a description of the packed attribute.
Please sign in to leave a comment.
Comments
2 comments