change TUSB_CFG_CONTROLLER0/1_MODE to TUSB_CFG_CONTROLLER_0/1_MODE for clearance

adding configuration docs for tinyusb_config.h
document HID mouse & keyboard API
This commit is contained in:
hathach
2013-10-24 15:32:54 +07:00
parent 2076e57d70
commit b71ffe3d5a
18 changed files with 5902 additions and 3416 deletions
+2351
View File
File diff suppressed because it is too large Load Diff
+137 -137
View File
@@ -1,137 +1,137 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file tusb_config.h @file tusb_config.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \file /** \file
* \brief TBD * \brief TBD
* *
* \note TBD * \note TBD
*/ */
/** \ingroup TBD /** \ingroup TBD
* \defgroup TBD * \defgroup TBD
* \brief TBD * \brief TBD
* *
* @{ * @{
*/ */
#ifndef _TUSB_TUSB_CONFIG_H_ #ifndef _TUSB_TUSB_CONFIG_H_
#define _TUSB_TUSB_CONFIG_H_ #define _TUSB_TUSB_CONFIG_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CONTROLLER CONFIGURATION // CONTROLLER CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_DEVICE) #define TUSB_CFG_CONTROLLER_0_MODE (TUSB_MODE_DEVICE)
#define TUSB_CFG_CONTROLLER1_MODE (TUSB_MODE_NONE) #define TUSB_CFG_CONTROLLER_1_MODE (TUSB_MODE_NONE)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// HOST CONFIGURATION // HOST CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_HOST_DEVICE_MAX 2 #define TUSB_CFG_HOST_DEVICE_MAX 2
#define TUSB_CFG_CONFIGURATION_MAX 1 #define TUSB_CFG_CONFIGURATION_MAX 1
//------------- USBD -------------// //------------- USBD -------------//
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256 #define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 0 #define TUSB_CFG_HOST_HUB 0
#define TUSB_CFG_HOST_HID_KEYBOARD 1 #define TUSB_CFG_HOST_HID_KEYBOARD 1
#define TUSB_CFG_HOST_HID_MOUSE 1 #define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_HID_GENERIC 0 #define TUSB_CFG_HOST_HID_GENERIC 0
#define TUSB_CFG_HOST_MSC 0 #define TUSB_CFG_HOST_MSC 0
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// DEVICE CONFIGURATION // DEVICE CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_DEVICE_USE_ROM_DRIVER 1 #define TUSB_CFG_DEVICE_USE_ROM_DRIVER 1
//------------- descriptors -------------// //------------- descriptors -------------//
#define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyusb.org" #define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyusb.org"
#define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Example" #define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Example"
#define TUSB_CFG_DEVICE_STRING_SERIAL "1234" #define TUSB_CFG_DEVICE_STRING_SERIAL "1234"
#define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP #define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP
//#define TUSB_CFG_DEVICE_PRODUCTID 0x4567 //#define TUSB_CFG_DEVICE_PRODUCTID 0x4567
#define TUSB_CFG_DEVICE_CONTROL_PACKET_SIZE 64 #define TUSB_CFG_DEVICE_CONTROL_PACKET_SIZE 64
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1 #define TUSB_CFG_DEVICE_HID_KEYBOARD 1
#define TUSB_CFG_DEVICE_HID_MOUSE 0 #define TUSB_CFG_DEVICE_HID_MOUSE 0
#define TUSB_CFG_DEVICE_HID_GENERIC 0 #define TUSB_CFG_DEVICE_HID_GENERIC 0
#define TUSB_CFG_DEVICE_MSC 0 #define TUSB_CFG_DEVICE_MSC 0
#define TUSB_CFG_DEVICE_CDC 0 #define TUSB_CFG_DEVICE_CDC 0
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// COMMON CONFIGURATION // COMMON CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_DEBUG 3 #define TUSB_CFG_DEBUG 3
#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build #define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build
//#define TUSB_CFG_OS_TASK_PRIO //#define TUSB_CFG_OS_TASK_PRIO
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000 #define TUSB_CFG_OS_TICKS_PER_SECOND 1000
#ifdef __CODE_RED // make use of code red's support for ram region macros #ifdef __CODE_RED // make use of code red's support for ram region macros
#if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX) #if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX)
#define TUSB_RAM_SECTION ".data.$RAM1" // TODO overflow usb ram #define TUSB_RAM_SECTION ".data.$RAM1" // TODO overflow usb ram
#elif (MCU == MCU_LPC43XX) #elif (MCU == MCU_LPC43XX)
#define TUSB_RAM_SECTION ".data.$RAM3" #define TUSB_RAM_SECTION ".data.$RAM3"
#elif (MCU == MCU_LPC175X_6X) #elif (MCU == MCU_LPC175X_6X)
#define TUSB_RAM_SECTION ".data.$RAM2" #define TUSB_RAM_SECTION ".data.$RAM2"
#else #else
forgot something thach ? forgot something thach ?
#endif #endif
#define TUSB_CFG_ATTR_USBRAM __attribute__ ((section(TUSB_RAM_SECTION))) #define TUSB_CFG_ATTR_USBRAM __attribute__ ((section(TUSB_RAM_SECTION)))
#elif defined __CC_ARM // Compiled with Keil armcc #elif defined __CC_ARM // Compiled with Keil armcc
#define TUSB_CFG_ATTR_USBRAM #define TUSB_CFG_ATTR_USBRAM
#else #else
#error compiler not specified #error compiler not specified
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _TUSB_TUSB_CONFIG_H_ */ #endif /* _TUSB_TUSB_CONFIG_H_ */
/** @} */ /** @} */
+126 -126
View File
@@ -1,126 +1,126 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file tusb_config.h @file tusb_config.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \file /** \file
* \brief TBD * \brief TBD
* *
* \note TBD * \note TBD
*/ */
/** \ingroup TBD /** \ingroup TBD
* \defgroup TBD * \defgroup TBD
* \brief TBD * \brief TBD
* *
* @{ * @{
*/ */
#ifndef _TUSB_TUSB_CONFIG_H_ #ifndef _TUSB_TUSB_CONFIG_H_
#define _TUSB_TUSB_CONFIG_H_ #define _TUSB_TUSB_CONFIG_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CONTROLLER CONFIGURATION // CONTROLLER CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_HOST) #define TUSB_CFG_CONTROLLER_0_MODE (TUSB_MODE_HOST)
#define TUSB_CFG_CONTROLLER1_MODE (TUSB_MODE_NONE) #define TUSB_CFG_CONTROLLER_1_MODE (TUSB_MODE_NONE)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// HOST CONFIGURATION // HOST CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_HOST_DEVICE_MAX 2 #define TUSB_CFG_HOST_DEVICE_MAX 2
#define TUSB_CFG_CONFIGURATION_MAX 1 #define TUSB_CFG_CONFIGURATION_MAX 1
//------------- USBD -------------// //------------- USBD -------------//
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256 #define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 0 #define TUSB_CFG_HOST_HUB 0
#define TUSB_CFG_HOST_HID_KEYBOARD 0 #define TUSB_CFG_HOST_HID_KEYBOARD 0
#define TUSB_CFG_HOST_HID_MOUSE 0 #define TUSB_CFG_HOST_HID_MOUSE 0
#define TUSB_CFG_HOST_HID_GENERIC 0 #define TUSB_CFG_HOST_HID_GENERIC 0
#define TUSB_CFG_HOST_MSC 0 #define TUSB_CFG_HOST_MSC 0
#define TUSB_CFG_HOST_CUSTOM_CLASS 1 #define TUSB_CFG_HOST_CUSTOM_CLASS 1
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// DEVICE CONFIGURATION // DEVICE CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
//#define TUSB_CFG_DEVICE //#define TUSB_CFG_DEVICE
//------------- CORE/CONTROLLER -------------// //------------- CORE/CONTROLLER -------------//
//------------- CLASS -------------// //------------- CLASS -------------//
//#define TUSB_CFG_DEVICE_CDC //#define TUSB_CFG_DEVICE_CDC
//#define TUSB_CFG_DEVICE_HID_KEYBOARD 1 //#define TUSB_CFG_DEVICE_HID_KEYBOARD 1
//#define TUSB_CFG_DEVICE_HID_MOUSE 1 //#define TUSB_CFG_DEVICE_HID_MOUSE 1
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// COMMON CONFIGURATION // COMMON CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_DEBUG 3 #define TUSB_CFG_DEBUG 3
//#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build //#define TUSB_CFG_OS TUSB_OS_NONE // defined using eclipse build
//#define TUSB_CFG_OS_TASK_PRIO //#define TUSB_CFG_OS_TASK_PRIO
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000 #define TUSB_CFG_OS_TICKS_PER_SECOND 1000
#ifdef __CODE_RED // make use of code red's support for ram region macros #ifdef __CODE_RED // make use of code red's support for ram region macros
#if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX) #if (MCU == MCU_LPC11UXX) || (MCU == MCU_LPC13UXX)
#define TUSB_RAM_SECTION ".data.$RAM2" #define TUSB_RAM_SECTION ".data.$RAM2"
#elif (MCU == MCU_LPC43XX) #elif (MCU == MCU_LPC43XX)
#define TUSB_RAM_SECTION ".data.$RAM3" #define TUSB_RAM_SECTION ".data.$RAM3"
#endif #endif
#define TUSB_CFG_ATTR_USBRAM __attribute__ ((section(TUSB_RAM_SECTION))) #define TUSB_CFG_ATTR_USBRAM __attribute__ ((section(TUSB_RAM_SECTION)))
#elif defined __CC_ARM // Compiled with Keil armcc #elif defined __CC_ARM // Compiled with Keil armcc
#define TUSB_CFG_ATTR_USBRAM #define TUSB_CFG_ATTR_USBRAM
#else #else
#error compiler not specified #error compiler not specified
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _TUSB_TUSB_CONFIG_H_ */ #endif /* _TUSB_TUSB_CONFIG_H_ */
/** @} */ /** @} */
+23 -23
View File
@@ -458,10 +458,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>25</ColumnNumber> <ColumnNumber>11</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>156</TopLine> <TopLine>144</TopLine>
<CurrentLine>160</CurrentLine> <CurrentLine>152</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\main.c</PathWithFileName> <PathWithFileName>..\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath> <FilenameWithoutPath>main.c</FilenameWithoutPath>
@@ -554,10 +554,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>18</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>226</TopLine> <TopLine>242</TopLine>
<CurrentLine>237</CurrentLine> <CurrentLine>250</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\cli.c</PathWithFileName> <PathWithFileName>..\src\cli.c</PathWithFileName>
<FilenameWithoutPath>cli.c</FilenameWithoutPath> <FilenameWithoutPath>cli.c</FilenameWithoutPath>
@@ -812,7 +812,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>357</TopLine> <TopLine>359</TopLine>
<CurrentLine>362</CurrentLine> <CurrentLine>362</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
@@ -828,8 +828,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>276</TopLine>
<CurrentLine>1</CurrentLine> <CurrentLine>284</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName>
<FilenameWithoutPath>ehci.c</FilenameWithoutPath> <FilenameWithoutPath>ehci.c</FilenameWithoutPath>
@@ -874,10 +874,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>40</ColumnNumber> <ColumnNumber>26</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine> <TopLine>61</TopLine>
<CurrentLine>0</CurrentLine> <CurrentLine>69</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\hal\hal_lpc43xx.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\hal\hal_lpc43xx.c</PathWithFileName>
<FilenameWithoutPath>hal_lpc43xx.c</FilenameWithoutPath> <FilenameWithoutPath>hal_lpc43xx.c</FilenameWithoutPath>
@@ -908,8 +908,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine> <TopLine>1</TopLine>
<CurrentLine>0</CurrentLine> <CurrentLine>9</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\common\errors.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\common\errors.c</PathWithFileName>
<FilenameWithoutPath>errors.c</FilenameWithoutPath> <FilenameWithoutPath>errors.c</FilenameWithoutPath>
@@ -1060,7 +1060,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>3</ColumnNumber> <ColumnNumber>3</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>577</TopLine> <TopLine>579</TopLine>
<CurrentLine>580</CurrentLine> <CurrentLine>580</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_cgu.c</PathWithFileName> <PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_cgu.c</PathWithFileName>
@@ -1116,7 +1116,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>19</ColumnNumber> <ColumnNumber>19</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>147</TopLine> <TopLine>149</TopLine>
<CurrentLine>152</CurrentLine> <CurrentLine>152</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName> <PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
@@ -1128,7 +1128,7 @@
<Group> <Group>
<GroupName>fatfs</GroupName> <GroupName>fatfs</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@@ -1140,7 +1140,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>47</ColumnNumber> <ColumnNumber>47</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>50</TopLine> <TopLine>51</TopLine>
<CurrentLine>59</CurrentLine> <CurrentLine>59</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName> <PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName>
@@ -1154,10 +1154,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>12</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>91</TopLine> <TopLine>1705</TopLine>
<CurrentLine>97</CurrentLine> <CurrentLine>1713</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\vendor\fatfs\ff.c</PathWithFileName> <PathWithFileName>..\..\..\vendor\fatfs\ff.c</PathWithFileName>
<FilenameWithoutPath>ff.c</FilenameWithoutPath> <FilenameWithoutPath>ff.c</FilenameWithoutPath>
@@ -1172,8 +1172,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine> <TopLine>1</TopLine>
<CurrentLine>0</CurrentLine> <CurrentLine>1</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\vendor\fatfs\ccsbcs.c</PathWithFileName> <PathWithFileName>..\..\..\vendor\fatfs\ccsbcs.c</PathWithFileName>
<FilenameWithoutPath>ccsbcs.c</FilenameWithoutPath> <FilenameWithoutPath>ccsbcs.c</FilenameWithoutPath>
+2 -5
View File
@@ -59,8 +59,8 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CONTROLLER CONFIGURATION // CONTROLLER CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_HOST) #define TUSB_CFG_CONTROLLER_0_MODE (TUSB_MODE_HOST)
#define TUSB_CFG_CONTROLLER1_MODE (TUSB_MODE_NONE) #define TUSB_CFG_CONTROLLER_1_MODE (TUSB_MODE_NONE)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// HOST CONFIGURATION // HOST CONFIGURATION
@@ -83,9 +83,6 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// DEVICE CONFIGURATION // DEVICE CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
//#define TUSB_CFG_DEVICE
//------------- CORE/CONTROLLER -------------//
//------------- CLASS -------------// //------------- CLASS -------------//
//#define TUSB_CFG_DEVICE_CDC //#define TUSB_CFG_DEVICE_CDC
+5 -5
View File
@@ -78,16 +78,16 @@
<type>2</type> <type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/demos</locationURI> <locationURI>PARENT-1-PROJECT_LOC/demos</locationURI>
</link> </link>
<link>
<name>doxygen.Doxyfile</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/doxygen.Doxyfile</locationURI>
</link>
<link> <link>
<name>tinyusb</name> <name>tinyusb</name>
<type>2</type> <type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/tinyusb</locationURI> <locationURI>PARENT-1-PROJECT_LOC/tinyusb</locationURI>
</link> </link>
<link>
<name>tinyusb.Doxyfile</name>
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/tinyusb.Doxyfile</locationURI>
</link>
</linkedResources> </linkedResources>
<filteredResources> <filteredResources>
<filter> <filter>
+131 -131
View File
@@ -1,131 +1,131 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file tusb_config.h @file tusb_config.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \file /** \file
* \brief TBD * \brief TBD
* *
* \note TBD * \note TBD
*/ */
/** \ingroup TBD /** \ingroup TBD
* \defgroup TBD * \defgroup TBD
* \brief TBD * \brief TBD
* *
* @{ * @{
*/ */
#ifndef _TUSB_TUSB_CONFIG_H_ #ifndef _TUSB_TUSB_CONFIG_H_
#define _TUSB_TUSB_CONFIG_H_ #define _TUSB_TUSB_CONFIG_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CONTROLLER CONFIGURATION // CONTROLLER CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_CONTROLLER0_MODE (TUSB_MODE_HOST | TUSB_MODE_DEVICE) #define TUSB_CFG_CONTROLLER_0_MODE (TUSB_MODE_HOST | TUSB_MODE_DEVICE)
#define TUSB_CFG_CONTROLLER1_MODE (TUSB_MODE_NONE) #define TUSB_CFG_CONTROLLER_1_MODE (TUSB_MODE_NONE)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// HOST CONFIGURATION // HOST CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
//------------- CORE -------------// //------------- CORE -------------//
#define TUSB_CFG_HOST_DEVICE_MAX 2 #define TUSB_CFG_HOST_DEVICE_MAX 2
#define TUSB_CFG_CONFIGURATION_MAX 1 #define TUSB_CFG_CONFIGURATION_MAX 1
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255 #define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 1 #define TUSB_CFG_HOST_HUB 1
#define TUSB_CFG_HOST_HID_KEYBOARD 1 #define TUSB_CFG_HOST_HID_KEYBOARD 1
#define TUSB_CFG_HOST_HID_MOUSE 1 #define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_MSC 1 #define TUSB_CFG_HOST_MSC 1
#define TUSB_CFG_HOST_CDC 1 #define TUSB_CFG_HOST_CDC 1
#define TUSB_CFG_HOST_CDC_RNDIS 1 #define TUSB_CFG_HOST_CDC_RNDIS 1
#define HOST_HCD_XFER_INTERRUPT #define HOST_HCD_XFER_INTERRUPT
#define HOST_HCD_XFER_BULK #define HOST_HCD_XFER_BULK
//#define HOST_HCD_XFER_ISOCHRONOUS //#define HOST_HCD_XFER_ISOCHRONOUS
// Test support // Test support
#define TEST_CONTROLLER_HOST_START_INDEX \ #define TEST_CONTROLLER_HOST_START_INDEX \
( ((CONTROLLER_HOST_NUMBER == 1) && (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)) ? 1 : 0) ( ((CONTROLLER_HOST_NUMBER == 1) && (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_HOST)) ? 1 : 0)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// DEVICE CONFIGURATION // DEVICE CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_DEVICE_USE_ROM_DRIVER 1 #define TUSB_CFG_DEVICE_USE_ROM_DRIVER 1
//------------- descriptors -------------// //------------- descriptors -------------//
#define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyusb.org" #define TUSB_CFG_DEVICE_STRING_MANUFACTURER "tinyusb.org"
#define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Example" #define TUSB_CFG_DEVICE_STRING_PRODUCT "Device Example"
#define TUSB_CFG_DEVICE_STRING_SERIAL "1234" #define TUSB_CFG_DEVICE_STRING_SERIAL "1234"
#define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP #define TUSB_CFG_DEVICE_VENDORID 0x1FC9 // NXP
//#define TUSB_CFG_DEVICE_PRODUCTID 0x4567 //#define TUSB_CFG_DEVICE_PRODUCTID 0x4567
#define TUSB_CFG_DEVICE_CONTROL_PACKET_SIZE 64 #define TUSB_CFG_DEVICE_CONTROL_PACKET_SIZE 64
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_DEVICE_HID_KEYBOARD 1 #define TUSB_CFG_DEVICE_HID_KEYBOARD 1
#define TUSB_CFG_DEVICE_HID_MOUSE 1 #define TUSB_CFG_DEVICE_HID_MOUSE 1
#define TUSB_CFG_DEVICE_HID_GENERIC 0 #define TUSB_CFG_DEVICE_HID_GENERIC 0
#define TUSB_CFG_DEVICE_MSC 0 #define TUSB_CFG_DEVICE_MSC 0
#define TUSB_CFG_DEVICE_CDC 0 #define TUSB_CFG_DEVICE_CDC 0
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// COMMON CONFIGURATION // COMMON CONFIGURATION
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#define TUSB_CFG_DEBUG 3 #define TUSB_CFG_DEBUG 3
#define TUSB_CFG_OS TUSB_OS_NONE #define TUSB_CFG_OS TUSB_OS_NONE
#define TUSB_CFG_OS_TICKS_PER_SECOND 1000 // 1 ms tick #define TUSB_CFG_OS_TICKS_PER_SECOND 1000 // 1 ms tick
#define TUSB_CFG_ATTR_USBRAM #define TUSB_CFG_ATTR_USBRAM
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#define RANDOM(n) (rand()%(n)) #define RANDOM(n) (rand()%(n))
#endif /* _TUSB_TUSB_CONFIG_H_ */ #endif /* _TUSB_TUSB_CONFIG_H_ */
/** @} */ /** @} */
+343 -343
View File
@@ -1,343 +1,343 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file cdc.h @file cdc.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \file /** \file
* \brief CDC Class Driver * \brief CDC Class Driver
* *
* \note TBD * \note TBD
*/ */
/** /**
* \addtogroup Group_ClassDriver Class Driver * \addtogroup ClassDriver Class Driver
* @{ * @{
* \defgroup Group_CDC Communication Device Class * \defgroup ClassDriver_CDC Communication Device Class
* @{ * @{
*/ */
#ifndef _TUSB_CDC_H__ #ifndef _TUSB_CDC_H__
#define _TUSB_CDC_H__ #define _TUSB_CDC_H__
#include "common/common.h" #include "common/common.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CDC COMMUNICATION INTERFACE CLASS // CDC COMMUNICATION INTERFACE CLASS
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
enum { enum {
CDC_COMM_SUBCLASS_DIRECT_LINE_CONTROL_MODEL = 0x01 , CDC_COMM_SUBCLASS_DIRECT_LINE_CONTROL_MODEL = 0x01 ,
CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL , CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL ,
CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL , CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL ,
CDC_COMM_SUBCLASS_MULTICHANNEL_CONTROL_MODEL , CDC_COMM_SUBCLASS_MULTICHANNEL_CONTROL_MODEL ,
CDC_COMM_SUBCLASS_CAPI_CONTROL_MODEL , CDC_COMM_SUBCLASS_CAPI_CONTROL_MODEL ,
CDC_COMM_SUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL , CDC_COMM_SUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL ,
CDC_COMM_SUBCLASS_ATM_NETWORKING_CONTROL_MODEL , CDC_COMM_SUBCLASS_ATM_NETWORKING_CONTROL_MODEL ,
CDC_COMM_SUBCLASS_WIRELESS_HANDSET_CONTROL_MODEL , CDC_COMM_SUBCLASS_WIRELESS_HANDSET_CONTROL_MODEL ,
CDC_COMM_SUBCLASS_DEVICE_MANAGEMENT , CDC_COMM_SUBCLASS_DEVICE_MANAGEMENT ,
CDC_COMM_SUBCLASS_MOBILE_DIRECT_LINE_MODEL , CDC_COMM_SUBCLASS_MOBILE_DIRECT_LINE_MODEL ,
CDC_COMM_SUBCLASS_OBEX , CDC_COMM_SUBCLASS_OBEX ,
CDC_COMM_SUBCLASS_ETHERNET_EMULATION_MODEL CDC_COMM_SUBCLASS_ETHERNET_EMULATION_MODEL
}; };
enum { enum {
CDC_COMM_PROTOCOL_ATCOMMAND = 0x01 , // ITU-T V2.50 CDC_COMM_PROTOCOL_ATCOMMAND = 0x01 , // ITU-T V2.50
CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101 , CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101 ,
CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101_AND_ANNEXO , CDC_COMM_PROTOCOL_ATCOMMAND_PCCA_101_AND_ANNEXO ,
CDC_COMM_PROTOCOL_ATCOMMAND_GSM_707 , CDC_COMM_PROTOCOL_ATCOMMAND_GSM_707 ,
CDC_COMM_PROTOCOL_ATCOMMAND_3GPP_27007 , CDC_COMM_PROTOCOL_ATCOMMAND_3GPP_27007 ,
CDC_COMM_PROTOCOL_ATCOMMAND_CDMA , // defined by TIA CDC_COMM_PROTOCOL_ATCOMMAND_CDMA , // defined by TIA
CDC_COMM_PROTOCOL_ETHERNET_EMULATION_MODEL CDC_COMM_PROTOCOL_ETHERNET_EMULATION_MODEL
}; };
//------------- SubType Descriptor in COMM Functional Descriptor -------------// //------------- SubType Descriptor in COMM Functional Descriptor -------------//
enum { enum {
CDC_FUNC_DESC_HEADER = 0x00 , CDC_FUNC_DESC_HEADER = 0x00 ,
CDC_FUNC_DESC_CALL_MANAGEMENT = 0x01 , CDC_FUNC_DESC_CALL_MANAGEMENT = 0x01 ,
CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT = 0x02 , CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT = 0x02 ,
CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT = 0x03 , CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT = 0x03 ,
CDC_FUNC_DESC_TELEPHONE_RINGER = 0x04 , CDC_FUNC_DESC_TELEPHONE_RINGER = 0x04 ,
CDC_FUNC_DESC_TELEPHONE_CALL_AND_LINE_STATE_REPORTING_CAPACITY = 0x05 , CDC_FUNC_DESC_TELEPHONE_CALL_AND_LINE_STATE_REPORTING_CAPACITY = 0x05 ,
CDC_FUNC_DESC_UNION = 0x06 , CDC_FUNC_DESC_UNION = 0x06 ,
CDC_FUNC_DESC_COUNTRY_SELECTION = 0x07 , CDC_FUNC_DESC_COUNTRY_SELECTION = 0x07 ,
CDC_FUNC_DESC_TELEPHONE_OPERATIONAL_MODES = 0x08 , CDC_FUNC_DESC_TELEPHONE_OPERATIONAL_MODES = 0x08 ,
CDC_FUNC_DESC_USB_TERMINAL = 0x09 , CDC_FUNC_DESC_USB_TERMINAL = 0x09 ,
CDC_FUNC_DESC_NETWORK_CHANNEL_TERMINAL = 0x0A , CDC_FUNC_DESC_NETWORK_CHANNEL_TERMINAL = 0x0A ,
CDC_FUNC_DESC_PROTOCOL_UNIT = 0x0B , CDC_FUNC_DESC_PROTOCOL_UNIT = 0x0B ,
CDC_FUNC_DESC_EXTENSION_UNIT = 0x0C , CDC_FUNC_DESC_EXTENSION_UNIT = 0x0C ,
CDC_FUNC_DESC_MULTICHANEL_MANAGEMENT = 0x0D , CDC_FUNC_DESC_MULTICHANEL_MANAGEMENT = 0x0D ,
CDC_FUNC_DESC_CAPI_CONTROL_MANAGEMENT = 0x0E , CDC_FUNC_DESC_CAPI_CONTROL_MANAGEMENT = 0x0E ,
CDC_FUNC_DESC_ETHERNET_NETWORKING = 0x0F , CDC_FUNC_DESC_ETHERNET_NETWORKING = 0x0F ,
CDC_FUNC_DESC_ATM_NETWORKING = 0x10 , CDC_FUNC_DESC_ATM_NETWORKING = 0x10 ,
CDC_FUNC_DESC_WIRELESS_HANDSET_CONTROL_MODEL = 0x11 , CDC_FUNC_DESC_WIRELESS_HANDSET_CONTROL_MODEL = 0x11 ,
CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL = 0x12 , CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL = 0x12 ,
CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL_DETAIL = 0x13 , CDC_FUNC_DESC_MOBILE_DIRECT_LINE_MODEL_DETAIL = 0x13 ,
CDC_FUNC_DESC_DEVICE_MANAGEMENT_MODEL = 0x14 , CDC_FUNC_DESC_DEVICE_MANAGEMENT_MODEL = 0x14 ,
CDC_FUNC_DESC_OBEX = 0x15 , CDC_FUNC_DESC_OBEX = 0x15 ,
CDC_FUNC_DESC_COMMAND_SET = 0x16 , CDC_FUNC_DESC_COMMAND_SET = 0x16 ,
CDC_FUNC_DESC_COMMAND_SET_DETAIL = 0x17 , CDC_FUNC_DESC_COMMAND_SET_DETAIL = 0x17 ,
CDC_FUNC_DESC_TELEPHONE_CONTROL_MODEL = 0x18 , CDC_FUNC_DESC_TELEPHONE_CONTROL_MODEL = 0x18 ,
CDC_FUNC_DESC_OBEX_SERVICE_IDENTIFIER = 0x19 CDC_FUNC_DESC_OBEX_SERVICE_IDENTIFIER = 0x19
}; };
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CDC DATA INTERFACE CLASS // CDC DATA INTERFACE CLASS
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// SUBCLASS code of Data Interface is not used and should/must be zero // SUBCLASS code of Data Interface is not used and should/must be zero
enum{ enum{
CDC_DATA_PROTOCOL_ISDN_BRI = 0x30, CDC_DATA_PROTOCOL_ISDN_BRI = 0x30,
CDC_DATA_PROTOCOL_HDLC = 0x31, CDC_DATA_PROTOCOL_HDLC = 0x31,
CDC_DATA_PROTOCOL_TRANSPARENT = 0x32, CDC_DATA_PROTOCOL_TRANSPARENT = 0x32,
CDC_DATA_PROTOCOL_Q921_MANAGEMENT = 0x50, CDC_DATA_PROTOCOL_Q921_MANAGEMENT = 0x50,
CDC_DATA_PROTOCOL_Q921_DATA_LINK = 0x51, CDC_DATA_PROTOCOL_Q921_DATA_LINK = 0x51,
CDC_DATA_PROTOCOL_Q921_TEI_MULTIPLEXOR = 0x52, CDC_DATA_PROTOCOL_Q921_TEI_MULTIPLEXOR = 0x52,
CDC_DATA_PROTOCOL_V42BIS_DATA_COMPRESSION = 0x90, CDC_DATA_PROTOCOL_V42BIS_DATA_COMPRESSION = 0x90,
CDC_DATA_PROTOCOL_EURO_ISDN = 0x91, CDC_DATA_PROTOCOL_EURO_ISDN = 0x91,
CDC_DATA_PROTOCOL_V24_RATE_ADAPTION_TO_ISDN = 0x92, CDC_DATA_PROTOCOL_V24_RATE_ADAPTION_TO_ISDN = 0x92,
CDC_DATA_PROTOCOL_CAPI_COMMAND = 0x93, CDC_DATA_PROTOCOL_CAPI_COMMAND = 0x93,
CDC_DATA_PROTOCOL_HOST_BASED_DRIVER = 0xFD, CDC_DATA_PROTOCOL_HOST_BASED_DRIVER = 0xFD,
CDC_DATA_PROTOCOL_IN_PROTOCOL_UNIT_FUNCTIONAL_DESCRIPTOR = 0xFE CDC_DATA_PROTOCOL_IN_PROTOCOL_UNIT_FUNCTIONAL_DESCRIPTOR = 0xFE
}; };
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MANAGEMENT ELEMENT REQUEST (CONTROL ENDPOINT) // MANAGEMENT ELEMENT REQUEST (CONTROL ENDPOINT)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
typedef enum { typedef enum {
SEND_ENCAPSULATED_COMMAND = 0x00, SEND_ENCAPSULATED_COMMAND = 0x00,
GET_ENCAPSULATED_RESPONSE = 0x01, GET_ENCAPSULATED_RESPONSE = 0x01,
SET_COMM_FEATURE = 0x02, SET_COMM_FEATURE = 0x02,
GET_COMM_FEATURE = 0x03, GET_COMM_FEATURE = 0x03,
CLEAR_COMM_FEATURE = 0x04, CLEAR_COMM_FEATURE = 0x04,
SET_AUX_LINE_STATE = 0x10, SET_AUX_LINE_STATE = 0x10,
SET_HOOK_STATE = 0x11, SET_HOOK_STATE = 0x11,
PULSE_SETUP = 0x12, PULSE_SETUP = 0x12,
SEND_PULSE = 0x13, SEND_PULSE = 0x13,
SET_PULSE_TIME = 0x14, SET_PULSE_TIME = 0x14,
RING_AUX_JACK = 0x15, RING_AUX_JACK = 0x15,
SET_LINE_CODING = 0x20, SET_LINE_CODING = 0x20,
GET_LINE_CODING = 0x21, GET_LINE_CODING = 0x21,
SET_CONTROL_LINE_STATE = 0x22, SET_CONTROL_LINE_STATE = 0x22,
SEND_BREAK = 0x23, SEND_BREAK = 0x23,
SET_RINGER_PARMS = 0x30, SET_RINGER_PARMS = 0x30,
GET_RINGER_PARMS = 0x31, GET_RINGER_PARMS = 0x31,
SET_OPERATION_PARMS = 0x32, SET_OPERATION_PARMS = 0x32,
GET_OPERATION_PARMS = 0x33, GET_OPERATION_PARMS = 0x33,
SET_LINE_PARMS = 0x34, SET_LINE_PARMS = 0x34,
GET_LINE_PARMS = 0x35, GET_LINE_PARMS = 0x35,
DIAL_DIGITS = 0x36, DIAL_DIGITS = 0x36,
SET_UNIT_PARAMETER = 0x37, SET_UNIT_PARAMETER = 0x37,
GET_UNIT_PARAMETER = 0x38, GET_UNIT_PARAMETER = 0x38,
CLEAR_UNIT_PARAMETER = 0x39, CLEAR_UNIT_PARAMETER = 0x39,
GET_PROFILE = 0x3A, GET_PROFILE = 0x3A,
SET_ETHERNET_MULTICAST_FILTERS = 0x40, SET_ETHERNET_MULTICAST_FILTERS = 0x40,
SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x41, SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x41,
GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x42, GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER = 0x42,
SET_ETHERNET_PACKET_FILTER = 0x43, SET_ETHERNET_PACKET_FILTER = 0x43,
GET_ETHERNET_STATISTIC = 0x44, GET_ETHERNET_STATISTIC = 0x44,
SET_ATM_DATA_FORMAT = 0x50, SET_ATM_DATA_FORMAT = 0x50,
GET_ATM_DEVICE_STATISTICS = 0x51, GET_ATM_DEVICE_STATISTICS = 0x51,
SET_ATM_DEFAULT_VC = 0x52, SET_ATM_DEFAULT_VC = 0x52,
GET_ATM_VC_STATISTICS = 0x53, GET_ATM_VC_STATISTICS = 0x53,
MDLM_SEMANTIC_MODEL = 0x60, MDLM_SEMANTIC_MODEL = 0x60,
}cdc_management_request_t; }cdc_management_request_t;
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MANAGEMENT ELEMENENT NOTIFICATION (NOTIFICATION ENDPOINT) // MANAGEMENT ELEMENENT NOTIFICATION (NOTIFICATION ENDPOINT)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
typedef enum { typedef enum {
NETWORK_CONNECTION = 0x00, NETWORK_CONNECTION = 0x00,
RESPONSE_AVAILABLE = 0x01, RESPONSE_AVAILABLE = 0x01,
AUX_JACK_HOOK_STATE = 0x08, AUX_JACK_HOOK_STATE = 0x08,
RING_DETECT = 0x09, RING_DETECT = 0x09,
SERIAL_STATE = 0x20, SERIAL_STATE = 0x20,
CALL_STATE_CHANGE = 0x28, CALL_STATE_CHANGE = 0x28,
LINE_STATE_CHANGE = 0x29, LINE_STATE_CHANGE = 0x29,
CONNECTION_SPEED_CHANGE = 0x2A, CONNECTION_SPEED_CHANGE = 0x2A,
MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40, MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40,
}cdc_notification_request_t; }cdc_notification_request_t;
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// FUNCTIONAL DESCRIPTOR // FUNCTIONAL DESCRIPTOR
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
}cdc_desc_func_header_t; }cdc_desc_func_header_t;
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
uint8_t bControlInterface ; ///< Interface number of Communication Interface uint8_t bControlInterface ; ///< Interface number of Communication Interface
uint8_t bSubordinateInterface ; ///< Array of Interface number of Data Interface uint8_t bSubordinateInterface ; ///< Array of Interface number of Data Interface
}cdc_desc_func_union_t; }cdc_desc_func_union_t;
#define cdc_desc_func_union_n_t(no_slave)\ #define cdc_desc_func_union_n_t(no_slave)\
ATTR_PACKED_STRUCT(struct) { \ ATTR_PACKED_STRUCT(struct) { \
uint8_t bLength ;\ uint8_t bLength ;\
uint8_t bDescriptorType ;\ uint8_t bDescriptorType ;\
uint8_t bDescriptorSubType ;\ uint8_t bDescriptorSubType ;\
uint8_t bControlInterface ;\ uint8_t bControlInterface ;\
uint8_t bSubordinateInterface[no_slave] ;\ uint8_t bSubordinateInterface[no_slave] ;\
} }
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes. uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes.
uint16_t wCountryCode[] ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country. uint16_t wCountryCode[] ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
}cdc_desc_func_country_selection_t; }cdc_desc_func_country_selection_t;
#define cdc_desc_func_country_selection_n_t(no_country) \ #define cdc_desc_func_country_selection_n_t(no_country) \
ATTR_PACKED_STRUCT(struct) {\ ATTR_PACKED_STRUCT(struct) {\
uint8_t bLength ;\ uint8_t bLength ;\
uint8_t bDescriptorType ;\ uint8_t bDescriptorType ;\
uint8_t bDescriptorSubType ;\ uint8_t bDescriptorSubType ;\
uint8_t iCountryCodeRelDate ;\ uint8_t iCountryCodeRelDate ;\
uint16_t wCountryCode[no_country] ;\ uint16_t wCountryCode[no_country] ;\
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// PUBLIC SWITCHED TELEPHONE NETWORK (PSTN) SUBCLASS // PUBLIC SWITCHED TELEPHONE NETWORK (PSTN) SUBCLASS
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
struct { struct {
uint8_t handle_call : 1; ///< 0 - Device sends/receives call management information only over the Communications Class interface. 1 - Device can send/receive call management information over a Data Class interface. uint8_t handle_call : 1; ///< 0 - Device sends/receives call management information only over the Communications Class interface. 1 - Device can send/receive call management information over a Data Class interface.
uint8_t send_recv_call : 1; ///< 0 - Device does not handle call management itself. 1 - Device handles call management itself. uint8_t send_recv_call : 1; ///< 0 - Device does not handle call management itself. 1 - Device handles call management itself.
uint8_t : 0; uint8_t : 0;
} bmCapabilities; } bmCapabilities;
uint8_t bDataInterface; uint8_t bDataInterface;
}cdc_desc_func_call_management_t; }cdc_desc_func_call_management_t;
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature. uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State. uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
uint8_t support_send_break : 1; ///< Device supports the request Send_Break uint8_t support_send_break : 1; ///< Device supports the request Send_Break
uint8_t support_notification_network_connection : 1; ///< Device supports the notification Network_Connection. uint8_t support_notification_network_connection : 1; ///< Device supports the notification Network_Connection.
uint8_t : 0; uint8_t : 0;
}cdc_acm_capability_t; }cdc_acm_capability_t;
STATIC_ASSERT(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler"); STATIC_ASSERT(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compiler");
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
cdc_acm_capability_t bmCapabilities ; cdc_acm_capability_t bmCapabilities ;
}cdc_desc_func_abstract_control_management_t; }cdc_desc_func_abstract_control_management_t;
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
struct { struct {
uint8_t require_pulse_setup : 1; ///< Device requires extra Pulse_Setup request during pulse dialing sequence to disengage holding circuit. uint8_t require_pulse_setup : 1; ///< Device requires extra Pulse_Setup request during pulse dialing sequence to disengage holding circuit.
uint8_t support_aux_request : 1; ///< Device supports the request combination of Set_Aux_Line_State, Ring_Aux_Jack, and notification Aux_Jack_Hook_State. uint8_t support_aux_request : 1; ///< Device supports the request combination of Set_Aux_Line_State, Ring_Aux_Jack, and notification Aux_Jack_Hook_State.
uint8_t support_pulse_request : 1; ///< Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time. uint8_t support_pulse_request : 1; ///< Device supports the request combination of Pulse_Setup, Send_Pulse, and Set_Pulse_Time.
uint8_t : 0; uint8_t : 0;
} bmCapabilities; } bmCapabilities;
}cdc_desc_func_direct_line_management_t; }cdc_desc_func_direct_line_management_t;
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
uint8_t bRingerVolSteps ; uint8_t bRingerVolSteps ;
uint8_t bNumRingerPatterns ; uint8_t bNumRingerPatterns ;
}cdc_desc_func_telephone_ringer_t; }cdc_desc_func_telephone_ringer_t;
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
struct { struct {
uint8_t simple_mode : 1; uint8_t simple_mode : 1;
uint8_t standalone_mode : 1; uint8_t standalone_mode : 1;
uint8_t computer_centric_mode : 1; uint8_t computer_centric_mode : 1;
uint8_t : 0; uint8_t : 0;
} bmCapabilities; } bmCapabilities;
}cdc_desc_func_telephone_operational_modes_t; }cdc_desc_func_telephone_operational_modes_t;
typedef ATTR_PACKED_STRUCT(struct) { typedef ATTR_PACKED_STRUCT(struct) {
uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bLength ; ///< Size of this descriptor in bytes.
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_ uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
struct { struct {
uint32_t interrupted_dialtone : 1; ///< 0 : Reports only dialtone (does not differentiate between normal and interrupted dialtone). 1 : Reports interrupted dialtone in addition to normal dialtone uint32_t interrupted_dialtone : 1; ///< 0 : Reports only dialtone (does not differentiate between normal and interrupted dialtone). 1 : Reports interrupted dialtone in addition to normal dialtone
uint32_t ringback_busy_fastbusy : 1; ///< 0 : Reports only dialing state. 1 : Reports ringback, busy, and fast busy states. uint32_t ringback_busy_fastbusy : 1; ///< 0 : Reports only dialing state. 1 : Reports ringback, busy, and fast busy states.
uint32_t caller_id : 1; ///< 0 : Does not report caller ID. 1 : Reports caller ID information. uint32_t caller_id : 1; ///< 0 : Does not report caller ID. 1 : Reports caller ID information.
uint32_t incoming_distinctive : 1; ///< 0 : Reports only incoming ringing. 1 : Reports incoming distinctive ringing patterns. uint32_t incoming_distinctive : 1; ///< 0 : Reports only incoming ringing. 1 : Reports incoming distinctive ringing patterns.
uint32_t dual_tone_multi_freq : 1; ///< 0 : Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 : Can report DTMF digits input remotely over the telephone line. uint32_t dual_tone_multi_freq : 1; ///< 0 : Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 : Can report DTMF digits input remotely over the telephone line.
uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification
uint32_t : 0; uint32_t : 0;
} bmCapabilities; } bmCapabilities;
}cdc_desc_func_telephone_call_state_reporting_capabilities_t; }cdc_desc_func_telephone_call_state_reporting_capabilities_t;
static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) ATTR_PURE ATTR_ALWAYS_INLINE; static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) ATTR_PURE ATTR_ALWAYS_INLINE;
static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
{ {
return p_desc[2]; return p_desc[2];
} }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif #endif
+505 -505
View File
File diff suppressed because it is too large Load Diff
+304 -304
View File
@@ -1,304 +1,304 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file hid_host.c @file hid_host.c
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
#include "tusb_option.h" #include "tusb_option.h"
#if (MODE_HOST_SUPPORTED && HOST_CLASS_HID) #if (MODE_HOST_SUPPORTED && HOST_CLASS_HID)
#define _TINY_USB_SOURCE_FILE_ #define _TINY_USB_SOURCE_FILE_
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// INCLUDE // INCLUDE
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#include "common/common.h" #include "common/common.h"
#include "hid_host.h" #include "hid_host.h"
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MACRO CONSTANT TYPEDEF // MACRO CONSTANT TYPEDEF
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// HID Interface common functions // HID Interface common functions
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE; static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid) static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid)
{ {
p_hid->pipe_hdl = hcd_pipe_open(dev_addr, p_endpoint_desc, TUSB_CLASS_HID); p_hid->pipe_hdl = hcd_pipe_open(dev_addr, p_endpoint_desc, TUSB_CLASS_HID);
p_hid->report_size = p_endpoint_desc->wMaxPacketSize.size; // TODO get size from report descriptor p_hid->report_size = p_endpoint_desc->wMaxPacketSize.size; // TODO get size from report descriptor
p_hid->interface_number = interface_number; p_hid->interface_number = interface_number;
ASSERT (pipehandle_is_valid(p_hid->pipe_hdl), TUSB_ERROR_HCD_FAILED); ASSERT (pipehandle_is_valid(p_hid->pipe_hdl), TUSB_ERROR_HCD_FAILED);
return TUSB_ERROR_NONE; return TUSB_ERROR_NONE;
} }
static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE; static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid) static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid)
{ {
(void) hcd_pipe_close(p_hid->pipe_hdl); (void) hcd_pipe_close(p_hid->pipe_hdl);
memclr_(p_hid, sizeof(hidh_interface_info_t)); memclr_(p_hid, sizeof(hidh_interface_info_t));
} }
// called from public API need to validate parameters // called from public API need to validate parameters
tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE; tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid) tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_interface_info_t *p_hid)
{ {
//------------- parameters validation -------------// //------------- parameters validation -------------//
// TODO change to use is configured function // TODO change to use is configured function
ASSERT_INT (TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY); ASSERT_INT (TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
ASSERT_PTR (report, TUSB_ERROR_INVALID_PARA); ASSERT_PTR (report, TUSB_ERROR_INVALID_PARA);
ASSERT_FALSE(hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY); ASSERT_FALSE(hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY);
ASSERT_STATUS( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ; ASSERT_STATUS( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
return TUSB_ERROR_NONE; return TUSB_ERROR_NONE;
} }
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// KEYBOARD // KEYBOARD
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#if TUSB_CFG_HOST_HID_KEYBOARD #if TUSB_CFG_HOST_HID_KEYBOARD
#define EXPAND_KEYCODE_TO_ASCII(keycode, ascii, shift_modified) \ #define EXPAND_KEYCODE_TO_ASCII(keycode, ascii, shift_modified) \
[0][keycode] = ascii,\ [0][keycode] = ascii,\
[1][keycode] = shift_modified,\ [1][keycode] = shift_modified,\
// TODO size of table should be a macro for application to check boundary // TODO size of table should be a macro for application to check boundary
uint8_t const hid_keycode_to_ascii_tbl[2][128] = uint8_t const hid_keycode_to_ascii_tbl[2][128] =
{ {
HID_KEYCODE_TABLE(EXPAND_KEYCODE_TO_ASCII) HID_KEYCODE_TABLE(EXPAND_KEYCODE_TO_ASCII)
}; };
STATIC_VAR hidh_interface_info_t keyboardh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1 STATIC_VAR hidh_interface_info_t keyboardh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
//------------- KEYBOARD PUBLIC API (parameter validation required) -------------// //------------- KEYBOARD PUBLIC API (parameter validation required) -------------//
bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr)
{ {
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboardh_data[dev_addr-1].pipe_hdl); return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboardh_data[dev_addr-1].pipe_hdl);
} }
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void* report) tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void* p_report)
{ {
return hidh_interface_get_report(dev_addr, report, &keyboardh_data[dev_addr-1]); return hidh_interface_get_report(dev_addr, p_report, &keyboardh_data[dev_addr-1]);
} }
bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr) bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr)
{ {
return tusbh_hid_keyboard_is_mounted(dev_addr) && return tusbh_hid_keyboard_is_mounted(dev_addr) &&
hcd_pipe_is_busy( keyboardh_data[dev_addr-1].pipe_hdl ); hcd_pipe_is_busy( keyboardh_data[dev_addr-1].pipe_hdl );
} }
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// MOUSE // MOUSE
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#if TUSB_CFG_HOST_HID_MOUSE #if TUSB_CFG_HOST_HID_MOUSE
STATIC_VAR hidh_interface_info_t mouseh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1 STATIC_VAR hidh_interface_info_t mouseh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
//------------- Public API -------------// //------------- Public API -------------//
bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr)
{ {
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouseh_data[dev_addr-1].pipe_hdl); return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouseh_data[dev_addr-1].pipe_hdl);
} }
bool tusbh_hid_mouse_is_busy(uint8_t dev_addr) bool tusbh_hid_mouse_is_busy(uint8_t dev_addr)
{ {
return tusbh_hid_mouse_is_mounted(dev_addr) && return tusbh_hid_mouse_is_mounted(dev_addr) &&
hcd_pipe_is_busy( mouseh_data[dev_addr-1].pipe_hdl ); hcd_pipe_is_busy( mouseh_data[dev_addr-1].pipe_hdl );
} }
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void * report) tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void * report)
{ {
return hidh_interface_get_report(dev_addr, report, &mouseh_data[dev_addr-1]); return hidh_interface_get_report(dev_addr, report, &mouseh_data[dev_addr-1]);
} }
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// GENERIC // GENERIC
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#if TUSB_CFG_HOST_HID_GENERIC #if TUSB_CFG_HOST_HID_GENERIC
//STATIC_ struct { //STATIC_ struct {
// hidh_interface_info_t // hidh_interface_info_t
//} generic_data[TUSB_CFG_HOST_DEVICE_MAX]; //} generic_data[TUSB_CFG_HOST_DEVICE_MAX];
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CLASS-USBH API (don't require to verify parameters) // CLASS-USBH API (don't require to verify parameters)
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void hidh_init(void) void hidh_init(void)
{ {
#if TUSB_CFG_HOST_HID_KEYBOARD #if TUSB_CFG_HOST_HID_KEYBOARD
memclr_(&keyboardh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX); memclr_(&keyboardh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
#endif #endif
#if TUSB_CFG_HOST_HID_MOUSE #if TUSB_CFG_HOST_HID_MOUSE
memclr_(&mouseh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX); memclr_(&mouseh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
#endif #endif
#if TUSB_CFG_HOST_HID_GENERIC #if TUSB_CFG_HOST_HID_GENERIC
hidh_generic_init(); hidh_generic_init();
#endif #endif
} }
#if 0 #if 0
uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM; uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM;
#endif #endif
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length)
{ {
tusb_error_t error; tusb_error_t error;
uint8_t const *p_desc = (uint8_t const *) p_interface_desc; uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
//------------- HID descriptor -------------// //------------- HID descriptor -------------//
p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH]; p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc; tusb_hid_descriptor_hid_t const *p_desc_hid = (tusb_hid_descriptor_hid_t const *) p_desc;
ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_INVALID_PARA); ASSERT_INT(HID_DESC_TYPE_HID, p_desc_hid->bDescriptorType, TUSB_ERROR_INVALID_PARA);
//------------- Endpoint Descriptor -------------// //------------- Endpoint Descriptor -------------//
p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH]; p_desc += p_desc[DESCRIPTOR_OFFSET_LENGTH];
tusb_descriptor_endpoint_t const * p_endpoint_desc = (tusb_descriptor_endpoint_t const *) p_desc; tusb_descriptor_endpoint_t const * p_endpoint_desc = (tusb_descriptor_endpoint_t const *) p_desc;
ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_endpoint_desc->bDescriptorType, TUSB_ERROR_INVALID_PARA); ASSERT_INT(TUSB_DESC_TYPE_ENDPOINT, p_endpoint_desc->bDescriptorType, TUSB_ERROR_INVALID_PARA);
OSAL_SUBTASK_BEGIN OSAL_SUBTASK_BEGIN
//------------- SET IDLE (0) request -------------// //------------- SET IDLE (0) request -------------//
OSAL_SUBTASK_INVOKED_AND_WAIT( OSAL_SUBTASK_INVOKED_AND_WAIT(
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE), usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE),
HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber, HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
0, NULL ), 0, NULL ),
error error
); );
#if 0 #if 0
//------------- Get Report Descriptor TODO HID parser -------------// //------------- Get Report Descriptor TODO HID parser -------------//
if ( p_desc_hid->bNumDescriptors ) if ( p_desc_hid->bNumDescriptors )
{ {
OSAL_SUBTASK_INVOKED_AND_WAIT( OSAL_SUBTASK_INVOKED_AND_WAIT(
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_INTERFACE), usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_INTERFACE),
TUSB_REQUEST_GET_DESCRIPTOR, (p_desc_hid->bReportType << 8), 0, TUSB_REQUEST_GET_DESCRIPTOR, (p_desc_hid->bReportType << 8), 0,
p_desc_hid->wReportLength, report_descriptor ), p_desc_hid->wReportLength, report_descriptor ),
error error
); );
// if error in getting report descriptor --> treating like there is none // if error in getting report descriptor --> treating like there is none
} }
#endif #endif
if ( HID_SUBCLASS_BOOT == p_interface_desc->bInterfaceSubClass ) if ( HID_SUBCLASS_BOOT == p_interface_desc->bInterfaceSubClass )
{ {
#if TUSB_CFG_HOST_HID_KEYBOARD #if TUSB_CFG_HOST_HID_KEYBOARD
if ( HID_PROTOCOL_KEYBOARD == p_interface_desc->bInterfaceProtocol) if ( HID_PROTOCOL_KEYBOARD == p_interface_desc->bInterfaceProtocol)
{ {
SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboardh_data[dev_addr-1]) ); SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboardh_data[dev_addr-1]) );
tusbh_hid_keyboard_mounted_cb(dev_addr); tusbh_hid_keyboard_mounted_cb(dev_addr);
} else } else
#endif #endif
#if TUSB_CFG_HOST_HID_MOUSE #if TUSB_CFG_HOST_HID_MOUSE
if ( HID_PROTOCOL_MOUSE == p_interface_desc->bInterfaceProtocol) if ( HID_PROTOCOL_MOUSE == p_interface_desc->bInterfaceProtocol)
{ {
SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouseh_data[dev_addr-1]) ); SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouseh_data[dev_addr-1]) );
tusbh_hid_mouse_mounted_cb(dev_addr); tusbh_hid_mouse_mounted_cb(dev_addr);
} else } else
#endif #endif
{ {
SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_PROTOCOL); // exit & restart task SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_PROTOCOL); // exit & restart task
} }
}else }else
{ {
SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_SUBCLASS); // exit & restart task SUBTASK_EXIT(TUSB_ERROR_HIDH_NOT_SUPPORTED_SUBCLASS); // exit & restart task
} }
*p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t); *p_length = sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t);
OSAL_SUBTASK_END OSAL_SUBTASK_END
} }
void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes)
{ {
#if TUSB_CFG_HOST_HID_KEYBOARD #if TUSB_CFG_HOST_HID_KEYBOARD
if ( pipehandle_is_equal(pipe_hdl, keyboardh_data[pipe_hdl.dev_addr-1].pipe_hdl) ) if ( pipehandle_is_equal(pipe_hdl, keyboardh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
{ {
tusbh_hid_keyboard_isr(pipe_hdl.dev_addr, event); tusbh_hid_keyboard_isr(pipe_hdl.dev_addr, event);
return; return;
} }
#endif #endif
#if TUSB_CFG_HOST_HID_MOUSE #if TUSB_CFG_HOST_HID_MOUSE
if ( pipehandle_is_equal(pipe_hdl, mouseh_data[pipe_hdl.dev_addr-1].pipe_hdl) ) if ( pipehandle_is_equal(pipe_hdl, mouseh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
{ {
tusbh_hid_mouse_isr(pipe_hdl.dev_addr, event); tusbh_hid_mouse_isr(pipe_hdl.dev_addr, event);
return; return;
} }
#endif #endif
#if TUSB_CFG_HOST_HID_GENERIC #if TUSB_CFG_HOST_HID_GENERIC
#endif #endif
} }
void hidh_close(uint8_t dev_addr) void hidh_close(uint8_t dev_addr)
{ {
#if TUSB_CFG_HOST_HID_KEYBOARD #if TUSB_CFG_HOST_HID_KEYBOARD
if ( pipehandle_is_valid( keyboardh_data[dev_addr-1].pipe_hdl ) ) if ( pipehandle_is_valid( keyboardh_data[dev_addr-1].pipe_hdl ) )
{ {
hidh_interface_close(dev_addr, &keyboardh_data[dev_addr-1]); hidh_interface_close(dev_addr, &keyboardh_data[dev_addr-1]);
tusbh_hid_keyboard_unmounted_cb(dev_addr); tusbh_hid_keyboard_unmounted_cb(dev_addr);
} }
#endif #endif
#if TUSB_CFG_HOST_HID_MOUSE #if TUSB_CFG_HOST_HID_MOUSE
if( pipehandle_is_valid( mouseh_data[dev_addr-1].pipe_hdl ) ) if( pipehandle_is_valid( mouseh_data[dev_addr-1].pipe_hdl ) )
{ {
hidh_interface_close(dev_addr, &mouseh_data[dev_addr-1]); hidh_interface_close(dev_addr, &mouseh_data[dev_addr-1]);
tusbh_hid_mouse_unmounted_cb( dev_addr ); tusbh_hid_mouse_unmounted_cb( dev_addr );
} }
#endif #endif
#if TUSB_CFG_HOST_HID_GENERIC #if TUSB_CFG_HOST_HID_GENERIC
hidh_generic_close(dev_addr); hidh_generic_close(dev_addr);
#endif #endif
} }
#endif #endif
+213 -119
View File
@@ -1,119 +1,213 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file hid_host.h @file hid_host.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \ingroup TBD /** \addtogroup ClassDriver_HID
* \defgroup TBD * @{ */
* \brief TBD
* #ifndef _TUSB_HID_HOST_H_
* @{ #define _TUSB_HID_HOST_H_
*/
#include "common/common.h"
#ifndef _TUSB_HID_HOST_H_ #include "host/usbh.h"
#define _TUSB_HID_HOST_H_ #include "hid.h"
#include "common/common.h" #ifdef __cplusplus
#include "host/usbh.h" extern "C" {
#include "hid.h" #endif
#ifdef __cplusplus /** \defgroup hid_keyboard Keyboard
extern "C" { * The interface API includes status checking function, data transferring function and callback functions
#endif * @{ */
//--------------------------------------------------------------------+
//--------------------------------------------------------------------+ // KEYBOARD Application API
// KEYBOARD Application API //--------------------------------------------------------------------+
//--------------------------------------------------------------------+ extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
/** \brief Check if device supports Keyboard interface or not
bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; * \param[in] dev_addr device address
bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; * \retval true if device supports Keyboard interface
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void * report) /*ATTR_WARN_UNUSED_RESULT*/; * \retval false if device does not support Keyboard interface or is not mounted
*/
//------------- Application Callback -------------// bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event);
void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr); /** \brief Check if the interface is currently busy or not
void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr); * \param[in] dev_addr device address
* \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to device
//--------------------------------------------------------------------+ * \retval false if the interface is not busy meaning the stack successfully transferred data from/to device
// MOUSE Application API * \note This function is primarily used for polling/waiting result after \ref tusbh_hid_keyboard_get_report.
//--------------------------------------------------------------------+ * Alternatively, asynchronous event API can be used
bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; */
bool tusbh_hid_mouse_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void* report) /*ATTR_WARN_UNUSED_RESULT*/;
/** \brief Perform a get report from Keyboard interface
//------------- Application Callback -------------// * \param[in] dev_addr device address
void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event); * \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref TUSB_CFG_ATTR_USBRAM)
void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr); * \returns \ref tusb_error_t type to indicate success or error condition.
void tusbh_hid_mouse_unmounted_cb(uint8_t dev_addr); * \retval TUSB_ERROR_NONE on success
* \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
//--------------------------------------------------------------------+ * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
// GENERIC Application API * \retval TUSB_ERROR_INVALID_PARA if inputs parameter are not correct
//--------------------------------------------------------------------+ * \note This function is non-blocking and returns immediately. The result of usb transfer will be reported by the interface's callback function
bool tusbh_hid_generic_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; */
tusb_error_t tusbh_hid_generic_get_report(uint8_t dev_addr, void* report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT; tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void * p_report) /*ATTR_WARN_UNUSED_RESULT*/;
tusb_error_t tusbh_hid_generic_set_report(uint8_t dev_addr, void* report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
tusb_interface_status_t tusbh_hid_generic_get_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; //------------- Application Callback -------------//
tusb_interface_status_t tusbh_hid_generic_set_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; /** \brief Callback function that is invoked when an transferring event occurred
* \param[in] dev_addr Address of device
//------------- Application Callback -------------// * \param[in] event an value from \ref tusb_event_t
void tusbh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event); * \note event can be one of following
* - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully.
//--------------------------------------------------------------------+ * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error.
// USBH-CLASS DRIVER API * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
//--------------------------------------------------------------------+ * \note Application should schedule the next report by calling \ref tusbh_hid_keyboard_get_report within this callback
#ifdef _TINY_USB_SOURCE_FILE_ */
void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event);
typedef struct {
pipe_handle_t pipe_hdl; /** \brief Callback function that will be invoked when a device with Keyboard interface is mounted
uint16_t report_size; * \param[in] dev_addr Address of newly mounted device
uint8_t interface_number; * \note This callback should be used by Application to set-up interface-related data
}hidh_interface_info_t; */
void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr);
void hidh_init(void);
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; /** \brief Callback function that will be invoked when a device with Keyboard interface is unmounted
void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes); * \param[in] dev_addr Address of newly unmounted device
void hidh_close(uint8_t dev_addr); * \note This callback should be used by Application to tear-down interface-related data
*/
#endif void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr);
/** @} */
#ifdef __cplusplus
} /** \defgroup hid_mouse Mouse
#endif * The interface API includes status checking function, data transferring function and callback functions
* @{ */
#endif /* _TUSB_HID_HOST_H_ */ //--------------------------------------------------------------------+
// MOUSE Application API
/** @} */ //--------------------------------------------------------------------+
/** \brief Check if device supports Mouse interface or not
* \param[in] dev_addr device address
* \retval true if device supports Mouse interface
* \retval false if device does not support Mouse interface or is not mounted
*/
bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
/** \brief Check if the interface is currently busy or not
* \param[in] dev_addr device address
* \retval true if the interface is busy meaning the stack is still transferring/waiting data from/to device
* \retval false if the interface is not busy meaning the stack successfully transferred data from/to device
* \note This function is primarily used for polling/waiting result after \ref tusbh_hid_mouse_get_report.
* Alternatively, asynchronous event API can be used
*/
bool tusbh_hid_mouse_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
/** \brief Perform a get report from Mouse interface
* \param[in] dev_addr device address
* \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref TUSB_CFG_ATTR_USBRAM)
* \returns \ref tusb_error_t type to indicate success or error condition.
* \retval TUSB_ERROR_NONE on success
* \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device
* \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request)
* \retval TUSB_ERROR_INVALID_PARA if inputs parameter are not correct
* \note This function is non-blocking and returns immediately. The result of usb transfer will be reported by the interface's callback function
*/
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void* p_report) /*ATTR_WARN_UNUSED_RESULT*/;
//------------- Application Callback -------------//
/** \brief Callback function that is invoked when an transferring event occurred
* \param[in] dev_addr Address of device
* \param[in] event an value from \ref tusb_event_t
* \note event can be one of following
* - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully.
* - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error.
* - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device.
* \note Application should schedule the next report by calling \ref tusbh_hid_mouse_get_report within this callback
*/
void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event);
/** \brief Callback function that will be invoked when a device with Mouse interface is mounted
* \param[in] dev_addr Address of newly mounted device
* \note This callback should be used by Application to set-up interface-related data
*/
void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr);
/** \brief Callback function that will be invoked when a device with Mouse interface is unmounted
* \param[in] dev_addr Address of newly unmounted device
* \note This callback should be used by Application to tear-down interface-related data
*/
void tusbh_hid_mouse_unmounted_cb(uint8_t dev_addr);
/** @} */
/** \defgroup hid_generic Generic (not supported yet)
* The interface API includes status checking function, data transferring function and callback functions
* @{ */
//--------------------------------------------------------------------+
// GENERIC Application API
//--------------------------------------------------------------------+
bool tusbh_hid_generic_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_hid_generic_get_report(uint8_t dev_addr, void* p_report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_hid_generic_set_report(uint8_t dev_addr, void* p_report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
tusb_interface_status_t tusbh_hid_generic_get_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
tusb_interface_status_t tusbh_hid_generic_set_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
//------------- Application Callback -------------//
void tusbh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event);
/** @} */
//--------------------------------------------------------------------+
// USBH-CLASS DRIVER API
//--------------------------------------------------------------------+
#ifdef _TINY_USB_SOURCE_FILE_
typedef struct {
pipe_handle_t pipe_hdl;
uint16_t report_size;
uint8_t interface_number;
}hidh_interface_info_t;
void hidh_init(void);
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT;
void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes);
void hidh_close(uint8_t dev_addr);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _TUSB_HID_HOST_H_ */
/** @} */
+39
View File
@@ -0,0 +1,39 @@
/** \addtogroup group_configuration
* @{ */
/**
USB controller in MCU often has limited access to specific RAM section. The Stack will use this macro to place internal variables
into the USB RAM section as follows. if your mcu's usb controller has no such limit, define TUSB_CFG_ATTR_USBRAM as empty macro.
@code
uint8_t tinyusb_data[10] TUSB_CFG_ATTR_USBRAM;
@endcode
*/
#define TUSB_CFG_ATTR_USBRAM
/** \defgroup TUSB_CFG_HOST Host
* @{ */
/// Maximum number of device host stack can manage
/// - If hub class is not enabled, set this equal to number of controllers in host mode
/// - if hub class is enabled, make sure hub is also counted
#define TUSB_CFG_HOST_DEVICE_MAX
/// Buffer size used for getting device configuration descriptor. You may want to increase this from default
/// to support lengthy composite device especially with Audio or Video class
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE
#define TUSB_CFG_HOST_HUB ///< Enable Hub Class
#define TUSB_CFG_HOST_HID_KEYBOARD ///< Enable HID Class for Keyboard
#define TUSB_CFG_HOST_HID_MOUSE ///< Enable HID Class for Mouse
#define TUSB_CFG_HOST_HID_GENERIC ///< Enable HID Class for Generic (not supported yet)
#define TUSB_CFG_HOST_MSC ///< Enable Mass Storage Class (SCSI subclass only)
#define TUSB_CFG_HOST_CDC ///< Enable Virtual Serial (Communication Device Class)
#define TUSB_CFG_HOST_CDC_RNDIS ///< Enable Remote Network Device (require TUSB_CFG_HOST_CDC to be enabled)
/** @} */ // group Host
/** @} */
-3
View File
@@ -1,3 +0,0 @@
# What is tinyUSB
![tinyUSB diagram](overview.png)
+123 -123
View File
@@ -1,123 +1,123 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file hal_lpc43xx.c @file hal_lpc43xx.c
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
#include "common/common.h" #include "common/common.h"
#include "hal.h" #include "hal.h"
#if MCU == MCU_LPC43XX #if MCU == MCU_LPC43XX
#include "lpc43xx_cgu.h" #include "lpc43xx_cgu.h"
#include "lpc43xx_scu.h" #include "lpc43xx_scu.h"
enum { enum {
LPC43XX_USBMODE_DEVICE = 2, LPC43XX_USBMODE_DEVICE = 2,
LPC43XX_USBMODE_HOST = 3 LPC43XX_USBMODE_HOST = 3
}; };
enum { enum {
LPC43XX_USBMODE_VBUS_LOW = 0, LPC43XX_USBMODE_VBUS_LOW = 0,
LPC43XX_USBMODE_VBUS_HIGH = 1 LPC43XX_USBMODE_VBUS_HIGH = 1
}; };
tusb_error_t hal_init(void) tusb_error_t hal_init(void)
{ {
//------------- USB0 Clock -------------// //------------- USB0 Clock -------------//
#if TUSB_CFG_CONTROLLER0_MODE #if TUSB_CFG_CONTROLLER_0_MODE
CGU_EnableEntity(CGU_CLKSRC_PLL0, DISABLE); /* Disable PLL first */ CGU_EnableEntity(CGU_CLKSRC_PLL0, DISABLE); /* Disable PLL first */
ASSERT_INT( CGU_ERROR_SUCCESS, CGU_SetPLL0(), TUSB_ERROR_FAILED); /* the usb core require output clock = 480MHz */ ASSERT_INT( CGU_ERROR_SUCCESS, CGU_SetPLL0(), TUSB_ERROR_FAILED); /* the usb core require output clock = 480MHz */
CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_CLKSRC_PLL0); CGU_EntityConnect(CGU_CLKSRC_XTAL_OSC, CGU_CLKSRC_PLL0);
CGU_EnableEntity(CGU_CLKSRC_PLL0, ENABLE); /* Enable PLL after all setting is done */ CGU_EnableEntity(CGU_CLKSRC_PLL0, ENABLE); /* Enable PLL after all setting is done */
LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */ LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */
// reset controller & set role // reset controller & set role
#if TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_HOST #if TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_HOST
hcd_controller_reset(0); // TODO where to place prototype hcd_controller_reset(0); // TODO where to place prototype
LPC_USB0->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5); LPC_USB0->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5);
#else // TODO OTG #else // TODO OTG
// dcd_controller_reset(0); // dcd_controller_reset(0);
// LPC_USB0->USBMODE_D = LPC43XX_USBMODE_DEVICE; // LPC_USB0->USBMODE_D = LPC43XX_USBMODE_DEVICE;
// LPC_USB0->OTGSC = (1<<3) | (1<<0) /*| (1<<16)| (1<<24)| (1<<25)| (1<<26)| (1<<27)| (1<<28)| (1<<29)| (1<<30)*/; // LPC_USB0->OTGSC = (1<<3) | (1<<0) /*| (1<<16)| (1<<24)| (1<<25)| (1<<26)| (1<<27)| (1<<28)| (1<<29)| (1<<30)*/;
// LPC_USB0->PORTSC1_D |= (1<<24); // force full speed // LPC_USB0->PORTSC1_D |= (1<<24); // force full speed
// dcd_controller_connect(0); // dcd_controller_connect(0);
#endif #endif
hal_interrupt_enable(0); hal_interrupt_enable(0);
#endif #endif
//------------- USB1 Clock, only use on-chip FS PHY -------------// //------------- USB1 Clock, only use on-chip FS PHY -------------//
#if TUSB_CFG_CONTROLLER1_MODE #if TUSB_CFG_CONTROLLER_1_MODE
// TODO confirm whether device mode require P2_5 or not // TODO confirm whether device mode require P2_5 or not
scu_pinmux(0x2, 5, MD_PLN | MD_EZI | MD_ZI, FUNC2); // USB1_VBUS monitor presence, must be high for bus reset occur scu_pinmux(0x2, 5, MD_PLN | MD_EZI | MD_ZI, FUNC2); // USB1_VBUS monitor presence, must be high for bus reset occur
/* connect CLK_USB1 to 60 MHz clock */ /* connect CLK_USB1 to 60 MHz clock */
CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_USB1); /* FIXME Run base BASE_USB1_CLK clock from PLL1 (assume PLL1 is 60 MHz, no division required) */ CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_USB1); /* FIXME Run base BASE_USB1_CLK clock from PLL1 (assume PLL1 is 60 MHz, no division required) */
//LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */ //LPC_CREG->CREG0 &= ~(1<<5); /* Turn on the phy */
LPC_SCU->SFSUSB = (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST) ? 0x16 : 0x12; // enable USB1 with on-chip FS PHY LPC_SCU->SFSUSB = (TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_HOST) ? 0x16 : 0x12; // enable USB1 with on-chip FS PHY
#if TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST #if TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_HOST
hcd_controller_reset(1); // TODO where to place prototype hcd_controller_reset(1); // TODO where to place prototype
LPC_USB1->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5); LPC_USB1->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5);
#else // TODO OTG #else // TODO OTG
// dcd_controller_reset(1); // dcd_controller_reset(1);
LPC_USB0->USBMODE_D = LPC43XX_USBMODE_DEVICE; LPC_USB0->USBMODE_D = LPC43XX_USBMODE_DEVICE;
dcd_controller_connect(1); dcd_controller_connect(1);
#endif #endif
LPC_USB1->PORTSC1_D |= (1<<24); // TODO abtract, force port to fullspeed LPC_USB1->PORTSC1_D |= (1<<24); // TODO abtract, force port to fullspeed
hal_interrupt_enable(1); hal_interrupt_enable(1);
#endif #endif
return TUSB_ERROR_NONE; return TUSB_ERROR_NONE;
} }
#if TUSB_CFG_CONTROLLER0_MODE #if TUSB_CFG_CONTROLLER_0_MODE
void USB0_IRQHandler(void) void USB0_IRQHandler(void)
{ {
tusb_isr(0); tusb_isr(0);
} }
#endif #endif
#if TUSB_CFG_CONTROLLER1_MODE #if TUSB_CFG_CONTROLLER_1_MODE
void USB1_IRQHandler(void) void USB1_IRQHandler(void)
{ {
tusb_isr(1); tusb_isr(1);
} }
#endif #endif
#endif #endif
+1098 -1098
View File
File diff suppressed because it is too large Load Diff
+98 -98
View File
@@ -1,98 +1,98 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file mcu_capacity.h @file mcu_capacity.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \file /** \file
* \brief TBD * \brief TBD
* *
* \note TBD * \note TBD
*/ */
/** \ingroup TBD /** \ingroup TBD
* \defgroup TBD * \defgroup TBD
* \brief TBD * \brief TBD
* *
* @{ * @{
*/ */
#ifndef _TUSB_MCU_CAPACITY_H_ #ifndef _TUSB_MCU_CAPACITY_H_
#define _TUSB_MCU_CAPACITY_H_ #define _TUSB_MCU_CAPACITY_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
// CAP is abbreviation for Capacity // CAP is abbreviation for Capacity
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// ARCHTECTURE // ARCHTECTURE
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Controller // Controller
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX #if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX
#define CAP_CONTROLLER_NUMBER 2 #define CAP_CONTROLLER_NUMBER 2
#else #else
#define CAP_CONTROLLER_NUMBER 1 #define CAP_CONTROLLER_NUMBER 1
#endif #endif
#define CAP_MODE_DEVICE #define CAP_MODE_DEVICE
#if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX || MCU == MCU_LPC175X_6X #if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX || MCU == MCU_LPC175X_6X
#define CAP_MODE_HOST #define CAP_MODE_HOST
#endif #endif
#if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX || MCU == MCU_LPC11UXX || MCU == MCU_LPC13UXX #if MCU == MCU_LPC43XX || MCU == MCU_LPC18XX || MCU == MCU_LPC11UXX || MCU == MCU_LPC13UXX
#define CAP_DEVICE_ROMDRIVER #define CAP_DEVICE_ROMDRIVER
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Validation // Validation
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#if (CAP_CONTROLLER_NUMBER == 1) && ( defined TUSB_CFG_CONTROLLER1_MODE) #if (CAP_CONTROLLER_NUMBER == 1) && ( defined TUSB_CFG_CONTROLLER_1_MODE)
#error current MCU does not have the required number of controllers #error current MCU does not have the required number of controllers
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* _TUSB_MCU_CAPACITY_H_ */ #endif /* _TUSB_MCU_CAPACITY_H_ */
/** @} */ /** @} */
+209 -204
View File
@@ -1,204 +1,209 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file osal.h @file osal.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \file /** \file
* \brief TBD * \brief TBD
* *
* \note TBD * \note TBD
*/ */
/** \ingroup TBD /** \ingroup TBD
* \defgroup TBD * \defgroup TBD
* \brief TBD * \brief TBD
* *
* @{ * @{
*/ */
#ifndef _TUSB_OSAL_H_ #ifndef _TUSB_OSAL_H_
#define _TUSB_OSAL_H_ #define _TUSB_OSAL_H_
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#include "tusb_option.h" #include "tusb_option.h"
#define TUSB_OS_NONE 1 /** \ingroup group_configuration
#define TUSB_OS_FREERTOS 2 * \defgroup TUSB_OS RTOS Integration Selection
#define TUSB_OS_CMSIS_RTX 3 * \brief TUSB_CFG_OS must be defined to one of these
#define TUSB_OS_UCOS2 4 * @{ */
#define TUSB_OS_UCOS3 5 #define TUSB_OS_NONE 1 ///< No RTOS is used
#define TUSB_OS_FREERTOS 2 ///< FreeRTOS is used
#ifndef _TEST_ #define TUSB_OS_CMSIS_RTX 3 ///< CMSIS RTX is used
#define TUSB_OS_UCOS2 4 ///< MicroC OS II is used (not supported yet)
#if TUSB_CFG_OS == TUSB_OS_NONE #define TUSB_OS_UCOS3 5 ///< MicroC OS III is used (not supported yet)
#include "osal_none.h" /** @} */
#else
#define OSAL_VAR #ifndef _TEST_
#if TUSB_CFG_OS == TUSB_OS_FREERTOS
#include "osal_freeRTOS.h" #if TUSB_CFG_OS == TUSB_OS_NONE
#elif TUSB_CFG_OS == TUSB_OS_CMSIS_RTX #include "osal_none.h"
#include "osal_cmsis_rtx.h" #else
#else #define OSAL_VAR
#error TUSB_CFG_OS is not defined or OS is not supported yet #if TUSB_CFG_OS == TUSB_OS_FREERTOS
#endif #include "osal_freeRTOS.h"
#endif #elif TUSB_CFG_OS == TUSB_OS_CMSIS_RTX
#include "osal_cmsis_rtx.h"
#else // OSAL API for cmock #else
#error TUSB_CFG_OS is not defined or OS is not supported yet
#define OSAL_VAR #endif
#include "osal_common.h" #endif
//------------- Tick -------------// #else // OSAL API for cmock
uint32_t osal_tick_get(void);
#define OSAL_VAR
//--------------------------------------------------------------------+ #include "osal_common.h"
// TASK API
//--------------------------------------------------------------------+ //------------- Tick -------------//
typedef uint32_t osal_task_t; uint32_t osal_tick_get(void);
tusb_error_t osal_task_create(osal_task_t *task);
//--------------------------------------------------------------------+
#define OSAL_TASK_DEF(code, stack_depth, prio) \ // TASK API
osal_task_t variable //--------------------------------------------------------------------+
typedef uint32_t osal_task_t;
#define OSAL_TASK_REF(name) (&name) tusb_error_t osal_task_create(osal_task_t *task);
#define OSAL_TASK_FUNCTION(task_name) \ #define OSAL_TASK_DEF(code, stack_depth, prio) \
void task_name osal_task_t variable
void osal_task_delay(uint32_t msec); #define OSAL_TASK_REF(name) (&name)
#define OSAL_TASK_LOOP_BEGIN #define OSAL_TASK_FUNCTION(task_name) \
#define OSAL_TASK_LOOP_END void task_name
#define SUBTASK_EXIT(error) return error; void osal_task_delay(uint32_t msec);
//------------- Sub Task -------------// #define OSAL_TASK_LOOP_BEGIN
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \ #define OSAL_TASK_LOOP_END
status = subtask
#define SUBTASK_EXIT(error) return error;
#define OSAL_SUBTASK_BEGIN
#define OSAL_SUBTASK_END \ //------------- Sub Task -------------//
return TUSB_ERROR_NONE; #define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) \
status = subtask
//------------- Sub Task Assert -------------//
#define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\ #define OSAL_SUBTASK_BEGIN
func_call; return error #define OSAL_SUBTASK_END \
return TUSB_ERROR_NONE;
#define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
//------------- Sub Task Assert -------------//
#define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \ #define _SUBTASK_ASSERT_ERROR_HANDLER(error, func_call)\
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\ func_call; return error
TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
#define SUBTASK_ASSERT_STATUS(sts) ASSERT_STATUS(sts)
#define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
#define SUBTASK_ASSERT_STATUS_WITH_HANDLER(sts, func_call) \
#define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \ ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, tusb_error_t status = (tusb_error_t)(sts),\
ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\ TUSB_ERROR_NONE == status, status, "%s", TUSB_ErrorStr[status])
condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
#define SUBTASK_ASSERT(condition) ASSERT(condition, TUSB_ERROR_OSAL_TASK_FAILED)
//--------------------------------------------------------------------+ #define SUBTASK_ASSERT_WITH_HANDLER(condition, func_call) \
// Semaphore API ASSERT_DEFINE_WITH_HANDLER(_SUBTASK_ASSERT_ERROR_HANDLER, func_call, ,\
//--------------------------------------------------------------------+ condition, TUSB_ERROR_OSAL_TASK_FAILED, "%s", "evaluated to false")
typedef volatile uint8_t osal_semaphore_t;
typedef osal_semaphore_t * osal_semaphore_handle_t;
//--------------------------------------------------------------------+
#define OSAL_SEM_DEF(name)\ // Semaphore API
osal_semaphore_t name //--------------------------------------------------------------------+
typedef volatile uint8_t osal_semaphore_t;
#define OSAL_SEM_REF(name)\ typedef osal_semaphore_t * osal_semaphore_handle_t;
&name
#define OSAL_SEM_DEF(name)\
osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem); osal_semaphore_t name
void osal_semaphore_wait(osal_semaphore_handle_t sem_hdl, uint32_t msec, tusb_error_t *p_error);
tusb_error_t osal_semaphore_post(osal_semaphore_handle_t sem_hdl); #define OSAL_SEM_REF(name)\
void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl); &name
//--------------------------------------------------------------------+ osal_semaphore_handle_t osal_semaphore_create(osal_semaphore_t * p_sem);
// MUTEX API (priority inheritance) void osal_semaphore_wait(osal_semaphore_handle_t sem_hdl, uint32_t msec, tusb_error_t *p_error);
//--------------------------------------------------------------------+ tusb_error_t osal_semaphore_post(osal_semaphore_handle_t sem_hdl);
#define OSAL_MUTEX_DEF(name)\ void osal_semaphore_reset(osal_semaphore_handle_t sem_hdl);
osal_mutex_t name
//--------------------------------------------------------------------+
#define OSAL_MUTEX_REF(name)\ // MUTEX API (priority inheritance)
&name //--------------------------------------------------------------------+
#define OSAL_MUTEX_DEF(name)\
typedef osal_semaphore_t osal_mutex_t; osal_mutex_t name
typedef osal_semaphore_handle_t osal_mutex_handle_t;
#define OSAL_MUTEX_REF(name)\
osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex); &name
void osal_mutex_wait(osal_mutex_handle_t mutex_hdl, uint32_t msec, tusb_error_t *p_error);
tusb_error_t osal_mutex_release(osal_mutex_handle_t mutex_hdl); typedef osal_semaphore_t osal_mutex_t;
void osal_mutex_reset(osal_mutex_handle_t mutex_hdl); typedef osal_semaphore_handle_t osal_mutex_handle_t;
//--------------------------------------------------------------------+
// QUEUE API osal_mutex_handle_t osal_mutex_create(osal_mutex_t * p_mutex);
//--------------------------------------------------------------------+ void osal_mutex_wait(osal_mutex_handle_t mutex_hdl, uint32_t msec, tusb_error_t *p_error);
typedef struct{ tusb_error_t osal_mutex_release(osal_mutex_handle_t mutex_hdl);
uint32_t * const buffer ; ///< buffer pointer void osal_mutex_reset(osal_mutex_handle_t mutex_hdl);
uint8_t const depth ; ///< buffer size //--------------------------------------------------------------------+
volatile uint8_t count ; ///< bytes in fifo // QUEUE API
volatile uint8_t wr_idx ; ///< write pointer //--------------------------------------------------------------------+
volatile uint8_t rd_idx ; ///< read pointer typedef struct{
} osal_queue_t; uint32_t * const buffer ; ///< buffer pointer
uint8_t const depth ; ///< buffer size
typedef osal_queue_t * osal_queue_handle_t; volatile uint8_t count ; ///< bytes in fifo
volatile uint8_t wr_idx ; ///< write pointer
#define OSAL_QUEUE_DEF(name, queue_depth, type) \ volatile uint8_t rd_idx ; ///< read pointer
osal_queue_t name } osal_queue_t;
#define OSAL_QUEUE_REF(name) (&name) typedef osal_queue_t * osal_queue_handle_t;
osal_queue_handle_t osal_queue_create (osal_queue_t *p_queue); #define OSAL_QUEUE_DEF(name, queue_depth, type) \
void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error); osal_queue_t name
tusb_error_t osal_queue_send (osal_queue_handle_t const queue_hdl, const void * data);
void osal_queue_flush(osal_queue_handle_t const queue_hdl); #define OSAL_QUEUE_REF(name) (&name)
//--------------------------------------------------------------------+ osal_queue_handle_t osal_queue_create (osal_queue_t *p_queue);
// TICK API void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error);
//--------------------------------------------------------------------+ tusb_error_t osal_queue_send (osal_queue_handle_t const queue_hdl, const void * data);
uint32_t osal_tick_get(void); void osal_queue_flush(osal_queue_handle_t const queue_hdl);
#endif
//--------------------------------------------------------------------+
#ifdef __cplusplus // TICK API
} //--------------------------------------------------------------------+
#endif uint32_t osal_tick_get(void);
#endif
#endif /* _TUSB_OSAL_H_ */
#ifdef __cplusplus
/** @} */ }
#endif
#endif /* _TUSB_OSAL_H_ */
/** @} */
+195 -192
View File
@@ -1,192 +1,195 @@
/**************************************************************************/ /**************************************************************************/
/*! /*!
@file tusb_option.h @file tusb_option.h
@author hathach (tinyusb.org) @author hathach (tinyusb.org)
@section LICENSE @section LICENSE
Software License Agreement (BSD License) Software License Agreement (BSD License)
Copyright (c) 2013, hathach (tinyusb.org) Copyright (c) 2013, hathach (tinyusb.org)
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the 3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission. derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This file is part of the tinyusb stack. This file is part of the tinyusb stack.
*/ */
/**************************************************************************/ /**************************************************************************/
/** \file #ifndef _TUSB_TUSB_OPTION_H_
* \brief Configure File #define _TUSB_TUSB_OPTION_H_
*
* \note TBD /** \defgroup group_configuration Configuration tusb_config.h
*/ * @{ */
/** #define TUSB_VERSION_YEAR 00
* \defgroup Group_TinyUSB_Configure Configuration tusb_option.h #define TUSB_VERSION_MONTH 00
* @{ #define TUSB_VERSION_WEEK 0
*/ #define TUSB_VERSION_NAME "alpha"
#define TUSB_VERSION XSTRING_(TUSB_VERSION_YEAR) "." XSTRING_(TUSB_VERSION_MONTH)
#ifndef _TUSB_TUSB_OPTION_H_
#define _TUSB_TUSB_OPTION_H_ /** \defgroup MCU_ MCU Selection
* \brief TUSB_CFG_MCU must be defined to one of these
#define TUSB_VERSION_YEAR 00 * @{ */
#define TUSB_VERSION_MONTH 00 #define MCU_LPC13XX_12ADC 1 ///< NXP LPC13xx 12 bit ADC family with USB on-chip Rom Driver (not supported yet)
#define TUSB_VERSION_WEEK 0 #define MCU_LPC13XX_10ADC 2 ///< NXP LPC13xx 10 bit ADC family (not supported yet)
#define TUSB_VERSION_NAME "alpha" #define MCU_LPC11UXX 3 ///< NXP LPC11Uxx family (not supported yet)
#define TUSB_VERSION XSTRING_(TUSB_VERSION_YEAR) "." XSTRING_(TUSB_VERSION_MONTH) #define MCU_LPC43XX 4 ///< NXP LPC43xx family
#define MCU_LPC18XX 5 ///< NXP LPC18xx family (not supported yet)
#define MCU_LPC13UXX 1 #define MCU_LPC175X_6X 6 ///< NXP LPC175x, LPC176x family (not supported yet)
#define MCU_LPC11UXX 2 #define MCU_LPC177X_8X 7 ///< NXP LPC177x, LPC178x family (not supported yet)
#define MCU_LPC43XX 3 /** @} */
#define MCU_LPC18XX 4
#define MCU_LPC175X_6X 5 #include "mcu_capacity.h"
#define MCU_LPC177X_8X 6
#ifdef TUSB_CFG_CONFIG_FILE
/// define this symbol will make tinyusb look for external configure file #include TUSB_CFG_CONFIG_FILE
#include "mcu_capacity.h" #else
#include "tusb_config.h"
#ifdef TUSB_CFG_CONFIG_FILE #endif
#include TUSB_CFG_CONFIG_FILE
#else //--------------------------------------------------------------------+
#include "tusb_config.h" // CONTROLLER
#endif //--------------------------------------------------------------------+
/** \defgroup TUSB_MODE Host/Device Mode Selection
//--------------------------------------------------------------------+ * \brief TUSB_CFG_CONTROLLER_N_MODE must be defined with these
// CONTROLLER * @{ */
//--------------------------------------------------------------------+ #define TUSB_MODE_HOST 0x02 ///< Host Mode
#define TUSB_MODE_HOST 0x02 #define TUSB_MODE_DEVICE 0x01 ///< Device Mode
#define TUSB_MODE_DEVICE 0x01 #define TUSB_MODE_NONE 0x00 ///< Disabled
#define TUSB_MODE_NONE 0x00 /** @} */
#define CONTROLLER_HOST_NUMBER (\ #define CONTROLLER_HOST_NUMBER (\
((TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_HOST) ? 1 : 0) + \ ((TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_HOST) ? 1 : 0) + \
((TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST) ? 1 : 0)) ((TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_HOST) ? 1 : 0))
#define CONTROLLER_DEVICE_NUMBER (\ #define CONTROLLER_DEVICE_NUMBER (\
((TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_DEVICE) ? 1 : 0) + \ ((TUSB_CFG_CONTROLLER_0_MODE & TUSB_MODE_DEVICE) ? 1 : 0) + \
((TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_DEVICE) ? 1 : 0)) ((TUSB_CFG_CONTROLLER_1_MODE & TUSB_MODE_DEVICE) ? 1 : 0))
#define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0) #define MODE_HOST_SUPPORTED (CONTROLLER_HOST_NUMBER > 0)
#define MODE_DEVICE_SUPPORTED (CONTROLLER_DEVICE_NUMBER > 0) #define MODE_DEVICE_SUPPORTED (CONTROLLER_DEVICE_NUMBER > 0)
#if !MODE_HOST_SUPPORTED && !MODE_DEVICE_SUPPORTED #if !MODE_HOST_SUPPORTED && !MODE_DEVICE_SUPPORTED
#error please configure at least 1 TUSB_CFG_CONTROLLERn_MODE to TUSB_MODE_HOST and/or TUSB_MODE_DEVICE #error please configure at least 1 TUSB_CFG_CONTROLLER_N_MODE to TUSB_MODE_HOST and/or TUSB_MODE_DEVICE
#endif #endif
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// COMMON OPTIONS // COMMON OPTIONS
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
/**
// level 3: ATTR_ALWAYS_INLINE is null, ASSERT has text, Error has its String, STATIC_VAR is NULL determines the debug level for the stack
// level 2: ATTR_ALWAYS_INLINE is attribute, ASSERT has no text, Error has no strings - Level 3: ATTR_ALWAYS_INLINE is null, ASSERT has text, Error has its String, STATIC_VAR is NULL
/// 0: no debug information 3: most debug information provided - Level 2: ATTR_ALWAYS_INLINE is attribute, ASSERT has no text, Error has no strings
#ifndef TUSB_CFG_DEBUG - Level 1: TBD
#define TUSB_CFG_DEBUG 2 - Level 0: no debug information is generated
#warning TUSB_CFG_DEBUG is not defined, default value is 3 */
#endif #ifndef TUSB_CFG_DEBUG
#define TUSB_CFG_DEBUG 2
/// USB RAM Section Placement, MCU's usb controller often has limited access to specific RAM region. This will be used to declare internal variables as follow: #warning TUSB_CFG_DEBUG is not defined, default value is 3
/// uint8_t tinyusb_data[10] TUSB_CFG_ATTR_USBRAM; #endif
/// if your mcu's usb controller has no such limit, define TUSB_CFG_ATTR_USBRAM as empty macro.
#ifndef TUSB_CFG_ATTR_USBRAM #ifndef TUSB_CFG_ATTR_USBRAM
#error TUSB_CFG_ATTR_USBRAM is not defined, please help me know how to place data in accessible RAM for usb controller #error TUSB_CFG_ATTR_USBRAM is not defined, please help me know how to place data in accessible RAM for usb controller
#endif #endif
#if TUSB_CFG_OS == TUSB_OS_NONE #if TUSB_CFG_OS == TUSB_OS_NONE
#ifndef TUSB_CFG_OS_TICKS_PER_SECOND #ifndef TUSB_CFG_OS_TICKS_PER_SECOND
#error TUSB_CFG_OS_TICKS_PER_SECOND is required to use with OS_NONE #error TUSB_CFG_OS_TICKS_PER_SECOND is required to use with OS_NONE
#endif #endif
#else #else
#ifndef TUSB_CFG_OS_TASK_PRIO #ifndef TUSB_CFG_OS_TASK_PRIO
#error TUSB_CFG_OS_TASK_PRIO need to be defined (hint: use the highest if possible) #error TUSB_CFG_OS_TASK_PRIO need to be defined (hint: use the highest if possible)
#endif #endif
#endif #endif
#ifndef TUSB_CFG_CONFIGURATION_MAX /**
#define TUSB_CFG_CONFIGURATION_MAX 1 * Maximum number of supported USB's configuration (currently only support only 1)
#warning TUSB_CFG_CONFIGURATION_MAX is not defined, default value is 1 */
#endif #ifndef TUSB_CFG_CONFIGURATION_MAX
#define TUSB_CFG_CONFIGURATION_MAX 1
//--------------------------------------------------------------------+ #warning TUSB_CFG_CONFIGURATION_MAX is not defined, default value is 1
// HOST OPTIONS #endif
//--------------------------------------------------------------------+
#if MODE_HOST_SUPPORTED //--------------------------------------------------------------------+
#ifndef TUSB_CFG_HOST_DEVICE_MAX // HOST OPTIONS
#define TUSB_CFG_HOST_DEVICE_MAX 1 //--------------------------------------------------------------------+
#warning TUSB_CFG_HOST_DEVICE_MAX is not defined, default value is 1 #if MODE_HOST_SUPPORTED
#endif #ifndef TUSB_CFG_HOST_DEVICE_MAX
#define TUSB_CFG_HOST_DEVICE_MAX 1
//------------- HUB CLASS -------------// #warning TUSB_CFG_HOST_DEVICE_MAX is not defined, default value is 1
#if TUSB_CFG_HOST_HUB && (TUSB_CFG_HOST_DEVICE_MAX == 1) #endif
#error there is no benefit enable hub with max device is 1. Please disable hub or increase TUSB_CFG_HOST_DEVICE_MAX
#endif //------------- HUB CLASS -------------//
#if TUSB_CFG_HOST_HUB && (TUSB_CFG_HOST_DEVICE_MAX == 1)
//------------- HID CLASS -------------// #error there is no benefit enable hub with max device is 1. Please disable hub or increase TUSB_CFG_HOST_DEVICE_MAX
#define HOST_CLASS_HID ( TUSB_CFG_HOST_HID_KEYBOARD + TUSB_CFG_HOST_HID_MOUSE + TUSB_CFG_HOST_HID_GENERIC ) #endif
#if HOST_CLASS_HID
#define HOST_HCD_XFER_INTERRUPT //------------- HID CLASS -------------//
#endif #define HOST_CLASS_HID ( TUSB_CFG_HOST_HID_KEYBOARD + TUSB_CFG_HOST_HID_MOUSE + TUSB_CFG_HOST_HID_GENERIC )
#if HOST_CLASS_HID
#ifndef TUSB_CFG_HOST_ENUM_BUFFER_SIZE #define HOST_HCD_XFER_INTERRUPT
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256 #endif
#warning TUSB_CFG_HOST_ENUM_BUFFER_SIZE is not defined, default value is 256
#endif #ifndef TUSB_CFG_HOST_ENUM_BUFFER_SIZE
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256
//------------- CLASS -------------// #warning TUSB_CFG_HOST_ENUM_BUFFER_SIZE is not defined, default value is 256
#endif // end TUSB_CFG_HOST #endif
//--------------------------------------------------------------------+ //------------- CLASS -------------//
// DEVICE OPTIONS #endif // MODE_HOST_SUPPORTED
//--------------------------------------------------------------------+
#if MODE_DEVICE_SUPPORTED //--------------------------------------------------------------------+
// DEVICE OPTIONS
#if defined(CAP_DEVICE_ROMDRIVER) && !TUSB_CFG_DEVICE_USE_ROM_DRIVER //--------------------------------------------------------------------+
#error only rom driver for these mcu are supported now #if MODE_DEVICE_SUPPORTED
#endif
#if defined(CAP_DEVICE_ROMDRIVER) && !TUSB_CFG_DEVICE_USE_ROM_DRIVER
#define DEVICE_CLASS_HID ( TUSB_CFG_DEVICE_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_MOUSE + TUSB_CFG_DEVICE_HID_GENERIC ) #error only rom driver for these mcu are supported now
#endif
#endif #define DEVICE_CLASS_HID ( TUSB_CFG_DEVICE_HID_KEYBOARD + TUSB_CFG_DEVICE_HID_MOUSE + TUSB_CFG_DEVICE_HID_GENERIC )
#endif // MODE_DEVICE_SUPPORTED
#define USB_FS_MAX_BULK_PACKET 64
#define USB_HS_MAX_BULK_PACKET USB_FS_MAX_BULK_PACKET /* Full speed device only */
/* HID In/Out Endpoint Address */ #define USB_FS_MAX_BULK_PACKET 64
#define HID_KEYBOARD_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(1) #define USB_HS_MAX_BULK_PACKET USB_FS_MAX_BULK_PACKET /* Full speed device only */
#define HID_MOUSE_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(4)
/* HID In/Out Endpoint Address */
/* CDC Endpoint Address */ #define HID_KEYBOARD_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(1)
#define CDC_NOTIFICATION_EP ENDPOINT_IN_LOGICAL_TO_PHYSICAL(2) #define HID_MOUSE_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(4)
#define CDC_DATA_EP_OUT ENDPOINT_OUT_LOGICAL_TO_PHYSICAL(3)
#define CDC_DATA_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(3) /* CDC Endpoint Address */
#define CDC_NOTIFICATION_EP ENDPOINT_IN_LOGICAL_TO_PHYSICAL(2)
#define CDC_NOTIFICATION_EP_MAXPACKETSIZE 8 #define CDC_DATA_EP_OUT ENDPOINT_OUT_LOGICAL_TO_PHYSICAL(3)
#define CDC_DATA_EP_MAXPACKET_SIZE 16 #define CDC_DATA_EP_IN ENDPOINT_IN_LOGICAL_TO_PHYSICAL(3)
#endif /* _TUSB_TUSB_OPTION_H_ */ #define CDC_NOTIFICATION_EP_MAXPACKETSIZE 8
#define CDC_DATA_EP_MAXPACKET_SIZE 16
/** @} */
#endif /* _TUSB_TUSB_OPTION_H_ */
/** @} */