diff options
| author | hathach <[email protected]> | 2013-05-23 13:22:46 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-05-23 13:22:46 +0700 |
| commit | 8cb7818bcc048a69b9e2b0a4607c8f75bc35c359 (patch) | |
| tree | 6307b044a94f013c7ec74b1462318484b30c1a76 /tinyusb | |
| parent | d7ae21203c1a7915c397157a9d231264ff0e66fc (diff) | |
- move CMSIS & driver lib for lpc13u to codebase bsp/lpc13xx
- change descriptor.c/h able to build device example
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/class/hid.h | 64 | ||||
| -rw-r--r-- | tinyusb/class/hid_device.h | 1 | ||||
| -rw-r--r-- | tinyusb/device/usbd.c | 66 | ||||
| -rw-r--r-- | tinyusb/device/usbd.h | 86 | ||||
| -rw-r--r-- | tinyusb/host/usbh.c | 14 | ||||
| -rw-r--r-- | tinyusb/host/usbh.h | 10 | ||||
| -rw-r--r-- | tinyusb/tusb.c | 6 | ||||
| -rw-r--r-- | tinyusb/tusb.h | 23 | ||||
| -rw-r--r-- | tinyusb/tusb_option.h | 4 |
9 files changed, 214 insertions, 60 deletions
diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h index cf70f66aa..7ede6eb0c 100644 --- a/tinyusb/class/hid.h +++ b/tinyusb/class/hid.h @@ -52,16 +52,16 @@ extern "C" { #endif -enum { - HID_SUBCLASS_NONE = 0, - HID_SUBCLASS_BOOT = 1 -}; - -enum { - HID_PROTOCOL_NONE = 0, - HID_PROTOCOL_KEYBOARD = 1, - HID_PROTOCOL_MOUSE = 2 -}; +//enum { +// HID_SUBCLASS_NONE = 0, +// HID_SUBCLASS_BOOT = 1 +//}; +// +//enum { +// HID_PROTOCOL_NONE = 0, +// HID_PROTOCOL_KEYBOARD = 1, +// HID_PROTOCOL_MOUSE = 2 +//}; enum { HID_DESC_HID = 0x21, @@ -382,28 +382,28 @@ enum { HID_USAGE_PAGE_DESKTOP = 0x01, HID_USAGE_PAGE_SIMULATE = 0x02, HID_USAGE_PAGE_VIRTUAL_REALITY = 0x03, - HID_USAGE_PAGE_SPORT = 0x04, - HID_USAGE_PAGE_GAME = 0x05, - HID_USAGE_PAGE_GENERIC_DEVICE = 0x06, - HID_USAGE_PAGE_KEYBOARD = 0x07, - HID_USAGE_PAGE_LED = 0x08, - HID_USAGE_PAGE_BUTTON = 0x09, - HID_USAGE_PAGE_ORDINAL = 0x0a, - HID_USAGE_PAGE_TELEPHONY = 0x0b, - HID_USAGE_PAGE_CONSUMER = 0x0c, - HID_USAGE_PAGE_DIGITIZER = 0x0d, - HID_USAGE_PAGE_PID = 0x0f, - HID_USAGE_PAGE_UNICODE = 0x10, - HID_USAGE_PAGE_ALPHA_DISPLAY = 0x14, - HID_USAGE_PAGE_MEDICAL = 0x40, - HID_USAGE_PAGE_MONITOR = 0x80, //0x80 - 0x83 - HID_USAGE_PAGE_POWER = 0x84, // 0x084 - 0x87 - HID_USAGE_PAGE_BARCODE_SCANNER = 0x8c, - HID_USAGE_PAGE_SCALE = 0x8d, - HID_USAGE_PAGE_MSR = 0x8e, - HID_USAGE_PAGE_CAMERA = 0x90, - HID_USAGE_PAGE_ARCADE = 0x91, - HID_USAGE_PAGE_VENDOR = 0xFFFF // 0xFF00 - 0xFFFF +// HID_USAGE_PAGE_SPORT = 0x04, +// HID_USAGE_PAGE_GAME = 0x05, +// HID_USAGE_PAGE_GENERIC_DEVICE = 0x06, +// HID_USAGE_PAGE_KEYBOARD = 0x07, +// HID_USAGE_PAGE_LED = 0x08, +// HID_USAGE_PAGE_BUTTON = 0x09, +// HID_USAGE_PAGE_ORDINAL = 0x0a, +// HID_USAGE_PAGE_TELEPHONY = 0x0b, +// HID_USAGE_PAGE_CONSUMER = 0x0c, +// HID_USAGE_PAGE_DIGITIZER = 0x0d, +// HID_USAGE_PAGE_PID = 0x0f, +// HID_USAGE_PAGE_UNICODE = 0x10, +// HID_USAGE_PAGE_ALPHA_DISPLAY = 0x14, +// HID_USAGE_PAGE_MEDICAL = 0x40, +// HID_USAGE_PAGE_MONITOR = 0x80, //0x80 - 0x83 +// HID_USAGE_PAGE_POWER = 0x84, // 0x084 - 0x87 +// HID_USAGE_PAGE_BARCODE_SCANNER = 0x8c, +// HID_USAGE_PAGE_SCALE = 0x8d, +// HID_USAGE_PAGE_MSR = 0x8e, +// HID_USAGE_PAGE_CAMERA = 0x90, +// HID_USAGE_PAGE_ARCADE = 0x91, +// HID_USAGE_PAGE_VENDOR = 0xFFFF // 0xFF00 - 0xFFFF }; /// HID Usage Table - Table 6: Generic Desktop Page diff --git a/tinyusb/class/hid_device.h b/tinyusb/class/hid_device.h index 5268654d1..f797007b0 100644 --- a/tinyusb/class/hid_device.h +++ b/tinyusb/class/hid_device.h @@ -52,6 +52,7 @@ #ifndef _TUSB_HID_DEVICE_H_ #define _TUSB_HID_DEVICE_H_ +#include "common/common.h" #include "hid.h" #ifdef __cplusplus diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c new file mode 100644 index 000000000..b5a4044c0 --- /dev/null +++ b/tinyusb/device/usbd.c @@ -0,0 +1,66 @@ +/**************************************************************************/ +/*! + @file usbd.c + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, hathach (tinyusb.org) + 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. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''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 COPYRIGHT HOLDER 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 tinyusb stack. +*/ +/**************************************************************************/ + +#include "tusb_option.h" + +#if MODE_DEVICE_SUPPORTED + +#define _TINY_USB_SOURCE_FILE_ + +//--------------------------------------------------------------------+ +// INCLUDE +//--------------------------------------------------------------------+ +#include "tusb.h" + +//--------------------------------------------------------------------+ +// MACRO CONSTANT TYPEDEF +//--------------------------------------------------------------------+ + +//--------------------------------------------------------------------+ +// INTERNAL OBJECT & FUNCTION DECLARATION +//--------------------------------------------------------------------+ + +//--------------------------------------------------------------------+ +// IMPLEMENTATION +//--------------------------------------------------------------------+ +tusb_error_t usbd_init (void) +{ + return TUSB_ERROR_NONE; +} + +#endif diff --git a/tinyusb/device/usbd.h b/tinyusb/device/usbd.h new file mode 100644 index 000000000..25aaaa946 --- /dev/null +++ b/tinyusb/device/usbd.h @@ -0,0 +1,86 @@ +/**************************************************************************/ +/*! + @file usbd.h + @author hathach (tinyusb.org) + + @section LICENSE + + Software License Agreement (BSD License) + + Copyright (c) 2013, hathach (tinyusb.org) + 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. Neither the name of the copyright holders nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''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 COPYRIGHT HOLDER 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 tinyusb stack. +*/ +/**************************************************************************/ + +/** \ingroup TBD + * \defgroup TBD + * \brief TBD + * + * @{ + */ + +#ifndef _TUSB_USBD_H_ +#define _TUSB_USBD_H_ + +//--------------------------------------------------------------------+ +// INCLUDE +//--------------------------------------------------------------------+ +#include "osal/osal.h" // TODO refractor move to common.h ? +#include "dcd.h" + +#ifdef __cplusplus + extern "C" { +#endif + +//--------------------------------------------------------------------+ +// MACRO CONSTANT TYPEDEF +//--------------------------------------------------------------------+ + +//--------------------------------------------------------------------+ +// INTERNAL OBJECT & FUNCTION DECLARATION +//--------------------------------------------------------------------+ + +//--------------------------------------------------------------------+ +// APPLICATION API +//--------------------------------------------------------------------+ + +//--------------------------------------------------------------------+ +// CLASS-USBD & INTERNAL API +//--------------------------------------------------------------------+ +#ifdef _TINY_USB_SOURCE_FILE_ + +tusb_error_t usbd_init(void); + +#endif + +#ifdef __cplusplus + } +#endif + +#endif /* _TUSB_USBD_H_ */ + +/** @} */ diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index 28c114e1e..c5f6ddeb2 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -48,14 +48,6 @@ #include "tusb.h" #include "usbh_hcd.h" -//TODO temporarily -#if TUSB_CFG_OS == TUSB_OS_NONE && !defined(_TEST_) -void tusb_tick_tock(void) -{ - osal_tick_tock(); -} -#endif - //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ @@ -300,7 +292,7 @@ tusb_error_t enumeration_body_subtask(void) #ifndef _TEST_ // TODO hack delay 20 ms for slow device (use retry on the 1st xfer instead later) - osal_task_delay(20); + osal_task_delay(50); #endif //------------- Get first 8 bytes of device descriptor to get Control Endpoint Size -------------// @@ -484,7 +476,7 @@ tusb_error_t enumeration_body_subtask(void) -#endif + //--------------------------------------------------------------------+ // INTERNAL HELPER @@ -512,3 +504,5 @@ static inline uint8_t get_configure_number_for_device(tusb_descriptor_device_t* return config_num; } + +#endif diff --git a/tinyusb/host/usbh.h b/tinyusb/host/usbh.h index 6e2eb0033..6dcf12066 100644 --- a/tinyusb/host/usbh.h +++ b/tinyusb/host/usbh.h @@ -101,16 +101,8 @@ uint8_t tusbh_device_attached_cb (tusb_descriptor_device_t const *p_desc_de void tusbh_device_mount_succeed_cb (uint8_t dev_addr) ATTR_WEAK; void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_device_t const *p_desc_device) ATTR_WEAK; // TODO refractor remove desc_device -#if TUSB_CFG_OS == TUSB_OS_NONE // TODO move later -//static inline void tusb_tick_tock(void) ATTR_ALWAYS_INLINE; -//static inline void tusb_tick_tock(void) -//{ -// osal_tick_tock(); -//} -#endif - //--------------------------------------------------------------------+ -// CLASS-USBD & INTERNAL API +// CLASS-USBH & INTERNAL API //--------------------------------------------------------------------+ #ifdef _TINY_USB_SOURCE_FILE_ diff --git a/tinyusb/tusb.c b/tinyusb/tusb.c index fe61c105d..57ebef53a 100644 --- a/tinyusb/tusb.c +++ b/tinyusb/tusb.c @@ -47,8 +47,8 @@ tusb_error_t tusb_init(void) ASSERT_STATUS( usbh_init() ); // host stack init #endif -#ifdef TUSB_CFG_DEVICE - ASSERT_STATUS( dcd_init(0) ); // device stack init +#if MODE_DEVICE_SUPPORTED + ASSERT_STATUS ( usbd_init() ); // device stack init #endif return TUSB_ERROR_NONE; @@ -61,7 +61,7 @@ void tusb_isr(uint8_t controller_id) hcd_isr(controller_id); #endif -#ifdef TUSB_CFG_DEVICE +#if MODE_DEVICE_SUPPORTED dcd_isr(controller_id); #endif diff --git a/tinyusb/tusb.h b/tinyusb/tusb.h index 7dcf06d12..f7c14d9f6 100644 --- a/tinyusb/tusb.h +++ b/tinyusb/tusb.h @@ -48,10 +48,14 @@ extern "C" { #endif +//--------------------------------------------------------------------+ +// INCLUDE +//--------------------------------------------------------------------+ #include "common/common.h" #include "hal/hal.h" #include "osal/osal.h" +//------------- HOST -------------// #if MODE_HOST_SUPPORTED #include "host/usbh.h" @@ -66,27 +70,38 @@ #endif +//------------- DEVICE -------------// #if MODE_DEVICE_SUPPORTED - #include "device/dcd.h" + #include "device/usbd.h" #if DEVICE_CLASS_HID #include "class/hid_device.h" #endif - #ifdef TUSB_CFG_DEVICE_CDC + #if TUSB_CFG_DEVICE_CDC #include "class/cdc.h" #endif #endif - - +//--------------------------------------------------------------------+ +// APPLICATION API +//--------------------------------------------------------------------+ tusb_error_t tusb_init(void); +// TODO merge with tick_tock #if TUSB_CFG_OS == TUSB_OS_NONE void tusb_task_runner(void); #endif +#if TUSB_CFG_OS == TUSB_OS_NONE && !defined(_TEST_) +static inline void tusb_tick_tock(void) ATTR_ALWAYS_INLINE; +static inline void tusb_tick_tock(void) +{ + osal_tick_tock(); +} +#endif + #ifdef __cplusplus } #endif diff --git a/tinyusb/tusb_option.h b/tinyusb/tusb_option.h index 4633ca2f0..75a01f103 100644 --- a/tinyusb/tusb_option.h +++ b/tinyusb/tusb_option.h @@ -156,7 +156,7 @@ //--------------------------------------------------------------------+ // DEVICE OPTIONS //--------------------------------------------------------------------+ -//#define TUSB_CFG_DEVICE +//#if MODE_DEVICE_SUPPORTED #define DEVICE_CLASS_HID ( (defined TUSB_CFG_DEVICE_HID_KEYBOARD) || (defined TUSB_CFG_DEVICE_HID_MOUSE) ) @@ -183,7 +183,7 @@ #define CDC_NOTIFICATION_EP_MAXPACKETSIZE 8 #define CDC_DATA_EP_MAXPACKET_SIZE 16 - +//#endif #ifdef __cplusplus } |
