]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Added LPC23xx USB support to existing lpcusb lib
authorMarek Peca <mp@duch.cz>
Mon, 14 Sep 2009 13:47:18 +0000 (15:47 +0200)
committerMarek Peca <mp@duch.cz>
Mon, 14 Sep 2009 13:47:18 +0000 (15:47 +0200)
common/libs4c/usb/base/usb/usbdebug.h
common/libs4c/usb/lpcusb/lpcusb.c

index c81adf52e0ffcf49d95602a596aea68b56577a44..e2bb017a8ff45e6e3d7f8def07d96b454461f5c4 100644 (file)
@@ -4,12 +4,16 @@
 #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 */
index 09b1eacdcafc0a280668bc36fa70d17923bbdb90..daa7e7a26da914c867971a6ed3e9087056d92533 100644 (file)
@@ -103,6 +103,7 @@ void lpc_usb_reset(void)
 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 */
@@ -122,6 +123,27 @@ void lpc_usb_hw_init (void)
   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();