Content originally posted in LPCWare by triffid_hunter on Mon Jul 02 08:00:29 MST 2012
Hi all,
Just pulled nxpUSBLib 0.95 and dropped into an existing project using arm-none-eabi-gcc (Sourcery G++ Lite 2011.03-42) 4.5.2
However, nxpUSBLib gives me the following errors:
<code>arm-none-eabi-gcc -Os -mcpu=cortex-m3 -mthumb -mthumb-interwork -mlong-calls -ffunction-sections -fdata-sections -Wall -g -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -I. -ICMSISv2p00_LPC17xx/inc -ILPC17xxLib/inc -InxpUSBLib/ -InxpUSBLib/Common -InxpUSBLib/Drivers -InxpUSBLib/Drivers/USB -InxpUSBLib/Drivers/USB/Core -InxpUSBLib/Drivers/USB/Core/LPC -InxpUSBLib/Drivers/USB/Core/LPC/HAL -InxpUSBLib/Drivers/USB/Core/LPC/HAL/LPC17XX -InxpUSBLib/Drivers/USB/Core/LPC/DCD -InxpUSBLib/Drivers/USB/Core/LPC/DCD/LPC17XX -InxpUSBLib/Drivers/USB/Core/LPC/HCD -InxpUSBLib/Drivers/USB/Core/LPC/HCD/EHCI -InxpUSBLib/Drivers/USB/Core/LPC/HCD/OHCI -InxpUSBLib/Drivers/USB/Class -InxpUSBLib/Drivers/USB/Class/Common -InxpUSBLib/Drivers/USB/Class/Host -InxpUSBLib/Drivers/USB/Class/Device -DMAX_URI_LENGTH=512 -D__LPC17XX__ -std=gnu99 -pipe -Wa,-adhlns=build/USBTask.lst -c -o build/USBTask.o nxpUSBLib/Drivers/USB/Core/USBTask.c
In file included from nxpUSBLib/Drivers/USB/Core/USBController.h:127:0,
from nxpUSBLib/Drivers/USB/Core/USBTask.h:50,
from nxpUSBLib/Drivers/USB/Core/USBTask.c:35:
nxpUSBLib/Drivers/USB/Core/LPC/USBController_LPC.h: In function 'USB_GetUSBModeFromUID':
nxpUSBLib/Drivers/USB/Core/LPC/USBController_LPC.h:360:9: error: 'USBSTA' undeclared (first use in this function)
nxpUSBLib/Drivers/USB/Core/LPC/USBController_LPC.h:360:9: note: each undeclared identifier is reported only once for each function it appears in
nxpUSBLib/Drivers/USB/Core/LPC/USBController_LPC.h:360:24: error: 'ID' undeclared (first use in this function)
nxpUSBLib/Drivers/USB/Core/USBTask.c: At top level:
nxpUSBLib/Drivers/USB/Core/USBTask.c:38:41: error: expected '=', ',', ';', 'asm' or '__attribute__' before '__DATA'
make: *** [build/USBTask.o] Error 1</code>
__DATA is defined for CodeRed and keil compilers only, in nxpUSBLib/Drivers/USB/Core/LPC/HAL/HAL_LPC.h.
Simply adding <code>#ifndef __DATA
#define __DATA(x)
#endif</code> near the end of this file solves this for me.
'USBSTA' and 'ID' have me stumped though, there's only one use of them in the whole of nxpUSBLib and zero definitions, and it's not entirely clear from context what it's supposed to represent:
<code> #if defined(USB_CAN_BE_BOTH)
static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t USB_GetUSBModeFromUID(void)
if (USBSTA & (1 << ID))
return USB_MODE_Device;
else
return USB_MODE_Host;
}
#endif</code>
I certainly can define these externally, but I'd really like to understand what they're supposed to represent rather than just blindly adding -DUSBSTA=1 -DID=0 to get device mode, or -DID=1 for host mode.
In fact, if I do add a numeric definition for ID, then compilation of LPC17xxLib/src/lpc17xx_can.c fails because it uses ID as a parameter in some function calls.
After digging around in the headers a bit, I discovered that defining USB_DEVICE_ONLY (or presumably USB_HOST_ONLY) prevents this error from occurring.
If this library can't handle switching modes, a more useful error message would be appreciated!