able to build with lpc43xx demo

This commit is contained in:
hathach
2012-12-04 14:12:48 +07:00
parent 8f00307986
commit 82820a2066
14 changed files with 887 additions and 17 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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
}

View File

@@ -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

View File

@@ -54,8 +54,6 @@
#include "arm_mx.h"
#include "LPC13Uxx.h"
#include "system_LPC13Uxx.h"
#endif /* _TUSB_ARCH_LPC134_X_H_ */

View File

@@ -53,6 +53,8 @@
//#define ARM_M0
#include "arm_mx.h"
#include "LPC43xx.h"
#include "lpc43xx_cgu.h"
#endif /* _TUSB_ARCH_LPC43XX_H_ */

View File

@@ -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"

View File

@@ -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;
}

54
tinyusb/hal/hal_lpc43xx.c Normal file
View File

@@ -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

View File

@@ -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