summaryrefslogtreecommitdiff
path: root/tinyusb
diff options
context:
space:
mode:
authorhathach <[email protected]>2012-12-04 14:12:48 +0700
committerhathach <[email protected]>2012-12-04 14:12:48 +0700
commit82820a206666a6415148b0d26985ac5c7a9eb279 (patch)
tree1b283af44b02506b332df29620d2f760a5375d3e /tinyusb
parent8f00307986b71fdc48210e0ee4821a95392be4c3 (diff)
able to build with lpc43xx demo
Diffstat (limited to 'tinyusb')
-rw-r--r--tinyusb/class/cdc.c2
-rw-r--r--tinyusb/class/cdc.h3
-rw-r--r--tinyusb/class/hid.c2
-rw-r--r--tinyusb/class/hid.h18
-rw-r--r--tinyusb/common/arch/arch.h3
-rw-r--r--tinyusb/common/arch/arch_lpc134x.h2
-rw-r--r--tinyusb/common/arch/arch_lpc43xx.h2
-rw-r--r--tinyusb/common/common.h2
-rw-r--r--tinyusb/device/dcd.c2
-rw-r--r--tinyusb/hal/hal.h (renamed from tinyusb/common/arch/hal.h)0
-rw-r--r--tinyusb/hal/hal_lpc134x.c (renamed from tinyusb/common/arch/hal_lpc134x.c)0
-rw-r--r--tinyusb/hal/hal_lpc43xx.c54
-rw-r--r--tinyusb/tusb_cfg.h2
13 files changed, 77 insertions, 15 deletions
diff --git a/tinyusb/class/cdc.c b/tinyusb/class/cdc.c
index d62b7aa7d..a163be13a 100644
--- a/tinyusb/class/cdc.c
+++ b/tinyusb/class/cdc.c
@@ -38,7 +38,7 @@
#include "cdc.h"
#include "common/fifo.h"
-#ifdef CFG_CLASS_CDC
+#if defined CFG_CLASS_CDC && defined CFG_TUSB_DEVICE
static USBD_HANDLE_T g_hCdc;
static CDC_LINE_CODING line_coding;
diff --git a/tinyusb/class/cdc.h b/tinyusb/class/cdc.h
index 5bcad17a0..e4660d9b0 100644
--- a/tinyusb/class/cdc.h
+++ b/tinyusb/class/cdc.h
@@ -93,6 +93,7 @@ uint16_t tusb_cdc_send(uint8_t* buffer, uint16_t count);
*/
uint16_t tusb_cdc_recv(uint8_t* buffer, uint16_t max);
+#ifdef DEVICE_ROMDRIVER
/** \brief initialize cdc driver
*
* \param[in] para1
@@ -111,3 +112,5 @@ TUSB_Error_t tusb_cdc_init(USBD_HANDLE_T hUsb, USB_INTERFACE_DESCRIPTOR const *c
*/
TUSB_Error_t tusb_cdc_configured(USBD_HANDLE_T hUsb);
#endif
+
+#endif
diff --git a/tinyusb/class/hid.c b/tinyusb/class/hid.c
index 76a93d572..659765c1a 100644
--- a/tinyusb/class/hid.c
+++ b/tinyusb/class/hid.c
@@ -37,7 +37,7 @@
#include "hid.h"
-#ifdef TUSB_CLASS_HID
+#if defined TUSB_CLASS_HID && defined CFG_TUSB_DEVICE
#ifdef CFG_CLASS_HID_KEYBOARD
USB_HID_KeyboardReport_t hid_keyboard_report;
diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h
index 4e56ffb4e..b5516e259 100644
--- a/tinyusb/class/hid.h
+++ b/tinyusb/class/hid.h
@@ -51,6 +51,10 @@
#ifndef _TUSB_HID_H_
#define _TUSB_HID_H_
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
// TODO refractor
#include "common/common.h"
#include "device/dcd.h"
@@ -61,24 +65,24 @@
*
* Type define for a standard Boot Protocol Mouse report
*/
-typedef PRE_PACK struct
+typedef ATTR_PREPACKED struct
{
uint8_t Button; /**< Button mask for currently pressed buttons in the mouse. */
int8_t X; /**< Current delta X movement of the mouse. */
int8_t Y; /**< Current delta Y movement on the mouse. */
-} POST_PACK USB_HID_MouseReport_t;
+} ATTR_PACKED USB_HID_MouseReport_t;
/** \struct USB_HID_KeyboardReport_t
* \brief Standard HID Boot Protocol Keyboard Report.
*
* Type define for a standard Boot Protocol Keyboard report
*/
-typedef PRE_PACK struct
+typedef ATTR_PREPACKED struct
{
uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of HID_KEYBOARD_MODIFER_* masks). */
uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */
uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */
-} POST_PACK USB_HID_KeyboardReport_t;
+} ATTR_PACKED USB_HID_KeyboardReport_t;
/** \enum USB_HID_MOUSE_BUTTON_CODE
* \brief Button codes for HID mouse
@@ -148,10 +152,7 @@ enum USB_HID_LOCAL_CODE
HID_Local_Turkish_F
};
-#ifdef __cplusplus
- extern "C" {
-#endif
-
+#ifdef DEVICE_ROMDRIVER
/** \brief Initialize HID driver
*
* \param[in] para1
@@ -187,6 +188,7 @@ TUSB_Error_t tusb_hid_keyboard_sendKeys(uint8_t modifier, uint8_t keycodes[], ui
* \note
*/
TUSB_Error_t tusb_hid_mouse_send(uint8_t buttons, int8_t x, int8_t y);
+#endif
#ifdef __cplusplus
}
diff --git a/tinyusb/common/arch/arch.h b/tinyusb/common/arch/arch.h
index aa806d3b0..1cc3fc83d 100644
--- a/tinyusb/common/arch/arch.h
+++ b/tinyusb/common/arch/arch.h
@@ -51,8 +51,9 @@
#ifndef _TUSB_ARCH_H_
#define _TUSB_ARCH_H_
-#define ARCH_LPC134X
+//#define ARCH_LPC134X
//#define ARCH_LPC11XX
+#define ARCH_LPC43XX
#define ENDIAN_LITTLE ///< MCU Endian
#define ALIGNMENT (4) ///< MCU Alignment
diff --git a/tinyusb/common/arch/arch_lpc134x.h b/tinyusb/common/arch/arch_lpc134x.h
index b43bcea7c..1779b784b 100644
--- a/tinyusb/common/arch/arch_lpc134x.h
+++ b/tinyusb/common/arch/arch_lpc134x.h
@@ -54,8 +54,6 @@
#include "arm_mx.h"
#include "LPC13Uxx.h"
-#include "system_LPC13Uxx.h"
-
#endif /* _TUSB_ARCH_LPC134_X_H_ */
diff --git a/tinyusb/common/arch/arch_lpc43xx.h b/tinyusb/common/arch/arch_lpc43xx.h
index a83d18c94..f96bbb0dc 100644
--- a/tinyusb/common/arch/arch_lpc43xx.h
+++ b/tinyusb/common/arch/arch_lpc43xx.h
@@ -53,6 +53,8 @@
//#define ARM_M0
#include "arm_mx.h"
+#include "LPC43xx.h"
+#include "lpc43xx_cgu.h"
#endif /* _TUSB_ARCH_LPC43XX_H_ */
diff --git a/tinyusb/common/common.h b/tinyusb/common/common.h
index 97bc32ae3..d073b8cca 100644
--- a/tinyusb/common/common.h
+++ b/tinyusb/common/common.h
@@ -63,7 +63,7 @@
#include "tusb_cfg.h"
#include "arch/arch.h"
-#include "arch/hal.h"
+#include "hal/hal.h"
#include "compiler/compiler.h"
#include "errors.h"
#include "core/tusb_types.h"
diff --git a/tinyusb/device/dcd.c b/tinyusb/device/dcd.c
index 480db2119..b3b97faf1 100644
--- a/tinyusb/device/dcd.c
+++ b/tinyusb/device/dcd.c
@@ -86,6 +86,7 @@ ErrorCode_t USB_Reset_Event (USBD_HANDLE_T hUsb)
TUSB_Error_t dcd_init(uint8_t coreid)
{
+#ifdef DEVICE_ROMDRIVER // TODO refractor later
/* ROM DRIVER INIT */
uint32_t membase = (uint32_t) usb_RomDriver_buffer;
uint32_t memsize = USB_ROM_SIZE;
@@ -139,6 +140,7 @@ TUSB_Error_t dcd_init(uint8_t coreid)
/* Perform USB soft connect */
USBD_API->hw->Connect(g_hUsb, 1);
+#endif
return tERROR_NONE;
}
diff --git a/tinyusb/common/arch/hal.h b/tinyusb/hal/hal.h
index 4229f6ea1..4229f6ea1 100644
--- a/tinyusb/common/arch/hal.h
+++ b/tinyusb/hal/hal.h
diff --git a/tinyusb/common/arch/hal_lpc134x.c b/tinyusb/hal/hal_lpc134x.c
index 10acd3388..10acd3388 100644
--- a/tinyusb/common/arch/hal_lpc134x.c
+++ b/tinyusb/hal/hal_lpc134x.c
diff --git a/tinyusb/hal/hal_lpc43xx.c b/tinyusb/hal/hal_lpc43xx.c
new file mode 100644
index 000000000..2291e7532
--- /dev/null
+++ b/tinyusb/hal/hal_lpc43xx.c
@@ -0,0 +1,54 @@
+/*
+ * hal_lpc43xx.c
+ *
+ * Created on: Dec 4, 2012
+ * Author: hathach
+ */
+
+/*
+ * Software License Agreement (BSD License)
+ * Copyright (c) 2012, hathach (tinyusb.net)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+ * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * This file is part of the tiny usb stack.
+ */
+
+#include "common/common.h"
+
+#ifdef ARCH_LPC43XX
+
+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 */
+ 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 */
+
+ return tERROR_NONE;
+}
+
+#endif
diff --git a/tinyusb/tusb_cfg.h b/tinyusb/tusb_cfg.h
index b31246eac..6cda15830 100644
--- a/tinyusb/tusb_cfg.h
+++ b/tinyusb/tusb_cfg.h
@@ -60,7 +60,7 @@
#define CFG_TUSB_HOST
/// Enable Device Support
-#define CFG_TUSB_DEVICE
+//#define CFG_TUSB_DEVICE
/// Enable CDC Support
#define CFG_CLASS_CDC