#ifndef _USB_DEBUG_H_
#define _USB_DEBUG_H_
-#if 1
+#ifndef NO_USB_DEBUG
+ #if 1
#include <stdio.h>
#define usb_printf printf
-#else
+ #else
int simple_printf(const char *f, ...);
#define usb_printf simple_printf
+ #endif
+#else
+ #define usb_printf(...)
#endif
/* Debug levels */
void lpc_usb_hw_init (void)
{
+#if defined(INC_LPC214x_H) || defined(MACH_LPC21XX)
PINSEL1 &= ~0xC000C000;
// PINSEL1 |= 0x40004000; /* Select USB Link, VBUS */
PINSEL1 |= 0x80000000; /* Select USB Link, VBUS */
PLLFEED48 = 0x55; /* Feed Sequence 2 */
USBDevIntEn = USBDevInt_DEV_STAT; /* Enable Device Status Interrupt */
+#endif /* MACH_LPC21XX */
+
+#ifdef MACH_LPC23XX
+ /**
+ ** ** ATTENTION **
+ ** USB clock (48MHz) should be set up externally before calling this fn
+ ** by setting USBCLKCFG (eg. USBCLKCFG = 5 for f_cco=288MHz).
+ ** If some of the pins shared with USB device are to be used for
+ ** different purpose, following PINSELs must be changed after retutn
+ ** from this fn.
+ **/
+
+ /* set up USB pins */
+ PINSEL1 = (PINSEL1 & ~(0x3<<26)) | (0x1<<26); /* USB_D+,- @ P0.29,30 */
+ PINSEL3 = (PINSEL3 & ~(0x3<<28)) | (0x2<<28); /* Vbus @ P1.30 */
+ PINSEL4 = (PINSEL4 & ~(0x3<<18)) | (0x1<<18); /* USB_CONNECT @ P2.9 */
+ /* switch USB power on */
+ PCONP |= 1<<31;
+ /* switch USB internal clock switch on */
+ USBClkCtrl = 0x12;
+#endif /* MACH_LPC23XX */
/* Partial Manual Reset since Automatic Bus Reset is not working */
lpc_usb_reset();