From c16632da0bf8d042388018c667cfbc176ed56436 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 17 Jan 2013 14:40:46 +0700 Subject: add UART support for ea4357 (tested) --- tinyusb/class/cdc.c | 5 ++++- tinyusb/device/dcd.c | 2 +- tinyusb/hal/hal_lpc11uxx.h | 1 + tinyusb/hal/hal_lpc13uxx.h | 2 +- tinyusb/hal/hal_lpc43xx.c | 2 +- tinyusb/hal/hal_lpc43xx.h | 1 + tinyusb/tusb.h | 4 ++++ 7 files changed, 13 insertions(+), 4 deletions(-) (limited to 'tinyusb') diff --git a/tinyusb/class/cdc.c b/tinyusb/class/cdc.c index 51dcc8bfb..5fc1cd5fd 100644 --- a/tinyusb/class/cdc.c +++ b/tinyusb/class/cdc.c @@ -316,8 +316,11 @@ TUSB_Error_t tusb_cdc_configured(USBD_HANDLE_T hUsb) #elif MCU == MCU_LPC13UXX fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB_IRQ_IRQn); // TX is non-overwritable fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB_IRQ_IRQn); // RX is overwritable + #elif MCU == MCU_LPC43XX + fifo_init (&ffTX, qBuffer[0], CDC_BUFFER_SIZE, false, USB0_IRQn); // TODO USB1 TX is non-overwritable + fifo_init (&ffRX, qBuffer[1], CDC_BUFFER_SIZE, true, USB0_IRQn); // RX is overwritable #else - #error "usb_cdc.c: No MCU defined" + #error No MCU defined" // TODO asbtract MCU #endif return tERROR_NONE; diff --git a/tinyusb/device/dcd.c b/tinyusb/device/dcd.c index 8df95e131..de9e4f07d 100644 --- a/tinyusb/device/dcd.c +++ b/tinyusb/device/dcd.c @@ -93,7 +93,7 @@ TUSB_Error_t dcd_init(uint8_t coreid) USBD_API_INIT_PARAM_T usb_param = { - .usb_reg_base = LPC_USB_BASE, + .usb_reg_base = DEVICE_ROM_REG_BASE, .max_num_ep = USB_MAX_EP_NUM, .mem_base = membase, .mem_size = memsize, diff --git a/tinyusb/hal/hal_lpc11uxx.h b/tinyusb/hal/hal_lpc11uxx.h index b984afbc1..3d44d8742 100644 --- a/tinyusb/hal/hal_lpc11uxx.h +++ b/tinyusb/hal/hal_lpc11uxx.h @@ -54,6 +54,7 @@ #include "LPC11Uxx.h" #define DEVICE_ROMDRIVER +#define DEVICE_ROM_REG_BASE LPC_USB_BASE #ifdef __cplusplus extern "C" { diff --git a/tinyusb/hal/hal_lpc13uxx.h b/tinyusb/hal/hal_lpc13uxx.h index c360f2909..b24d774b6 100644 --- a/tinyusb/hal/hal_lpc13uxx.h +++ b/tinyusb/hal/hal_lpc13uxx.h @@ -54,7 +54,7 @@ #include "LPC13Uxx.h" #define DEVICE_ROMDRIVER - +#define DEVICE_ROM_REG_BASE LPC_USB_BASE #ifdef __cplusplus extern "C" { diff --git a/tinyusb/hal/hal_lpc43xx.c b/tinyusb/hal/hal_lpc43xx.c index 2fcd885f5..2b60d29c3 100644 --- a/tinyusb/hal/hal_lpc43xx.c +++ b/tinyusb/hal/hal_lpc43xx.c @@ -43,7 +43,7 @@ TUSB_Error_t hal_init() { /* Set up USB0 clock */ CGU_EnableEntity(CGU_CLKSRC_PLL0, DISABLE); /* Disable PLL first */ - ASSERT_MESSAGE( CGU_SetPLL0() == CGU_ERROR_SUCCESS, tERROR_FAILED, "set PLL failed"); /* the usb core require output clock = 480MHz */ + ASSERT_INT( CGU_ERROR_SUCCESS, CGU_SetPLL0(), tERROR_FAILED); /* the usb core require output clock = 480MHz */ CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_CLKSRC_PLL0); CGU_EnableEntity(CGU_CLKSRC_PLL0, ENABLE); /* Enable PLL after all setting is done */ LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */ diff --git a/tinyusb/hal/hal_lpc43xx.h b/tinyusb/hal/hal_lpc43xx.h index 2efd6da81..6fba59dfb 100644 --- a/tinyusb/hal/hal_lpc43xx.h +++ b/tinyusb/hal/hal_lpc43xx.h @@ -59,6 +59,7 @@ #endif #define DEVICE_ROMDRIVER +#define DEVICE_ROM_REG_BASE LPC_USB0_BASE // TODO USB1 static inline void hal_interrupt_enable() { diff --git a/tinyusb/tusb.h b/tinyusb/tusb.h index 9eb153371..8d1fd66bc 100644 --- a/tinyusb/tusb.h +++ b/tinyusb/tusb.h @@ -58,6 +58,10 @@ #include "device/dcd.h" #endif +#if !(defined TUSB_CFG_HOST) && !(defined TUSB_CFG_DEVICE) + #error please enable either TUSB_CFG_HOST or TUSB_CFG_DEVICE +#endif + #if DEVICE_CLASS_HID #include "class/hid.h" #endif -- cgit v1.3.1