/*-Sizes-*/\r
define symbol __ICFEDIT_size_vectors__ = 0x100;\r
define symbol __ICFEDIT_size_cstack__ = 0x400; \r
-define symbol __ICFEDIT_size_sysstack__ = 0x60;\r
-define symbol __ICFEDIT_size_irqstack__ = 0x60;\r
+define symbol __ICFEDIT_size_sysstack__ = 0x600;\r
+define symbol __ICFEDIT_size_irqstack__ = 0x600;\r
define symbol __ICFEDIT_size_heap__ = 0x0;\r
/*-Exports-*/\r
export symbol __ICFEDIT_region_RAM_start__;\r
+++ /dev/null
-/* ----------------------------------------------------------------------------\r
- * SAM Software Package License \r
- * ----------------------------------------------------------------------------\r
- * Copyright (c) 2012, Atmel Corporation\r
- *\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions are met:\r
- *\r
- * - Redistributions of source code must retain the above copyright notice,\r
- * this list of conditions and the disclaimer below.\r
- *\r
- * Atmel's name may not be used to endorse or promote products derived from\r
- * this software without specific prior written permission.\r
- *\r
- * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
- * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES// LOSS OF USE, DATA,\r
- * OR PROFITS// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- * ----------------------------------------------------------------------------\r
- */\r
-\r
- \r
-\r
-/** \file */\r
-\r
-\r
-/** \r
- * \addtogroup cp15_cache Cache Operations\r
- *\r
- * \section Usage\r
- *\r
- * They are performed as MCR instructions and only operate on a level 1 cache associated with \r
- * ATM v7 processor.\r
- * The supported operations are:\r
- * <ul>\r
- * <li> Any of these operations can be applied to\r
- * -# any data cache\r
- * -# any unified cache.\r
- * <li> Invalidate by MVA\r
- * Performs an invalidate of a data or unified cache line based on the address it contains.\r
- * <li> Invalidate by set/way\r
- * Performs an invalidate of a data or unified cache line based on its location in the cache hierarchy.\r
- * <li> Clean by MVA\r
- * Performs a clean of a data or unified cache line based on the address it contains.\r
- * <li> Clean by set/way\r
- * Performs a clean of a data or unified cache line based on its location in the cache hierarchy.\r
- * <li> Clean and Invalidate by MVA\r
- * Performs a clean and invalidate of a data or unified cache line based on the address it contains.\r
- * <li> Clean and Invalidate by set/way\r
- * Performs a clean and invalidate of a data or unified cache line based on its location in the cache hierarchy.\r
- * </ul>\r
- *\r
- * Related files:\n\r
- * \ref cp15.h\n\r
- * \ref cp15_arm_gnu.S \n\r
- */\r
- \r
-/*----------------------------------------------------------------------------\r
- * Functions to access CP15 coprocessor register\r
- *----------------------------------------------------------------------------*/\r
- .global CP15_ReadID\r
- .global CP15_ReadControl\r
- .global CP15_WriteControl\r
- .global CP15_WriteDomainAccessControl\r
- .global CP15_WriteTTB\r
- .global CP15_InvalidateIcacheInnerSharable\r
- .global CP15_InvalidateBTBinnerSharable\r
- .global CP15_InvalidateIcache\r
- .global CP15_InvalidateIcacheByMva\r
- .global CP15_FlushBTB\r
- .global CP15_FlushBTBbyMva\r
- .global CP15_InvalidateDcacheLineByMva\r
- .global CP15_InvalidateDcacheLineBySetWay\r
- .global CP15_CleanDCacheByMva\r
- .global CP15_CleanDCacheBySetWay\r
- .global CP15_CleanDCacheMva\r
- .global CP15_CleanInvalidateDcacheLineByMva\r
- .global CP15_CleanInvalidateDcacheLine\r
- .global CP15_coherent_dcache_for_dma\r
- .global CP15_invalidate_dcache_for_dma\r
- .global CP15_clean_dcache_for_dma\r
- .global CP15_flush_dcache_for_dma\r
- .global CP15_flush_kern_dcache_for_dma\r
-\r
-/** \r
- * \brief Register c0 accesses the ID Register, Cache Type Register, and TCM Status Registers.\r
- * Reading from this register returns the device ID, the cache type, or the TCM status\r
- * depending on the value of Opcode_2 used. \r
- */\r
- .section .CP15_ReadID\r
- .global CP15_ReadID\r
-CP15_ReadID:\r
- mov r0, #0\r
- mrc p15, 0, r0, c0, c0, 0\r
- bx lr\r
-\r
-/** \r
- * \brief Register c1 is the Control Register for the ARM926EJ-S processor.\r
- * This register specifies the configuration used to enable and disable the\r
- * caches and MMU. It is recommended that you access this register using a\r
- * read-modify-write sequence\r
- */\r
- .section .CP15_ReadControl\r
- .global CP15_ReadControl\r
-CP15_ReadControl:\r
- mov r0, #0\r
- mrc p15, 0, r0, c1, c0, 0 \r
- bx lr\r
-\r
- .section .CP15_WriteControl\r
- .global CP15_WriteControl\r
-CP15_WriteControl:\r
- mcr p15, 0, r0, c1, c0, 0\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- bx lr\r
-\r
- .section .CP15_WriteDomainAccessControl\r
- .global CP15_WriteDomainAccessControl\r
-CP15_WriteDomainAccessControl:\r
- mcr p15, 0, r0, c3, c0, 0\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- bx lr\r
- \r
-/** \r
- * \brief ARMv7A architecture supports two translation tables\r
- * Configure translation table base (TTB) control register cp15,c2\r
- * to a value of all zeros, indicates we are using TTB register 0.\r
- * write the address of our page table base to TTB register 0.\r
- */\r
-\r
- .section .CP15_WriteTTB\r
- .global CP15_WriteTTB\r
-CP15_WriteTTB:\r
- mcr p15, 0, r0, c2, c0, 0\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- nop\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Invalidate I cache predictor array inner Sharable\r
- */\r
- .section .CP15_InvalidateIcacheInnerSharable\r
- .global CP15_InvalidateIcacheInnerSharable\r
-CP15_InvalidateIcacheInnerSharable:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c1, 0\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Invalidate entire branch predictor array inner Sharable\r
- */\r
- .section .CP15_InvalidateBTBinnerSharable\r
- .global CP15_InvalidateBTBinnerSharable\r
-CP15_InvalidateBTBinnerSharable:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c1, 6\r
- bx lr\r
-\r
-/**\r
- * \brief Invalidate all instruction caches to PoU, also flushes branch target cache\r
- */\r
- .section .CP15_InvalidateIcache\r
- .global CP15_InvalidateIcache\r
-CP15_InvalidateIcache:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c5, 0\r
- bx lr\r
-\r
-/**\r
- * \brief Invalidate instruction caches by VA to PoU\r
- */\r
- .section .CP15_InvalidateIcacheByMva\r
- .global CP15_InvalidateIcacheByMva\r
-CP15_InvalidateIcacheByMva:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c5, 1\r
- bx lr\r
-\r
-/**\r
- * \brief Flush entire branch predictor array\r
- */\r
- .section .CP15_FlushBTB\r
- .global CP15_FlushBTB\r
-CP15_FlushBTB:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c5, 6\r
- bx lr\r
-\r
-/**\r
- * \brief Flush branch predictor array entry by MVA\r
- */\r
- .section .CP15_FlushBTBbyMva\r
- .global CP15_FlushBTBbyMva\r
-CP15_FlushBTBbyMva:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c5, 7\r
- bx lr\r
-\r
-/**\r
- * \brief Invalidate data cache line by VA to Poc\r
- */\r
- .section .CP15_InvalidateDcacheLineByMva\r
- .global CP15_InvalidateDcacheLineByMva\r
-CP15_InvalidateDcacheLineByMva:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c6, 1\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Invalidate data cache line by set/way\r
- */\r
- .section .CP15_InvalidateDcacheLineBySetWay\r
- .global CP15_InvalidateDcacheLineBySetWay\r
-CP15_InvalidateDcacheLineBySetWay:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c6, 2\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Clean data cache line by MVA\r
- */\r
- .section .CP15_CleanDCacheByMva\r
- .global CP15_CleanDCacheByMva\r
-CP15_CleanDCacheByMva:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c10, 1\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Clean data cache line by Set/way\r
- */\r
- .section .CP15_CleanDCacheBySetWay\r
- .global CP15_CleanDCacheBySetWay\r
-CP15_CleanDCacheBySetWay:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c10, 2\r
- bx lr\r
-\r
-/**\r
- * \brief Clean unified cache line by MVA \r
- */\r
- .section .CP15_CleanDCacheMva\r
- .global CP15_CleanDCacheMva\r
-CP15_CleanDCacheMva:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c11, 1\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Clean and invalidate data cache line by VA to PoC\r
- */\r
- .section .CP15_CleanInvalidateDcacheLineByMva\r
- .global CP15_CleanInvalidateDcacheLineByMva\r
-CP15_CleanInvalidateDcacheLineByMva:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c14, 1 \r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Clean and Incalidate data cache line by Set/Way\r
- */\r
- .section .CP15_CleanInvalidateDcacheLine\r
- .global CP15_CleanInvalidateDcacheLine\r
-CP15_CleanInvalidateDcacheLine:\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c14, 2\r
- bx lr\r
-\r
-/**\r
- * \brief Ensure that the I and D caches are coherent within specified\r
- * region. This is typically used when code has been written to\r
- * a memory region, and will be executed.\r
- * \param start virtual start address of region\r
- * \param end virtual end address of region\r
- */\r
- .section .CP15_coherent_dcache_for_dma\r
- .global CP15_coherent_dcache_for_dma\r
-CP15_coherent_dcache_for_dma:\r
- \r
- mrc p15, 0, r3, c0, c0, 1 \r
- lsr r3, r3, #16\r
- and r3, r3, #0xf \r
- mov r2, #4 \r
- mov r2, r2, lsl r3 \r
-\r
- sub r3, r2, #1\r
- bic r12, r0, r3\r
-1:\r
- mcr p15, 0, r12, c7, c11, 1 \r
- add r12, r12, r2\r
- cmp r12, r1\r
- blo 1b\r
- dsb\r
-\r
- mrc p15, 0, r3, c0, c0, 1 \r
- and r3, r3, #0xf \r
- mov r2, #4 \r
- mov r2, r2, lsl r3 \r
-\r
- sub r3, r2, #1\r
- bic r12, r0, r3\r
-2:\r
- mcr p15, 0, r12, c7, c5, 1 \r
- add r12, r12, r2\r
- cmp r12, r1\r
- blo 2b\r
- mov r0, #0\r
- mcr p15, 0, r0, c7, c1, 6 \r
- mcr p15, 0, r0, c7, c5, 6 \r
- dsb\r
- isb\r
- bx lr\r
- \r
-\r
-/**\r
- * \brief Invalidate the data cache within the specified region; we will\r
- * be performing a DMA operation in this region and we want to\r
- * purge old data in the cache.\r
- * \param start virtual start address of region\r
- * \param end virtual end address of region\r
- */ \r
- .section .CP15_invalidate_dcache_for_dma\r
- .global CP15_invalidate_dcache_for_dma\r
-CP15_invalidate_dcache_for_dma:\r
-\r
- mrc p15, 0, r3, c0, c0, 1 \r
- lsr r3, r3, #16\r
- and r3, r3, #0xf \r
- mov r2, #4 \r
- mov r2, r2, lsl r3 \r
-\r
- sub r3, r2, #1\r
- tst r0, r3\r
- bic r0, r0, r3\r
-\r
- mcrne p15, 0, r0, c7, c14, 1 \r
-\r
- tst r1, r3\r
- bic r1, r1, r3\r
- mcrne p15, 0, r1, c7, c14, 1 \r
-3:\r
- mcr p15, 0, r0, c7, c6, 1 \r
- add r0, r0, r2\r
- cmp r0, r1\r
- blo 3b\r
- dsb\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Clean the data cache within the specified region\r
- * \param start virtual start address of region\r
- * \param end virtual end address of region\r
- */\r
- .section .CP15_clean_dcache_for_dma\r
- .global CP15_clean_dcache_for_dma\r
-CP15_clean_dcache_for_dma:\r
- mrc p15, 0, r3, c0, c0, 1 \r
- lsr r3, r3, #16\r
- and r3, r3, #0xf \r
- mov r2, #4 \r
- mov r2, r2, lsl r3 \r
-\r
- sub r3, r2, #1\r
- bic r0, r0, r3\r
-4:\r
- mcr p15, 0, r0, c7, c10, 1 \r
- add r0, r0, r2\r
- cmp r0, r1\r
- blo 4b\r
- dsb\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief Flush the data cache within the specified region\r
- * \param start virtual start address of region\r
- * \param end virtual end address of region\r
- */\r
- .section .CP15_flush_dcache_for_dma\r
- .global CP15_flush_dcache_for_dma\r
-CP15_flush_dcache_for_dma:\r
- mrc p15, 0, r3, c0, c0, 1 \r
- lsr r3, r3, #16\r
- and r3, r3, #0xf \r
- mov r2, #4 \r
- mov r2, r2, lsl r3 \r
- sub r3, r2, #1\r
- bic r0, r0, r3\r
-5:\r
- mcr p15, 0, r0, c7, c14, 1 \r
- add r0, r0, r2\r
- cmp r0, r1\r
- blo 5b\r
- dsb\r
- bx lr\r
-\r
-\r
-/**\r
- * \brief CP15_flush_kern_dcache_for_dma\r
- * Ensure that the data held in the page kaddr is written back to the page in question.\r
- * \param start virtual start address of region\r
- * \param end virtual end address of region\r
- */\r
- .section .CP15_flush_kern_dcache_for_dma\r
- .global CP15_flush_kern_dcache_for_dma\r
-CP15_flush_kern_dcache_for_dma:\r
- mrc p15, 0, r3, c0, c0, 1 \r
- lsr r3, r3, #16\r
- and r3, r3, #0xf \r
- mov r2, #4 \r
- mov r2, r2, lsl r3 \r
-\r
- add r1, r0, r1\r
- sub r3, r2, #1\r
- bic r0, r0, r3\r
-\r
- mcr p15, 0, r0, c7, c14, 1 \r
- add r0, r0, r2\r
- cmp r0, r1\r
- blo 1b\r
- dsb\r
- bx lr\r
- \r
/* ----------------------------------------------------------------------------\r
- * SAM Software Package License \r
+ * SAM Software Package License\r
* ----------------------------------------------------------------------------\r
* Copyright (c) 2012, Atmel Corporation\r
*\r
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
* ----------------------------------------------------------------------------\r
*/\r
- \r
+\r
\r
/** \file */\r
\r
\r
/** \file */\r
-/** \r
+/**\r
* \addtogroup cp15_cache Cache Operations\r
*\r
* \section Usage\r
*\r
- * They are performed as MCR instructions and only operate on a level 1 cache associated with \r
+ * They are performed as MCR instructions and only operate on a level 1 cache associated with\r
* ATM v7 processor.\r
* The supported operations are:\r
* <ul>\r
* \ref cp15.h\n\r
* \ref cp15_arm_iar.s \n\r
*/\r
- \r
+\r
\r
MODULE ?cp15\r
\r
/*----------------------------------------------------------------------------\r
* Headers\r
*----------------------------------------------------------------------------*/\r
-#define __ASSEMBLY__\r
\r
\r
/*----------------------------------------------------------------------------\r
PUBLIC CP15_flush_dcache_for_dma\r
PUBLIC CP15_flush_kern_dcache_for_dma\r
\r
-/** \r
+/**\r
* \brief Register c0 accesses the ID Register, Cache Type Register, and TCM Status Registers.\r
* Reading from this register returns the device ID, the cache type, or the TCM status\r
- * depending on the value of Opcode_2 used. \r
+ * depending on the value of Opcode_2 used.\r
*/\r
SECTION .CP15_ReadID:DATA:NOROOT(2)\r
PUBLIC CP15_ReadID\r
mrc p15, 0, r0, c0, c0, 0\r
bx lr\r
\r
-/** \r
+/**\r
* \brief Register c1 is the Control Register for the ARM926EJ-S processor.\r
* This register specifies the configuration used to enable and disable the\r
* caches and MMU. It is recommended that you access this register using a\r
PUBLIC CP15_ReadControl\r
CP15_ReadControl:\r
mov r0, #0\r
- mrc p15, 0, r0, c1, c0, 0 \r
+ mrc p15, 0, r0, c1, c0, 0\r
bx lr\r
\r
SECTION .CP15_WriteControl:CODE:NOROOT(2)\r
nop\r
nop\r
bx lr\r
- \r
-/** \r
+\r
+/**\r
* \brief ARMv7A architecture supports two translation tables\r
* Configure translation table base (TTB) control register cp15,c2\r
* to a value of all zeros, indicates we are using TTB register 0.\r
bx lr\r
\r
/**\r
- * \brief Clean unified cache line by MVA \r
+ * \brief Clean unified cache line by MVA\r
*/\r
SECTION .CP15_CleanDCacheMva:CODE:NOROOT(2)\r
PUBLIC CP15_CleanDCacheMva\r
PUBLIC CP15_CleanInvalidateDcacheLineByMva\r
CP15_CleanInvalidateDcacheLineByMva:\r
mov r0, #0\r
- mcr p15, 0, r0, c7, c14, 1 \r
+ mcr p15, 0, r0, c7, c14, 1\r
bx lr\r
\r
/**\r
PUBLIC CP15_coherent_dcache_for_dma\r
CP15_coherent_dcache_for_dma:\r
// dcache_line_size r2, r3\r
- \r
+\r
mrc p15, 0, r3, c0, c0, 1 // read ctr\r
lsr r3, r3, #16\r
and r3, r3, #0xf // cache line size encoding\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * SAM Software Package License \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2011, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+\r
+/** \file\r
+ * \addtogroup usbd_cdc\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include "board.h"\r
+#include "include/USBD_Config.h"\r
+#include "CDCDSerialDriver.h"\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Definitions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_cdc_serial_device_ids CDC Serial Device IDs\r
+ * @{\r
+ * This page lists the IDs used in the CDC Serial Device Descriptor.\r
+ *\r
+ * \section IDs\r
+ * - CDCDSerialDriverDescriptors_PRODUCTID\r
+ * - CDCDSerialDriverDescriptors_VENDORID\r
+ * - CDCDSerialDriverDescriptors_RELEASE\r
+ */\r
+\r
+/** Device product ID. */\r
+#define CDCDSerialDriverDescriptors_PRODUCTID 0x6119\r
+/** Device vendor ID (Atmel). */\r
+#define CDCDSerialDriverDescriptors_VENDORID 0x03EB\r
+/** Device release number. */\r
+#define CDCDSerialDriverDescriptors_RELEASE 0x0100\r
+/** @}*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Macros\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** Returns the minimum between two values. */\r
+#define MIN(a, b) ((a < b) ? a : b)\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported variables\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** Standard USB device descriptor for the CDC serial driver */\r
+const USBDeviceDescriptor deviceDescriptor = {\r
+\r
+ sizeof(USBDeviceDescriptor),\r
+ USBGenericDescriptor_DEVICE,\r
+ USBDeviceDescriptor_USB2_00,\r
+ CDCDeviceDescriptor_CLASS,\r
+ CDCDeviceDescriptor_SUBCLASS,\r
+ CDCDeviceDescriptor_PROTOCOL,\r
+ CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),\r
+ CDCDSerialDriverDescriptors_VENDORID,\r
+ CDCDSerialDriverDescriptors_PRODUCTID,\r
+ CDCDSerialDriverDescriptors_RELEASE,\r
+ 0, /* No string descriptor for manufacturer */\r
+ 1, /* Index of product string descriptor is #1 */\r
+ 0, /* No string descriptor for serial number */\r
+ 1 /* Device has 1 possible configuration */\r
+};\r
+\r
+/** Standard USB configuration descriptor for the CDC serial driver */\r
+const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsFS = {\r
+\r
+ /* Standard configuration descriptor */\r
+ {\r
+ sizeof(USBConfigurationDescriptor),\r
+ USBGenericDescriptor_CONFIGURATION,\r
+ sizeof(CDCDSerialDriverConfigurationDescriptors),\r
+ 2, /* There are two interfaces in this configuration */\r
+ 1, /* This is configuration #1 */\r
+ 0, /* No string descriptor for this configuration */\r
+ USBD_BMATTRIBUTES,\r
+ USBConfigurationDescriptor_POWER(100)\r
+ },\r
+ /* Communication class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 0, /* This is interface #0 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 1, /* This interface uses 1 endpoint */\r
+ CDCCommunicationInterfaceDescriptor_CLASS,\r
+ CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,\r
+ CDCCommunicationInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Class-specific header functional descriptor */\r
+ {\r
+ sizeof(CDCHeaderDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_HEADER,\r
+ CDCGenericDescriptor_CDC1_10\r
+ },\r
+ /* Class-specific call management functional descriptor */\r
+ {\r
+ sizeof(CDCCallManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_CALLMANAGEMENT,\r
+ CDCCallManagementDescriptor_SELFCALLMANAGEMENT,\r
+ 0 /* No associated data interface */\r
+ },\r
+ /* Class-specific abstract control management functional descriptor */\r
+ {\r
+ sizeof(CDCAbstractControlManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,\r
+ CDCAbstractControlManagementDescriptor_LINE\r
+ },\r
+ /* Class-specific union functional descriptor with one slave interface */\r
+ {\r
+ sizeof(CDCUnionDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_UNION,\r
+ 0, /* Number of master interface is #0 */\r
+ 1 /* First slave interface is #1 */\r
+ },\r
+ /* Notification endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor),\r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_INTERRUPT,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),\r
+ 10 /* Endpoint is polled every 10ms */\r
+ },\r
+ /* Data class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 1, /* This is interface #1 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 2, /* This interface uses 2 endpoints */\r
+ CDCDataInterfaceDescriptor_CLASS,\r
+ CDCDataInterfaceDescriptor_SUBCLASS,\r
+ CDCDataInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Bulk-OUT endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor),\r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,\r
+ CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_MAXBULKSIZE_FS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ },\r
+ /* Bulk-IN endpoint descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor),\r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_MAXBULKSIZE_FS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ }\r
+};\r
+\r
+/** Other-speed configuration descriptor (when in full-speed). */\r
+const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsFS = {\r
+\r
+ /* Standard configuration descriptor */\r
+ {\r
+ sizeof(USBConfigurationDescriptor),\r
+ USBGenericDescriptor_OTHERSPEEDCONFIGURATION,\r
+ sizeof(CDCDSerialDriverConfigurationDescriptors),\r
+ 2, /* There are two interfaces in this configuration */\r
+ 1, /* This is configuration #1 */\r
+ 0, /* No string descriptor for this configuration */\r
+ BOARD_USB_BMATTRIBUTES,\r
+ USBConfigurationDescriptor_POWER(100)\r
+ },\r
+ /* Communication class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 0, /* This is interface #0 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 1, /* This interface uses 1 endpoint */\r
+ CDCCommunicationInterfaceDescriptor_CLASS,\r
+ CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,\r
+ CDCCommunicationInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Class-specific header functional descriptor */\r
+ {\r
+ sizeof(CDCHeaderDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_HEADER,\r
+ CDCGenericDescriptor_CDC1_10\r
+ },\r
+ /* Class-specific call management functional descriptor */\r
+ {\r
+ sizeof(CDCCallManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_CALLMANAGEMENT,\r
+ CDCCallManagementDescriptor_SELFCALLMANAGEMENT,\r
+ 0 /* No associated data interface */\r
+ },\r
+ /* Class-specific abstract control management functional descriptor */\r
+ {\r
+ sizeof(CDCAbstractControlManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,\r
+ CDCAbstractControlManagementDescriptor_LINE\r
+ },\r
+ /* Class-specific union functional descriptor with one slave interface */\r
+ {\r
+ sizeof(CDCUnionDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_UNION,\r
+ 0, /* Number of master interface is #0 */\r
+ 1 /* First slave interface is #1 */\r
+ },\r
+ /* Notification endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor), \r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_INTERRUPT,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),\r
+ 8 /* Endpoint is polled every 16ms */\r
+ },\r
+ /* Data class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 1, /* This is interface #1 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 2, /* This interface uses 2 endpoints */\r
+ CDCDataInterfaceDescriptor_CLASS,\r
+ CDCDataInterfaceDescriptor_SUBCLASS,\r
+ CDCDataInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Bulk-OUT endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor), \r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,\r
+ CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_MAXBULKSIZE_HS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ },\r
+ /* Bulk-IN endpoint descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor),\r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_MAXBULKSIZE_HS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ }\r
+};\r
+\r
+/** Configuration descriptor (when in high-speed). */\r
+const CDCDSerialDriverConfigurationDescriptors configurationDescriptorsHS = {\r
+\r
+ /* Standard configuration descriptor */\r
+ {\r
+ sizeof(USBConfigurationDescriptor),\r
+ USBGenericDescriptor_CONFIGURATION,\r
+ sizeof(CDCDSerialDriverConfigurationDescriptors),\r
+ 2, /* There are two interfaces in this configuration */\r
+ 1, /* This is configuration #1 */\r
+ 0, /* No string descriptor for this configuration */\r
+ BOARD_USB_BMATTRIBUTES,\r
+ USBConfigurationDescriptor_POWER(100)\r
+ },\r
+ /* Communication class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 0, /* This is interface #0 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 1, /* This interface uses 1 endpoint */\r
+ CDCCommunicationInterfaceDescriptor_CLASS,\r
+ CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,\r
+ CDCCommunicationInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Class-specific header functional descriptor */\r
+ {\r
+ sizeof(CDCHeaderDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_HEADER,\r
+ CDCGenericDescriptor_CDC1_10\r
+ },\r
+ /* Class-specific call management functional descriptor */\r
+ {\r
+ sizeof(CDCCallManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_CALLMANAGEMENT,\r
+ CDCCallManagementDescriptor_SELFCALLMANAGEMENT,\r
+ 0 /* No associated data interface */\r
+ },\r
+ /* Class-specific abstract control management functional descriptor */\r
+ {\r
+ sizeof(CDCAbstractControlManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,\r
+ CDCAbstractControlManagementDescriptor_LINE\r
+ },\r
+ /* Class-specific union functional descriptor with one slave interface */\r
+ {\r
+ sizeof(CDCUnionDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_UNION,\r
+ 0, /* Number of master interface is #0 */\r
+ 1 /* First slave interface is #1 */\r
+ },\r
+ /* Notification endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor), \r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_INTERRUPT,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),\r
+ 8 /* Endpoint is polled every 16ms */\r
+ },\r
+ /* Data class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 1, /* This is interface #1 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 2, /* This interface uses 2 endpoints */\r
+ CDCDataInterfaceDescriptor_CLASS,\r
+ CDCDataInterfaceDescriptor_SUBCLASS,\r
+ CDCDataInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Bulk-OUT endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor), \r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,\r
+ CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_MAXBULKSIZE_HS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ },\r
+ /* Bulk-IN endpoint descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor),\r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_MAXBULKSIZE_HS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ }\r
+};\r
+\r
+/** Other-speed configuration descriptor (when in high-speed). */\r
+const CDCDSerialDriverConfigurationDescriptors otherSpeedDescriptorsHS = {\r
+\r
+ /* Standard configuration descriptor */\r
+ {\r
+ sizeof(USBConfigurationDescriptor),\r
+ USBGenericDescriptor_OTHERSPEEDCONFIGURATION,\r
+ sizeof(CDCDSerialDriverConfigurationDescriptors),\r
+ 2, /* There are two interfaces in this configuration */\r
+ 1, /* This is configuration #1 */\r
+ 0, /* No string descriptor for this configuration */\r
+ BOARD_USB_BMATTRIBUTES,\r
+ USBConfigurationDescriptor_POWER(100)\r
+ },\r
+ /* Communication class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 0, /* This is interface #0 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 1, /* This interface uses 1 endpoint */\r
+ CDCCommunicationInterfaceDescriptor_CLASS,\r
+ CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL,\r
+ CDCCommunicationInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Class-specific header functional descriptor */\r
+ {\r
+ sizeof(CDCHeaderDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_HEADER,\r
+ CDCGenericDescriptor_CDC1_10\r
+ },\r
+ /* Class-specific call management functional descriptor */\r
+ {\r
+ sizeof(CDCCallManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_CALLMANAGEMENT,\r
+ CDCCallManagementDescriptor_SELFCALLMANAGEMENT,\r
+ 0 /* No associated data interface */\r
+ },\r
+ /* Class-specific abstract control management functional descriptor */\r
+ {\r
+ sizeof(CDCAbstractControlManagementDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT,\r
+ CDCAbstractControlManagementDescriptor_LINE\r
+ },\r
+ /* Class-specific union functional descriptor with one slave interface */\r
+ {\r
+ sizeof(CDCUnionDescriptor),\r
+ CDCGenericDescriptor_INTERFACE,\r
+ CDCGenericDescriptor_UNION,\r
+ 0, /* Number of master interface is #0 */\r
+ 1 /* First slave interface is #1 */\r
+ },\r
+ /* Notification endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor), \r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_INTERRUPT,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_NOTIFICATION),\r
+ USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),\r
+ 10 /* Endpoint is polled every 10ms */\r
+ },\r
+ /* Data class interface standard descriptor */\r
+ {\r
+ sizeof(USBInterfaceDescriptor),\r
+ USBGenericDescriptor_INTERFACE,\r
+ 1, /* This is interface #1 */\r
+ 0, /* This is alternate setting #0 for this interface */\r
+ 2, /* This interface uses 2 endpoints */\r
+ CDCDataInterfaceDescriptor_CLASS,\r
+ CDCDataInterfaceDescriptor_SUBCLASS,\r
+ CDCDataInterfaceDescriptor_NOPROTOCOL,\r
+ 0 /* No string descriptor for this interface */\r
+ },\r
+ /* Bulk-OUT endpoint standard descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor), \r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,\r
+ CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAOUT),\r
+ USBEndpointDescriptor_MAXBULKSIZE_FS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ },\r
+ /* Bulk-IN endpoint descriptor */\r
+ {\r
+ sizeof(USBEndpointDescriptor),\r
+ USBGenericDescriptor_ENDPOINT,\r
+ USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,\r
+ CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_BULK,\r
+ MIN(CHIP_USB_ENDPOINTS_MAXPACKETSIZE(CDCDSerialDriverDescriptors_DATAIN),\r
+ USBEndpointDescriptor_MAXBULKSIZE_FS),\r
+ 0 /* Must be 0 for full-speed bulk endpoints */\r
+ }\r
+};\r
+\r
+/** Language ID string descriptor */\r
+const unsigned char languageIdStringDescriptor[] = {\r
+\r
+ USBStringDescriptor_LENGTH(1),\r
+ USBGenericDescriptor_STRING,\r
+ USBStringDescriptor_ENGLISH_US\r
+};\r
+\r
+/** Product string descriptor */\r
+const unsigned char productStringDescriptor[] = {\r
+\r
+ USBStringDescriptor_LENGTH(13),\r
+ USBGenericDescriptor_STRING,\r
+ USBStringDescriptor_UNICODE('A'),\r
+ USBStringDescriptor_UNICODE('T'),\r
+ USBStringDescriptor_UNICODE('9'),\r
+ USBStringDescriptor_UNICODE('1'),\r
+ USBStringDescriptor_UNICODE('U'),\r
+ USBStringDescriptor_UNICODE('S'),\r
+ USBStringDescriptor_UNICODE('B'),\r
+ USBStringDescriptor_UNICODE('S'),\r
+ USBStringDescriptor_UNICODE('e'),\r
+ USBStringDescriptor_UNICODE('r'),\r
+ USBStringDescriptor_UNICODE('i'),\r
+ USBStringDescriptor_UNICODE('a'),\r
+ USBStringDescriptor_UNICODE('l')\r
+};\r
+\r
+/** List of string descriptors used by the device */\r
+const unsigned char *stringDescriptors[] = {\r
+\r
+ languageIdStringDescriptor,\r
+ productStringDescriptor,\r
+};\r
+\r
+/** List of standard descriptors for the serial driver. */\r
+WEAK const USBDDriverDescriptors cdcdSerialDriverDescriptors = {\r
+\r
+ &deviceDescriptor,\r
+ (USBConfigurationDescriptor *) &(configurationDescriptorsFS),\r
+ 0, /* No full-speed device qualifier descriptor */\r
+ (USBConfigurationDescriptor *) &(otherSpeedDescriptorsFS),\r
+ 0, /* No high-speed device descriptor (uses FS one) */\r
+ (USBConfigurationDescriptor *) &(configurationDescriptorsHS),\r
+ 0, /* No high-speed device qualifier descriptor */\r
+ (USBConfigurationDescriptor *) &(otherSpeedDescriptorsHS),\r
+ stringDescriptors,\r
+ 2 /* 2 string descriptors in list */\r
+};\r
+\r
+/**@}*/\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ Implementation of the CDCLineCoding class.\r
+ */\r
+/** \addtogroup usb_cdc\r
+ *@{\r
+ */\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Headers\r
+ *----------------------------------------------------------------------------*/\r
+\r
+#include <CDCRequests.h>\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Exported functions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Initializes the bitrate, number of stop bits, parity checking and\r
+ * number of data bits of a CDCLineCoding object.\r
+ * \param lineCoding Pointer to a CDCLineCoding instance.\r
+ * \param bitrate Bitrate of the virtual COM connection.\r
+ * \param stopbits Number of stop bits\r
+ * (\ref usb_cdc_stop CDC LineCoding StopBits).\r
+ * \param parity Parity check type\r
+ * (\ref usb_cdc_parity CDC LineCoding ParityChecking).\r
+ * \param databits Number of data bits.\r
+ */\r
+void CDCLineCoding_Initialize(CDCLineCoding *lineCoding,\r
+ uint32_t bitrate,\r
+ uint8_t stopbits,\r
+ uint8_t parity,\r
+ uint8_t databits)\r
+{\r
+ lineCoding->dwDTERate = bitrate;\r
+ lineCoding->bCharFormat = stopbits;\r
+ lineCoding->bParityType = parity;\r
+ lineCoding->bDataBits = databits;\r
+}\r
+\r
+/**@}*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ *\r
+ * Implementation of the CDCSetControlLineStateRequest class.\r
+ */\r
+\r
+/** \addtogroup usb_cdc\r
+ *@{\r
+ */\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Headers\r
+ *----------------------------------------------------------------------------*/\r
+\r
+#include <CDCRequests.h>\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Exported functions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Notifies if the given request indicates that the DTE signal is present.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return 1 if the DTE signal is present, otherwise 0.\r
+ */\r
+uint8_t CDCSetControlLineStateRequest_IsDtePresent(\r
+ const USBGenericRequest *request)\r
+{\r
+ if ((USBGenericRequest_GetValue(request) & 0x0001) != 0) {\r
+\r
+ return 1;\r
+ }\r
+ else {\r
+\r
+ return 0;\r
+ }\r
+}\r
+\r
+/**\r
+ * Notifies if the given request indicates that the device carrier should\r
+ * be activated.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return 1 is the device should activate its carrier, 0 otherwise.\r
+ */\r
+uint8_t CDCSetControlLineStateRequest_ActivateCarrier(\r
+ const USBGenericRequest *request)\r
+{\r
+ if ((USBGenericRequest_GetValue(request) & 0x0002) != 0) {\r
+\r
+ return 1;\r
+ }\r
+ else {\r
+\r
+ return 0;\r
+ }\r
+}\r
+\r
+/**@}*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ *\r
+ * Implements for USB descriptor methods described by the USB specification.\r
+ */\r
+\r
+/** \addtogroup usb_descriptor\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include "USBDescriptors.h"\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Returns the length of a descriptor.\r
+ * \param descriptor Pointer to a USBGenericDescriptor instance.\r
+ * \return Length of descriptor in bytes.\r
+ */\r
+uint32_t USBGenericDescriptor_GetLength(\r
+ const USBGenericDescriptor *descriptor)\r
+{\r
+ return descriptor->bLength;\r
+}\r
+\r
+/**\r
+ * Returns the type of a descriptor.\r
+ * \param descriptor Pointer to a USBGenericDescriptor instance.\r
+ * \return Type of descriptor.\r
+ */\r
+uint8_t USBGenericDescriptor_GetType(\r
+ const USBGenericDescriptor *descriptor)\r
+{\r
+ return descriptor->bDescriptorType;\r
+}\r
+\r
+/**\r
+ * Returns a pointer to the descriptor right after the given one, when\r
+ * parsing a Configuration descriptor.\r
+ * \param descriptor - Pointer to a USBGenericDescriptor instance.\r
+ * \return Pointer to the next descriptor.\r
+ */\r
+USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(\r
+ const USBGenericDescriptor *descriptor)\r
+{\r
+ return (USBGenericDescriptor *)\r
+ (((char *) descriptor) + USBGenericDescriptor_GetLength(descriptor));\r
+}\r
+\r
+/** Parses the given descriptor list via costomized function.\r
+ * \param descriptor Pointer to the start of the whole descriptors list.\r
+ * \param totalLength Total size of descriptors in bytes.\r
+ * \param parseFunction Function to parse each descriptor scanned.\r
+ * Return 0 to continue parsing.\r
+ * \param parseArg Argument passed to parse function.\r
+ * \return Pointer to USBGenericDescriptor instance for next descriptor.\r
+ */\r
+USBGenericDescriptor *USBGenericDescriptor_Parse(\r
+ const USBGenericDescriptor *descriptor,\r
+ uint32_t totalLength,\r
+ USBDescriptorParseFunction parseFunction,\r
+ void *parseArg)\r
+{\r
+ int32_t size = totalLength;\r
+\r
+ if (size == 0)\r
+ return 0;\r
+\r
+ /* Start parsing descriptors */\r
+ while (1) {\r
+\r
+ uint32_t parseRC = 0;\r
+\r
+ /* Parse current descriptor */\r
+ if (parseFunction) {\r
+\r
+ parseRC = parseFunction((void*)descriptor, parseArg);\r
+ }\r
+\r
+ /* Get next descriptor */\r
+ size -= USBGenericDescriptor_GetLength(descriptor);\r
+ descriptor = USBGenericDescriptor_GetNextDescriptor(descriptor);\r
+\r
+ if (size) {\r
+ if (parseRC != 0) {\r
+\r
+ return (USBGenericDescriptor *)descriptor;\r
+ }\r
+ }\r
+ else\r
+ break;\r
+ }\r
+ /* No descriptors remaining */\r
+ return 0;\r
+}\r
+\r
+\r
+/**\r
+ * Returns the number of an endpoint given its descriptor.\r
+ * \param endpoint Pointer to a USBEndpointDescriptor instance.\r
+ * \return Endpoint number.\r
+ */\r
+uint8_t USBEndpointDescriptor_GetNumber(\r
+ const USBEndpointDescriptor *endpoint)\r
+{\r
+ return endpoint->bEndpointAddress & 0xF;\r
+}\r
+\r
+/**\r
+ * Returns the direction of an endpoint given its descriptor.\r
+ * \param endpoint Pointer to a USBEndpointDescriptor instance.\r
+ * \return Endpoint direction (see \ref usb_ep_dir).\r
+ */\r
+uint8_t USBEndpointDescriptor_GetDirection(\r
+ const USBEndpointDescriptor *endpoint)\r
+{\r
+ if ((endpoint->bEndpointAddress & 0x80) != 0) {\r
+\r
+ return USBEndpointDescriptor_IN;\r
+ }\r
+ else {\r
+\r
+ return USBEndpointDescriptor_OUT;\r
+ }\r
+}\r
+\r
+/**\r
+ * Returns the type of an endpoint given its descriptor.\r
+ * \param endpoint Pointer to a USBEndpointDescriptor instance.\r
+ * \return Endpoint type (see \ref usb_ep_type).\r
+ */\r
+uint8_t USBEndpointDescriptor_GetType(\r
+ const USBEndpointDescriptor *endpoint)\r
+{\r
+ return endpoint->bmAttributes & 0x3;\r
+}\r
+\r
+/**\r
+ * Returns the maximum size of a packet (in bytes) on an endpoint given\r
+ * its descriptor.\r
+ * \param endpoint - Pointer to a USBEndpointDescriptor instance.\r
+ * \return Maximum packet size of endpoint.\r
+ */\r
+uint16_t USBEndpointDescriptor_GetMaxPacketSize(\r
+ const USBEndpointDescriptor *endpoint)\r
+{\r
+uint16_t usTemp;\r
+uint8_t *pc1, *pc2;\r
+\r
+ pc1 = ( uint8_t * ) &( endpoint->wMaxPacketSize );\r
+ pc2 = pc1 + 1;\r
+ usTemp = ( ( *pc2 ) << 8 ) | *pc1;\r
+\r
+ return usTemp;\r
+#warning The original code below crashes when build for A5 as endpoint can be misaligned.\r
+ //_RB_return endpoint->wMaxPacketSize;\r
+}\r
+\r
+/**\r
+ * Returns the polling interval on an endpoint given its descriptor.\r
+ * \param endpoint - Pointer to a USBEndpointDescriptor instance.\r
+ * \return Polling interval of endpoint.\r
+ */\r
+uint8_t USBEndpointDescriptor_GetInterval(\r
+ const USBEndpointDescriptor *endpoint)\r
+{\r
+ return endpoint->bInterval;\r
+}\r
+\r
+\r
+\r
+/** Returns the total length of a configuration, i.e. including the\r
+ * descriptors following it.\r
+ * \param configuration Pointer to a USBConfigurationDescriptor instance.\r
+ * \return Total length (in bytes) of the configuration.\r
+ */\r
+volatile unsigned long ulCount = 0;\r
+uint32_t USBConfigurationDescriptor_GetTotalLength(\r
+ const USBConfigurationDescriptor *configuration)\r
+{\r
+ulCount++;\r
+if( ulCount == 5 )\r
+{\r
+ __asm volatile( "NOP" );\r
+}\r
+ return configuration->wTotalLength;\r
+}\r
+\r
+/** Returns the number of interfaces in a configuration.\r
+ * \param configuration Pointer to a USBConfigurationDescriptor instance.\r
+ * \return Number of interfaces in configuration.\r
+ */\r
+unsigned char USBConfigurationDescriptor_GetNumInterfaces(\r
+ const USBConfigurationDescriptor *configuration)\r
+{\r
+ return configuration->bNumInterfaces;\r
+}\r
+\r
+/** Indicates if the device is self-powered when in a given configuration.\r
+ * \param configuration Pointer to a USBConfigurationDescriptor instance.\r
+ * \return 1 if the device is self-powered when in the given configuration;\r
+ * otherwise 0.\r
+ */\r
+unsigned char USBConfigurationDescriptor_IsSelfPowered(\r
+ const USBConfigurationDescriptor *configuration)\r
+{\r
+ if ((configuration->bmAttributes & (1 << 6)) != 0) {\r
+\r
+ return 1;\r
+ }\r
+ else {\r
+\r
+ return 0;\r
+ }\r
+}\r
+\r
+/** Parses the given Configuration descriptor (followed by relevant\r
+ * interface, endpoint and class-specific descriptors) into three arrays.\r
+ * *Each array must have its size equal or greater to the number of\r
+ * descriptors it stores plus one*. A null-value is inserted after the last\r
+ * descriptor of each type to indicate the array end.\r
+ *\r
+ * Note that if the pointer to an array is null (0), nothing is stored in\r
+ * it.\r
+ * \param configuration Pointer to the start of the whole Configuration\r
+ * descriptor.\r
+ * \param interfaces Pointer to the Interface descriptor array.\r
+ * \param endpoints Pointer to the Endpoint descriptor array.\r
+ * \param others Pointer to the class-specific descriptor array.\r
+ */\r
+void USBConfigurationDescriptor_Parse(\r
+ const USBConfigurationDescriptor *configuration,\r
+ USBInterfaceDescriptor **interfaces,\r
+ USBEndpointDescriptor **endpoints,\r
+ USBGenericDescriptor **others)\r
+{\r
+ /* Get size of configuration to parse */\r
+ int size = USBConfigurationDescriptor_GetTotalLength(configuration);\r
+ size -= sizeof(USBConfigurationDescriptor);\r
+\r
+ /* Start parsing descriptors */\r
+ USBGenericDescriptor *descriptor = (USBGenericDescriptor *) configuration;\r
+ while (size > 0) {\r
+\r
+ /* Get next descriptor */\r
+ descriptor = USBGenericDescriptor_GetNextDescriptor(descriptor);\r
+ size -= USBGenericDescriptor_GetLength(descriptor);\r
+\r
+ /* Store descriptor in correponding array */\r
+ if (USBGenericDescriptor_GetType(descriptor)\r
+ == USBGenericDescriptor_INTERFACE) {\r
+\r
+ if (interfaces) {\r
+\r
+ *interfaces = (USBInterfaceDescriptor *) descriptor;\r
+ interfaces++;\r
+ }\r
+ }\r
+ else if (USBGenericDescriptor_GetType(descriptor)\r
+ == USBGenericDescriptor_ENDPOINT) {\r
+\r
+ if (endpoints) {\r
+\r
+ *endpoints = (USBEndpointDescriptor *) descriptor;\r
+ endpoints++;\r
+ }\r
+ }\r
+ else if (others) {\r
+\r
+ *others = descriptor;\r
+ others++;\r
+ }\r
+ }\r
+\r
+ /* Null-terminate arrays */\r
+ if (interfaces) {\r
+\r
+ *interfaces = 0;\r
+ }\r
+ if (endpoints) {\r
+\r
+ *endpoints = 0;\r
+ }\r
+ if (others) {\r
+\r
+ *others = 0;\r
+ }\r
+}\r
+\r
+/**@}*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * \section Purpose\r
+ * \r
+ * Implements for USB requests described by the USB specification.\r
+ */\r
+\r
+/** \addtogroup usb_request\r
+ * @{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+ \r
+#include <USBRequests.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Returns the type of the given request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return "USB Request Types"\r
+ */\r
+extern uint8_t USBGenericRequest_GetType(const USBGenericRequest *request)\r
+{\r
+ return ((request->bmRequestType >> 5) & 0x3);\r
+}\r
+\r
+/**\r
+ * Returns the request code of the given request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Request code.\r
+ * \sa "USB Request Codes"\r
+ */\r
+uint8_t USBGenericRequest_GetRequest(const USBGenericRequest *request)\r
+{\r
+ return request->bRequest;\r
+}\r
+\r
+/**\r
+ * Returns the wValue field of the given request.\r
+ * \param request - Pointer to a USBGenericRequest instance.\r
+ * \return Request value.\r
+ */\r
+uint16_t USBGenericRequest_GetValue(const USBGenericRequest *request)\r
+{\r
+ return request->wValue;\r
+}\r
+\r
+/**\r
+ * Returns the wIndex field of the given request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Request index;\r
+ */\r
+uint16_t USBGenericRequest_GetIndex(const USBGenericRequest *request)\r
+{\r
+ return request->wIndex;\r
+}\r
+\r
+/**\r
+ * Returns the expected length of the data phase following a request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Length of data phase.\r
+ */\r
+uint16_t USBGenericRequest_GetLength(const USBGenericRequest *request)\r
+{\r
+ return request->wLength;\r
+}\r
+\r
+/**\r
+ * Returns the endpoint number targetted by a given request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Endpoint number.\r
+ */\r
+uint8_t USBGenericRequest_GetEndpointNumber(\r
+ const USBGenericRequest *request)\r
+{\r
+ return USBGenericRequest_GetIndex(request) & 0xF;\r
+}\r
+\r
+/**\r
+ * Returns the intended recipient of a given request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Request recipient.\r
+ * \sa "USB Request Recipients"\r
+ */\r
+uint8_t USBGenericRequest_GetRecipient(const USBGenericRequest *request)\r
+{\r
+ /* Recipient is in bits [0..4] of the bmRequestType field */\r
+ return request->bmRequestType & 0xF;\r
+}\r
+\r
+/**\r
+ * Returns the direction of the data transfer following the given request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Transfer direction.\r
+ * \sa "USB Request Directions"\r
+ */\r
+uint8_t USBGenericRequest_GetDirection(const USBGenericRequest *request)\r
+{\r
+ /* Transfer direction is located in bit D7 of the bmRequestType field */\r
+ if ((request->bmRequestType & 0x80) != 0) {\r
+\r
+ return USBGenericRequest_IN;\r
+ }\r
+ else {\r
+\r
+ return USBGenericRequest_OUT;\r
+ }\r
+}\r
+\r
+\r
+/**\r
+ * Returns the type of the descriptor requested by the host given the\r
+ * corresponding GET_DESCRIPTOR request.\r
+ * \param request Pointer to a USBGenericDescriptor instance.\r
+ * \return Type of the requested descriptor.\r
+ */\r
+uint8_t USBGetDescriptorRequest_GetDescriptorType(\r
+ const USBGenericRequest *request)\r
+{\r
+ /* Requested descriptor type is in the high-byte of the wValue field */\r
+ return (USBGenericRequest_GetValue(request) >> 8) & 0xFF;\r
+}\r
+\r
+/**\r
+ * Returns the index of the requested descriptor, given the corresponding\r
+ * GET_DESCRIPTOR request.\r
+ * \param request Pointer to a USBGenericDescriptor instance.\r
+ * \return Index of the requested descriptor.\r
+ */\r
+uint8_t USBGetDescriptorRequest_GetDescriptorIndex(\r
+ const USBGenericRequest *request)\r
+{\r
+ /* Requested descriptor index if in the low byte of the wValue field */\r
+ return USBGenericRequest_GetValue(request) & 0xFF;\r
+}\r
+\r
+\r
+/**\r
+ * Returns the address that the device must take in response to a\r
+ * SET_ADDRESS request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return New device address.\r
+ */\r
+uint8_t USBSetAddressRequest_GetAddress(const USBGenericRequest *request)\r
+{\r
+ return USBGenericRequest_GetValue(request) & 0x7F;\r
+}\r
+\r
+\r
+/**\r
+ * Returns the number of the configuration that should be set in response\r
+ * to the given SET_CONFIGURATION request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Number of the requested configuration.\r
+ */\r
+uint8_t USBSetConfigurationRequest_GetConfiguration(\r
+ const USBGenericRequest *request)\r
+{\r
+ return USBGenericRequest_GetValue(request);\r
+}\r
+\r
+\r
+/**\r
+ * Indicates which interface is targetted by a GET_INTERFACE or\r
+ * SET_INTERFACE request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Interface number.\r
+ */\r
+uint8_t USBInterfaceRequest_GetInterface(const USBGenericRequest *request)\r
+{\r
+ return (USBGenericRequest_GetIndex(request) & 0xFF);\r
+}\r
+\r
+/**\r
+ * Indicates the new alternate setting that the interface targetted by a\r
+ * SET_INTERFACE request should use.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return New active setting for the interface.\r
+ */\r
+uint8_t USBInterfaceRequest_GetAlternateSetting(\r
+ const USBGenericRequest *request)\r
+{\r
+ return (USBGenericRequest_GetValue(request) & 0xFF);\r
+}\r
+\r
+\r
+/**\r
+ * Returns the feature selector of a given CLEAR_FEATURE or SET_FEATURE\r
+ * request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Feature selector.\r
+ */\r
+uint8_t USBFeatureRequest_GetFeatureSelector(\r
+ const USBGenericRequest *request)\r
+{\r
+ return USBGenericRequest_GetValue(request);\r
+}\r
+\r
+/**\r
+ * Indicates the test that the device must undertake following a\r
+ * SET_FEATURE request.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return Test selector.\r
+ */\r
+uint8_t USBFeatureRequest_GetTestSelector(\r
+ const USBGenericRequest *request)\r
+{\r
+ return (USBGenericRequest_GetIndex(request) >> 8) & 0xFF;\r
+}\r
+\r
+/**@}*/\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\file\r
+ * Implementation of a single CDC serial port function for USB device.\r
+ */\r
+\r
+/** \addtogroup usbd_cdc\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include "CDCDSerial.h"\r
+\r
+#include <USBLib_Trace.h>\r
+#include <USBDDriver.h>\r
+#include <USBD_HAL.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Types\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Internal variables\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** Serial Port instance list */\r
+static CDCDSerialPort cdcdSerial;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Internal functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * USB CDC Serial Port Event Handler.\r
+ * \param event Event code.\r
+ * \param param Event parameter.\r
+ */\r
+static uint32_t CDCDSerial_EventHandler(uint32_t event,\r
+ uint32_t param)\r
+{\r
+ switch (event) {\r
+ case CDCDSerialPortEvent_SETCONTROLLINESTATE:\r
+ {\r
+ if (CDCDSerial_ControlLineStateChanged != NULL) {\r
+ CDCDSerial_ControlLineStateChanged(\r
+ (param & CDCControlLineState_DTR) > 0,\r
+ (param & CDCControlLineState_RTS) > 0);\r
+ }\r
+ }\r
+ break;\r
+ case CDCDSerialPortEvent_SETLINECODING:\r
+ {\r
+ if (NULL != CDCDSerial_LineCodingIsToChange) {\r
+ event = CDCDSerial_LineCodingIsToChange(\r
+ (CDCLineCoding*)param);\r
+ if (event != USBRC_SUCCESS)\r
+ return event;\r
+ }\r
+ }\r
+ break;\r
+ default:\r
+ return USBRC_SUCCESS;\r
+ }\r
+\r
+ return USBRC_SUCCESS;\r
+}\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Initializes the USB Device CDC serial driver & USBD Driver.\r
+ * \param pUsbd Pointer to USBDDriver instance.\r
+ * \param bInterfaceNb Interface number for the function.\r
+ */\r
+void CDCDSerial_Initialize(\r
+ USBDDriver *pUsbd, uint8_t bInterfaceNb)\r
+{\r
+ CDCDSerialPort *pCdcd = &cdcdSerial;\r
+\r
+ TRACE_INFO("CDCDSerial_Initialize\n\r");\r
+\r
+ /* Initialize serial port function */\r
+ CDCDSerialPort_Initialize(\r
+ pCdcd, pUsbd,\r
+ (CDCDSerialPortEventHandler)CDCDSerial_EventHandler,\r
+ 0,\r
+ bInterfaceNb, 2);\r
+}\r
+\r
+/**\r
+ * Invoked whenever the device is changed by the\r
+ * host.\r
+ * \pDescriptors Pointer to the descriptors for function configure.\r
+ * \wLength Length of descriptors in number of bytes.\r
+ */\r
+void CDCDSerial_ConfigureFunction(USBGenericDescriptor *pDescriptors,\r
+ uint16_t wLength)\r
+{\r
+ CDCDSerialPort *pCdcd = &cdcdSerial;\r
+ CDCDSerialPort_ParseInterfaces(pCdcd,\r
+ (USBGenericDescriptor*)pDescriptors,\r
+ wLength);\r
+}\r
+\r
+/**\r
+ * Handles CDC-specific SETUP requests. Should be called from a\r
+ * re-implementation of USBDCallbacks_RequestReceived() method.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ */\r
+uint32_t CDCDSerial_RequestHandler(const USBGenericRequest *request)\r
+{\r
+ CDCDSerialPort * pCdcd = &cdcdSerial;\r
+\r
+ TRACE_INFO_WP("Cdcf ");\r
+ return CDCDSerialPort_RequestHandler(pCdcd, request);\r
+}\r
+\r
+/**\r
+ * Receives data from the host through the virtual COM port created by\r
+ * the CDC device serial driver. This function behaves like USBD_Read.\r
+ * \param data Pointer to the data buffer to put received data.\r
+ * \param size Size of the data buffer in bytes.\r
+ * \param callback Optional callback function to invoke when the transfer\r
+ * finishes.\r
+ * \param argument Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the read operation has been started normally;\r
+ * otherwise, the corresponding error code.\r
+ */\r
+uint32_t CDCDSerial_Read(void *data,\r
+ uint32_t size,\r
+ TransferCallback callback,\r
+ void *argument)\r
+{\r
+ CDCDSerialPort * pCdcd = &cdcdSerial;\r
+ return CDCDSerialPort_Read(pCdcd, data, size, callback, argument);\r
+}\r
+\r
+/**\r
+ * Sends a data buffer through the virtual COM port created by the CDC\r
+ * device serial driver. This function behaves exactly like USBD_Write.\r
+ * \param data Pointer to the data buffer to send.\r
+ * \param size Size of the data buffer in bytes.\r
+ * \param callback Optional callback function to invoke when the transfer\r
+ * finishes.\r
+ * \param argument Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the read operation has been started normally;\r
+ * otherwise, the corresponding error code.\r
+ */\r
+uint32_t CDCDSerial_Write(void *data,\r
+ uint32_t size,\r
+ TransferCallback callback,\r
+ void *argument)\r
+{\r
+ CDCDSerialPort * pCdcd = &cdcdSerial;\r
+ return CDCDSerialPort_Write(pCdcd, data, size, callback, argument);\r
+}\r
+\r
+/**\r
+ * Returns the current control line state of the RS-232 line.\r
+ */\r
+uint8_t CDCDSerial_GetControlLineState(void)\r
+{\r
+ CDCDSerialPort * pCdcd = &cdcdSerial;\r
+ return CDCDSerialPort_GetControlLineState(pCdcd);\r
+}\r
+\r
+/**\r
+ * Copy current line coding settings to pointered space.\r
+ * \param pLineCoding Pointer to CDCLineCoding instance.\r
+ */\r
+void CDCDSerial_GetLineCoding(CDCLineCoding* pLineCoding)\r
+{\r
+ CDCDSerialPort * pCdcd = &cdcdSerial;\r
+ CDCDSerialPort_GetLineCoding(pCdcd, pLineCoding);\r
+}\r
+\r
+/**\r
+ * Returns the current status of the RS-232 line.\r
+ */\r
+uint16_t CDCDSerial_GetSerialState(void)\r
+{\r
+ CDCDSerialPort * pCdcd = &cdcdSerial;\r
+ return CDCDSerialPort_GetSerialState(pCdcd);\r
+}\r
+\r
+/**\r
+ * Sets the current serial state of the device to the given value.\r
+ * \param serialState New device state.\r
+ */\r
+void CDCDSerial_SetSerialState(uint16_t serialState)\r
+{\r
+ CDCDSerialPort * pCdcd = &cdcdSerial;\r
+ CDCDSerialPort_SetSerialState(pCdcd, serialState);\r
+}\r
+\r
+/**@}*/\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\file\r
+ * Title: CDCDSerialDriver implementation\r
+ *\r
+ * About: Purpose\r
+ * Implementation of the CDCDSerialDriver class methods.\r
+ */\r
+\r
+/** \addtogroup usbd_cdc\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include "CDCDSerialDriver.h"\r
+\r
+#include <USBLib_Trace.h>\r
+#include <USBDDriver.h>\r
+#include <USBD_HAL.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Types\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Internal variables\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Internal functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Initializes the USB Device CDC serial driver & USBD Driver.\r
+ * \param pDescriptors Pointer to Descriptors list for CDC Serial Device.\r
+ */\r
+void CDCDSerialDriver_Initialize(const USBDDriverDescriptors *pDescriptors)\r
+{\r
+ USBDDriver *pUsbd = USBD_GetDriver();\r
+\r
+ /* Initialize the standard driver */\r
+ USBDDriver_Initialize(pUsbd,\r
+ pDescriptors,\r
+ 0); /* Multiple settings for interfaces not supported */\r
+\r
+ CDCDSerial_Initialize(pUsbd, CDCDSerialDriver_CC_INTERFACE);\r
+\r
+ /* Initialize the USB driver */\r
+ USBD_Init();\r
+}\r
+\r
+/**\r
+ * Invoked whenever the active configuration of device is changed by the\r
+ * host.\r
+ * \param cfgnum Configuration number.\r
+ */\r
+void CDCDSerialDriver_ConfigurationChangedHandler(uint8_t cfgnum)\r
+{\r
+ USBDDriver *pUsbd = USBD_GetDriver();\r
+ USBConfigurationDescriptor *pDesc;\r
+ if (cfgnum) {\r
+ pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);\r
+ CDCDSerial_ConfigureFunction((USBGenericDescriptor *)pDesc,\r
+ pDesc->wTotalLength);\r
+ }\r
+}\r
+\r
+/**\r
+ * Handles CDC-specific SETUP requests. Should be called from a\r
+ * re-implementation of USBDCallbacks_RequestReceived() method.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ */\r
+void CDCDSerialDriver_RequestHandler(const USBGenericRequest *request)\r
+{\r
+ USBDDriver *pUsbd = USBD_GetDriver();\r
+ TRACE_INFO_WP("NewReq ");\r
+ if (CDCDSerial_RequestHandler(request))\r
+ USBDDriver_RequestHandler(pUsbd, request);\r
+}\r
+\r
+/**@}*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\file\r
+ * Implementation of the CDCDSerialPort class methods.\r
+ */\r
+\r
+/** \addtogroup usbd_cdc\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include <CDCDSerialPort.h>\r
+#include <CDCDescriptors.h>\r
+#include <USBLib_Trace.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Types\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** Parse data extention for descriptor parsing */\r
+typedef struct _CDCDParseData {\r
+ /** Pointer to CDCDSerialPort instance */\r
+ CDCDSerialPort * pCdcd;\r
+ /** Pointer to found interface descriptor */\r
+ USBInterfaceDescriptor * pIfDesc;\r
+ \r
+} CDCDParseData;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Internal variables\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** Line coding values */\r
+static CDCLineCoding lineCoding;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Internal functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Parse descriptors: Interface, Bulk IN/OUT, Interrupt IN.\r
+ * \param desc Pointer to descriptor list.\r
+ * \param arg Argument, pointer to AUDDParseData instance.\r
+ */\r
+static uint32_t _Interfaces_Parse(USBGenericDescriptor *pDesc,\r
+ CDCDParseData * pArg)\r
+{\r
+ CDCDSerialPort *pCdcd = pArg->pCdcd;\r
+\r
+ /* Not a valid descriptor */\r
+ if (pDesc->bLength == 0)\r
+ return USBRC_PARAM_ERR;\r
+\r
+ /* Find interface descriptor */\r
+ if (pDesc->bDescriptorType == USBGenericDescriptor_INTERFACE) {\r
+ USBInterfaceDescriptor *pIf = (USBInterfaceDescriptor*)pDesc;\r
+\r
+ /* Obtain interface from descriptor */\r
+ if (pCdcd->bInterfaceNdx == 0xFF) {\r
+ /* First interface is communication */\r
+ if (pIf->bInterfaceClass ==\r
+ CDCCommunicationInterfaceDescriptor_CLASS) {\r
+ pCdcd->bInterfaceNdx = pIf->bInterfaceNumber;\r
+ pCdcd->bNumInterface = 2;\r
+ }\r
+ /* Only data interface */\r
+ else if(pIf->bInterfaceClass == CDCDataInterfaceDescriptor_CLASS) {\r
+ pCdcd->bInterfaceNdx = pIf->bInterfaceNumber;\r
+ pCdcd->bNumInterface = 1;\r
+ }\r
+ pArg->pIfDesc = pIf;\r
+ }\r
+ else if (pCdcd->bInterfaceNdx <= pIf->bInterfaceNumber\r
+ && pCdcd->bInterfaceNdx + pCdcd->bNumInterface\r
+ > pIf->bInterfaceNumber) {\r
+ pArg->pIfDesc = pIf;\r
+ }\r
+ }\r
+\r
+ /* Parse valid interfaces */\r
+ if (pArg->pIfDesc == 0)\r
+ return 0;\r
+\r
+ /* Find endpoint descriptors */\r
+ if (pDesc->bDescriptorType == USBGenericDescriptor_ENDPOINT) {\r
+ USBEndpointDescriptor *pEp = (USBEndpointDescriptor*)pDesc;\r
+ switch(pEp->bmAttributes & 0x3) {\r
+ case USBEndpointDescriptor_INTERRUPT:\r
+ if (pEp->bEndpointAddress & 0x80)\r
+ pCdcd->bIntInPIPE = pEp->bEndpointAddress & 0x7F;\r
+ break;\r
+ case USBEndpointDescriptor_BULK:\r
+ if (pEp->bEndpointAddress & 0x80)\r
+ pCdcd->bBulkInPIPE = pEp->bEndpointAddress & 0x7F;\r
+ else\r
+ pCdcd->bBulkOutPIPE = pEp->bEndpointAddress;\r
+ }\r
+ }\r
+\r
+ if ( pCdcd->bInterfaceNdx != 0xFF\r
+ && pCdcd->bBulkInPIPE != 0\r
+ && pCdcd->bBulkOutPIPE != 0)\r
+ return USBRC_FINISHED;\r
+\r
+ return 0;\r
+}\r
+\r
+/**\r
+ * Callback function which should be invoked after the data of a\r
+ * SetLineCoding request has been retrieved. Sends a zero-length packet\r
+ * to the host for acknowledging the request.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ */\r
+static void _SetLineCodingCallback(CDCDSerialPort * pCdcd)\r
+{\r
+ uint32_t exec = 1;\r
+ if (pCdcd->fEventHandler) {\r
+ uint32_t rc = pCdcd->fEventHandler(\r
+ CDCDSerialPortEvent_SETLINECODING,\r
+ (uint32_t)(&lineCoding),\r
+ pCdcd->pArg);\r
+ if (rc == USBD_STATUS_SUCCESS) {\r
+ pCdcd->lineCoding.dwDTERate = lineCoding.dwDTERate;\r
+ pCdcd->lineCoding.bCharFormat = lineCoding.bCharFormat;\r
+ pCdcd->lineCoding.bParityType = lineCoding.bParityType;\r
+ pCdcd->lineCoding.bDataBits = lineCoding.bDataBits;\r
+ }\r
+ else\r
+ exec = 0;\r
+ }\r
+ if (exec) USBD_Write(0, 0, 0, 0, 0);\r
+ else USBD_Stall(0);\r
+}\r
+\r
+/**\r
+ * Receives new line coding information from the USB host.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ */\r
+static void _SetLineCoding(CDCDSerialPort * pCdcd)\r
+{\r
+ TRACE_INFO_WP("sLineCoding ");\r
+\r
+ USBD_Read(0,\r
+ (void *) & (lineCoding),\r
+ sizeof(CDCLineCoding),\r
+ (TransferCallback)_SetLineCodingCallback,\r
+ (void*)pCdcd);\r
+}\r
+\r
+/**\r
+ * Sends the current line coding information to the host through Control\r
+ * endpoint 0.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ */\r
+static void _GetLineCoding(CDCDSerialPort * pCdcd)\r
+{\r
+ TRACE_INFO_WP("gLineCoding ");\r
+\r
+ USBD_Write(0,\r
+ (void *) &(pCdcd->lineCoding),\r
+ sizeof(CDCLineCoding),\r
+ 0,\r
+ 0);\r
+}\r
+\r
+/**\r
+ * Changes the state of the serial driver according to the information\r
+ * sent by the host via a SetControlLineState request, and acknowledges\r
+ * the request with a zero-length packet.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ */\r
+static void _SetControlLineState(\r
+ CDCDSerialPort * pCdcd,\r
+ const USBGenericRequest *request)\r
+{\r
+ #if (TRACE_LEVEL >= TRACE_LEVEL_INFO)\r
+ uint8_t DTR, RTS;\r
+\r
+ DTR = ((request->wValue & CDCControlLineState_DTR) > 0);\r
+ RTS = ((request->wValue & CDCControlLineState_RTS) > 0);\r
+ TRACE_INFO_WP("sControlLineState(%d, %d) ", DTR, RTS);\r
+ #endif\r
+\r
+ pCdcd->bControlLineState = (uint8_t)request->wValue;\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+\r
+ if (pCdcd->fEventHandler)\r
+ pCdcd->fEventHandler(CDCDSerialPortEvent_SETCONTROLLINESTATE,\r
+
+ (uint32_t)pCdcd->bControlLineState,\r
+ pCdcd->pArg);\r
+}\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Initializes the USB Device CDC serial port function.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param pUsbd Pointer to USBDDriver instance.\r
+ * \param fEventHandler Pointer to event handler function.\r
+ * \param firstInterface First interface index for the function\r
+ * (0xFF to parse from descriptors).\r
+ * \param numInterface Number of interfaces for the function.\r
+ */\r
+void CDCDSerialPort_Initialize(CDCDSerialPort * pCdcd,\r
+ USBDDriver * pUsbd,\r
+ CDCDSerialPortEventHandler fEventHandler,\r
+ void * pArg,\r
+ uint8_t firstInterface,uint8_t numInterface)\r
+{\r
+ TRACE_INFO("CDCDSerialPort_Initialize\n\r");\r
+\r
+ /* Initialize event handler */\r
+ pCdcd->fEventHandler = fEventHandler;\r
+ pCdcd->pArg = pArg;\r
+\r
+ /* Initialize USB Device Driver interface */\r
+ pCdcd->pUsbd = pUsbd;\r
+ pCdcd->bInterfaceNdx = firstInterface;\r
+ pCdcd->bNumInterface = numInterface;\r
+ pCdcd->bIntInPIPE = 0;\r
+ pCdcd->bBulkInPIPE = 0;\r
+ pCdcd->bBulkOutPIPE = 0;\r
+\r
+ /* Initialize Abstract Control Model attributes */\r
+ pCdcd->bControlLineState = 0;\r
+ pCdcd->wSerialState = 0;\r
+ CDCLineCoding_Initialize(&(pCdcd->lineCoding),\r
+ 115200,\r
+ CDCLineCoding_ONESTOPBIT,\r
+ CDCLineCoding_NOPARITY,\r
+ 8);\r
+}\r
+\r
+/**\r
+ * Parse CDC Serial Port information for CDCDSerialPort instance.\r
+ * Accepted interfaces:\r
+ * - Communication Interface + Data Interface\r
+ * - Data Interface ONLY\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param pDescriptors Pointer to descriptor list.\r
+ * \param dwLength Descriptor list size in bytes.\r
+ */\r
+USBGenericDescriptor *CDCDSerialPort_ParseInterfaces(\r
+ CDCDSerialPort *pCdcd,\r
+ USBGenericDescriptor *pDescriptors,\r
+ uint32_t dwLength)\r
+{\r
+ CDCDParseData parseData;\r
+\r
+ parseData.pCdcd = pCdcd;\r
+ parseData.pIfDesc = 0;\r
+\r
+ return USBGenericDescriptor_Parse(\r
+ pDescriptors, dwLength,\r
+ (USBDescriptorParseFunction)_Interfaces_Parse,\r
+ &parseData);\r
+}\r
+\r
+\r
+/**\r
+ * Handles CDC-specific SETUP requests. Should be called from a\r
+ * re-implementation of USBDCallbacks_RequestReceived() method.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param request Pointer to a USBGenericRequest instance.\r
+ * \return USBRC_SUCCESS if request handled, otherwise error.\r
+ */\r
+uint32_t CDCDSerialPort_RequestHandler(\r
+ CDCDSerialPort *pCdcd,\r
+ const USBGenericRequest *request)\r
+{\r
+ if (USBGenericRequest_GetType(request) != USBGenericRequest_CLASS)\r
+ return USBRC_PARAM_ERR;\r
+\r
+ TRACE_INFO_WP("Cdcs ");\r
+\r
+ /* Validate interface */\r
+ if (request->wIndex >= pCdcd->bInterfaceNdx &&\r
+ request->wIndex < pCdcd->bInterfaceNdx + pCdcd->bNumInterface) {\r
+ }\r
+ else {\r
+ return USBRC_PARAM_ERR;\r
+ }\r
+\r
+ /* Handle the request */\r
+ switch (USBGenericRequest_GetRequest(request)) {\r
+\r
+ case CDCGenericRequest_SETLINECODING:\r
+\r
+ _SetLineCoding(pCdcd);\r
+ break;\r
+\r
+ case CDCGenericRequest_GETLINECODING:\r
+\r
+ _GetLineCoding(pCdcd);\r
+ break;\r
+\r
+ case CDCGenericRequest_SETCONTROLLINESTATE:\r
+\r
+ _SetControlLineState(pCdcd, request);\r
+ break;\r
+\r
+ default:\r
+\r
+ return USBRC_PARAM_ERR;\r
+ }\r
+\r
+ return USBRC_SUCCESS;\r
+}\r
+\r
+/**\r
+ * Receives data from the host through the virtual COM port created by\r
+ * the CDC device serial driver. This function behaves like USBD_Read.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param pData Pointer to the data buffer to put received data.\r
+ * \param dwSize Size of the data buffer in bytes.\r
+ * \param fCallback Optional callback function to invoke when the transfer\r
+ * finishes.\r
+ * \param pArg Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the read operation has been started normally;\r
+ * otherwise, the corresponding error code.\r
+ */\r
+uint32_t CDCDSerialPort_Read(const CDCDSerialPort * pCdcd,\r
+ void * pData,uint32_t dwSize,\r
+ TransferCallback fCallback,void * pArg)\r
+{\r
+ if (pCdcd->bBulkOutPIPE == 0)\r
+ return USBRC_PARAM_ERR;\r
+\r
+ return USBD_Read(pCdcd->bBulkOutPIPE,\r
+ pData, dwSize,\r
+ fCallback, pArg);\r
+}\r
+\r
+/**\r
+ * Sends a data buffer through the virtual COM port created by the CDC\r
+ * device serial driver. This function behaves exactly like USBD_Write.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param pData Pointer to the data buffer to send.\r
+ * \param dwSize Size of the data buffer in bytes.\r
+ * \param fCallback Optional callback function to invoke when the transfer\r
+ * finishes.\r
+ * \param pArg Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the read operation has been started normally;\r
+ * otherwise, the corresponding error code.\r
+ */\r
+uint32_t CDCDSerialPort_Write(const CDCDSerialPort * pCdcd,\r
+ void * pData, uint32_t dwSize,\r
+ TransferCallback fCallback, void * pArg)\r
+{\r
+ if (pCdcd->bBulkInPIPE == 0)\r
+ return USBRC_PARAM_ERR;\r
+\r
+ return USBD_Write(pCdcd->bBulkInPIPE,\r
+ pData, dwSize,\r
+ fCallback, pArg);\r
+}\r
+\r
+/**\r
+ * Returns the current control line state of the RS-232 line.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ */\r
+uint8_t CDCDSerialPort_GetControlLineState(const CDCDSerialPort * pCdcd)\r
+{\r
+ return pCdcd->bControlLineState;\r
+}\r
+\r
+/**\r
+ * Copy current line coding settings to pointered space.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param pLineCoding Pointer to CDCLineCoding instance.\r
+ */\r
+void CDCDSerialPort_GetLineCoding(const CDCDSerialPort * pCdcd,\r
+ CDCLineCoding* pLineCoding)\r
+{\r
+ if (pLineCoding) {\r
+ pLineCoding->dwDTERate = pCdcd->lineCoding.dwDTERate;\r
+ pLineCoding->bCharFormat = pCdcd->lineCoding.bCharFormat;\r
+ pLineCoding->bParityType = pCdcd->lineCoding.bParityType;\r
+ pLineCoding->bDataBits = pCdcd->lineCoding.bDataBits;\r
+ }\r
+}\r
+\r
+/**\r
+ * Returns the current status of the RS-232 line.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ */\r
+uint16_t CDCDSerialPort_GetSerialState(const CDCDSerialPort * pCdcd)\r
+{\r
+ return pCdcd->wSerialState;\r
+}\r
+\r
+/**\r
+ * Sets the current serial state of the device to the given value.\r
+ * \param pCdcd Pointer to CDCDSerialPort instance.\r
+ * \param wSerialState New device state.\r
+ */\r
+void CDCDSerialPort_SetSerialState(CDCDSerialPort * pCdcd,\r
+ uint16_t wSerialState)\r
+{\r
+ if (pCdcd->bIntInPIPE == 0)\r
+ return;\r
+\r
+ /* If new state is different from previous one, send a notification to the\r
+ host */\r
+ if (pCdcd->wSerialState != wSerialState) {\r
+\r
+ pCdcd->wSerialState = wSerialState;\r
+ USBD_Write(pCdcd->bIntInPIPE,\r
+ &(pCdcd->wSerialState),\r
+ 2,\r
+ 0,\r
+ 0);\r
+\r
+ /* Reset one-time flags */\r
+ pCdcd->wSerialState &= ~(CDCSerialState_OVERRUN\r
+ | CDCSerialState_PARITY\r
+ | CDCSerialState_FRAMING\r
+ | CDCSerialState_RINGSIGNAL\r
+ | CDCSerialState_BREAK);\r
+ }\r
+}\r
+\r
+/**@}*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/* These headers were introduced in C99\r
+ by working group ISO/IEC JTC1/SC22/WG14. */\r
+#include <stdint.h>\r
+\r
+#include "CDCDSerial.h"\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Default callback functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Invoked when the CDC LineCoding is requested to changed\r
+ * \param port Port number.\r
+ * \param pLineCoding Pointer to new LineCoding settings.\r
+ * \return USBRC_SUCCESS if ready to receive the line coding.\r
+ */\r
+extern WEAK uint8_t CDCDSerial_LineCodingIsToChange(\r
+ CDCLineCoding * pLineCoding)\r
+{\r
+ /* Accept any of linecoding settings */\r
+ pLineCoding = pLineCoding;\r
+ return USBRC_SUCCESS;\r
+}\r
+\r
+/**\r
+ * Invoked when the CDC ControlLineState is changed\r
+ * \param port Port number.\r
+ * \param DTR New DTR value.\r
+ * \param RTS New RTS value.\r
+ */\r
+extern WEAK void CDCDSerial_ControlLineStateChanged(uint8_t DTR,\r
+ uint8_t RTS)\r
+{\r
+ /* Do nothing */\r
+ DTR = DTR; RTS = RTS;\r
+}\r
+\r
--- /dev/null
+;\r
+; Windows USB CDC Driver Setup File for ATMEL AT91SAM products\r
+;\r
+; On Windows 7, right click to update driver software. It may take a while to\r
+; get this option, even if you cancel the auto driver search.\r
+; choose "browse my computer for driver software",\r
+; choose "let me pick from a list of device drivers on my computer",\r
+; Click "have disk" and browse to this .inf file\r
+; If there is a problem, right click and uninstall, checking delete driver software.\r
+\r
+;------------------------------------------------------------------------------\r
+\r
+[Version]\r
+Signature="$Windows NT$"\r
+Class=Ports\r
+ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}\r
+Provider=%ATMEL%\r
+LayoutFile=layout.inf\r
+\r
+DriverVer= 03/09/2011,2.0.0.0\r
+\r
+[Manufacturer]\r
+%ATMEL%=DeviceList,NTamd64\r
+\r
+[DestinationDirs]\r
+DefaultDestDir=12\r
+\r
+\r
+;------------------------------------------------------------------------------\r
+; Windows 2000/XP/Vista32 Support\r
+;------------------------------------------------------------------------------\r
+[DriverInstall.nt]\r
+include=mdmcpq.inf\r
+CopyFiles=DriverCopyFiles.nt\r
+AddReg=DriverInstall.nt.AddReg\r
+\r
+[DriverCopyFiles.nt]\r
+usbser.sys,,,0x20\r
+\r
+[DriverInstall.nt.AddReg]\r
+HKR,,DevLoader,,*ntkern\r
+HKR,,NTMPDriver,,usbser.sys\r
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"\r
+\r
+[DriverInstall.nt.Services]\r
+AddService=usbser, 0x00000002, DriverService.nt\r
+\r
+[DriverService.nt]\r
+DisplayName=%USBtoSerialConverter%\r
+ServiceType=1\r
+StartType=3\r
+ErrorControl=1\r
+ServiceBinary=%12%\usbser.sys\r
+\r
+;------------------------------------------------------------------------------\r
+; Windows Vista64 Support\r
+;------------------------------------------------------------------------------\r
+\r
+[DriverInstall.NTamd64]\r
+include=mdmcpq.inf\r
+CopyFiles=DriverCopyFiles.NTamd64\r
+AddReg=DriverInstall.NTamd64.AddReg\r
+\r
+[DriverCopyFiles.NTamd64]\r
+usbser.sys,,,0x20\r
+\r
+[DriverInstall.NTamd64.AddReg]\r
+HKR,,DevLoader,,*ntkern\r
+HKR,,NTMPDriver,,usbser.sys\r
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"\r
+\r
+\r
+[DriverInstall.NTamd64.Services]\r
+AddService=usbser, 0x00000002, DriverService.NTamd64\r
+\r
+[DriverService.NTamd64]\r
+DisplayName=%USBtoSerialConverter%\r
+ServiceType=1\r
+StartType=3\r
+ErrorControl=1\r
+ServiceBinary=%12%\usbser.sys\r
+\r
+\r
+;------------------------------------------------------------------------------\r
+; VID/PID Settings\r
+;------------------------------------------------------------------------------\r
+[SourceDisksFiles]\r
+[SourceDisksNames]\r
+[DeviceList]\r
+%USBtoSerialConverter%=DriverInstall, USB\VID_03EB&PID_6119\r
+\r
+[DeviceList.NTamd64]\r
+%USBtoSerialConverter%=DriverInstall, USB\VID_03EB&PID_6119\r
+\r
+;------------------------------------------------------------------------------\r
+; String Definitions\r
+;------------------------------------------------------------------------------\r
+[Strings]\r
+\r
+ATMEL="ATMEL Corp." ; String value for the ATMEL symbol\r
+USBtoSerialConverter="AT91 USB to Serial Converter" ; String value for the USBtoSerialConverter symbol\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * Implementation of USB device functions on a UDP controller.\r
+ *\r
+ * See \ref usbd_api "USBD API Methods".\r
+ */\r
+\r
+/** \addtogroup usbd_interface\r
+ *@{\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+#include "USBD.h"\r
+#include "USBD_HAL.h"\r
+\r
+#include <USBLib_Trace.h>\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Definitions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Internal variables\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/** Device current state. */\r
+static uint8_t deviceState;\r
+/** Indicates the previous device state */\r
+static uint8_t previousDeviceState;\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Internal Functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Exported functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * USBD: Event handlers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Handle the USB suspend event, should be invoked whenever\r
+ * HW reports a suspend signal.\r
+ */\r
+void USBD_SuspendHandler(void)\r
+{\r
+ /* Don't do anything if the device is already suspended */\r
+ if (deviceState != USBD_STATE_SUSPENDED) {\r
+\r
+ /* Switch to the Suspended state */\r
+ previousDeviceState = deviceState;\r
+ deviceState = USBD_STATE_SUSPENDED;\r
+\r
+ /* Suspend HW interface */\r
+ USBD_HAL_Suspend();\r
+\r
+ /* Invoke the User Suspended callback (Suspend System?) */\r
+ if (NULL != USBDCallbacks_Suspended)\r
+ USBDCallbacks_Suspended();\r
+ }\r
+}\r
+\r
+/**\r
+ * Handle the USB resume event, should be invoked whenever\r
+ * HW reports a resume signal.\r
+ */\r
+void USBD_ResumeHandler(void)\r
+{\r
+ /* Don't do anything if the device was not suspended */\r
+ if (deviceState == USBD_STATE_SUSPENDED) {\r
+ /* Active the device */\r
+ USBD_HAL_Activate();\r
+ deviceState = previousDeviceState;\r
+ if (deviceState >= USBD_STATE_DEFAULT) {\r
+ /* Invoke the Resume callback */\r
+ if (NULL != USBDCallbacks_Resumed)\r
+ USBDCallbacks_Resumed();\r
+ }\r
+ }\r
+}\r
+\r
+/**\r
+ * Handle the USB reset event, should be invoked whenever\r
+ * HW found USB reset signal on bus, which usually is called\r
+ * "end of bus reset" status.\r
+ */\r
+void USBD_ResetHandler()\r
+{\r
+ /* The device enters the Default state */\r
+ deviceState = USBD_STATE_DEFAULT;\r
+ /* Active the USB HW */\r
+ USBD_HAL_Activate();\r
+ /* Only EP0 enabled */\r
+ USBD_HAL_ResetEPs(0xFFFFFFFF, USBD_STATUS_RESET, 0);\r
+ USBD_ConfigureEndpoint(0);\r
+ /* Invoke the Reset callback */\r
+ if (NULL != USBDCallbacks_Reset)\r
+ USBDCallbacks_Reset();\r
+}\r
+\r
+/**\r
+ * Handle the USB setup package received, should be invoked\r
+ * when an endpoint got a setup package as request.\r
+ * \param bEndpoint Endpoint number.\r
+ * \param pRequest Pointer to content of request.\r
+ */\r
+void USBD_RequestHandler(uint8_t bEndpoint,\r
+ const USBGenericRequest* pRequest)\r
+{\r
+ if (bEndpoint != 0) {\r
+ TRACE_WARNING("EP%d request not supported, default EP only",\r
+ bEndpoint);\r
+ }\r
+ else if (NULL != USBDCallbacks_RequestReceived) {\r
+ USBDCallbacks_RequestReceived(pRequest);\r
+ }\r
+}\r
+\r
+/*---------------------------------------------------------------------------\r
+ * USBD: Library interface\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Configures an endpoint according to its Endpoint Descriptor.\r
+ * \param pDescriptor Pointer to an Endpoint descriptor.\r
+ */\r
+void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor)\r
+{\r
+ USBD_HAL_ConfigureEP(pDescriptor);\r
+}\r
+\r
+/**\r
+ * Sends data through a USB endpoint. Sets up the transfer descriptor,\r
+ * writes one or two data payloads (depending on the number of FIFO bank\r
+ * for the endpoint) and then starts the actual transfer. The operation is\r
+ * complete when all the data has been sent.\r
+ *\r
+ * *If the size of the buffer is greater than the size of the endpoint\r
+ * (or twice the size if the endpoint has two FIFO banks), then the buffer\r
+ * must be kept allocated until the transfer is finished*. This means that\r
+ * it is not possible to declare it on the stack (i.e. as a local variable\r
+ * of a function which returns after starting a transfer).\r
+ *\r
+ * \param bEndpoint Endpoint number.\r
+ * \param pData Pointer to a buffer with the data to send.\r
+ * \param dLength Size of the data buffer.\r
+ * \param fCallback Optional callback function to invoke when the transfer is\r
+ * complete.\r
+ * \param pArgument Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the transfer has been started;\r
+ * otherwise, the corresponding error status code.\r
+ */\r
+uint8_t USBD_Write( uint8_t bEndpoint,\r
+ const void *pData,\r
+ uint32_t dLength,\r
+ TransferCallback fCallback,\r
+ void *pArgument )\r
+{\r
+ USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument);\r
+ return USBD_HAL_Write(bEndpoint, pData, dLength);\r
+}\r
+#if 0\r
+/**\r
+ * Sends data frames through a USB endpoint. Sets up the transfer descriptor\r
+ * list, writes one or two data payloads (depending on the number of FIFO bank\r
+ * for the endpoint) and then starts the actual transfer. The operation is\r
+ * complete when all the data has been sent.\r
+ *\r
+ * *If the size of the frame is greater than the size of the endpoint\r
+ * (or twice the size if the endpoint has two FIFO banks), then the buffer\r
+ * must be kept allocated until the frame is finished*. This means that\r
+ * it is not possible to declare it on the stack (i.e. as a local variable\r
+ * of a function which returns after starting a transfer).\r
+ *\r
+ * \param bEndpoint Endpoint number.\r
+ * \param pMbl Pointer to a frame (USBDTransferBuffer) list that describes\r
+ * the buffer list to send.\r
+ * \param wListSize Size of the frame list.\r
+ * \param bCircList Circle the list.\r
+ * \param wStartNdx For circled list only, the first buffer index to transfer.\r
+ * \param fCallback Optional callback function to invoke when the transfer is\r
+ * complete.\r
+ * \param pArgument Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the transfer has been started;\r
+ * otherwise, the corresponding error status code.\r
+ * \see USBDTransferBuffer, MblTransferCallback, USBD_MblReuse\r
+ */\r
+uint8_t USBD_MblWrite( uint8_t bEndpoint,\r
+ void *pMbl,\r
+ uint16_t wListSize,\r
+ uint8_t bCircList,\r
+ uint16_t wStartNdx,\r
+ MblTransferCallback fCallback,\r
+ void *pArgument )\r
+{\r
+ Endpoint *pEndpoint = &(endpoints[bEndpoint]);\r
+ MblTransfer *pTransfer = (MblTransfer*)&(pEndpoint->transfer);\r
+ uint16_t i;\r
+\r
+ /* EP0 is not suitable for Mbl */\r
+\r
+ if (bEndpoint == 0) {\r
+\r
+ return USBD_STATUS_INVALID_PARAMETER;\r
+ }\r
+\r
+ /* Check that the endpoint is in Idle state */\r
+\r
+ if (pEndpoint->state != UDP_ENDPOINT_IDLE) {\r
+\r
+ return USBD_STATUS_LOCKED;\r
+ }\r
+ pEndpoint->state = UDP_ENDPOINT_SENDINGM;\r
+\r
+ TRACE_DEBUG_WP("WriteM%d(0x%x,%d) ", bEndpoint, pMbl, wListSize);\r
+\r
+ /* Start from first if not circled list */\r
+\r
+ if (!bCircList) wStartNdx = 0;\r
+\r
+ /* Setup the transfer descriptor */\r
+\r
+ pTransfer->pMbl = (USBDTransferBuffer*)pMbl;\r
+ pTransfer->listSize = wListSize;\r
+ pTransfer->fCallback = fCallback;\r
+ pTransfer->pArgument = pArgument;\r
+ pTransfer->currBuffer = wStartNdx;\r
+ pTransfer->freedBuffer = 0;\r
+ pTransfer->pLastLoaded = &(((USBDTransferBuffer*)pMbl)[wStartNdx]);\r
+ pTransfer->circList = bCircList;\r
+ pTransfer->allUsed = 0;\r
+\r
+ /* Clear all buffer */\r
+\r
+ for (i = 0; i < wListSize; i ++) {\r
+\r
+ pTransfer->pMbl[i].transferred = 0;\r
+ pTransfer->pMbl[i].buffered = 0;\r
+ pTransfer->pMbl[i].remaining = pTransfer->pMbl[i].size;\r
+ }\r
+\r
+ /* Send the first packet */\r
+\r
+ while((UDP->UDP_CSR[bEndpoint]&UDP_CSR_TXPKTRDY)==UDP_CSR_TXPKTRDY);\r
+ UDP_MblWriteFifo(bEndpoint);\r
+ SET_CSR(bEndpoint, UDP_CSR_TXPKTRDY);\r
+\r
+ /* If double buffering is enabled and there is data remaining, */\r
+\r
+ /* prepare another packet */\r
+\r
+ if ((CHIP_USB_ENDPOINTS_BANKS(bEndpoint) > 1)\r
+ && (pTransfer->pMbl[pTransfer->currBuffer].remaining > 0)) {\r
+\r
+ UDP_MblWriteFifo(bEndpoint);\r
+ }\r
+\r
+ /* Enable interrupt on endpoint */\r
+\r
+ UDP->UDP_IER = 1 << bEndpoint;\r
+\r
+ return USBD_STATUS_SUCCESS;\r
+}\r
+#endif\r
+/**\r
+ * Reads incoming data on an USB endpoint This methods sets the transfer\r
+ * descriptor and activate the endpoint interrupt. The actual transfer is\r
+ * then carried out by the endpoint interrupt handler. The Read operation\r
+ * finishes either when the buffer is full, or a short packet (inferior to\r
+ * endpoint maximum size) is received.\r
+ *\r
+ * *The buffer must be kept allocated until the transfer is finished*.\r
+ * \param bEndpoint Endpoint number.\r
+ * \param pData Pointer to a data buffer.\r
+ * \param dLength Size of the data buffer in bytes.\r
+ * \param fCallback Optional end-of-transfer callback function.\r
+ * \param pArgument Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the read operation has been started;\r
+ * otherwise, the corresponding error code.\r
+ */\r
+uint8_t USBD_Read(uint8_t bEndpoint,\r
+ void *pData,\r
+ uint32_t dLength,\r
+ TransferCallback fCallback,\r
+ void *pArgument)\r
+{\r
+ USBD_HAL_SetTransferCallback(bEndpoint, fCallback, pArgument);\r
+ return USBD_HAL_Read(bEndpoint, pData, dLength);\r
+}\r
+#if 0\r
+/**\r
+ * Reuse first used/released buffer with new buffer address and size to be used\r
+ * in transfer again. Only valid when frame list is ringed. Can be used for\r
+ * both read & write.\r
+ * \param bEndpoint Endpoint number.\r
+ * \param pNewBuffer Pointer to new buffer with data to send (0 to keep last).\r
+ * \param wNewSize Size of the data buffer\r
+ */\r
+uint8_t USBD_MblReuse( uint8_t bEndpoint,\r
+ uint8_t *pNewBuffer,\r
+ uint16_t wNewSize )\r
+{\r
+ Endpoint *pEndpoint = &(endpoints[bEndpoint]);\r
+ MblTransfer *pTransfer = (MblTransfer*)&(pEndpoint->transfer);\r
+ USBDTransferBuffer *pBi = &(pTransfer->pMbl[pTransfer->freedBuffer]);\r
+\r
+ TRACE_DEBUG_WP("MblReuse(%d), st%x, circ%d\n\r",\r
+ bEndpoint, pEndpoint->state, pTransfer->circList);\r
+\r
+ /* Only for Multi-buffer-circle list */\r
+\r
+ if (bEndpoint != 0\r
+ && (pEndpoint->state == UDP_ENDPOINT_RECEIVINGM\r
+ || pEndpoint->state == UDP_ENDPOINT_SENDINGM)\r
+ && pTransfer->circList) {\r
+ }\r
+ else {\r
+\r
+ return USBD_STATUS_WRONG_STATE;\r
+ }\r
+\r
+ /* Check if there is freed buffer */\r
+\r
+ if (pTransfer->freedBuffer == pTransfer->currBuffer\r
+ && !pTransfer->allUsed) {\r
+\r
+ return USBD_STATUS_LOCKED;\r
+ }\r
+\r
+ /* Update transfer information */\r
+\r
+ if ((++ pTransfer->freedBuffer) == pTransfer->listSize)\r
+ pTransfer->freedBuffer = 0;\r
+ if (pNewBuffer) {\r
+ pBi->pBuffer = pNewBuffer;\r
+ pBi->size = wNewSize;\r
+ }\r
+ pBi->buffered = 0;\r
+ pBi->transferred = 0;\r
+ pBi->remaining = pBi->size;\r
+\r
+ /* At least one buffer is not processed */\r
+\r
+ pTransfer->allUsed = 0;\r
+ return USBD_STATUS_SUCCESS;\r
+}\r
+#endif\r
+/**\r
+ * Sets the HALT feature on the given endpoint (if not already in this state).\r
+ * \param bEndpoint Endpoint number.\r
+ */\r
+void USBD_Halt(uint8_t bEndpoint)\r
+{\r
+ USBD_HAL_Halt(bEndpoint, 1);\r
+}\r
+\r
+/**\r
+ * Clears the Halt feature on the given endpoint.\r
+ * \param bEndpoint Index of endpoint\r
+ */\r
+void USBD_Unhalt(uint8_t bEndpoint)\r
+{\r
+ USBD_HAL_Halt(bEndpoint, 0);\r
+}\r
+\r
+/**\r
+ * Returns the current Halt status of an endpoint.\r
+ * \param bEndpoint Index of endpoint\r
+ * \return 1 if the endpoint is currently halted; otherwise 0\r
+ */\r
+uint8_t USBD_IsHalted(uint8_t bEndpoint)\r
+{\r
+ return USBD_HAL_Halt(bEndpoint, 0xFF);\r
+}\r
+\r
+/**\r
+ * Indicates if the device is running in high or full-speed. Always returns 0\r
+ * since UDP does not support high-speed mode.\r
+ */\r
+uint8_t USBD_IsHighSpeed(void)\r
+{\r
+ return USBD_HAL_IsHighSpeed();\r
+}\r
+\r
+/**\r
+ * Causes the given endpoint to acknowledge the next packet it receives\r
+ * with a STALL handshake.\r
+ * \param bEndpoint Endpoint number.\r
+ * \return USBD_STATUS_SUCCESS or USBD_STATUS_LOCKED.\r
+ */\r
+uint8_t USBD_Stall(uint8_t bEndpoint)\r
+\r
+{\r
+ return USBD_HAL_Stall(bEndpoint);\r
+}\r
+\r
+/**\r
+ * Sets the device address to the given value.\r
+ * \param address New device address.\r
+ */\r
+void USBD_SetAddress(uint8_t address)\r
+{\r
+ TRACE_INFO_WP("SetAddr(%d) ", address);\r
+\r
+ USBD_HAL_SetAddress(address);\r
+ if (address == 0) deviceState = USBD_STATE_DEFAULT;\r
+ else deviceState = USBD_STATE_ADDRESS;\r
+}\r
+\r
+/**\r
+ * Sets the current device configuration.\r
+ * \param cfgnum - Configuration number to set.\r
+ */\r
+void USBD_SetConfiguration(uint8_t cfgnum)\r
+{\r
+ TRACE_INFO_WP("SetCfg(%d) ", cfgnum);\r
+\r
+ USBD_HAL_SetConfiguration(cfgnum);\r
+\r
+ if (cfgnum != 0) {\r
+ deviceState = USBD_STATE_CONFIGURED;\r
+ }\r
+ else {\r
+ deviceState = USBD_STATE_ADDRESS;\r
+ /* Reset all endpoints but Control 0 */\r
+ USBD_HAL_ResetEPs(0xFFFFFFFE, USBD_STATUS_RESET, 0);\r
+ }\r
+}\r
+\r
+/*---------------------------------------------------------------------------\r
+ * USBD: Library API\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Starts a remote wake-up procedure.\r
+ */\r
+void USBD_RemoteWakeUp(void)\r
+{\r
+ /* Device is NOT suspended */\r
+ if (deviceState != USBD_STATE_SUSPENDED) {\r
+\r
+ TRACE_INFO("USBD_RemoteWakeUp: Device is not suspended\n\r");\r
+ return;\r
+ }\r
+ USBD_HAL_Activate();\r
+ USBD_HAL_RemoteWakeUp();\r
+}\r
+\r
+/**\r
+ * Connects the pull-up on the D+ line of the USB.\r
+ */\r
+void USBD_Connect(void)\r
+{\r
+ USBD_HAL_Connect();\r
+}\r
+\r
+/**\r
+ * Disconnects the pull-up from the D+ line of the USB.\r
+ */\r
+void USBD_Disconnect(void)\r
+{\r
+ USBD_HAL_Disconnect();\r
+\r
+ /* Device returns to the Powered state */\r
+\r
+ if (deviceState > USBD_STATE_POWERED) {\r
+\r
+ deviceState = USBD_STATE_POWERED;\r
+ }\r
+\r
+ if (previousDeviceState > USBD_STATE_POWERED) {\r
+\r
+ previousDeviceState = USBD_STATE_POWERED;\r
+ }\r
+}\r
+\r
+/**\r
+ * Initializes the USB driver.\r
+ */\r
+void USBD_Init(void)\r
+{\r
+ TRACE_INFO_WP("USBD_Init\n\r");\r
+\r
+ /* HW Layer Initialize */\r
+ USBD_HAL_Init();\r
+\r
+ /* Device is in the Attached state */\r
+ deviceState = USBD_STATE_SUSPENDED;\r
+ previousDeviceState = USBD_STATE_POWERED;\r
+\r
+ /* Upper Layer Initialize */\r
+ if (NULL != USBDCallbacks_Initialized)\r
+ USBDCallbacks_Initialized();\r
+}\r
+\r
+/**\r
+ * Returns the current state of the USB device.\r
+ * \return Device current state.\r
+ */\r
+uint8_t USBD_GetState(void)\r
+{\r
+ return deviceState;\r
+}\r
+\r
+/**\r
+ * Certification test for High Speed device.\r
+ * \param bIndex Test to be done\r
+ */\r
+void USBD_Test(uint8_t bIndex)\r
+{\r
+ USBD_HAL_Test(bIndex);\r
+}\r
+\r
+/**@}*/\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * Definitions of callbacks used by the USBD API to notify the user\r
+ * application of incoming events. These functions are declared as 'weak',\r
+ * so they can be re-implemented elsewhere in the application in a\r
+ * transparent way.\r
+ *\r
+ * \addtogroup usbd_interface\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include "USBD.h"\r
+#include "USBDDriver.h"\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported function\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Invoked after the USB driver has been initialized. By default, do nothing.\r
+ */\r
+WEAK void USBDCallbacks_Initialized(void)\r
+{\r
+ /* Does nothing */\r
+ __asm volatile( "NOP" );\r
+}\r
+\r
+/**\r
+ * Invoked when the USB driver is reset. Does nothing by default.\r
+ */\r
+WEAK void USBDCallbacks_Reset(void)\r
+{\r
+ /* Does nothing*/\r
+}\r
+\r
+/**\r
+ * Invoked when the USB device gets suspended. By default, do nothing.\r
+ */\r
+WEAK void USBDCallbacks_Suspended(void) {}\r
+\r
+/**\r
+ * Invoked when the USB device leaves the Suspended state. By default,\r
+ * Do nothing.\r
+ */\r
+WEAK void USBDCallbacks_Resumed(void) {}\r
+\r
+/**\r
+ * USBDCallbacks_RequestReceived - Invoked when a new SETUP request is\r
+ * received. Does nothing by default.\r
+ * \param request Pointer to the request to handle.\r
+ */\r
+WEAK void USBDCallbacks_RequestReceived(const USBGenericRequest *request)\r
+{\r
+ /* Does basic enumeration */\r
+ USBDDriver_RequestHandler(USBD_GetDriver(), request);\r
+}\r
+\r
+/**@}*/\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * \addtogroup usbd_interface\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include <USBLib_Trace.h>\r
+\r
+#include "USBDDriver.h"\r
+#include "USBD.h"\r
+#include "USBD_HAL.h"\r
+\r
+#include <string.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Local variables\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** Default device driver instance, for all class drivers in USB Lib. */\r
+static USBDDriver usbdDriver;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Local functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Send a NULL packet\r
+ */\r
+static void TerminateCtrlInWithNull(void *pArg,\r
+ uint8_t status,\r
+ uint32_t transferred,\r
+ uint32_t remaining)\r
+{\r
+ pArg = pArg; status = status;\r
+ transferred = transferred; remaining = remaining;\r
+ USBD_Write(0, /* Endpoint #0 */\r
+ 0, /* No data buffer */\r
+ 0, /* No data buffer */\r
+ (TransferCallback) 0,\r
+ (void *) 0);\r
+}\r
+\r
+/**\r
+ * Configures the device by setting it into the Configured state and\r
+ * initializing all endpoints.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ * \param cfgnum Configuration number to set.\r
+ */\r
+static void SetConfiguration(USBDDriver *pDriver, uint8_t cfgnum)\r
+{\r
+ USBEndpointDescriptor *pEndpoints[17];\r
+ const USBConfigurationDescriptor *pConfiguration;\r
+\r
+ /* Use different descriptor depending on device speed */\r
+ if ( USBD_HAL_IsHighSpeed()\r
+ && pDriver->pDescriptors->pHsConfiguration) {\r
+\r
+ pConfiguration = pDriver->pDescriptors->pHsConfiguration;\r
+ }\r
+ else {\r
+\r
+ pConfiguration = pDriver->pDescriptors->pFsConfiguration;\r
+ }\r
+\r
+ /* Set & save the desired configuration */\r
+ USBD_SetConfiguration(cfgnum);\r
+\r
+ pDriver->cfgnum = cfgnum;\r
+ pDriver->isRemoteWakeUpEnabled =\r
+ ((pConfiguration->bmAttributes & 0x20) > 0);\r
+\r
+ /* If the configuration is not 0, configure endpoints */\r
+ if (cfgnum != 0) {\r
+\r
+ /* Parse configuration to get endpoint descriptors */\r
+ USBConfigurationDescriptor_Parse(pConfiguration, 0, pEndpoints, 0);\r
+\r
+ /* Configure endpoints */\r
+ int i = 0;\r
+ while (pEndpoints[i] != 0) {\r
+\r
+ USBD_ConfigureEndpoint(pEndpoints[i]);\r
+ i++;\r
+ }\r
+ }\r
+ /* Should be done before send the ZLP */\r
+ if (NULL != USBDDriverCallbacks_ConfigurationChanged)\r
+ USBDDriverCallbacks_ConfigurationChanged(cfgnum);\r
+\r
+ /* Acknowledge the request */\r
+ USBD_Write(0, /* Endpoint #0 */\r
+ 0, /* No data buffer */\r
+ 0, /* No data buffer */\r
+ (TransferCallback) 0,\r
+ (void *) 0);\r
+}\r
+\r
+/**\r
+ * Sends the current configuration number to the host.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ */\r
+static void GetConfiguration(const USBDDriver *pDriver)\r
+{\r
+ unsigned long tmp; // Coud be unsigned char : unsigned long has been chose to avoid any potential alignment issue with DMA \r
+ \r
+ if( USBD_GetState() < USBD_STATE_CONFIGURED) \r
+ tmp = 0; // If device is unconfigured, returned configuration must be 0 \r
+ else \r
+ tmp = pDriver->cfgnum; \r
+\r
+ USBD_Write(0, &tmp, 1, 0, 0); \r
+}\r
+\r
+/**\r
+ * Sends the current status of the device to the host.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ */\r
+static void GetDeviceStatus(const USBDDriver *pDriver)\r
+{\r
+ static unsigned short data;\r
+ const USBConfigurationDescriptor *pConfiguration;\r
+\r
+ data = 0;\r
+ /* Use different configuration depending on device speed */\r
+\r
+ if (USBD_IsHighSpeed()) {\r
+\r
+ pConfiguration = pDriver->pDescriptors->pHsConfiguration;\r
+ }\r
+ else {\r
+\r
+ pConfiguration = pDriver->pDescriptors->pFsConfiguration;\r
+ }\r
+\r
+ /* Check current configuration for power mode (if device is configured) */\r
+\r
+ if (pDriver->cfgnum != 0) {\r
+\r
+ if (USBConfigurationDescriptor_IsSelfPowered(pConfiguration)) {\r
+\r
+ data |= 1;\r
+ }\r
+ }\r
+\r
+ /* Check if remote wake-up is enabled */\r
+\r
+ if (pDriver->isRemoteWakeUpEnabled) {\r
+\r
+ data |= 2;\r
+ }\r
+\r
+ /* Send the device status */\r
+\r
+ USBD_Write(0, &data, 2, 0, 0);\r
+}\r
+\r
+/**\r
+ * Sends the current status of an endpoints to the USB host.\r
+ * \param bEndpoint Endpoint number.\r
+ */\r
+static void GetEndpointStatus(uint8_t bEndpoint)\r
+{\r
+ static unsigned short data;\r
+\r
+ data = 0;\r
+\r
+ switch (USBD_HAL_Halt(bEndpoint, 0xFF)) {\r
+\r
+ case USBD_STATUS_INVALID_PARAMETER: /* the endpoint not exists */\r
+ USBD_Stall(0);\r
+ break;\r
+\r
+ case 1:\r
+ data = 1;\r
+ case 0:\r
+ /* Send the endpoint status */\r
+ USBD_Write(0, &data, 2, 0, 0);\r
+ break;\r
+ }\r
+}\r
+\r
+/**\r
+ * Sends the requested USB descriptor to the host if available, or STALLs the\r
+ * request.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ * \param type Type of the requested descriptor\r
+ * \param index Index of the requested descriptor.\r
+ * \param length Maximum number of bytes to return.\r
+ */\r
+static void GetDescriptor(\r
+ const USBDDriver *pDriver,\r
+ uint8_t type,\r
+ uint8_t indexRDesc,\r
+ uint32_t length)\r
+{\r
+ const USBDeviceDescriptor *pDevice;\r
+ const USBConfigurationDescriptor *pConfiguration;\r
+ const USBDeviceQualifierDescriptor *pQualifier;\r
+ const USBConfigurationDescriptor *pOtherSpeed;\r
+ const USBGenericDescriptor **pStrings =\r
+ (const USBGenericDescriptor **) pDriver->pDescriptors->pStrings;\r
+ const USBGenericDescriptor *pString;\r
+ uint8_t numStrings = pDriver->pDescriptors->numStrings;\r
+ uint8_t terminateWithNull = 0;\r
+\r
+ /* Use different set of descriptors depending on device speed */\r
+\r
+ /* By default, we uses full speed values */\r
+ pDevice = pDriver->pDescriptors->pFsDevice;\r
+ pConfiguration = pDriver->pDescriptors->pFsConfiguration;\r
+\r
+ /* HS, we try HS values */\r
+ if (USBD_HAL_IsHighSpeed()) {\r
+\r
+ TRACE_DEBUG_WP("HS ");\r
+ if (pDriver->pDescriptors->pHsDevice)\r
+ pDevice = pDriver->pDescriptors->pHsDevice;\r
+ if (pDriver->pDescriptors->pHsConfiguration)\r
+ pConfiguration = pDriver->pDescriptors->pHsConfiguration;\r
+ pQualifier = pDriver->pDescriptors->pHsQualifier;\r
+ pOtherSpeed = pDriver->pDescriptors->pHsOtherSpeed;\r
+ }\r
+ else {\r
+\r
+ TRACE_DEBUG_WP("FS ");\r
+ pQualifier = pDriver->pDescriptors->pFsQualifier;\r
+ pOtherSpeed = pDriver->pDescriptors->pFsOtherSpeed;\r
+ }\r
+\r
+ /* Check the descriptor type */\r
+\r
+ switch (type) {\r
+\r
+ case USBGenericDescriptor_DEVICE:\r
+ TRACE_INFO_WP("Dev ");\r
+\r
+ /* Adjust length and send descriptor */\r
+\r
+ if (length > USBGenericDescriptor_GetLength((USBGenericDescriptor *) pDevice)) {\r
+\r
+ length = USBGenericDescriptor_GetLength((USBGenericDescriptor *) pDevice);\r
+ }\r
+ USBD_Write(0, pDevice, length, 0, 0);\r
+ break;\r
+\r
+ case USBGenericDescriptor_CONFIGURATION:\r
+ TRACE_INFO_WP("Cfg ");\r
+\r
+ /* Adjust length and send descriptor */\r
+\r
+ if (length > USBConfigurationDescriptor_GetTotalLength(pConfiguration)) {\r
+\r
+ length = USBConfigurationDescriptor_GetTotalLength(pConfiguration);\r
+ terminateWithNull = ((length % pDevice->bMaxPacketSize0) == 0);\r
+ }\r
+ USBD_Write(0,\r
+ pConfiguration,\r
+ length,\r
+ terminateWithNull ? TerminateCtrlInWithNull : 0,\r
+ 0);\r
+ break;\r
+\r
+ case USBGenericDescriptor_DEVICEQUALIFIER:\r
+ TRACE_INFO_WP("Qua ");\r
+\r
+ /* Check if descriptor exists */\r
+\r
+ if (!pQualifier) {\r
+\r
+ USBD_Stall(0);\r
+ }\r
+ else {\r
+\r
+ /* Adjust length and send descriptor */\r
+\r
+ if (length > USBGenericDescriptor_GetLength((USBGenericDescriptor *) pQualifier)) {\r
+\r
+ length = USBGenericDescriptor_GetLength((USBGenericDescriptor *) pQualifier);\r
+ }\r
+ USBD_Write(0, pQualifier, length, 0, 0);\r
+ }\r
+ break;\r
+\r
+ case USBGenericDescriptor_OTHERSPEEDCONFIGURATION:\r
+ TRACE_INFO_WP("OSC ");\r
+\r
+ /* Check if descriptor exists */\r
+\r
+ if (!pOtherSpeed) {\r
+\r
+ USBD_Stall(0);\r
+ }\r
+ else {\r
+\r
+ /* Adjust length and send descriptor */\r
+\r
+ if (length > USBConfigurationDescriptor_GetTotalLength(pOtherSpeed)) {\r
+\r
+ length = USBConfigurationDescriptor_GetTotalLength(pOtherSpeed);\r
+ terminateWithNull = ((length % pDevice->bMaxPacketSize0) == 0);\r
+ }\r
+ USBD_Write(0,\r
+ pOtherSpeed,\r
+ length,\r
+ terminateWithNull ? TerminateCtrlInWithNull : 0,\r
+ 0);\r
+ }\r
+ break;\r
+\r
+ case USBGenericDescriptor_STRING:\r
+ TRACE_INFO_WP("Str%d ", indexRDesc);\r
+\r
+ /* Check if descriptor exists */\r
+\r
+ if (indexRDesc >= numStrings) {\r
+\r
+ USBD_Stall(0);\r
+ }\r
+ else {\r
+\r
+ pString = pStrings[indexRDesc];\r
+\r
+ /* Adjust length and send descriptor */\r
+\r
+ if (length > USBGenericDescriptor_GetLength(pString)) {\r
+\r
+ length = USBGenericDescriptor_GetLength(pString);\r
+ terminateWithNull = ((length % pDevice->bMaxPacketSize0) == 0);\r
+ }\r
+ USBD_Write(0,\r
+ pString,\r
+ length,\r
+ terminateWithNull ? TerminateCtrlInWithNull : 0,\r
+ 0);\r
+ }\r
+ break;\r
+\r
+ default:\r
+ TRACE_WARNING(\r
+ "USBDDriver_GetDescriptor: Unknown descriptor type (%d)\n\r",\r
+ type);\r
+ USBD_Stall(0);\r
+ }\r
+}\r
+\r
+/**\r
+ * Sets the active setting of the given interface if the configuration supports\r
+ * it; otherwise, the control pipe is STALLed. If the setting of an interface\r
+ * changes.\r
+ * \parma pDriver Pointer to a USBDDriver instance.\r
+ * \parma infnum Interface number.\r
+ * \parma setting New active setting for the interface.\r
+ */\r
+static void SetInterface(\r
+ USBDDriver *pDriver,\r
+ uint8_t infnum,\r
+ uint8_t setting)\r
+{\r
+ /* Make sure alternate settings are supported */\r
+\r
+ if (!pDriver->pInterfaces) {\r
+\r
+ USBD_Stall(0);\r
+ }\r
+ else {\r
+\r
+ /* Change the current setting of the interface and trigger the callback */\r
+ /* if necessary */\r
+ if (pDriver->pInterfaces[infnum] != setting) {\r
+\r
+ pDriver->pInterfaces[infnum] = setting;\r
+ if (NULL != USBDDriverCallbacks_InterfaceSettingChanged)\r
+ USBDDriverCallbacks_InterfaceSettingChanged(infnum, setting);\r
+ }\r
+\r
+ /* Acknowledge the request */\r
+\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ }\r
+}\r
+\r
+/**\r
+ * Sends the currently active setting of the given interface to the USB\r
+ * host. If alternate settings are not supported, this function STALLs the\r
+ * control pipe.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ * \param infnum Interface number.\r
+ */\r
+static void GetInterface(\r
+ const USBDDriver *pDriver,\r
+ uint8_t infnum)\r
+{\r
+ /* Make sure alternate settings are supported, or STALL the control pipe */\r
+\r
+ if (!pDriver->pInterfaces) {\r
+\r
+ USBD_Stall(0);\r
+ }\r
+ else {\r
+\r
+ /* Sends the current interface setting to the host */\r
+\r
+ USBD_Write(0, &(pDriver->pInterfaces[infnum]), 1, 0, 0);\r
+ }\r
+}\r
+\r
+/**\r
+ * Performs the selected test on the USB device (high-speed only).\r
+ * \param test Test selector value.\r
+ */\r
+static void USBDDriver_Test(const USBDDriver *pDriver, uint8_t test)\r
+{\r
+ pDriver = pDriver;\r
+ TRACE_DEBUG("UDPHS_Test\n\r");\r
+\r
+ /* the lower byte of wIndex must be zero\r
+ the most significant byte of wIndex is used to specify the specific test mode */\r
+\r
+ switch (test) {\r
+ case USBFeatureRequest_TESTPACKET:\r
+ /*Test mode Test_Packet: */\r
+ /*Upon command, a port must repetitively transmit the following test packet until */\r
+ /*the exit action is taken. This enables the testing of rise and fall times, eye */\r
+ /*patterns, jitter, and any other dynamic waveform specifications. */\r
+ /*The test packet is made up by concatenating the following strings. */\r
+ /*(Note: For J/K NRZI data, and for NRZ data, the bit on the left is the first one */\r
+ /*transmitted. \93S?indicates that a bit stuff occurs, which inserts an \93extra?NRZI data bit. */\r
+ /*? N?is used to indicate N occurrences of a string of bits or symbols.) */\r
+ /*A port in Test_Packet mode must send this packet repetitively. The inter-packet timing */\r
+ /*must be no less than the minimum allowable inter-packet gap as defined in Section 7.1.18 and */\r
+ /*no greater than 125 us. */\r
+\r
+ /* Send ZLP */\r
+ USBD_Test(USBFeatureRequest_TESTSENDZLP);\r
+ /* Tst PACKET */\r
+ USBD_Test(USBFeatureRequest_TESTPACKET);\r
+ while (1);\r
+ /*break; not reached */\r
+\r
+\r
+ case USBFeatureRequest_TESTJ:\r
+ /*Test mode Test_J: */\r
+ /*Upon command, a port\92s transceiver must enter the high-speed J state and remain in that */\r
+ /*state until the exit action is taken. This enables the testing of the high output drive */\r
+ /*level on the D+ line. */\r
+\r
+ /* Send ZLP */\r
+ USBD_Test(USBFeatureRequest_TESTSENDZLP);\r
+ /* Tst J */\r
+ USBD_Test(USBFeatureRequest_TESTJ);\r
+ while (1);\r
+ /*break; not reached */\r
+\r
+\r
+ case USBFeatureRequest_TESTK:\r
+ /*Test mode Test_K: */\r
+ /*Upon command, a port\92s transceiver must enter the high-speed K state and remain in */\r
+ /*that state until the exit action is taken. This enables the testing of the high output drive */\r
+ /*level on the D- line. */\r
+\r
+ /* Send a ZLP */\r
+ USBD_Test(USBFeatureRequest_TESTSENDZLP);\r
+ USBD_Test(USBFeatureRequest_TESTK);\r
+ while (1);\r
+ /*break; not reached */\r
+\r
+\r
+ case USBFeatureRequest_TESTSE0NAK:\r
+ /*Test mode Test_SE0_NAK: */\r
+ /*Upon command, a port\92s transceiver must enter the high-speed receive mode */\r
+ /*and remain in that mode until the exit action is taken. This enables the testing */\r
+ /*of output impedance, low level output voltage, and loading characteristics. */\r
+ /*In addition, while in this mode, upstream facing ports (and only upstream facing ports) */\r
+ /*must respond to any IN token packet with a NAK handshake (only if the packet CRC is */\r
+ /*determined to be correct) within the normal allowed device response time. This enables testing of */\r
+ /*the device squelch level circuitry and, additionally, provides a general purpose stimulus/response */\r
+ /*test for basic functional testing. */\r
+\r
+ /* Send a ZLP */\r
+ USBD_Test(USBFeatureRequest_TESTSENDZLP);\r
+ /* Test SE0_NAK */\r
+ USBD_Test(USBFeatureRequest_TESTSE0NAK);\r
+ while (1);\r
+ /*break; not reached */\r
+\r
+\r
+ default:\r
+ USBD_Stall(0);\r
+ break;\r
+\r
+ }\r
+ /* The exit action is to power cycle the device. */\r
+ /* The device must be disconnected from the host */\r
+}\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Return USBDDriver instance pointer for global usage.\r
+ */\r
+USBDDriver *USBD_GetDriver(void)\r
+{\r
+ return &usbdDriver;\r
+}\r
+\r
+/**\r
+ * Initializes a USBDDriver instance with a list of descriptors. If\r
+ * interfaces can have multiple alternate settings, an array to store the\r
+ * current setting for each interface must be provided.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ * \param pDescriptors Pointer to a USBDDriverDescriptors instance.\r
+ * \param pInterfaces Pointer to an array for storing the current alternate\r
+ * setting of each interface (optional).\r
+ */\r
+void USBDDriver_Initialize(\r
+ USBDDriver *pDriver,\r
+ const USBDDriverDescriptors *pDescriptors,\r
+ uint8_t *pInterfaces)\r
+{\r
+\r
+ pDriver->cfgnum = 0;\r
+ pDriver->isRemoteWakeUpEnabled = 0;\r
+\r
+ pDriver->pDescriptors = pDescriptors;\r
+ pDriver->pInterfaces = pInterfaces;\r
+\r
+ /* Initialize interfaces array if not null */\r
+\r
+ if (pInterfaces != 0) {\r
+\r
+ memset(pInterfaces, sizeof(pInterfaces), 0);\r
+ }\r
+}\r
+\r
+/**\r
+ * Returns configuration descriptor list.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ * \param cfgNum Reserved.\r
+ */\r
+USBConfigurationDescriptor *USBDDriver_GetCfgDescriptors(\r
+ USBDDriver *pDriver, uint8_t cfgNum)\r
+{\r
+ USBDDriverDescriptors *pDescList = (USBDDriverDescriptors *)pDriver->pDescriptors;\r
+ USBConfigurationDescriptor *pCfg;\r
+\r
+ cfgNum = cfgNum;\r
+ if (USBD_HAL_IsHighSpeed() && pDescList->pHsConfiguration)\r
+ pCfg = (USBConfigurationDescriptor *)pDescList->pHsConfiguration;\r
+ else\r
+ pCfg = (USBConfigurationDescriptor *)pDescList->pFsConfiguration;\r
+\r
+ return pCfg;\r
+}\r
+\r
+/**\r
+ * Handles the given request if it is standard, otherwise STALLs it.\r
+ * \param pDriver Pointer to a USBDDriver instance.\r
+ * \param pRequest Pointer to a USBGenericRequest instance.\r
+ */\r
+void USBDDriver_RequestHandler(\r
+ USBDDriver *pDriver,\r
+ const USBGenericRequest *pRequest)\r
+{\r
+ uint8_t cfgnum;\r
+ uint8_t infnum;\r
+ uint8_t eptnum;\r
+ uint8_t setting;\r
+ uint8_t type;\r
+ uint8_t indexDesc;\r
+ uint32_t length;\r
+ uint32_t address;\r
+\r
+ TRACE_INFO_WP("Std ");\r
+\r
+ /* Check request code */\r
+ switch (USBGenericRequest_GetRequest(pRequest)) {\r
+\r
+ case USBGenericRequest_GETDESCRIPTOR:\r
+ TRACE_INFO_WP("gDesc ");\r
+\r
+ /* Send the requested descriptor */\r
+ type = USBGetDescriptorRequest_GetDescriptorType(pRequest);\r
+ indexDesc = USBGetDescriptorRequest_GetDescriptorIndex(pRequest);\r
+ length = USBGenericRequest_GetLength(pRequest);\r
+ GetDescriptor(pDriver, type, indexDesc, length);\r
+ break;\r
+\r
+ case USBGenericRequest_SETADDRESS:\r
+ TRACE_INFO_WP("sAddr ");\r
+\r
+ /* Sends a zero-length packet and then set the device address */\r
+ address = USBSetAddressRequest_GetAddress(pRequest);\r
+ USBD_Write(0, 0, 0, (TransferCallback) USBD_SetAddress, (void *) address);\r
+ break;\r
+\r
+ case USBGenericRequest_SETCONFIGURATION:\r
+ TRACE_INFO_WP("sCfg ");\r
+\r
+ /* Set the requested configuration */\r
+ cfgnum = USBSetConfigurationRequest_GetConfiguration(pRequest);\r
+ SetConfiguration(pDriver, cfgnum);\r
+ break;\r
+\r
+ case USBGenericRequest_GETCONFIGURATION:\r
+ TRACE_INFO_WP("gCfg ");\r
+\r
+ /* Send the current configuration number */\r
+ GetConfiguration(pDriver);\r
+ break;\r
+\r
+ case USBGenericRequest_GETSTATUS:\r
+ TRACE_INFO_WP("gSta ");\r
+\r
+ /* Check who is the recipient */\r
+ switch (USBGenericRequest_GetRecipient(pRequest)) {\r
+\r
+ case USBGenericRequest_DEVICE:\r
+ TRACE_INFO_WP("Dev ");\r
+\r
+ /* Send the device status */\r
+ GetDeviceStatus(pDriver);\r
+ break;\r
+\r
+ case USBGenericRequest_ENDPOINT:\r
+ TRACE_INFO_WP("Ept ");\r
+\r
+ /* Send the endpoint status */\r
+ eptnum = USBGenericRequest_GetEndpointNumber(pRequest);\r
+ GetEndpointStatus(eptnum);\r
+ break;\r
+\r
+ default:\r
+ TRACE_WARNING(\r
+ "USBDDriver_RequestHandler: Unknown recipient (%d)\n\r",\r
+ USBGenericRequest_GetRecipient(pRequest));\r
+ USBD_Stall(0);\r
+ }\r
+ break;\r
+\r
+ case USBGenericRequest_CLEARFEATURE:\r
+ TRACE_INFO_WP("cFeat ");\r
+\r
+ /* Check which is the requested feature */\r
+ switch (USBFeatureRequest_GetFeatureSelector(pRequest)) {\r
+\r
+ case USBFeatureRequest_ENDPOINTHALT:\r
+ TRACE_INFO_WP("Hlt ");\r
+\r
+ /* Unhalt endpoint and send a zero-length packet */\r
+ USBD_Unhalt(USBGenericRequest_GetEndpointNumber(pRequest));\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ break;\r
+\r
+ case USBFeatureRequest_DEVICEREMOTEWAKEUP:\r
+ TRACE_INFO_WP("RmWU ");\r
+\r
+ /* Disable remote wake-up and send a zero-length packet */\r
+ pDriver->isRemoteWakeUpEnabled = 0;\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ break;\r
+\r
+ default:\r
+ TRACE_WARNING(\r
+ "USBDDriver_RequestHandler: Unknown feature selector (%d)\n\r",\r
+ USBFeatureRequest_GetFeatureSelector(pRequest));\r
+ USBD_Stall(0);\r
+ }\r
+ break;\r
+\r
+ case USBGenericRequest_SETFEATURE:\r
+ TRACE_INFO_WP("sFeat ");\r
+\r
+ /* Check which is the selected feature */\r
+ switch (USBFeatureRequest_GetFeatureSelector(pRequest)) {\r
+\r
+ case USBFeatureRequest_DEVICEREMOTEWAKEUP:\r
+ TRACE_INFO_WP("RmWU ");\r
+\r
+ /* Enable remote wake-up and send a ZLP */\r
+ pDriver->isRemoteWakeUpEnabled = 1;\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ break;\r
+\r
+ case USBFeatureRequest_ENDPOINTHALT:\r
+ TRACE_INFO_WP("Halt ");\r
+ /* Halt endpoint */\r
+ USBD_Halt(USBGenericRequest_GetEndpointNumber(pRequest));\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ break;\r
+\r
+ case USBFeatureRequest_TESTMODE:\r
+ /* 7.1.20 Test Mode Support, 9.4.9 Set Feature */\r
+ if ((USBGenericRequest_GetRecipient(pRequest) == USBGenericRequest_DEVICE)\r
+ && ((USBGenericRequest_GetIndex(pRequest) & 0x000F) == 0)) {\r
+\r
+ /* Handle test request */\r
+ USBDDriver_Test(pDriver,\r
+ USBFeatureRequest_GetTestSelector(pRequest));\r
+ }\r
+ else {\r
+\r
+ USBD_Stall(0);\r
+ }\r
+ break;\r
+\r
+#if 0\r
+ case USBFeatureRequest_OTG_B_HNP_ENABLE:\r
+ TRACE_INFO_WP("OTG_B_HNP_ENABLE ");\r
+ pDriver->otg_features_supported |=\r
+ 1<<USBFeatureRequest_OTG_B_HNP_ENABLE;\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ break;\r
+ case USBFeatureRequest_OTG_A_HNP_SUPPORT:\r
+ TRACE_INFO_WP("OTG_A_HNP_SUPPORT ");\r
+ pDriver->otg_features_supported |=\r
+ 1<<USBFeatureRequest_OTG_A_HNP_SUPPORT;\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ break;\r
+ case USBFeatureRequest_OTG_A_ALT_HNP_SUPPORT:\r
+ TRACE_INFO_WP("OTG_A_ALT_HNP_SUPPORT ");\r
+ pDriver->otg_features_supported |=\r
+ 1<<USBFeatureRequest_OTG_A_ALT_HNP_SUPPORT;\r
+ USBD_Write(0, 0, 0, 0, 0);\r
+ break;\r
+#endif\r
+ default:\r
+ TRACE_WARNING(\r
+ "USBDDriver_RequestHandler: Unknown feature selector (%d)\n\r",\r
+ USBFeatureRequest_GetFeatureSelector(pRequest));\r
+ USBD_Stall(0);\r
+ }\r
+ break;\r
+\r
+ case USBGenericRequest_SETINTERFACE:\r
+ TRACE_INFO_WP("sInterface ");\r
+\r
+ infnum = USBInterfaceRequest_GetInterface(pRequest);\r
+ setting = USBInterfaceRequest_GetAlternateSetting(pRequest);\r
+ SetInterface(pDriver, infnum, setting);\r
+ break;\r
+\r
+ case USBGenericRequest_GETINTERFACE:\r
+ TRACE_INFO_WP("gInterface ");\r
+\r
+ infnum = USBInterfaceRequest_GetInterface(pRequest);\r
+ GetInterface(pDriver, infnum);\r
+ break;\r
+\r
+ default:\r
+ TRACE_WARNING(\r
+ "USBDDriver_RequestHandler: Unknown request code (%d)\n\r",\r
+ USBGenericRequest_GetRequest(pRequest));\r
+ USBD_Stall(0);\r
+ }\r
+}\r
+\r
+\r
+/**\r
+ * Test if RemoteWakeUP feature is enabled\r
+ * \param pDriver Pointer to an USBDDriver instance.\r
+ * \return 1 if remote wake up has been enabled by the host; otherwise, returns\r
+ * 0\r
+ */\r
+uint8_t USBDDriver_IsRemoteWakeUpEnabled(const USBDDriver *pDriver)\r
+{\r
+ return pDriver->isRemoteWakeUpEnabled;\r
+}\r
+\r
+/**\r
+ * Return OTG features supported\r
+ * \param pDriver Pointer to an USBDDriver instance.\r
+ * \return the OTG features\r
+ */\r
+uint8_t USBDDriver_returnOTGFeatures(const USBDDriver *pDriver)\r
+{\r
+ return pDriver->otg_features_supported;\r
+}\r
+\r
+/**\r
+ * Clear OTG features supported\r
+ * \param pDriver Pointer to an USBDDriver instance.\r
+ * \return none\r
+ */\r
+void USBDDriver_clearOTGFeatures(USBDDriver *pDriver)\r
+{\r
+ pDriver->otg_features_supported = 0;\r
+}\r
+\r
+/**@}*/\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ *\r
+ * \section Purpose\r
+ * \r
+ * Definition of several callbacks which are triggered by the USB software\r
+ * driver after receiving specific requests.\r
+ * \r
+ * \section Usage\r
+ * \r
+ * -# Re-implement the USBDDriverCallbacks_ConfigurationChanged\r
+ * callback to know when the hosts changes the active configuration of\r
+ * the device.\r
+ * -# Re-implement the USBDDriverCallbacks_InterfaceSettingChanged\r
+ * callback to get notified whenever the active setting of an interface\r
+ * is changed by the host.\r
+ *\r
+ * \addtogroup usbd_interface \r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include "USBDDriver.h"\r
+#include <USBLib_Trace.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Global functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * Indicates that the current configuration of the device has changed.\r
+ * \param cfgnum New device configuration index.\r
+ */\r
+WEAK void USBDDriverCallbacks_ConfigurationChanged(uint8_t cfgnum)\r
+{\r
+ cfgnum = cfgnum;\r
+ TRACE_INFO_WP("cfgChanged%d ", cfgnum);\r
+}\r
+\r
+/**\r
+ * Notifies of a change in the currently active setting of an interface.\r
+ * \param interface Number of the interface whose setting has changed.\r
+ * \param setting New interface setting.\r
+ */\r
+WEAK void USBDDriverCallbacks_InterfaceSettingChanged(\r
+ uint8_t interface,\r
+ uint8_t setting)\r
+{\r
+ interface = interface; setting = setting;\r
+ TRACE_INFO_WP("ifSettingChanged%d.%d ", interface, setting);\r
+}\r
+\r
+/**@}*/\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * Definitions and methods for USB composite device implement.\r
+ * \r
+ */\r
+\r
+#ifndef CDCAUDDDRIVER_H\r
+#define CDCAUDDDRIVER_H\r
+/** \addtogroup usbd_composite_cdcaud\r
+ *@{\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+#include <USBRequests.h>\r
+#include <CDCDescriptors.h>\r
+#include <AUDDescriptors.h>\r
+#include "USBD.h"\r
+#include <USBDDriver.h>\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Definitions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_cdc_aud_desc USB CDC(Serial) + AUD(Speaker) Definitions\r
+ * @{\r
+ */\r
+/** Number of interfaces of the device (5, can be 4 if no mic support */\r
+#define CDCAUDDDriverDescriptors_MaxNumInterfaces 5\r
+/** Number of the CDC interface. */\r
+#define CDCAUDDDriverDescriptors_CDC_INTERFACE 0\r
+/** Number of the Audio interface. */\r
+#define CDCAUDDDriverDescriptors_AUD_INTERFACE 2\r
+/** Number of Audio function channels (M,L,R) */\r
+#define AUDD_NumChannels 3\r
+/** @}*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Types\r
+ *---------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+\r
+/** Audio header descriptor with 1 interface */\r
+typedef struct _AUDHeaderDescriptor1{\r
+\r
+ /** Header descriptor.*/\r
+ AUDHeaderDescriptor header;\r
+ /** Id of the first grouped interface.*/\r
+ uint8_t bInterface0;\r
+\r
+} __attribute__ ((__packed__)) AUDHeaderDescriptor1;\r
+\r
+/** Audio header descriptor with 2 interface */\r
+typedef struct _AUDHeaderDescriptor2 {\r
+\r
+ /** Header descriptor. */\r
+ AUDHeaderDescriptor header;\r
+ /** Id of the first grouped interface - Speaker. */\r
+ uint8_t bInterface0;\r
+ /** Id of the second grouped interface - Speakerphone. */\r
+ uint8_t bInterface1;\r
+\r
+} __attribute__ ((__packed__)) AUDHeaderDescriptor2; /* GCC */\r
+\r
+/**\r
+ * Feature unit descriptor with 3 channel controls (master, right, left).\r
+ */\r
+typedef struct _AUDFeatureUnitDescriptor3{\r
+\r
+ /** Feature unit descriptor.*/\r
+ AUDFeatureUnitDescriptor feature;\r
+ /** Available controls for each channel.*/\r
+ uint8_t bmaControls[AUDD_NumChannels];\r
+ /** Index of a string descriptor for the feature unit.*/\r
+ uint8_t iFeature;\r
+\r
+} __attribute__ ((__packed__)) AUDFeatureUnitDescriptor3;\r
+\r
+/**\r
+ * List of descriptors for detailling the audio control interface of a\r
+ * device using a USB audio speaker function.\r
+ */\r
+typedef struct _AUDDSpeakerAcDescriptors{\r
+\r
+ /** Header descriptor (with one slave interface).*/\r
+ AUDHeaderDescriptor1 header;\r
+ /** Input terminal descriptor.*/\r
+ AUDInputTerminalDescriptor input;\r
+ /** Output terminal descriptor.*/\r
+ AUDOutputTerminalDescriptor output;\r
+ /** Feature unit descriptor.*/\r
+ AUDFeatureUnitDescriptor3 feature;\r
+\r
+} __attribute__ ((__packed__)) AUDDSpeakerAcDescriptors;\r
+\r
+/**\r
+ * List of descriptors for detailling the audio control interface of a\r
+ * device using a USB Audio Speakerphoneer function.\r
+ */\r
+typedef struct _AUDDSpeakerPhoneAcDescriptors {\r
+\r
+ /** Header descriptor (with one slave interface). */\r
+ AUDHeaderDescriptor2 header;\r
+ /** Input terminal descriptor. */\r
+ AUDInputTerminalDescriptor inputSpeakerPhone;\r
+ /** Output terminal descriptor. */\r
+ AUDOutputTerminalDescriptor outputSpeakerPhone;\r
+ /** Feature unit descriptor - SpeakerPhone. */\r
+ AUDFeatureUnitDescriptor3 featureSpeakerPhone;\r
+ /** Input terminal descriptor. */\r
+ AUDInputTerminalDescriptor inputRec;\r
+ /** Output terminal descriptor. */\r
+ AUDOutputTerminalDescriptor outputRec;\r
+ /** Feature unit descriptor - SpeakerPhonephone. */\r
+ AUDFeatureUnitDescriptor3 featureRec;\r
+\r
+} __attribute__ ((__packed__)) AUDDSpeakerPhoneAcDescriptors;\r
+\r
+/**\r
+ * Format type I descriptor with one discrete sampling frequency.\r
+ */\r
+typedef struct _AUDFormatTypeOneDescriptor1{\r
+\r
+ /** Format type I descriptor.*/\r
+ AUDFormatTypeOneDescriptor formatType;\r
+ /** Sampling frequency in Hz.*/\r
+ uint8_t tSamFreq[3];\r
+\r
+} __attribute__ ((__packed__)) AUDFormatTypeOneDescriptor1;\r
+\r
+/**\r
+ * Configuration descriptor list for a device implementing\r
+ * CDC(Serial) + Audio(Speaker) composite driver.\r
+ */\r
+typedef struct _CdcAudspkdDriverConfigurationDescriptors {\r
+\r
+ /** Standard configuration descriptor. */\r
+ USBConfigurationDescriptor configuration;\r
+\r
+ /* --- CDC 0 */\r
+ /** IAD 0 */\r
+ USBInterfaceAssociationDescriptor cdcIAD0;\r
+ /** Communication interface descriptor */\r
+ USBInterfaceDescriptor cdcCommunication0;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor cdcHeader0;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor cdcCallManagement0;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor cdcUnion0;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor cdcNotification0;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor cdcData0;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataOut0;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataIn0;\r
+\r
+ /* --- AUDIO (AC) */\r
+ /** IAD 1*/\r
+ USBInterfaceAssociationDescriptor audIAD;\r
+ /** Audio control interface.*/\r
+ USBInterfaceDescriptor audInterface;\r
+ /** Descriptors for the audio control interface.*/\r
+ AUDDSpeakerAcDescriptors audControl;\r
+ /* -- AUDIO out (AS) */\r
+ /** Streaming out interface descriptor (with no endpoint, required).*/\r
+ USBInterfaceDescriptor audStreamingOutNoIsochronous;\r
+ /** Streaming out interface descriptor.*/\r
+ USBInterfaceDescriptor audStreamingOut;\r
+ /** Audio class descriptor for the streaming out interface.*/\r
+ AUDStreamingInterfaceDescriptor audStreamingOutClass;\r
+ /** Stream format descriptor.*/\r
+ AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;\r
+ /** Streaming out endpoint descriptor.*/\r
+ AUDEndpointDescriptor audStreamingOutEndpoint;\r
+ /** Audio class descriptor for the streaming out endpoint.*/\r
+ AUDDataEndpointDescriptor audStreamingOutDataEndpoint;\r
+\r
+} __attribute__ ((__packed__)) CdcAudspkdDriverConfigurationDescriptors;\r
+\r
+/**\r
+ * Configuration descriptor list for a device implementing\r
+ * CDC(Serial) + Audio(SpeakerPhone) composite driver.\r
+ */\r
+typedef struct _CdcAuddDriverConfigurationDescriptors {\r
+\r
+ /** Standard configuration descriptor. */\r
+ USBConfigurationDescriptor configuration;\r
+\r
+ /* --- CDC 0 */\r
+ /** IAD 0 */\r
+ USBInterfaceAssociationDescriptor cdcIAD0;\r
+ /** Communication interface descriptor */\r
+ USBInterfaceDescriptor cdcCommunication0;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor cdcHeader0;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor cdcCallManagement0;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor cdcUnion0;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor cdcNotification0;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor cdcData0;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataOut0;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataIn0;\r
+\r
+ /* --- AUDIO (AC) */\r
+ /** IAD 1*/\r
+ USBInterfaceAssociationDescriptor audIAD;\r
+ /** Audio control interface.*/\r
+ USBInterfaceDescriptor audInterface;\r
+ /** Descriptors for the audio control interface.*/\r
+ AUDDSpeakerPhoneAcDescriptors audControl;\r
+ /* -- AUDIO out (AS) */\r
+ /** Streaming out interface descriptor (with no endpoint, required).*/\r
+ USBInterfaceDescriptor audStreamingOutNoIsochronous;\r
+ /** Streaming out interface descriptor.*/\r
+ USBInterfaceDescriptor audStreamingOut;\r
+ /** Audio class descriptor for the streaming out interface.*/\r
+ AUDStreamingInterfaceDescriptor audStreamingOutClass;\r
+ /** Stream format descriptor.*/\r
+ AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;\r
+ /** Streaming out endpoint descriptor.*/\r
+ AUDEndpointDescriptor audStreamingOutEndpoint;\r
+ /** Audio class descriptor for the streaming out endpoint.*/\r
+ AUDDataEndpointDescriptor audStreamingOutDataEndpoint;\r
+ /*- AUDIO IN */\r
+ /** Streaming in interface descriptor (with no endpoint, required). */\r
+ USBInterfaceDescriptor streamingInNoIsochronous;\r
+ /** Streaming in interface descriptor. */\r
+ USBInterfaceDescriptor streamingIn;\r
+ /** Audio class descriptor for the streaming in interface. */\r
+ AUDStreamingInterfaceDescriptor streamingInClass;\r
+ /** Stream format descriptor. */\r
+ AUDFormatTypeOneDescriptor1 streamingInFormatType;\r
+ /** Streaming in endpoint descriptor. */\r
+ AUDEndpointDescriptor streamingInEndpoint;\r
+ /** Audio class descriptor for the streaming in endpoint. */\r
+ AUDDataEndpointDescriptor streamingInDataEndpoint;\r
+\r
+} __attribute__ ((__packed__)) CdcAuddDriverConfigurationDescriptors;\r
+\r
+#pragma pack()\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Exported functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+extern void CDCAUDDDriver_Initialize(const USBDDriverDescriptors * pDescriptors);\r
+extern void CDCAUDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);\r
+extern void CDCAUDDDriver_InterfaceSettingChangedHandler(\r
+ uint8_t interface, uint8_t setting);\r
+extern void CDCAUDDDriver_RequestHandler(const USBGenericRequest *request);\r
+\r
+/**@}*/\r
+#endif //#ifndef CDCHIDDDRIVER_H\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * Single CDC Serial Port Function for USB device & composite driver.\r
+ */\r
+\r
+#ifndef CDCDSERIAL_H\r
+#define CDCDSERIAL_H\r
+\r
+/** \addtogroup usbd_cdc\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/* These headers were introduced in C99\r
+ by working group ISO/IEC JTC1/SC22/WG14. */\r
+#include <stdint.h>\r
+\r
+#include <USBRequests.h>\r
+\r
+#include <USBDDriver.h>\r
+#include <CDCDSerialPort.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Definitions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Types\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+extern void CDCDSerial_Initialize(\r
+ USBDDriver * pUsbd, uint8_t bInterfaceNb);\r
+\r
+extern uint32_t CDCDSerial_RequestHandler(\r
+ const USBGenericRequest *request);\r
+\r
+extern void CDCDSerial_ConfigureFunction(\r
+ USBGenericDescriptor * pDescriptors, uint16_t wLength);\r
+\r
+extern uint32_t CDCDSerial_Write(\r
+ void *data,\r
+ uint32_t size,\r
+ TransferCallback callback,\r
+ void *argument);\r
+\r
+extern uint32_t CDCDSerial_Read(\r
+ void *data,\r
+ uint32_t size,\r
+ TransferCallback callback,\r
+ void *argument);\r
+\r
+extern void CDCDSerial_GetLineCoding(CDCLineCoding * pLineCoding);\r
+\r
+extern uint8_t CDCDSerial_GetControlLineState(void);\r
+\r
+extern uint16_t CDCDSerial_GetSerialState(void);\r
+\r
+extern void CDCDSerial_SetSerialState(uint16_t serialState);\r
+\r
+extern uint8_t CDCDSerial_LineCodingIsToChange(\r
+ CDCLineCoding * pLineCoding);\r
+\r
+extern void CDCDSerial_ControlLineStateChanged(\r
+ uint8_t DTR,uint8_t RTS);\r
+\r
+/**@}*/\r
+\r
+#endif /*#ifndef CDCSERIAL_H*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * Definition of a class for implementing a USB device CDC serial driver.\r
+ *\r
+ * \section Usage\r
+ *\r
+ * -# Re-implement the USBDCallbacks_RequestReceived method to pass\r
+ * received requests to CDCDSerialDriver_RequestHandler. *This is\r
+ * automatically done unless the NOAUTOCALLBACK symbol is defined*.\r
+ * -# Initialize the CDC serial and USB drivers using\r
+ * CDCDSerialDriver_Initialize.\r
+ * -# Logically connect the device to the host using USBD_Connect.\r
+ * -# Send serial data to the USB host using CDCDSerialDriver_Write.\r
+ * -# Receive serial data from the USB host using CDCDSerialDriver_Read.\r
+ */\r
+\r
+#ifndef CDCDSERIALDRIVER_H\r
+#define CDCDSERIALDRIVER_H\r
+\r
+/** \addtogroup usbd_cdc\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/* These headers were introduced in C99\r
+ by working group ISO/IEC JTC1/SC22/WG14. */\r
+#include <stdint.h>\r
+\r
+#include <USBRequests.h>\r
+#include <CDCRequests.h>\r
+#include <CDCDescriptors.h>\r
+#include <CDCNotifications.h>\r
+\r
+#include <CDCDSerial.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Definitions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_cdc_if USB Device CDC Serial Interface IDs\r
+ * @{\r
+ */\r
+/** Communication Class Interface ID */\r
+#define CDCDSerialDriver_CC_INTERFACE 0\r
+/** Data Class Interface ID */\r
+#define CDCDSerialDriver_DC_INTERFACE 1\r
+/** @}*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Types\r
+ *------------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+\r
+/**\r
+ * \typedef CDCDSerialDriverConfigurationDescriptors\r
+ * \brief Configuration descriptor list for a device implementing a\r
+ * CDC serial driver.\r
+ */\r
+typedef struct _CDCDSerialDriverConfigurationDescriptors {\r
+\r
+ /** Standard configuration descriptor. */\r
+ USBConfigurationDescriptor configuration;\r
+ /** Communication interface descriptor. */\r
+ USBInterfaceDescriptor communication;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor header;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor callManagement;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor abstractControlManagement;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor union1;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor notification;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor data;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor dataOut;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor dataIn;\r
+\r
+} __attribute__ ((__packed__)) CDCDSerialDriverConfigurationDescriptors;\r
+\r
+/**\r
+ * \typedef CDCDSerialDriverConfigurationDescriptorsOTG\r
+ * \brief Configuration descriptor list for a device implementing a\r
+ * CDC serial OTG driver.\r
+ */\r
+typedef struct _CDCDSerialDriverConfigurationDescriptorsOTG {\r
+\r
+ /** Standard configuration descriptor. */\r
+ USBConfigurationDescriptor configuration;\r
+ /* OTG descriptor */\r
+ USBOtgDescriptor otgDescriptor;\r
+ /** Communication interface descriptor. */\r
+ USBInterfaceDescriptor communication;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor header;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor callManagement;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor abstractControlManagement;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor union1;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor notification;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor data;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor dataOut;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor dataIn;\r
+\r
+} __attribute__ ((__packed__)) CDCDSerialDriverConfigurationDescriptorsOTG;\r
+\r
+#pragma pack()\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+extern void CDCDSerialDriver_Initialize(\r
+ const USBDDriverDescriptors *pDescriptors);\r
+\r
+extern void CDCDSerialDriver_ConfigurationChangedHandler(uint8_t cfgnum);\r
+\r
+extern void CDCDSerialDriver_RequestHandler(\r
+ const USBGenericRequest *request);\r
+\r
+/**\r
+ * Sends a data buffer through the virtual COM port created by the CDC\r
+ * device serial driver. This function behaves exactly like USBD_Write.\r
+ * \param data Pointer to the data buffer to send.\r
+ * \param size Size of the data buffer in bytes.\r
+ * \param callback Optional callback function to invoke when the transfer\r
+ * finishes.\r
+ * \param argument Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the read operation has been started normally;\r
+ * otherwise, the corresponding error code.\r
+ */\r
+static inline uint32_t CDCDSerialDriver_Write(\r
+ void *data,\r
+ uint32_t size,\r
+ TransferCallback callback,\r
+ void *argument)\r
+{\r
+ return CDCDSerial_Write(data, size, callback, argument);\r
+}\r
+\r
+/**\r
+ * Receives data from the host through the virtual COM port created by\r
+ * the CDC device serial driver. This function behaves like USBD_Read.\r
+ * \param data Pointer to the data buffer to put received data.\r
+ * \param size Size of the data buffer in bytes.\r
+ * \param callback Optional callback function to invoke when the transfer\r
+ * finishes.\r
+ * \param argument Optional argument to the callback function.\r
+ * \return USBD_STATUS_SUCCESS if the read operation has been started normally;\r
+ * otherwise, the corresponding error code.\r
+ */\r
+static inline uint32_t CDCDSerialDriver_Read(\r
+ void *data,\r
+ uint32_t size,\r
+ TransferCallback callback,\r
+ void *argument)\r
+{\r
+ return CDCDSerial_Read(data, size, callback, argument);\r
+}\r
+\r
+/**\r
+ * Copy current line coding settings to pointered space.\r
+ * \param pLineCoding Pointer to CDCLineCoding instance.\r
+ */\r
+static inline void CDCDSerialDriver_GetLineCoding(CDCLineCoding * pLineCoding)\r
+{\r
+ CDCDSerial_GetLineCoding(pLineCoding);\r
+}\r
+\r
+/**\r
+ * Returns the current control line state of the RS-232 line.\r
+ */\r
+static inline uint8_t CDCDSerialDriver_GetControlLineState(void)\r
+{\r
+ return CDCDSerial_GetControlLineState();\r
+}\r
+\r
+/**\r
+ * Returns the current status of the RS-232 line.\r
+ */\r
+static inline uint16_t CDCDSerialDriver_GetSerialState(void)\r
+{\r
+ return CDCDSerial_GetSerialState();\r
+}\r
+\r
+/**\r
+ * Sets the current serial state of the device to the given value.\r
+ * \param serialState New device state.\r
+ */\r
+static inline void CDCDSerialDriver_SetSerialState(uint16_t serialState)\r
+{\r
+ CDCDSerial_SetSerialState(serialState);\r
+}\r
+\r
+/**@}*/\r
+\r
+#endif /*#ifndef CDCSERIALDRIVER_H*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * Definition of a class for implementing a USB device\r
+ * CDC serial port function.\r
+ */\r
+\r
+#ifndef _CDCDSERIALPORT_H_\r
+#define _CDCDSERIALPORT_H_\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+ \r
+/* These headers were introduced in C99\r
+ by working group ISO/IEC JTC1/SC22/WG14. */\r
+#include <stdint.h>\r
+\r
+#include <USBRequests.h>\r
+#include <CDCRequests.h>\r
+#include <CDCNotifications.h>\r
+#include "USBD.h"\r
+#include <USBDDriver.h>\r
+/** \addtogroup usbd_cdc\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Defines\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_cdc_serial_desc USB Device Serial Port Descriptor Values\r
+ * @{\r
+ */\r
+/** Default CDC interrupt endpoints max packat size (8). */\r
+#define CDCDSerialPort_INTERRUPT_MAXPACKETSIZE 8\r
+/** Default CDC interrupt endpoint polling rate of High Speed (16ms). */\r
+#define CDCDSerialPort_INTERRUPT_INTERVAL_HS 8\r
+/** Default CDC interrupt endpoint polling rate of Full Speed (16ms). */\r
+#define CDCDSerialPort_INTERRUPT_INTERVAL_FS 16\r
+/** Default CDC bulk endpoints max packat size (512, for HS actually). */\r
+#define CDCDSerialPort_BULK_MAXPACKETSIZE_HS 512\r
+/** Default CDC bulk endpoints max packat size (64, for FS actually). */\r
+#define CDCDSerialPort_BULK_MAXPACKETSIZE_FS 64\r
+/** @}*/\r
+\r
+/** \addtogroup usbd_cdc_serial_events USB Device Serial Port Events\r
+ * @{\r
+ */\r
+/** SetControlLineState event, value is changed */\r
+#define CDCDSerialPortEvent_SETCONTROLLINESTATE 0\r
+/** SetLineCoding event, value is to changed according to return value */\r
+#define CDCDSerialPortEvent_SETLINECODING 1\r
+/** @}*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Types\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** Callback function for serial port events */\r
+typedef uint32_t (*CDCDSerialPortEventHandler)(uint32_t dwEvent,\r
+ uint32_t dwParam,\r
+ void * pArguments);\r
+\r
+/**\r
+ * Struct for USB CDC virtual COM serial port function.\r
+ */\r
+typedef struct _CDCDSerialPort {\r
+ /** USB Driver for the %device */\r
+ USBDDriver *pUsbd;\r
+ /** Callback for serial port events */\r
+ CDCDSerialPortEventHandler fEventHandler;\r
+ /** Callback arguments */\r
+ void *pArg;\r
+ /** USB starting interface index */\r
+ uint8_t bInterfaceNdx;\r
+ /** USB number of interfaces */\r
+ uint8_t bNumInterface;\r
+ /** USB interrupt IN endpoint address */\r
+ uint8_t bIntInPIPE;\r
+ /** USB bulk IN endpoint address */\r
+ uint8_t bBulkInPIPE;\r
+ /** USB bulk OUT endpoint address */\r
+ uint8_t bBulkOutPIPE;\r
+\r
+ /** Serial port ControlLineState */\r
+ uint8_t bControlLineState;\r
+ /** Serial port SerialState */\r
+ uint16_t wSerialState;\r
+ /** Serial port linecoding */\r
+ CDCLineCoding lineCoding;\r
+\r
+ uint8_t bReserved;\r
+} CDCDSerialPort;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+extern void CDCDSerialPort_Initialize(CDCDSerialPort *pCdcd,\r
+ USBDDriver *pUsbd,\r
+ CDCDSerialPortEventHandler fCallback,\r
+ void *pArg,\r
+ uint8_t firstInterface,\r
+ uint8_t numInterface);\r
+\r
+extern USBGenericDescriptor * CDCDSerialPort_ParseInterfaces(\r
+ CDCDSerialPort * pCdcd,\r
+ USBGenericDescriptor * pDescriptors, uint32_t dwLength);\r
+\r
+extern uint32_t CDCDSerialPort_RequestHandler(\r
+ CDCDSerialPort *pCdcd,\r
+ const USBGenericRequest *pRequest);\r
+\r
+extern uint32_t CDCDSerialPort_Write(\r
+ const CDCDSerialPort *pCdcd,\r
+ void *pData, uint32_t dwSize,\r
+ TransferCallback fCallback, void* pArg);\r
+\r
+extern uint32_t CDCDSerialPort_Read(\r
+ const CDCDSerialPort *pCdcd,\r
+ void *pData, uint32_t dwSize,\r
+ TransferCallback fCallback, void* pArg);\r
+\r
+extern uint16_t CDCDSerialPort_GetSerialState(\r
+ const CDCDSerialPort *pCdcd);\r
+\r
+extern void CDCDSerialPort_SetSerialState(\r
+ CDCDSerialPort *pCdcd,\r
+ uint16_t wSerialState);\r
+\r
+extern uint8_t CDCDSerialPort_GetControlLineState(\r
+ const CDCDSerialPort * pCdcd);\r
+\r
+extern void CDCDSerialPort_GetLineCoding(\r
+ const CDCDSerialPort * pCdcd,\r
+ CDCLineCoding * pLineCoding);\r
+\r
+/**@}*/\r
+#endif /* #ifndef _CDCDSERIALPORT_H_ */\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ *\r
+ * Definitions and classes for USB CDC class descriptors.\r
+ */\r
+\r
+#ifndef _CDCDESCRIPTORS_H_\r
+#define _CDCDESCRIPTORS_H_\r
+/** \addtogroup usb_cdc\r
+ *@{\r
+ */\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Includes\r
+ *----------------------------------------------------------------------------*/\r
+\r
+#include <stdint.h>\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Definitions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usb_cdc_ver USB CDC Specification Release Numbers\r
+ * @{\r
+ * This section list the CDC Spec. Release Numbers.\r
+ * - \ref CDCGenericDescriptor_CDC1_10\r
+ */\r
+ \r
+/** Identify CDC specification version 1.10. */\r
+#define CDCGenericDescriptor_CDC1_10 0x0110\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_desc_type CDC Descriptro Types\r
+ * @{\r
+ * This section lists CDC descriptor types.\r
+ * - \ref CDCGenericDescriptor_INTERFACE\r
+ * - \ref CDCGenericDescriptor_ENDPOINT\r
+ */\r
+/**Indicates that a CDC descriptor applies to an interface. */\r
+#define CDCGenericDescriptor_INTERFACE 0x24\r
+/** Indicates that a CDC descriptor applies to an endpoint. */\r
+#define CDCGenericDescriptor_ENDPOINT 0x25\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_desc_subtype CDC Descriptor Subtypes\r
+ * @{\r
+ * This section lists CDC descriptor sub types\r
+ * - \ref CDCGenericDescriptor_HEADER\r
+ * - \ref CDCGenericDescriptor_CALLMANAGEMENT\r
+ * - \ref CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT\r
+ * - \ref CDCGenericDescriptor_UNION\r
+ */\r
+\r
+/** Header functional descriptor subtype. */\r
+#define CDCGenericDescriptor_HEADER 0x00\r
+/** Call management functional descriptor subtype. */\r
+#define CDCGenericDescriptor_CALLMANAGEMENT 0x01\r
+/** Abstract control management descriptor subtype. */\r
+#define CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT 0x02\r
+/** Union descriptor subtype. */\r
+#define CDCGenericDescriptor_UNION 0x06\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_descriptor USB CDC Device Descriptor Values\r
+ * @{\r
+ * This section lists the values for CDC Device Descriptor.\r
+ * - \ref CDCDeviceDescriptor_CLASS\r
+ * - \ref CDCDeviceDescriptor_SUBCLASS\r
+ * - \ref CDCDeviceDescriptor_PROTOCOL\r
+ */\r
+/** Device class code when using the CDC class. */\r
+#define CDCDeviceDescriptor_CLASS 0x02\r
+/** Device subclass code when using the CDC class. */\r
+#define CDCDeviceDescriptor_SUBCLASS 0x00\r
+/** Device protocol code when using the CDC class. */\r
+#define CDCDeviceDescriptor_PROTOCOL 0x00\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_if_desc USB CDC Communication Interface Descriptor\r
+ * @{\r
+ * This section lists the values for CDC Communication Interface Descriptor.\r
+ * - \ref CDCCommunicationInterfaceDescriptor_CLASS\r
+ * - \ref CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL\r
+ * - \ref CDCCommunicationInterfaceDescriptor_NOPROTOCOL\r
+ */\r
+/** Interface class code for a CDC communication class interface. */\r
+#define CDCCommunicationInterfaceDescriptor_CLASS 0x02\r
+/** Interface subclass code for an Abstract Control Model interface descriptor.\r
+ */\r
+#define CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL 0x02\r
+/** Interface protocol code when a CDC communication interface does not\r
+ implemenent any particular protocol. */\r
+#define CDCCommunicationInterfaceDescriptor_NOPROTOCOL 0x00\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_data_if USB CDC Data Interface Values\r
+ * @{\r
+ * This section lists the values for CDC Data Interface Descriptor.\r
+ * - \ref CDCDataInterfaceDescriptor_CLASS\r
+ * - \ref CDCDataInterfaceDescriptor_SUBCLASS\r
+ * - \ref CDCDataInterfaceDescriptor_NOPROTOCOL\r
+ */\r
+ \r
+/** Interface class code for a data class interface. */\r
+#define CDCDataInterfaceDescriptor_CLASS 0x0A\r
+/** Interface subclass code for a data class interface. */\r
+#define CDCDataInterfaceDescriptor_SUBCLASS 0x00\r
+/** Protocol code for a data class interface which does not implement any\r
+ particular protocol. */\r
+#define CDCDataInterfaceDescriptor_NOPROTOCOL 0x00\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_cb_man_desc USB CDC CallManagement Capabilities\r
+ * @{\r
+ * This section lists CDC CallManagement Capabilities.\r
+ * - \ref CDCCallManagementDescriptor_SELFCALLMANAGEMENT\r
+ * - \ref CDCCallManagementDescriptor_DATACALLMANAGEMENT\r
+ */\r
+/** Device handles call management itself. */\r
+#define CDCCallManagementDescriptor_SELFCALLMANAGEMENT (1 << 0)\r
+/** Device can exchange call management information over a Data class interface.\r
+ */\r
+#define CDCCallManagementDescriptor_DATACALLMANAGEMENT (1 << 1)\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_acm USB CDC ACM Capabilities\r
+ * @{\r
+ *\r
+ * This section lists the capabilities of the CDC ACM.\r
+ * - \ref CDCAbstractControlManagementDescriptor_COMMFEATURE\r
+ * - \ref CDCAbstractControlManagementDescriptor_LINE\r
+ * - \ref CDCAbstractControlManagementDescriptor_SENDBREAK\r
+ * - \ref CDCAbstractControlManagementDescriptor_NETWORKCONNECTION\r
+ */\r
+ \r
+/** Device supports the request combination of SetCommFeature, ClearCommFeature\r
+ and GetCommFeature. */\r
+#define CDCAbstractControlManagementDescriptor_COMMFEATURE (1 << 0)\r
+/** Device supports the request combination of SetLineCoding, GetLineCoding and\r
+ SetControlLineState. */\r
+#define CDCAbstractControlManagementDescriptor_LINE (1 << 1)\r
+/** Device supports the SendBreak request. */\r
+#define CDCAbstractControlManagementDescriptor_SENDBREAK (1 << 2)\r
+/** Device supports the NetworkConnection notification. */\r
+#define CDCAbstractControlManagementDescriptor_NETWORKCONNECTION (1 << 3)\r
+/** @}*/\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Types\r
+ *----------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+/**\r
+ * \typedef CDCHeaderDescriptor\r
+ * \brief Marks the beginning of the concatenated set of functional descriptors\r
+ * for the interface.\r
+ */\r
+typedef struct _CDCHeaderDescriptor {\r
+\r
+ /** Size of this descriptor in bytes. */\r
+ uint8_t bFunctionLength;\r
+ /** Descriptor type . */\r
+ uint8_t bDescriptorType;\r
+ /** Descriptor sub-type . */\r
+ uint8_t bDescriptorSubtype;\r
+ /** USB CDC specification release number. */\r
+ uint16_t bcdCDC;\r
+\r
+} __attribute__ ((__packed__)) CDCHeaderDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef CDCUnionDescriptor\r
+ * \brief Describes the relationship between a group of interfaces that can\r
+ * be considered to form a functional unit.\r
+ */\r
+typedef struct _CDCUnionDescriptor {\r
+\r
+ /** Size of the descriptor in bytes. */\r
+ uint8_t bFunctionLength;\r
+ /** Descriptor type . */\r
+ uint8_t bDescriptorType;\r
+ /** Descriptor subtype . */\r
+ uint8_t bDescriptorSubtype;\r
+ /** Number of the master interface for this union. */\r
+ uint8_t bMasterInterface;\r
+ /** Number of the first slave interface for this union. */\r
+ uint8_t bSlaveInterface0;\r
+\r
+} __attribute__ ((__packed__)) CDCUnionDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef CDCCallManagementDescriptor\r
+ * \brief Describes the processing of calls for the communication class\r
+ * interface.\r
+ */\r
+typedef struct _CDCCallManagementDescriptor {\r
+\r
+ /** Size of this descriptor in bytes. */\r
+ uint8_t bFunctionLength;\r
+ /** Descriptor type . */\r
+ uint8_t bDescriptorType;\r
+ /** Descriptor sub-type . */\r
+ uint8_t bDescriptorSubtype;\r
+ /** Configuration capabilities\r
+ \sa usb_cdc_cb_man_desc CDC CallManagement Capabilities. */\r
+ uint8_t bmCapabilities;\r
+ /** Interface number of the data class interface used for call management\r
+ (optional). */\r
+ uint8_t bDataInterface;\r
+\r
+} __attribute__ ((__packed__)) CDCCallManagementDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef CDCAbstractControlManagementDescriptor\r
+ * \brief Describes the command supported by the communication interface class\r
+ * with the Abstract Control Model subclass code.\r
+ */\r
+typedef struct _CDCAbstractControlManagementDescriptor {\r
+\r
+ /** Size of this descriptor in bytes. */\r
+ uint8_t bFunctionLength;\r
+ /** Descriptor type . */\r
+ uint8_t bDescriptorType;\r
+ /** Descriptor subtype . */\r
+ uint8_t bDescriptorSubtype;\r
+ /** Configuration capabilities.\r
+ \sa usb_cdc_acm CDC ACM Capabilities. */\r
+ uint8_t bmCapabilities;\r
+\r
+} __attribute__ ((__packed__)) CDCAbstractControlManagementDescriptor; /* GCC */\r
+\r
+#pragma pack()\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Functions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+\r
+/**@}*/\r
+#endif /* #ifndef _CDCDESCRIPTORS_H_ */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * Definitions and methods for USB composite device implement.\r
+ * \r
+ * \section Usage\r
+ * \r
+ * -# Initialize USB function specified driver ( for MSD currently )\r
+ * - MSDDFunctionDriver_Initialize()\r
+ *\r
+ * -# Initialize USB composite driver and USB driver\r
+ * - CDCHIDDDriver_Initialize()\r
+ *\r
+ * -# Handle and dispach USB requests\r
+ * - CDCHIDDDriver_RequestHandler()\r
+ *\r
+ * -# Try starting a remote wake-up sequence\r
+ * - CDCHIDDDriver_RemoteWakeUp()\r
+ */\r
+\r
+#ifndef CDCHIDDDRIVER_H\r
+#define CDCHIDDDRIVER_H\r
+/** \addtogroup usbd_composite_cdchid\r
+ *@{\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+#include <USBRequests.h>\r
+#include <CDCDescriptors.h>\r
+#include <HIDDescriptors.h>\r
+#include "USBD.h"\r
+#include <USBDDriver.h>\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Definitions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_cdc_hid_desc USB CDC(Serial) + HID(Kbd) Descriptors define\r
+ * @{\r
+ */\r
+/** Number of interfaces of the device */\r
+#define CDCHIDDDriverDescriptors_NUMINTERFACE 3\r
+/** Number of the CDC interface. */\r
+#define CDCHIDDDriverDescriptors_CDC_INTERFACE 0\r
+/** Number of the HID interface. */\r
+#define CDCHIDDDriverDescriptors_HID_INTERFACE 2\r
+/** @}*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Types\r
+ *---------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+/**\r
+ * \typedef CdcHidDriverConfigurationDescriptors\r
+ * \brief Configuration descriptor list for a device implementing a\r
+ * composite driver.\r
+ */\r
+typedef struct _CdcHidDriverConfigurationDescriptors {\r
+\r
+ /** Standard configuration descriptor. */\r
+ USBConfigurationDescriptor configuration;\r
+\r
+ /* --- CDC 0 */\r
+ /** IAD 0 */\r
+ USBInterfaceAssociationDescriptor cdcIAD0;\r
+ /** Communication interface descriptor */\r
+ USBInterfaceDescriptor cdcCommunication0;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor cdcHeader0;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor cdcCallManagement0;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor cdcUnion0;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor cdcNotification0;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor cdcData0;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataOut0;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataIn0;\r
+\r
+ /* --- HID */\r
+ USBInterfaceDescriptor hidInterface;\r
+ HIDDescriptor1 hid;\r
+ USBEndpointDescriptor hidInterruptIn;\r
+ USBEndpointDescriptor hidInterruptOut;\r
+\r
+} __attribute__ ((__packed__)) CdcHidDriverConfigurationDescriptors;\r
+\r
+#pragma pack()\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Exported functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/* -CDCHID */\r
+extern void CDCHIDDDriver_Initialize(\r
+ const USBDDriverDescriptors * pDescriptors);\r
+\r
+extern void CDCHIDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);\r
+\r
+extern void CDCHIDDDriver_RequestHandler(const USBGenericRequest *request);\r
+\r
+extern void CDCHIDDDriver_RemoteWakeUp(void);\r
+\r
+/**@}*/\r
+#endif //#ifndef CDCHIDDDRIVER_H\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * Definitions and methods for USB CDCMSD device implement.\r
+ * \r
+ * \section Usage\r
+ * \r
+ * -# Initialize USB function specified driver ( for MSD currently )\r
+ * - MSDDFunctionDriver_Initialize\r
+ *\r
+ * -# Initialize USB CDCMSD driver and USB driver\r
+ * - CDCMSDDDriver_Initialize\r
+ *\r
+ * -# Handle and dispach USB requests\r
+ * - CDCMSDDDriver_RequestHandler\r
+ *\r
+ * -# Try starting a remote wake-up sequence\r
+ * - CDCMSDDDriver_RemoteWakeUp\r
+ */\r
+\r
+#ifndef CDCMSDDDRIVER_H\r
+#define CDCMSDDDRIVER_H\r
+/** \addtogroup usbd_composite_cdcmsd\r
+ *@{\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+#include <USBRequests.h>\r
+#include <CDCDescriptors.h>\r
+#include <MSDescriptors.h>\r
+#include <MSDLun.h>\r
+#include "USBD.h"\r
+#include <USBDDriver.h>\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Consts\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_cdc_msd_desc USB CDC(Serial) + MS Descriptors define\r
+ * @{\r
+ */\r
+/** Number of interfaces of the device */\r
+#define CDCMSDDriverDescriptors_NUMINTERFACE 3\r
+/** Number of the CDC interface. */\r
+#define CDCMSDDriverDescriptors_CDC_INTERFACE 0\r
+/** Number of the HID interface. */\r
+#define CDCMSDDriverDescriptors_MSD_INTERFACE 2\r
+/** @}*/\r
+\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Types\r
+ *---------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+/**\r
+ * \typedef CDCMSDDriverConfigurationDescriptors\r
+ * \brief Configuration descriptor list for a device implementing\r
+ * a CDCMSD driver.\r
+ */\r
+typedef struct _CDCMSDDriverConfigurationDescriptors {\r
+\r
+ /** Standard configuration descriptor. */\r
+ USBConfigurationDescriptor configuration;\r
+\r
+ /* --- CDC 0 */\r
+ /** IAD 0 */\r
+ USBInterfaceAssociationDescriptor cdcIAD0;\r
+ /** Communication interface descriptor */\r
+ USBInterfaceDescriptor cdcCommunication0;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor cdcHeader0;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor cdcCallManagement0;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor cdcUnion0;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor cdcNotification0;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor cdcData0;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataOut0;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataIn0;\r
+\r
+ /* --- MSD */\r
+ /** Mass storage interface descriptor. */\r
+ USBInterfaceDescriptor msdInterface;\r
+ /** Bulk-out endpoint descriptor. */\r
+ USBEndpointDescriptor msdBulkOut;\r
+ /** Bulk-in endpoint descriptor. */\r
+ USBEndpointDescriptor msdBulkIn;\r
+\r
+} __attribute__ ((__packed__)) CDCMSDDriverConfigurationDescriptors;\r
+\r
+#pragma pack()\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Exported functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/* -CDCMSD */\r
+extern void CDCMSDDriver_Initialize(\r
+ const USBDDriverDescriptors *pDescriptors,\r
+ MSDLun *pLuns, unsigned char numLuns);\r
+\r
+extern void CDCMSDDriver_ConfigurationChangedHandler(unsigned char cfgnum);\r
+\r
+extern void CDCMSDDriver_RequestHandler(const USBGenericRequest *request);\r
+\r
+/**@}*/\r
+#endif /* #ifndef CDCMSDDDRIVER_H */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * Definitions and methods for USB CDC Notifications.\r
+ */\r
+\r
+#ifndef _CDCNOTIFICATIONS_H_\r
+#define _CDCNOTIFICATIONS_H_\r
+/** \addtogroup usb_cdc\r
+ *@{\r
+ */\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Includes\r
+ *----------------------------------------------------------------------------*/\r
+\r
+#include <stdint.h>\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Definitions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup cdc_serial_states CDC SerialState bits\r
+ * @{\r
+ * This page lists the bit map for CDC Serial States.\r
+ *\r
+ * - \ref CDCSerialState_RXDRIVER\r
+ * - \ref CDCSerialState_TXCARRIER\r
+ * - \ref CDCSerialState_BREAK\r
+ * - \ref CDCSerialState_RINGSIGNAL\r
+ * - \ref CDCSerialState_FRAMING\r
+ * - \ref CDCSerialState_PARITY\r
+ * - \ref CDCSerialState_OVERRUN\r
+ */\r
+\r
+/** Indicates the receiver carrier signal is present */\r
+#define CDCSerialState_RXDRIVER (1 << 0)\r
+/** Indicates the transmission carrier signal is present */\r
+#define CDCSerialState_TXCARRIER (1 << 1)\r
+/** Indicates a break has been detected */\r
+#define CDCSerialState_BREAK (1 << 2)\r
+/** Indicates a ring signal has been detected */\r
+#define CDCSerialState_RINGSIGNAL (1 << 3)\r
+/** Indicates a framing error has occured */\r
+#define CDCSerialState_FRAMING (1 << 4)\r
+/** Indicates a parity error has occured */\r
+#define CDCSerialState_PARITY (1 << 5)\r
+/** Indicates a data overrun error has occured */\r
+#define CDCSerialState_OVERRUN (1 << 6)\r
+/** @}*/\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Types\r
+ *----------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+/** USB CDC SerialState struct (bitmap) */\r
+typedef struct _CDCSerialState {\r
+ uint16_t bRxCarrier:1, /**< State of receive carrier detection (V2.4 signal\r
+ 109 and RS-232 signal DCD) */\r
+ bTxCarrier:1, /**< State of transmission carrier */\r
+ bBreak:1, /**< State of break detection */\r
+ bRingSignal:1, /**< State of ring signal */\r
+ bFraming:1, /**< Framing error */\r
+ bParity:1, /**< Parity error */\r
+ bOverRun:1, /**< Received data discarded due to overrun error */\r
+ reserved:9; /**< Reserved */\r
+} __attribute__ ((__packed__)) CDCSerialState;\r
+\r
+#pragma pack()\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Functions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/**@}*/\r
+#endif /* #ifndef _CDCNOTIFICATIONS_H_ */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ *\r
+ * Definitions and classes for USB CDC class requests\r
+ * (mostly for ACM).\r
+ *\r
+ * \section CDCLineCoding\r
+ *\r
+ * -# Initialize a CDCLineCoding instance using CDCLineCoding_Initialize.\r
+ * -# Send a CDCLineCoding object to the host in response to a GetLineCoding\r
+ * request.\r
+ * -# Receive a CDCLineCoding object from the host after a SetLineCoding\r
+ * request.\r
+ * \r
+ */\r
+\r
+#ifndef _CDCREQUESTS_H_\r
+#define _CDCREQUESTS_H_\r
+/** \addtogroup usb_cdc\r
+ *@{\r
+ */\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Includes\r
+ *----------------------------------------------------------------------------*/\r
+\r
+#include <stdint.h>\r
+\r
+#include <USBRequests.h>\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Definitions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usb_cdc_request USB CDC Request Codes\r
+ * @{\r
+ * This section lists USB CDC Request Codes.\r
+ * - \ref CDCGenericRequest_SETLINECODING\r
+ * - \ref CDCGenericRequest_GETLINECODING\r
+ * - \ref CDCGenericRequest_SETCONTROLLINESTATE\r
+ */\r
+\r
+/** SetLineCoding request code. */\r
+#define CDCGenericRequest_SETLINECODING 0x20\r
+/** GetLineCoding request code. */\r
+#define CDCGenericRequest_GETLINECODING 0x21\r
+/** SetControlLineState request code. */\r
+#define CDCGenericRequest_SETCONTROLLINESTATE 0x22\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_ctrl_line_state USB CDC ControlLineState bitmap\r
+ * @{\r
+ * This section lists CDC ControlLineState bitmap.\r
+ * - \ref CDCControlLineState_DTR, CDCControlLineState_DTE_PRESENT\r
+ * - \ref CDCControlLineState_RTS, CDCControlLineState_CARRIER_ON\r
+ */\r
+/** Indicates to DCE if DTE is present or not. */\r
+#define CDCControlLineState_DTE_PRESENT (1 << 0)\r
+/** RS232 signal DTR: Data Terminal Ready. */\r
+#define CDCControlLineState_DTR (1 << 0)\r
+/** Carrier control for half duplex modems. */\r
+#define CDCControlLineState_CARRIER_ON (1 << 1)\r
+/** RS232 signal RTS: Request to send. */\r
+#define CDCControlLineState_RTS (1 << 1)\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_stop USB CDC LineCoding StopBits\r
+ * @{\r
+ * This section lists Stop Bits for CDC Line Coding.\r
+ * - \ref CDCLineCoding_ONESTOPBIT\r
+ * - \ref CDCLineCoding_ONE5STOPBIT\r
+ * - \ref CDCLineCoding_TWOSTOPBITS\r
+ */\r
+/** The transmission protocol uses one stop bit. */\r
+#define CDCLineCoding_ONESTOPBIT 0\r
+/** The transmission protocol uses 1.5 stop bit. */\r
+#define CDCLineCoding_ONE5STOPBIT 1\r
+/** The transmissin protocol uses two stop bits. */\r
+#define CDCLineCoding_TWOSTOPBITS 2\r
+/** @}*/\r
+\r
+/** \addtogroup usb_cdc_parity USB CDC LineCoding ParityCheckings\r
+ * @{\r
+ * This section lists Parity checkings for CDC Line Coding.\r
+ * - \ref CDCLineCoding_NOPARITY\r
+ * - \ref CDCLineCoding_ODDPARITY\r
+ * - \ref CDCLineCoding_EVENPARITY\r
+ * - \ref CDCLineCoding_MARKPARITY\r
+ * - \ref CDCLineCoding_SPACEPARITY\r
+ */\r
+/** No parity checking. */\r
+#define CDCLineCoding_NOPARITY 0\r
+/** Odd parity checking. */\r
+#define CDCLineCoding_ODDPARITY 1\r
+/** Even parity checking. */\r
+#define CDCLineCoding_EVENPARITY 2\r
+/** Mark parity checking. */\r
+#define CDCLineCoding_MARKPARITY 3\r
+/** Space parity checking. */\r
+#define CDCLineCoding_SPACEPARITY 4\r
+/** @}*/\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Types\r
+ *----------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+\r
+/**\r
+ * \typedef CDCLineCoding\r
+ * \brief Format of the data returned when a GetLineCoding request is received.\r
+ */\r
+typedef struct _CDCLineCoding {\r
+\r
+ /** Data terminal rate in bits per second. */\r
+ uint32_t dwDTERate;\r
+ /** Number of stop bits.\r
+ \sa usb_cdc_stop CDC LineCoding StopBits. */\r
+ uint8_t bCharFormat;\r
+ /** Type of parity checking used.\r
+ \sa usb_cdc_parity CDC LineCoding ParityCheckings. */\r
+ uint8_t bParityType;\r
+ /** Number of data bits (5, 6, 7, 8 or 16). */\r
+ uint8_t bDataBits;\r
+\r
+} __attribute__ ((__packed__)) CDCLineCoding; /* GCC */\r
+\r
+#pragma pack()\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Functions\r
+ *----------------------------------------------------------------------------*/\r
+\r
+extern uint8_t CDCSetControlLineStateRequest_IsDtePresent(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t CDCSetControlLineStateRequest_ActivateCarrier(\r
+ const USBGenericRequest *request);\r
+\r
+extern void CDCLineCoding_Initialize(CDCLineCoding *lineCoding,\r
+ uint32_t bitrate,\r
+ uint8_t stopbits,\r
+ uint8_t parity,\r
+ uint8_t databits);\r
+\r
+\r
+/**@}*/\r
+#endif /* #define _CDCREQUESTS_H_ */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * Definitions and methods for USB composite device implement.\r
+ * \r
+ */\r
+\r
+#ifndef DUALCDCDDRIVER_H\r
+#define DUALCDCDDRIVER_H\r
+/** \addtogroup usbd_composite_cdccdc\r
+ *@{\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+#include <USBRequests.h>\r
+#include <CDCDescriptors.h>\r
+\r
+#include "USBD.h"\r
+#include <CDCDSerialPort.h>\r
+\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Defines\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_composite_cdccdc_desc\r
+ * The driver uses these interface numbers in configuration descriptor.\r
+ * @{\r
+ */\r
+/** Number of interfaces of the device */\r
+#define DUALCDCDDriverDescriptors_NUMINTERFACE 4\r
+/** Number of the CDC0 interface. */\r
+#define DUALCDCDDriverDescriptors_INTERFACENUM0 0\r
+/** Number of the CDC1 interface. */\r
+#define DUALCDCDDriverDescriptors_INTERFACENUM1 2\r
+/** @}*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Types\r
+ *---------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+/**\r
+ * \typedef DualCdcDriverConfigurationDescriptors\r
+ * \brief Configuration descriptor list for a device implementing a\r
+ * dual CDC serial composite driver.\r
+ */\r
+typedef struct _DualCdcDriverConfigurationDescriptors {\r
+\r
+ /** Standard configuration descriptor. */\r
+ USBConfigurationDescriptor configuration;\r
+\r
+ /* --- CDC 0 */\r
+ /** IAD 0 */\r
+ USBInterfaceAssociationDescriptor cdcIAD0;\r
+ /** Communication interface descriptor */\r
+ USBInterfaceDescriptor cdcCommunication0;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor cdcHeader0;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor cdcCallManagement0;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor cdcUnion0;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor cdcNotification0;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor cdcData0;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataOut0;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataIn0;\r
+\r
+ /* --- CDC 1 */\r
+ /** IAD 1 */\r
+ USBInterfaceAssociationDescriptor cdcIAD1;\r
+ /** Communication interface descriptor */\r
+ USBInterfaceDescriptor cdcCommunication1;\r
+ /** CDC header functional descriptor. */\r
+ CDCHeaderDescriptor cdcHeader1;\r
+ /** CDC call management functional descriptor. */\r
+ CDCCallManagementDescriptor cdcCallManagement1;\r
+ /** CDC abstract control management functional descriptor. */\r
+ CDCAbstractControlManagementDescriptor cdcAbstractControlManagement1;\r
+ /** CDC union functional descriptor (with one slave interface). */\r
+ CDCUnionDescriptor cdcUnion1;\r
+ /** Notification endpoint descriptor. */\r
+ USBEndpointDescriptor cdcNotification1;\r
+ /** Data interface descriptor. */\r
+ USBInterfaceDescriptor cdcData1;\r
+ /** Data OUT endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataOut1;\r
+ /** Data IN endpoint descriptor. */\r
+ USBEndpointDescriptor cdcDataIn1;\r
+\r
+} __attribute__ ((__packed__)) DualCdcDriverConfigurationDescriptors;\r
+\r
+#pragma pack()\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Exported functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/* -DUALCDC */\r
+extern void DUALCDCDDriver_Initialize(\r
+ const USBDDriverDescriptors* pDescriptors);\r
+\r
+extern void DUALCDCDDriver_ConfigurationChangeHandler(uint8_t cfgnum);\r
+\r
+extern void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request);\r
+\r
+extern CDCDSerialPort* DUALCDCDDriver_GetSerialPort(uint32_t port);\r
+\r
+/**@}*/\r
+#endif /* #ifndef DUALCDCDDRIVER_H */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * \section Purpose\r
+ *\r
+ * SCSI definitions.\r
+ *\r
+ * \section Usage\r
+ *\r
+ * -# After command block received, Access and decode the SCSI command block\r
+ * with SBCCommand structure.\r
+ */\r
+\r
+#ifndef SBC_H\r
+#define SBC_H\r
+\r
+/** \addtogroup usbd_msd\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Definitions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_sbc_operation_codes SBC Operation Codes\r
+ * @{\r
+ * This page lists operation codes of commands described in the SBC-3\r
+ * standard.\r
+ *\r
+ * \note That most commands are actually defined in other standards,\r
+ * like SPC-4. Optional commands are not included here.\r
+ *\r
+ * \see sbc3r07.pdf - Section 5.1 - Table 12\r
+ * \see spc4r06.pdf\r
+ * \see SBCCommand\r
+ *\r
+ * \section Codes\r
+ * - SBC_INQUIRY\r
+ * - SBC_READ_10\r
+ * - SBC_READ_CAPACITY_10\r
+ * - SBC_REQUEST_SENSE\r
+ * - SBC_TEST_UNIT_READY\r
+ * - SBC_WRITE_10\r
+ *\r
+ * \section Optional Codes but required by Windows\r
+ * - SBC_PREVENT_ALLOW_MEDIUM_REMOVAL\r
+ * - SBC_MODE_SENSE_6\r
+ * - SBC_VERIFY_10\r
+ * - SBC_READ_FORMAT_CAPACITIES\r
+ */\r
+\r
+/** Request information regarding parameters of the target and Logical Unit. */\r
+#define SBC_INQUIRY 0x12\r
+/** Request the transfer data to the host. */\r
+#define SBC_READ_10 0x28\r
+/** Request capacities of the currently installed medium. */\r
+#define SBC_READ_CAPACITY_10 0x25\r
+/** Request that the device server transfer sense data. */\r
+#define SBC_REQUEST_SENSE 0x03\r
+/** Check if the LUN is ready */\r
+#define SBC_TEST_UNIT_READY 0x00\r
+/** Request that the device write the data transferred by the host. */\r
+#define SBC_WRITE_10 0x2A\r
+\r
+/** Request that the target enable or disable the removal of the medium in */\r
+/** the Logical Unit. */\r
+#define SBC_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E\r
+/** Report parameters. */\r
+#define SBC_MODE_SENSE_6 0x1A\r
+/** Request that the %device verify the data on the medium. */\r
+#define SBC_VERIFY_10 0x2F\r
+/** Request a list of the possible capacities that can be formatted on medium */\r
+#define SBC_READ_FORMAT_CAPACITIES 0x23\r
+/** @}*/\r
+\r
+/** \addtogroup usbd_sbc_periph_quali SBC Periph. Qualifiers\r
+ * @{\r
+ * This page lists the peripheral qualifier values specified in the INQUIRY\r
+ * data\r
+ * \see spc4r06.pdf - Section 6.4.2 - Table 83\r
+ * \see SBCInquiryData\r
+ *\r
+ * \section Qualifiers\r
+ * - SBC_PERIPHERAL_DEVICE_CONNECTED\r
+ * - SBC_PERIPHERAL_DEVICE_NOT_CONNECTED\r
+ * - SBC_PERIPHERAL_DEVICE_NOT_SUPPORTED\r
+ */\r
+\r
+#define SBC_PERIPHERAL_DEVICE_CONNECTED 0x00\r
+#define SBC_PERIPHERAL_DEVICE_NOT_CONNECTED 0x01\r
+#define SBC_PERIPHERAL_DEVICE_NOT_SUPPORTED 0x03\r
+/** @}*/\r
+\r
+/** \addtogroup usbd_sbc_periph_types SBC Periph. Types\r
+ * @{\r
+ * This page lists peripheral device types specified in the INQUIRY data\r
+ * \see spc4r06.pdf - Section 6.4.2 - Table 84\r
+ * \see SBCInquiryData\r
+ *\r
+ * \section Types\r
+ * - SBC_DIRECT_ACCESS_BLOCK_DEVICE\r
+ * - SBC_SEQUENTIAL_ACCESS_DEVICE\r
+ * - SBC_PRINTER_DEVICE\r
+ * - SBC_PROCESSOR_DEVICE\r
+ * - SBC_WRITE_ONCE_DEVICE\r
+ * - SBC_CD_DVD_DEVICE\r
+ * - SBC_SCANNER_DEVICE\r
+ * - SBC_OPTICAL_MEMORY_DEVICE\r
+ * - SBC_MEDIA_CHANGER_DEVICE\r
+ * - SBC_COMMUNICATION_DEVICE\r
+ * - SBC_STORAGE_ARRAY_CONTROLLER_DEVICE\r
+ * - SBC_ENCLOSURE_SERVICES_DEVICE\r
+ * - SBC_SIMPLIFIED_DIRECT_ACCESS_DEVICE\r
+ * - SBC_OPTICAL_CARD_READER_WRITER_DEVICE\r
+ * - SBC_BRIDGE_CONTROLLER_COMMANDS\r
+ * - SBC_OBJECT_BASED_STORAGE_DEVICE\r
+ */\r
+\r
+#define SBC_DIRECT_ACCESS_BLOCK_DEVICE 0x00\r
+#define SBC_SEQUENTIAL_ACCESS_DEVICE 0x01\r
+#define SBC_PRINTER_DEVICE 0x02\r
+#define SBC_PROCESSOR_DEVICE 0x03\r
+#define SBC_WRITE_ONCE_DEVICE 0x04\r
+#define SBC_CD_DVD_DEVICE 0x05\r
+#define SBC_SCANNER_DEVICE 0x06\r
+#define SBC_OPTICAL_MEMORY_DEVICE 0x07\r
+#define SBC_MEDIA_CHANGER_DEVICE 0x08\r
+#define SBC_COMMUNICATION_DEVICE 0x09\r
+#define SBC_STORAGE_ARRAY_CONTROLLER_DEVICE 0x0C\r
+#define SBC_ENCLOSURE_SERVICES_DEVICE 0x0D\r
+#define SBC_SIMPLIFIED_DIRECT_ACCESS_DEVICE 0x0E\r
+#define SBC_OPTICAL_CARD_READER_WRITER_DEVICE 0x0F\r
+#define SBC_BRIDGE_CONTROLLER_COMMANDS 0x10\r
+#define SBC_OBJECT_BASED_STORAGE_DEVICE 0x11\r
+/** @}*/\r
+\r
+/*------------------------------------------------------------------------------ */\r
+/** \brief Version value for the SBC-3 specification */\r
+/** \see spc4r06.pdf - Section 6.4.2 - Table 85 */\r
+#define SBC_SPC_VERSION_4 0x06\r
+/*------------------------------------------------------------------------------ */\r
+\r
+/*------------------------------------------------------------------------------ */\r
+/** \brief Values for the TPGS field returned in INQUIRY data */\r
+/** \see spc4r06.pdf - Section 6.4.2 - Table 86 */\r
+#define SBC_TPGS_NONE 0x0\r
+#define SBC_TPGS_ASYMMETRIC 0x1\r
+#define SBC_TPGS_SYMMETRIC 0x2\r
+#define SBC_TPGS_BOTH 0x3\r
+/*------------------------------------------------------------------------------ */\r
+\r
+/*------------------------------------------------------------------------------ */\r
+/** \brief Version descriptor value for the SBC-3 specification */\r
+/** \see spc4r06.pdf - Section 6.4.2 - Table 87 */\r
+#define SBC_VERSION_DESCRIPTOR_SBC_3 0x04C0\r
+/*------------------------------------------------------------------------------ */\r
+\r
+/** \addtogroup usbd_sbc_secse_codes SBC Sense Response Codes\r
+ * @{\r
+ * This page lists sense data response codes returned in REQUEST SENSE data\r
+ * \see spc4r06.pdf - Section 4.5.1 - Table 12\r
+ *\r
+ * \section Codes\r
+ * - SBC_SENSE_DATA_FIXED_CURRENT\r
+ * - SBC_SENSE_DATA_FIXED_DEFERRED\r
+ * - SBC_SENSE_DATA_DESCRIPTOR_CURRENT\r
+ * - SBC_SENSE_DATA_DESCRIPTOR_DEFERRED\r
+ */\r
+\r
+#define SBC_SENSE_DATA_FIXED_CURRENT 0x70\r
+#define SBC_SENSE_DATA_FIXED_DEFERRED 0x71\r
+#define SBC_SENSE_DATA_DESCRIPTOR_CURRENT 0x72\r
+#define SBC_SENSE_DATA_DESCRIPTOR_DEFERRED 0x73\r
+/** @}*/\r
+\r
+/** \addtogroup usbd_sbc_sense_keys SBC Sense Keys\r
+ * @{\r
+ * This page lists sense key values returned in the REQUEST SENSE data\r
+ * \see spc4r06.pdf - Section 4.5.6 - Table 27\r
+ *\r
+ * \section Keys\r
+ * - SBC_SENSE_KEY_NO_SENSE\r
+ * - SBC_SENSE_KEY_RECOVERED_ERROR\r
+ * - SBC_SENSE_KEY_NOT_READY\r
+ * - SBC_SENSE_KEY_MEDIUM_ERROR\r
+ * - SBC_SENSE_KEY_HARDWARE_ERROR\r
+ * - SBC_SENSE_KEY_ILLEGAL_REQUEST\r
+ * - SBC_SENSE_KEY_UNIT_ATTENTION\r
+ * - SBC_SENSE_KEY_DATA_PROTECT\r
+ * - SBC_SENSE_KEY_BLANK_CHECK\r
+ * - SBC_SENSE_KEY_VENDOR_SPECIFIC\r
+ * - SBC_SENSE_KEY_COPY_ABORTED\r
+ * - SBC_SENSE_KEY_ABORTED_COMMAND\r
+ * - SBC_SENSE_KEY_VOLUME_OVERFLOW\r
+ * - SBC_SENSE_KEY_MISCOMPARE\r
+ */\r
+\r
+/** No specific sense key. Successful command. */\r
+#define SBC_SENSE_KEY_NO_SENSE 0x00\r
+/** Command completed succesfully with some recovery action by the %device. */\r
+#define SBC_SENSE_KEY_RECOVERED_ERROR 0x01\r
+/** The device can not be accessed. */\r
+#define SBC_SENSE_KEY_NOT_READY 0x02\r
+/** Command terminated with a error condition that was probably caused by a */\r
+/** flaw in the medium or an error in the recorded data. */\r
+#define SBC_SENSE_KEY_MEDIUM_ERROR 0x03\r
+/** Hardware failure while performing the command or during a self test. */\r
+#define SBC_SENSE_KEY_HARDWARE_ERROR 0x04\r
+/** Illegal parameter found in the command or additional parameters. */\r
+#define SBC_SENSE_KEY_ILLEGAL_REQUEST 0x05\r
+/** Removable medium may have been changed or the %device has been reset. */\r
+#define SBC_SENSE_KEY_UNIT_ATTENTION 0x06\r
+/** Write on a block that is protected. */\r
+#define SBC_SENSE_KEY_DATA_PROTECT 0x07\r
+/** Indicates that a write-once device or a sequential-access device */\r
+/** encountered blank medium or format-defined end-of-data indication while */\r
+/** reading or a write-once device encountered a non-blank medium while writing. */\r
+#define SBC_SENSE_KEY_BLANK_CHECK 0x08\r
+/** Reporting vendor specific conditions. */\r
+#define SBC_SENSE_KEY_VENDOR_SPECIFIC 0x09\r
+/** EXTENDED COPY command was aborted. */\r
+#define SBC_SENSE_KEY_COPY_ABORTED 0x0A\r
+/** Device aborted the command. */\r
+#define SBC_SENSE_KEY_ABORTED_COMMAND 0x0B\r
+/** A buffered peripheral device is overflow. */\r
+#define SBC_SENSE_KEY_VOLUME_OVERFLOW 0x0D\r
+/** The source data did not match the data read from the medium. */\r
+#define SBC_SENSE_KEY_MISCOMPARE 0x0E\r
+/** @}*/\r
+\r
+/** \addtogroup usbd_sbc_sense_additionals SBC Sense Additionals\r
+ * @{\r
+ * This page lists additional sense code values returned in REQUEST SENSE data\r
+ * \see spc4r06.pdf - Section 4.5.6 - Table 28\r
+ *\r
+ * \section Additional Codes\r
+ * - SBC_ASC_LOGICAL_UNIT_NOT_READY\r
+ * - SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE\r
+ * - SBC_ASC_INVALID_FIELD_IN_CDB\r
+ * - SBC_ASC_WRITE_PROTECTED\r
+ * - SBC_ASC_FORMAT_CORRUPTED\r
+ * - SBC_ASC_INVALID_COMMAND_OPERATION_CODE\r
+ * - SBC_ASC_TOO_MUCH_WRITE_DATA\r
+ * - SBC_ASC_NOT_READY_TO_READY_CHANGE\r
+ * - SBC_ASC_MEDIUM_NOT_PRESENT\r
+ */\r
+\r
+#define SBC_ASC_LOGICAL_UNIT_NOT_READY 0x04\r
+#define SBC_ASC_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21\r
+#define SBC_ASC_INVALID_FIELD_IN_CDB 0x24\r
+#define SBC_ASC_WRITE_PROTECTED 0x27\r
+#define SBC_ASC_FORMAT_CORRUPTED 0x31\r
+#define SBC_ASC_INVALID_COMMAND_OPERATION_CODE 0x20\r
+#define SBC_ASC_TOO_MUCH_WRITE_DATA 0x26\r
+#define SBC_ASC_NOT_READY_TO_READY_CHANGE 0x28\r
+#define SBC_ASC_MEDIUM_NOT_PRESENT 0x3A\r
+/** @}*/\r
+\r
+/*------------------------------------------------------------------------------ */\r
+/** \brief MEDIUM TYPE field value for direct-access block devices */\r
+/** \see sbc3r06.pdf - Section 6.3.1 */\r
+#define SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE 0x00\r
+/*------------------------------------------------------------------------------ */\r
+\r
+/*------------------------------------------------------------------------------ */\r
+/** \brief MRIE field values */\r
+/** \see sbc3r06.pdf - Section 7.4.11 - Table 286 */\r
+#define SBC_MRIE_NO_REPORTING 0x00\r
+#define SBC_MRIE_ASYNCHRONOUS 0x01\r
+#define SBC_MRIE_GENERATE_UNIT_ATTENTION 0x02\r
+#define SBC_MRIE_COND_GENERATE_RECOVERED_ERROR 0x03\r
+#define SBC_MRIE_UNCOND_GENERATE_RECOVERED_ERROR 0x04\r
+#define SBC_MRIE_GENERATE_NO_SENSE 0x05\r
+#define SBC_MRIE_ON_REQUEST 0x06\r
+/*------------------------------------------------------------------------------ */\r
+\r
+/*------------------------------------------------------------------------------ */\r
+/** \brief Supported mode pages */\r
+/** \see sbc3r06.pdf - Section 6.3.1 - Table 115 */\r
+#define SBC_PAGE_READ_WRITE_ERROR_RECOVERY 0x01\r
+#define SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL 0x1C\r
+#define SBC_PAGE_RETURN_ALL 0x3F\r
+#define SBC_PAGE_VENDOR_SPECIFIC 0x00\r
+/*------------------------------------------------------------------------------ */\r
+\r
+/** \addtogroup usbd_msd_endian_macros MSD Endian Macros\r
+ * @{\r
+ * This page lists the macros for endianness conversion.\r
+ *\r
+ * \section Macros\r
+ * - WORDB\r
+ * - DWORDB\r
+ * - STORE_DWORDB\r
+ * - STORE_WORDB\r
+ */\r
+\r
+ /** \brief Converts a byte array to a word value using the big endian format */\r
+#define WORDB(bytes) ((unsigned short) ((bytes[0] << 8) | bytes[1]))\r
+\r
+/** \brief Converts a byte array to a dword value using the big endian format */\r
+#define DWORDB(bytes) ((unsigned int) ((bytes[0] << 24) | (bytes[1] << 16) \\r
+ | (bytes[2] << 8) | bytes[3]))\r
+\r
+/** \brief Stores a dword value in a byte array, in big endian format */\r
+#define STORE_DWORDB(dword, bytes) \\r
+ bytes[0] = (unsigned char) (((dword) >> 24) & 0xFF); \\r
+ bytes[1] = (unsigned char) (((dword) >> 16) & 0xFF); \\r
+ bytes[2] = (unsigned char) (((dword) >> 8) & 0xFF); \\r
+ bytes[3] = (unsigned char) ((dword) & 0xFF);\r
+\r
+/** \brief Stores a word value in a byte array, in big endian format */\r
+#define STORE_WORDB(word, bytes) \\r
+ bytes[0] = (unsigned char) (((word) >> 8) & 0xFF); \\r
+ bytes[1] = (unsigned char) ((word) & 0xFF);\r
+/** @}*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Structures\r
+ *------------------------------------------------------------------------------*/\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+/**\r
+ * \typedef SBCInquiry\r
+ * \brief Structure for the INQUIRY command\r
+ * \see spc4r06.pdf - Section 6.4.1 - Table 81\r
+ */\r
+typedef struct _SBCInquiry {\r
+\r
+ unsigned char bOperationCode; /*!< 0x12 : SBC_INQUIRY */\r
+ unsigned char isEVPD:1, /*!< Type of requested data */\r
+ bReserved1:7; /*!< Reserved bits */\r
+ unsigned char bPageCode; /*!< Specifies the VPD to return */\r
+ unsigned char pAllocationLength[2]; /*!< Size of host buffer */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} __attribute__ ((__packed__)) SBCInquiry; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCInquiryData\r
+ * \brief Standard INQUIRY data format returned by the device\r
+ * \see spc4r06.pdf - Section 6.4.2 - Table 82\r
+ */\r
+typedef struct _SBCInquiryData {\r
+\r
+ unsigned char bPeripheralDeviceType:5, /*!< Peripheral device type */\r
+ bPeripheralQualifier :3; /*!< Peripheral qualifier */\r
+ unsigned char bReserved1:7, /*!< Reserved bits */\r
+ isRMB :1; /*!< Is media removable ? */\r
+ unsigned char bVersion; /*!< SPC version used */\r
+ unsigned char bResponseDataFormat:4, /*!< Must be 0x2 */\r
+ isHIGHSUP :1, /*!< Hierarchical addressing used ? */\r
+ isNORMACA :1, /*!< ACA attribute supported ? */\r
+ bObsolete1 :2; /*!< Obsolete bits */\r
+ unsigned char bAdditionalLength; /*!< Length of remaining INQUIRY data */\r
+ unsigned char isSCCS :1, /*!< Embedded SCC ? */\r
+ isACC :1, /*!< Access control coordinator ? */\r
+ bTPGS :2, /*!< Target port support group */\r
+ is3PC :1, /*!< Third-party copy supported ? */\r
+ bReserved2:2, /*!< Reserved bits */\r
+ isProtect :1; /*!< Protection info supported ? */\r
+ unsigned char bObsolete2:1, /*!< Obsolete bit */\r
+ isEncServ :1, /*!< Embedded enclosure service comp? */\r
+ isVS :1, /*!< ??? */\r
+ isMultiP :1, /*!< Multi-port device ? */\r
+ bObsolete3:3, /*!< Obsolete bits */\r
+ bUnused1 :1; /*!< Unused feature */\r
+ unsigned char bUnused2:6, /*!< Unused features */\r
+ isCmdQue:1, /*!< Task management model supported ? */\r
+ isVS2 :1; /*!< ??? */\r
+ unsigned char pVendorID[8]; /*!< T10 vendor identification */\r
+ unsigned char pProductID[16]; /*!< Vendor-defined product ID */\r
+ unsigned char pProductRevisionLevel[4];/*!< Vendor-defined product revision */\r
+ unsigned char pVendorSpecific[20]; /*!< Vendor-specific data */\r
+ unsigned char bUnused3; /*!< Unused features */\r
+ unsigned char bReserved3; /*!< Reserved bits */\r
+ unsigned short pVersionDescriptors[8]; /*!< Standards the device complies to */\r
+ unsigned char pReserved4[22]; /*!< Reserved bytes */\r
+\r
+} __attribute__ ((__packed__)) SBCInquiryData; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCRead10\r
+ * \brief Data structure for the READ (10) command\r
+ * \see sbc3r07.pdf - Section 5.7 - Table 34\r
+ */\r
+typedef struct _SBCRead10 {\r
+\r
+ unsigned char bOperationCode; /*!< 0x28 : SBC_READ_10 */\r
+ unsigned char bObsolete1:1, /*!< Obsolete bit */\r
+ isFUA_NV:1, /*!< Cache control bit */\r
+ bReserved1:1, /*!< Reserved bit */\r
+ isFUA:1, /*!< Cache control bit */\r
+ isDPO:1, /*!< Cache control bit */\r
+ bRdProtect:3; /*!< Protection information to send */\r
+ unsigned char pLogicalBlockAddress[4]; /*!< Index of first block to read */\r
+ unsigned char bGroupNumber:5, /*!< Information grouping */\r
+ bReserved2:3; /*!< Reserved bits */\r
+ unsigned char pTransferLength[2]; /*!< Number of blocks to transmit */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} __attribute__ ((__packed__)) SBCRead10; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCReadCapacity10\r
+ * \brief Structure for the READ CAPACITY (10) command\r
+ * \see sbc3r07.pdf - Section 5.11.1 - Table 40\r
+ */\r
+typedef struct _SBCReadCapacity10 {\r
+\r
+ unsigned char bOperationCode; /*!< 0x25 : RBC_READ_CAPACITY */\r
+ unsigned char bObsolete1:1, /*!< Obsolete bit */\r
+ bReserved1:7; /*!< Reserved bits */\r
+ unsigned char pLogicalBlockAddress[4]; /*!< Block to evaluate if PMI is set */\r
+ unsigned char pReserved2[2]; /*!< Reserved bytes */\r
+ unsigned char isPMI:1, /*!< Partial medium indicator bit */\r
+ bReserved3:7; /*!< Reserved bits */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} SBCReadCapacity10;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * \brief Data returned by the device after a READ CAPACITY (10) command\r
+ * \see sbc3r07.pdf - Section 5.11.2 - Table 41\r
+ *------------------------------------------------------------------------------*/\r
+typedef struct {\r
+\r
+ unsigned char pLogicalBlockAddress[4]; /*!< Address of last logical block */\r
+ unsigned char pLogicalBlockLength[4]; /*!< Length of each logical block */\r
+\r
+} SBCReadCapacity10Data;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * \brief Structure for the REQUEST SENSE command\r
+ * \see spc4r06.pdf - Section 6.26 - Table 170\r
+ *------------------------------------------------------------------------------*/\r
+typedef struct {\r
+\r
+ unsigned char bOperationCode; /*!< 0x03 : SBC_REQUEST_SENSE */\r
+ unsigned char isDesc :1, /*!< Type of information expected */\r
+ bReserved1:7; /*!< Reserved bits */\r
+ unsigned char pReserved2[2]; /*!< Reserved bytes */\r
+ unsigned char bAllocationLength; /*!< Size of host buffer */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} SBCRequestSense;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * \brief Fixed format sense data returned after a REQUEST SENSE command has\r
+ * been received with a DESC bit cleared.\r
+ * \see spc4r06.pdf - Section 4.5.3 - Table 26\r
+ *------------------------------------------------------------------------------*/\r
+typedef struct {\r
+\r
+ unsigned char bResponseCode:7, /*!< Sense data format */\r
+ isValid :1; /*!< Information field is standard */\r
+ unsigned char bObsolete1; /*!< Obsolete byte */\r
+ unsigned char bSenseKey :4, /*!< Generic error information */\r
+ bReserved1:1, /*!< Reserved bit */\r
+ isILI :1, /*!< SSC */\r
+ isEOM :1, /*!< SSC */\r
+ isFilemark:1; /*!< SSC */\r
+ unsigned char pInformation[4]; /*!< Command-specific */\r
+ unsigned char bAdditionalSenseLength; /*!< sizeof(SBCRequestSense_data)-8 */\r
+ unsigned char pCommandSpecificInformation[4]; /*!< Command-specific */\r
+ unsigned char bAdditionalSenseCode; /*!< Additional error information */\r
+ unsigned char bAdditionalSenseCodeQualifier; /*!< Further error information */\r
+ unsigned char bFieldReplaceableUnitCode; /*!< Specific component code */\r
+ unsigned char bSenseKeySpecific:7, /*!< Additional exception info */\r
+ isSKSV :1; /*!< Is sense key specific valid? */\r
+ unsigned char pSenseKeySpecific[2]; /*!< Additional exception info */\r
+\r
+} SBCRequestSenseData;\r
+\r
+/**\r
+ * \brief SBCTestUnitReady\r
+ * Data structure for the TEST UNIT READY command\r
+ * \see spc4r06.pdf - Section 6.34 - Table 192\r
+ */\r
+typedef struct _SBCTestUnitReady {\r
+\r
+ unsigned char bOperationCode; /*!< 0x00 : SBC_TEST_UNIT_READY */\r
+ unsigned char pReserved1[4]; /*!< Reserved bits */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} __attribute__ ((__packed__)) SBCTestUnitReady; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCWrite10\r
+ * \brief Structure for the WRITE (10) command\r
+ * \see sbc3r07.pdf - Section 5.26 - Table 70\r
+ */\r
+typedef struct _SBCWrite10 {\r
+\r
+ unsigned char bOperationCode; /*!< 0x2A : SBC_WRITE_10 */\r
+ unsigned char bObsolete1:1, /*!< Obsolete bit */\r
+ isFUA_NV:1, /*!< Cache control bit */\r
+ bReserved1:1, /*!< Reserved bit */\r
+ isFUA:1, /*!< Cache control bit */\r
+ isDPO:1, /*!< Cache control bit */\r
+ bWrProtect:3; /*!< Protection information to send */\r
+ unsigned char pLogicalBlockAddress[4]; /*!< First block to write */\r
+ unsigned char bGroupNumber:5, /*!< Information grouping */\r
+ bReserved2:3; /*!< Reserved bits */\r
+ unsigned char pTransferLength[2]; /*!< Number of blocks to write */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} SBCWrite10;\r
+\r
+/**\r
+ * \typedef SBCMediumRemoval\r
+ * \brief Structure for the PREVENT/ALLOW MEDIUM REMOVAL command\r
+ * \see sbc3r07.pdf - Section 5.5 - Table 30\r
+ */\r
+typedef struct _SBCMediumRemoval {\r
+\r
+ unsigned char bOperationCode; /*!< 0x1E : SBC_PREVENT_ALLOW_MEDIUM_REMOVAL */\r
+ unsigned char pReserved1[3]; /*!< Reserved bytes */\r
+ unsigned char bPrevent:2, /*!< Accept/prohibit removal */\r
+ bReserved2:6; /*!< Reserved bits */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} __attribute__ ((__packed__)) SBCMediumRemoval; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCModeSense6\r
+ * \brief Structure for the MODE SENSE (6) command\r
+ * \see spc4r06 - Section 6.9.1 - Table 98\r
+ */\r
+typedef struct _SBCModeSense6 {\r
+\r
+ unsigned char bOperationCode; /*!< 0x1A : SBC_MODE_SENSE_6 */\r
+ unsigned char bReserved1:3, /*!< Reserved bits */\r
+ isDBD:1, /*!< Disable block descriptors bit */\r
+ bReserved2:4; /*!< Reserved bits */\r
+ unsigned char bPageCode:6, /*!< Mode page to return */\r
+ bPC:2; /*!< Type of parameter values to return */\r
+ unsigned char bSubpageCode; /*!< Mode subpage to return */\r
+ unsigned char bAllocationLength; /*!< Host buffer allocated size */\r
+ unsigned char bControl; /*!< 0x00 */\r
+\r
+} __attribute__ ((__packed__)) SBCModeSense6; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCModeParameterHeader6\r
+ * \brief Header for the data returned after a MODE SENSE (6) command\r
+ * \see spc4r06.pdf - Section 7.4.3 - Table 268\r
+ */\r
+typedef struct _SBCModeParameterHeader6 {\r
+\r
+ unsigned char bModeDataLength; /*!< Length of mode data to follow */\r
+ unsigned char bMediumType; /*!< Type of medium (SBC_MEDIUM_TYPE_DIRECT_ACCESS_BLOCK_DEVICE) */\r
+ unsigned char bReserved1:4, /*!< Reserved bits */\r
+ isDPOFUA:1, /*!< DPO/FUA bits supported ? */\r
+ bReserved2:2, /*!< Reserved bits */\r
+ isWP:1; /*!< Is medium write-protected ? */\r
+ unsigned char bBlockDescriptorLength; /*!< Length of all block descriptors */\r
+\r
+} __attribute__ ((__packed__)) SBCModeParameterHeader6; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCInformationalExceptionsControl\r
+ * \brief Informational exceptions control mode page\r
+ * \see spc4r06.pdf - Section 7.4.11 - Table 285\r
+ */\r
+typedef struct _SBCInformationalExceptionsControl {\r
+\r
+ unsigned char bPageCode:6, /*!< 0x1C : SBC_PAGE_INFORMATIONAL_EXCEPTIONS_CONTROL */\r
+ isSPF:1, /*!< Page or subpage data format */\r
+ isPS:1; /*!< Parameters saveable ? */\r
+ unsigned char bPageLength; /*!< Length of page data (0x0A) */\r
+ unsigned char isLogErr:1, /*!< Should informational exceptions be logged ? */\r
+ isEBackErr:1, /*!< Enable background error bit */\r
+ isTest:1, /*!< Create a device test failure ? */\r
+ isDExcpt:1, /*!< Disable exception control bit */\r
+ isEWasc:1, /*!< Report warnings ? */\r
+ isEBF:1, /*!< Enable background function bit */\r
+ bReserved1:1, /*!< Reserved bit */\r
+ isPerf:1; /*!< Delay acceptable when treating exceptions ? */\r
+ unsigned char bMRIE:4, /*!< Method of reporting informational exceptions */\r
+ bReserved2:4; /*!< Reserved bits */\r
+ unsigned char pIntervalTimer[4]; /*!< Error reporting period */\r
+ unsigned char pReportCount[4]; /*!< Maximum number of time a report can be issued */\r
+\r
+} __attribute__ ((__packed__)) SBCInformationalExceptionsControl; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCReadWriteErrorRecovery\r
+ * \brief Read/write error recovery mode page\r
+ * \see sbc3r07.pdf - Section 6.3.5 - Table 122\r
+ */\r
+typedef struct _SBCReadWriteErrorRecovery {\r
+\r
+ unsigned char bPageCode:6, /*!< 0x01 : SBC_PAGE_READ_WRITE_ERROR_RECOVERY */\r
+ isSPF:1, /*!< Page or subpage data format */\r
+ isPS:1; /*!< Parameters saveable ? */\r
+ unsigned char bPageLength; /*!< Length of page data (0x0A) */\r
+ unsigned char isDCR:1, /*!< Disable correction bit */\r
+ isDTE:1, /*!< Data terminate on error bit */\r
+ isPER:1, /*!< Post error bit */\r
+ isEER:1, /*!< Enable early recovery bit */\r
+ isRC:1, /*!< Read continuous bit */\r
+ isTB:1, /*!< Transfer block bit */\r
+ isARRE:1, /*!< Automatic read reallocation enabled bit */\r
+ isAWRE:1; /*!< Automatic write reallocation enabled bit */\r
+ unsigned char bReadRetryCount; /*!< Number of retries when reading */\r
+ unsigned char pObsolete1[3]; /*!< Obsolete bytes */\r
+ unsigned char bReserved1; /*!< Reserved byte */\r
+ unsigned char bWriteRetryCount; /*!< Number of retries when writing */\r
+ unsigned char bReserved2; /*!< Reserved byte */\r
+ unsigned char pRecoveryTimeLimit[2]; /*!< Maximum time duration for error recovery */\r
+\r
+} __attribute__ ((__packed__)) SBCReadWriteErrorRecovery; /* GCC */\r
+\r
+/**\r
+ * \typedef SBCCommand\r
+ * \brief Generic structure for holding information about SBC commands\r
+ * \see SBCInquiry\r
+ * \see SBCRead10\r
+ * \see SBCReadCapacity10\r
+ * \see SBCRequestSense\r
+ * \see SBCTestUnitReady\r
+ * \see SBCWrite10\r
+ * \see SBCMediumRemoval\r
+ * \see SBCModeSense6\r
+ */\r
+typedef union _SBCCommand {\r
+\r
+ unsigned char bOperationCode; /*!< Operation code of the command */\r
+ SBCInquiry inquiry; /*!< INQUIRY command */\r
+ SBCRead10 read10; /*!< READ (10) command */\r
+ SBCReadCapacity10 readCapacity10; /*!< READ CAPACITY (10) command */\r
+ SBCRequestSense requestSense; /*!< REQUEST SENSE command */\r
+ SBCTestUnitReady testUnitReady; /*!< TEST UNIT READY command */\r
+ SBCWrite10 write10; /*!< WRITE (10) command */\r
+ SBCMediumRemoval mediumRemoval; /*!< PREVENT/ALLOW MEDIUM REMOVAL command */\r
+ SBCModeSense6 modeSense6; /*!< MODE SENSE (6) command */\r
+\r
+} SBCCommand;\r
+\r
+#pragma pack()\r
+\r
+/**@}*/\r
+\r
+#endif /*#ifndef SBC_H */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * \section Purpose\r
+ *\r
+ * SCSI commands implementation.\r
+ *\r
+ * section Usage\r
+ *\r
+ * -# After a CBW is received from host, use SBC_GetCommandInformation to check\r
+ * if the command is supported, and get the command length and type\r
+ * information before processing it.\r
+ * -# Then SBC_ProcessCommand can be used to handle a valid command, to\r
+ * perform the command operations.\r
+ * -# SBC_UpdateSenseData is used to update the sense data that will be sent\r
+ * to host.\r
+ */\r
+\r
+#ifndef SBCMETHODS_H\r
+#define SBCMETHODS_H\r
+\r
+/** \addtogroup usbd_msd\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+#include "SBC.h"\r
+#include "MSDLun.h"\r
+#include "MSDDStateMachine.h"\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Definitions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/** \addtogroup usbd_sbc_command_state SBC Command States\r
+ * @{\r
+ * This page lists the possible states of a SBC command.\r
+ *\r
+ * \section States\r
+ * - SBC_STATE_READ\r
+ * - SBC_STATE_WAIT_READ\r
+ * - SBC_STATE_WRITE\r
+ * - SBC_STATE_WAIT_WRITE\r
+ * - SBC_STATE_NEXT_BLOCK\r
+ */\r
+\r
+/** Start of reading bulk data */\r
+#define SBC_STATE_READ 0x01\r
+/** Waiting for the bulk data reading complete */\r
+#define SBC_STATE_WAIT_READ 0x02\r
+/** Read error state */\r
+#define SBC_STATE_READ_ERROR 0x03\r
+/** Start next read block */\r
+#define SBC_STATE_NEXT_READ 0x04\r
+/** Start writing bulk data to host */\r
+#define SBC_STATE_WRITE 0x05\r
+/** Waiting for the bulk data sending complete */\r
+#define SBC_STATE_WAIT_WRITE 0x06\r
+/** Write error state */\r
+#define SBC_STATE_WRITE_ERROR 0x07\r
+/** Start next write block */\r
+#define SBC_STATE_NEXT_WRITE 0x08\r
+/** Start next command block */\r
+#define SBC_STATE_NEXT_BLOCK 0x09\r
+/** @}*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+void SBC_UpdateSenseData(SBCRequestSenseData *requestSenseData,\r
+ unsigned char senseKey,\r
+ unsigned char additionalSenseCode,\r
+ unsigned char additionalSenseCodeQualifier);\r
+\r
+unsigned char SBC_GetCommandInformation(void *command,\r
+ unsigned int *length,\r
+ unsigned char *type,\r
+ MSDLun *lun);\r
+\r
+unsigned char SBC_ProcessCommand(MSDLun *lun,\r
+ MSDCommandState *commandState);\r
+\r
+/**@}*/\r
+\r
+#endif /*#ifndef SBCMETHODS_H */\r
+\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * Collection of methods for using the USB device controller on AT91\r
+ * microcontrollers.\r
+ *\r
+ * \section Usage\r
+ *\r
+ * Please refer to the corresponding application note.\r
+ * - \ref usbd_framework AT91 USB device framework\r
+ * - \ref usbd_api USBD API\r
+ *\r
+ */\r
+\r
+#ifndef USBD_H\r
+#define USBD_H\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Headers\r
+ *----------------------------------------------------------------------------*/\r
+\r
+\r
+#include "USBDescriptors.h"\r
+#include "USBRequests.h"\r
+\r
+#include "USBLib_Types.h"\r
+\r
+#include <stdio.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Definitions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/* Define attribute */\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+ #define WEAK __attribute__ ((weak))\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */\r
+ #define WEAK __weak\r
+#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */\r
+ #define WEAK __attribute__ ((weak))\r
+#endif\r
+\r
+/* Define NO_INIT attribute */\r
+#if defined ( __CC_ARM )\r
+ #define NO_INIT\r
+#elif defined ( __ICCARM__ )\r
+ #define NO_INIT __no_init\r
+#elif defined ( __GNUC__ )\r
+ #define NO_INIT\r
+#endif\r
+\r
+\r
+/** \addtogroup usbd_interface\r
+ *@{*/\r
+\r
+/**\r
+ * \addtogroup usbd_rc USB device API return codes\r
+ * @{\r
+ * This section lists the return codes for the USB device driver API\r
+ * - \ref USBD_STATUS_SUCCESS\r
+ * - \ref USBD_STATUS_LOCKED\r
+ * - \ref USBD_STATUS_ABORTED\r
+ * - \ref USBD_STATUS_RESET\r
+ */\r
+\r
+/** Indicates the operation was successful. */\r
+#define USBD_STATUS_SUCCESS USBRC_SUCCESS\r
+/** Endpoint/device is already busy. */\r
+#define USBD_STATUS_LOCKED USBRC_BUSY\r
+/** Operation has been aborted (error or stall). */\r
+#define USBD_STATUS_ABORTED USBRC_ABORTED\r
+/** Operation has been canceled (by user). */\r
+#define USBD_STATUS_CANCELED USBRC_CANCELED\r
+/** Operation has been aborted because the device init/reset/un-configure. */\r
+#define USBD_STATUS_RESET USBRC_RESET\r
+/** Part ot operation successfully done. */\r
+#define USBD_STATUS_PARTIAL_DONE USBRC_PARTIAL_DONE\r
+/** Operation failed because parameter error */\r
+#define USBD_STATUS_INVALID_PARAMETER USBRC_PARAM_ERR\r
+/** Operation failed because in unexpected state */\r
+#define USBD_STATUS_WRONG_STATE USBRC_STATE_ERR\r
+/** Operation failed because SW not supported */\r
+#define USBD_STATUS_SW_NOT_SUPPORTED USBRC_SW_NOT_SUPPORTED\r
+/** Operation failed because HW not supported */\r
+#define USBD_STATUS_HW_NOT_SUPPORTED USBRC_HW_NOT_SUPPORTED\r
+/** @}*/\r
+\r
+/** \addtogroup usbd_states USB device states\r
+ * @{\r
+ * This section lists the device states of the USB device driver.\r
+ * - \ref USBD_STATE_SUSPENDED\r
+ * - \ref USBD_STATE_ATTACHED\r
+ * - \ref USBD_STATE_POWERED\r
+ * - \ref USBD_STATE_DEFAULT\r
+ * - \ref USBD_STATE_ADDRESS\r
+ * - \ref USBD_STATE_CONFIGURED\r
+ */\r
+\r
+/** The device is currently suspended. */\r
+#define USBD_STATE_SUSPENDED 0\r
+/** USB cable is plugged into the device. */\r
+#define USBD_STATE_ATTACHED 1\r
+/** Host is providing +5V through the USB cable. */\r
+#define USBD_STATE_POWERED 2\r
+/** Device has been reset. */\r
+#define USBD_STATE_DEFAULT 3\r
+/** The device has been given an address on the bus. */\r
+#define USBD_STATE_ADDRESS 4\r
+/** A valid configuration has been selected. */\r
+#define USBD_STATE_CONFIGURED 5\r
+/** @}*/\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Types\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * \brief Buffer struct used for multi-buffer-listed transfer.\r
+ *\r
+ * The driver can process 255 bytes of buffers or buffer list window.\r
+ */\r
+typedef struct _USBDTransferBuffer {\r
+ /** Pointer to frame buffer */\r
+ uint8_t * pBuffer;\r
+ /** Size of the frame (up to 64K-1) */\r
+ uint16_t size;\r
+ /** Bytes transferred */\r
+ uint16_t transferred;\r
+ /** Bytes in FIFO */\r
+ uint16_t buffered;\r
+ /** Bytes remaining */\r
+ uint16_t remaining;\r
+} USBDTransferBuffer;\r
+\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */\r
+#define __attribute__(...)\r
+#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */\r
+#endif\r
+\r
+/**\r
+ * \brief Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes\r
+ * aligned.\r
+ *\r
+ * (For USB, DMA transfer is linked to EPs and FIFO address is EP defined)\r
+ */\r
+typedef struct _USBDDmaDescriptor {\r
+ /** Pointer to Next Descriptor */\r
+ void* pNxtDesc;\r
+ /** Pointer to data buffer address */\r
+ void* pDataAddr;\r
+ /** DMA Control setting register value */\r
+ uint32_t ctrlSettings:8, /** Control settings */\r
+ reserved:8, /** Not used */\r
+ bufferLength:16; /** Length of buffer */\r
+ /** Loaded to DMA register, OK to modify */\r
+ uint32_t used;\r
+} __attribute__((aligned(16))) USBDDmaDescriptor;\r
+\r
+#pragma pack()\r
+\r
+/**\r
+ * Callback used by transfer functions (USBD_Read & USBD_Write) to notify\r
+ * that a transaction is complete.\r
+ */\r
+typedef void (*TransferCallback)(void *pArg,\r
+ uint8_t status,\r
+ uint32_t transferred,\r
+ uint32_t remaining);\r
+\r
+/**\r
+ * Callback used by MBL transfer functions (USBD_Read & USBD_Write) to notify\r
+ * that a transaction is complete.\r
+ * \param pArg Pointer to callback arguments.\r
+ * \param status USBD status.\r
+ */\r
+typedef void (*MblTransferCallback)(void *pArg,\r
+ uint8_t status);\r
+\r
+/**@}*/\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+//extern void USBD_IrqHandler(void);\r
+\r
+extern void USBD_Init(void);\r
+\r
+extern void USBD_ConfigureSpeed(uint8_t forceFS);\r
+\r
+extern void USBD_Connect(void);\r
+\r
+extern void USBD_Disconnect(void);\r
+\r
+extern uint8_t USBD_Write(\r
+ uint8_t bEndpoint,\r
+ const void *pData,\r
+ uint32_t size,\r
+ TransferCallback callback,\r
+ void *pArg);\r
+\r
+extern uint8_t USBD_Read(\r
+ uint8_t bEndpoint,\r
+ void *pData,\r
+ uint32_t dLength,\r
+ TransferCallback fCallback,\r
+ void *pArg);\r
+\r
+extern uint8_t USBD_Stall(uint8_t bEndpoint);\r
+\r
+extern void USBD_Halt(uint8_t bEndpoint);\r
+\r
+extern void USBD_Unhalt(uint8_t bEndpoint);\r
+\r
+extern void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor);\r
+\r
+extern uint8_t USBD_IsHalted(uint8_t bEndpoint);\r
+\r
+extern void USBD_RemoteWakeUp(void);\r
+\r
+extern void USBD_SetAddress(uint8_t address);\r
+\r
+extern void USBD_SetConfiguration(uint8_t cfgnum);\r
+\r
+extern uint8_t USBD_GetState(void);\r
+\r
+extern uint8_t USBD_IsHighSpeed(void);\r
+\r
+extern void USBD_Test(uint8_t bIndex);\r
+\r
+extern void USBD_SuspendHandler(void);\r
+extern void USBD_ResumeHandler(void);\r
+extern void USBD_ResetHandler(void);\r
+extern void USBD_RequestHandler(uint8_t bEndpoint,\r
+ const USBGenericRequest * pRequest);\r
+\r
+\r
+extern void USBDCallbacks_Initialized(void);\r
+extern void USBDCallbacks_Reset(void);\r
+extern void USBDCallbacks_Suspended(void);\r
+extern void USBDCallbacks_Resumed(void);\r
+extern void USBDCallbacks_RequestReceived(const USBGenericRequest *request);\r
+\r
+#endif /*#ifndef USBD_H*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \section Purpose\r
+ *\r
+ * USB Device Driver class definition.\r
+ *\r
+ * \section Usage\r
+ *\r
+ * -# Instanciate a USBDDriver object and initialize it using\r
+ * USBDDriver_Initialize.\r
+ * -# When a USB SETUP request is received, forward it to the standard\r
+ * driver using USBDDriver_RequestHandler.\r
+ * -# Check the Remote Wakeup setting via USBDDriver_IsRemoteWakeUpEnabled.\r
+ */\r
+\r
+#ifndef USBDDRIVER_H\r
+#define USBDDRIVER_H\r
+\r
+/** \addtogroup usbd_interface\r
+ *@{\r
+ */\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Headers\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/* These headers were introduced in C99 by working group\r
+ * ISO/IEC JTC1/SC22/WG14.\r
+ */\r
+#include <stdbool.h>\r
+#include <stdint.h>\r
+#include <stdio.h>\r
+\r
+#include <USBRequests.h>\r
+#include <USBDescriptors.h>\r
+#include <USBLib_Types.h>\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Types\r
+ *------------------------------------------------------------------------------*/\r
+\r
+/**\r
+ * \typedef USBDDriverDescriptors\r
+ * \brief List of all descriptors used by a USB device driver. Each descriptor\r
+ * can be provided in two versions: full-speed and high-speed. Devices\r
+ * which are not high-speed capable do not need to provided high-speed\r
+ * descriptors and the full-speed qualifier & other speed descriptors.\r
+ */\r
+typedef struct _USBDDriverDescriptors {\r
+\r
+ /** Pointer to the full-speed device descriptor */\r
+ const USBDeviceDescriptor *pFsDevice;\r
+ /** Pointer to the full-speed configuration descriptor */\r
+ const USBConfigurationDescriptor *pFsConfiguration;\r
+ /** Pointer to the full-speed qualifier descriptor */\r
+ const USBDeviceQualifierDescriptor *pFsQualifier;\r
+ /** Pointer to the full-speed other speed configuration descriptor */\r
+ const USBConfigurationDescriptor *pFsOtherSpeed;\r
+ /** Pointer to the high-speed device descriptor */\r
+ const USBDeviceDescriptor *pHsDevice;\r
+ /** Pointer to the high-speed configuration descriptor */\r
+ const USBConfigurationDescriptor *pHsConfiguration;\r
+ /** Pointer to the high-speed qualifier descriptor */\r
+ const USBDeviceQualifierDescriptor *pHsQualifier;\r
+ /** Pointer to the high-speed other speed configuration descriptor */\r
+ const USBConfigurationDescriptor *pHsOtherSpeed;\r
+ /** Pointer to the list of string descriptors */\r
+ const uint8_t **pStrings;\r
+ /** Number of string descriptors in list */\r
+ uint8_t numStrings;\r
+\r
+} USBDDriverDescriptors;\r
+\r
+/**\r
+ * \typedef USBDDriver\r
+ * \brief USB device driver structure, holding a list of descriptors identifying\r
+ * the device as well as the driver current state.\r
+ */\r
+typedef struct _USBDDriver {\r
+\r
+ /** List of descriptors used by the device. */\r
+ const USBDDriverDescriptors *pDescriptors;\r
+ /** Current setting for each interface. */\r
+ uint8_t *pInterfaces;\r
+ /** Current configuration number (0 -> device is not configured). */\r
+ uint8_t cfgnum;\r
+ /** Indicates if remote wake up has been enabled by the host. */\r
+ uint8_t isRemoteWakeUpEnabled;\r
+ /** Features supported by OTG */\r
+ uint8_t otg_features_supported;\r
+} USBDDriver;\r
+\r
+/*------------------------------------------------------------------------------\r
+ * Exported functions\r
+ *------------------------------------------------------------------------------*/\r
+\r
+extern USBDDriver *USBD_GetDriver(void);\r
+extern void USBDDriver_Initialize(\r
+ USBDDriver *pDriver,\r
+ const USBDDriverDescriptors *pDescriptors,\r
+ uint8_t *pInterfaces);\r
+extern USBConfigurationDescriptor* USBDDriver_GetCfgDescriptors(\r
+ USBDDriver * pDriver,\r
+ uint8_t cfgNum);\r
+extern void USBDDriver_RequestHandler(\r
+ USBDDriver *pDriver,\r
+ const USBGenericRequest *pRequest);\r
+extern uint8_t USBDDriver_IsRemoteWakeUpEnabled(const USBDDriver *pDriver);\r
+extern uint8_t USBDDriver_returnOTGFeatures(const USBDDriver *pDriver);\r
+extern void USBDDriver_clearOTGFeatures(USBDDriver *pDriver);\r
+\r
+extern void USBDDriverCallbacks_ConfigurationChanged(uint8_t cfgnum);\r
+extern void USBDDriverCallbacks_InterfaceSettingChanged(uint8_t interface,\r
+ uint8_t setting);\r
+\r
+/**@}*/\r
+\r
+#endif /*#ifndef USBDDRIVER_H*/\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2009, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+#ifndef USBD_HAL_H\r
+#define USBD_HAL_H\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * This file defines functions for USB Device Hardware Access Level.\r
+ */\r
+\r
+/** \addtogroup usbd_hal\r
+ *@{*/\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Headers\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/* Introduced in C99 by working group ISO/IEC JTC1/SC22/WG14. */\r
+#include <stdbool.h>\r
+#include <stdint.h>\r
+#include <stdio.h>\r
+\r
+#include "USBD.h"\r
+#include <USBDescriptors.h>\r
+#include <USBRequests.h>\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Consts\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Macros\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/** Get bitmap for an endpoint */\r
+#define bmEP(bEP) (1 << (bEP))\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Types\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Exported functoins\r
+ *----------------------------------------------------------------------------*/\r
+\r
+extern void USBD_HAL_Init(void);\r
+extern void USBD_HAL_Connect(void);\r
+extern void USBD_HAL_Disconnect(void);\r
+\r
+extern void USBD_HAL_RemoteWakeUp(void);\r
+extern void USBD_HAL_SetConfiguration(uint8_t cfgnum);\r
+extern void USBD_HAL_SetAddress(uint8_t address);\r
+extern uint8_t USBD_HAL_IsHighSpeed(void);\r
+\r
+extern void USBD_HAL_Suspend(void);\r
+extern void USBD_HAL_Activate(void);\r
+\r
+extern void USBD_HAL_ResetEPs(uint32_t bmEPs,uint8_t bStatus, uint8_t bKeepCfg);\r
+extern void USBD_HAL_CancelIo(uint32_t bmEPs);\r
+extern uint8_t USBD_HAL_ConfigureEP(const USBEndpointDescriptor * pDescriptor);\r
+\r
+extern uint8_t USBD_HAL_SetTransferCallback(uint8_t bEP,\r
+ TransferCallback fCallback,\r
+ void * pCbData);\r
+extern uint8_t USBD_HAL_SetupMblTransfer(uint8_t bEndpoint,\r
+ USBDTransferBuffer * pMbList,\r
+ uint16_t mblSize,\r
+ uint16_t startOffset);\r
+extern uint8_t USBD_HAL_Write(uint8_t bEndpoint,\r
+ const void * pData,\r
+ uint32_t dLength);\r
+extern uint8_t USBD_HAL_WrWithHdr(uint8_t bEndpoint,\r
+ const void * pHdr, uint8_t bHdrLen,\r
+ const void * pData, uint32_t dLength);\r
+extern uint8_t USBD_HAL_Read(uint8_t bEndpoint,\r
+ void * pData,\r
+ uint32_t dLength);\r
+extern uint8_t USBD_HAL_Stall(uint8_t bEP);\r
+extern uint8_t USBD_HAL_Halt(uint8_t bEndpoint,uint8_t ctl);\r
+extern void USBD_HAL_Test(uint8_t bIndex);\r
+/**@}*/\r
+\r
+#endif // #define USBD_HAL_H\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * \section Purpose\r
+ *\r
+ * Definitions and methods for USB descriptor structures described by the\r
+ * USB specification.\r
+ *\r
+ * \section Usage\r
+ *\r
+ */\r
+\r
+#ifndef _USBDESCRIPTORS_H_\r
+#define _USBDESCRIPTORS_H_\r
+/** \addtogroup usb_general\r
+ * @{\r
+ * \addtogroup usb_descriptor USB Descriptors\r
+ * @{\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/* These headers were introduced in C99 by working group\r
+ * ISO/IEC JTC1/SC22/WG14.\r
+ */\r
+#include <stdint.h>\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Definitions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/*--------- Generic Descriptors --------*/\r
+\r
+/** \addtogroup usb_desc_type USB Descriptor types\r
+ * @{\r
+ * This section lists the codes of the usb descriptor types\r
+ * - \ref USBGenericDescriptor_DEVICE\r
+ * - \ref USBGenericDescriptor_CONFIGURATION\r
+ * - \ref USBGenericDescriptor_STRING\r
+ * - \ref USBGenericDescriptor_INTERFACE\r
+ * - \ref USBGenericDescriptor_ENDPOINT\r
+ * - \ref USBGenericDescriptor_DEVICEQUALIFIER\r
+ * - \ref USBGenericDescriptor_OTHERSPEEDCONFIGURATION\r
+ * - \ref USBGenericDescriptor_INTERFACEPOWER\r
+ * - \ref USBGenericDescriptor_OTG\r
+ * - \ref USBGenericDescriptor_DEBUG\r
+ * - \ref USBGenericDescriptor_INTERFACEASSOCIATION\r
+ */\r
+/** Device descriptor type. */\r
+#define USBGenericDescriptor_DEVICE 1\r
+/** Configuration descriptor type. */\r
+#define USBGenericDescriptor_CONFIGURATION 2\r
+/** String descriptor type. */\r
+#define USBGenericDescriptor_STRING 3\r
+/** Interface descriptor type. */\r
+#define USBGenericDescriptor_INTERFACE 4\r
+/** Endpoint descriptor type. */\r
+#define USBGenericDescriptor_ENDPOINT 5\r
+/** Device qualifier descriptor type. */\r
+#define USBGenericDescriptor_DEVICEQUALIFIER 6\r
+/** Other speed configuration descriptor type. */\r
+#define USBGenericDescriptor_OTHERSPEEDCONFIGURATION 7\r
+/** Interface power descriptor type. */\r
+#define USBGenericDescriptor_INTERFACEPOWER 8\r
+/** On-The-Go descriptor type. */\r
+#define USBGenericDescriptor_OTG 9\r
+/** Debug descriptor type. */\r
+#define USBGenericDescriptor_DEBUG 10\r
+/** Interface association descriptor type. */\r
+#define USBGenericDescriptor_INTERFACEASSOCIATION 11\r
+/** @}*/\r
+\r
+\r
+/*--------- Device Descriptors --------*/\r
+\r
+/** \addtogroup usb_release_number USB release numbers\r
+ * @{\r
+ * This section lists the codes of USB release numbers.\r
+ * - \ref USBDeviceDescriptor_USB2_00\r
+ */\r
+\r
+/** The device supports USB 2.00. */\r
+#define USBDeviceDescriptor_USB2_00 0x0200\r
+/** @}*/\r
+\r
+\r
+/*--------- Configuration Descriptors --------*/\r
+\r
+/** \addtogroup usb_attributes USB Device Attributes\r
+ * @{\r
+ * This section lists the codes of the usb attributes.\r
+ * - \ref USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP\r
+ * - \ref USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP\r
+ * - \ref USBConfigurationDescriptor_BUSPOWERED_RWAKEUP\r
+ * - \ref USBConfigurationDescriptor_SELFPOWERED_RWAKEUP\r
+ * - \ref USBConfigurationDescriptor_POWER\r
+ */\r
+/** Device is bus-powered and not support remote wake-up. */\r
+#define USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP 0x80\r
+/** Device is self-powered and not support remote wake-up. */\r
+#define USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP 0xC0\r
+/** Device is bus-powered and supports remote wake-up. */\r
+#define USBConfigurationDescriptor_BUSPOWERED_RWAKEUP 0xA0\r
+/** Device is self-powered and supports remote wake-up. */\r
+#define USBConfigurationDescriptor_SELFPOWERED_RWAKEUP 0xE0\r
+/** Calculates the value of the power consumption field given the value in mA.\r
+ * \param power The power consumption value in mA\r
+ * \return The value that should be set to the field in descriptor\r
+ */\r
+#define USBConfigurationDescriptor_POWER(power) (power / 2)\r
+/** @}*/\r
+\r
+\r
+/*--------- Endpoint Descriptors --------*/\r
+\r
+/** \addtogroup usb_ep_define USB Endpoint definitions\r
+ * @{\r
+ * This section lists definitions and macro for endpoint descriptors.\r
+ * - \ref usb_ep_dir USB Endpoint directions\r
+ * - \ref USBEndpointDescriptor_OUT\r
+ * - \ref USBEndpointDescriptor_IN\r
+ *\r
+ * - \ref usb_ep_type USB Endpoint types\r
+ * - \ref USBEndpointDescriptor_CONTROL\r
+ * - \ref USBEndpointDescriptor_ISOCHRONOUS\r
+ * - \ref USBEndpointDescriptor_BULK\r
+ * - \ref USBEndpointDescriptor_INTERRUPT\r
+ *\r
+ * - \ref usb_ep_size USB Endpoint maximun sizes\r
+ * - \ref USBEndpointDescriptor_MAXCTRLSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXCTRLSIZE_HS\r
+ * - \ref USBEndpointDescriptor_MAXBULKSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXBULKSIZE_HS\r
+ * - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_HS\r
+ * - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS\r
+ *\r
+ * - \ref usb_ep_addr USB Endpoint address define\r
+ * - \ref USBEndpointDescriptor_ADDRESS\r
+ */\r
+\r
+/** \addtogroup usb_ep_dir USB Endpoint directions\r
+ * @{\r
+ * This section lists definitions of USB endpoint directions.\r
+ * - USBEndpointDescriptor_OUT\r
+ * - USBEndpointDescriptor_IN\r
+ */\r
+/** Endpoint receives data from the host. */\r
+#define USBEndpointDescriptor_OUT 0\r
+/** Endpoint sends data to the host. */\r
+#define USBEndpointDescriptor_IN 1\r
+/** @}*/\r
+\r
+/** \addtogroup usb_ep_type USB Endpoint types\r
+ * @{\r
+ * This section lists definitions of USB endpoint types.\r
+ * - \ref USBEndpointDescriptor_CONTROL\r
+ * - \ref USBEndpointDescriptor_ISOCHRONOUS\r
+ * - \ref USBEndpointDescriptor_BULK\r
+ * - \ref USBEndpointDescriptor_INTERRUPT\r
+ */\r
+/** Control endpoint type. */\r
+#define USBEndpointDescriptor_CONTROL 0\r
+/** Isochronous endpoint type. */\r
+#define USBEndpointDescriptor_ISOCHRONOUS 1\r
+/** Bulk endpoint type. */\r
+#define USBEndpointDescriptor_BULK 2\r
+/** Interrupt endpoint type. */\r
+#define USBEndpointDescriptor_INTERRUPT 3\r
+/** @}*/\r
+\r
+/** \addtogroup usb_ep_size USB Endpoint maximun sizes\r
+ * @{\r
+ * This section lists definitions of USB endpoint maximun sizes.\r
+ * - \ref USBEndpointDescriptor_MAXCTRLSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXCTRLSIZE_HS\r
+ * - \ref USBEndpointDescriptor_MAXBULKSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXBULKSIZE_HS\r
+ * - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXINTERRUPTSIZE_HS\r
+ * - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS\r
+ * - \ref USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS\r
+ */\r
+/** Maximum size for a full-speed control endpoint. */\r
+#define USBEndpointDescriptor_MAXCTRLSIZE_FS 64\r
+/** Maximum size for a high-speed control endpoint. */\r
+#define USBEndpointDescriptor_MAXCTRLSIZE_HS 64\r
+/** Maximum size for a full-speed bulk endpoint. */\r
+#define USBEndpointDescriptor_MAXBULKSIZE_FS 64\r
+/** Maximum size for a high-speed bulk endpoint. */\r
+#define USBEndpointDescriptor_MAXBULKSIZE_HS 512\r
+/** Maximum size for a full-speed interrupt endpoint. */\r
+#define USBEndpointDescriptor_MAXINTERRUPTSIZE_FS 64\r
+/** Maximum size for a high-speed interrupt endpoint. */\r
+#define USBEndpointDescriptor_MAXINTERRUPTSIZE_HS 1024\r
+/** Maximum size for a full-speed isochronous endpoint. */\r
+#define USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS 1023\r
+/** Maximum size for a high-speed isochronous endpoint. */\r
+#define USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS 1024\r
+/** @}*/\r
+\r
+/** \addtogroup usb_ep_addr USB Endpoint address define\r
+ * @{\r
+ * This section lists macro for USB endpoint address definition.\r
+ * - \ref USBEndpointDescriptor_ADDRESS\r
+ */\r
+/**\r
+ * Calculates the address of an endpoint given its number and direction\r
+ * \param direction USB endpoint direction definition\r
+ * \param number USB endpoint number\r
+ * \return The value used to set the endpoint descriptor based on input number\r
+ * and direction\r
+ */\r
+#define USBEndpointDescriptor_ADDRESS(direction, number) \\r
+ (((direction & 0x01) << 7) | (number & 0xF))\r
+/** @}*/\r
+/** @}*/\r
+\r
+\r
+/*--------- Generic Descriptors --------*/\r
+\r
+/** \addtogroup usb_string_descriptor USB String Descriptor Definitions\r
+ * @{\r
+ * This section lists the codes and macros for USB string descriptor definition.\r
+ *\r
+ * \par Language IDs\r
+ * - USBStringDescriptor_ENGLISH_US\r
+ *\r
+ * \par String Descriptor Length\r
+ * - USBStringDescriptor_LENGTH\r
+ *\r
+ * \par ASCII to UNICODE convertion\r
+ * - USBStringDescriptor_UNICODE\r
+ */\r
+/** Language ID for US english. */\r
+#define USBStringDescriptor_ENGLISH_US 0x09, 0x04\r
+/**\r
+ * Calculates the length of a string descriptor given the number of ascii\r
+ * characters/language IDs in it.\r
+ * \param length The ascii format string length.\r
+ * \return The actual data length in bytes.\r
+ */\r
+#define USBStringDescriptor_LENGTH(length) ((length) * 2 + 2)\r
+/**\r
+ * Converts an ascii character to its unicode representation.\r
+ * \param ascii The ASCII character to convert\r
+ * \return A 2-byte-array for the UNICODE based on given ASCII\r
+ */\r
+#define USBStringDescriptor_UNICODE(ascii) (ascii), 0\r
+/** @}*/\r
+\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Types\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/*\r
+ * Function types\r
+ */\r
+\r
+typedef uint32_t (*USBDescriptorParseFunction)(void *descriptor, void *parseArg);\r
+\r
+\r
+/*\r
+ * Descriptor structs types\r
+ */\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm */\r
+#define __attribute__(...)\r
+#define __packed__ packed\r
+#elif defined ( __GNUC__ ) /* GCC CS3 */\r
+#define __packed__ aligned(1)\r
+#endif\r
+/**\r
+ \typedef USBGenericDescriptor\r
+ \brief Holds the few fields shared by all USB descriptors.\r
+ */\r
+typedef struct _USBGenericDescriptor {\r
+\r
+ /** Length of the descriptor in bytes. */\r
+ uint8_t bLength;\r
+ /** Descriptor type. */\r
+ uint8_t bDescriptorType;\r
+\r
+} __attribute__ ((__packed__)) USBGenericDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef USBDeviceDescriptor\r
+ * \brief USB standard device descriptor structure.\r
+ */\r
+typedef struct _USBDeviceDescriptor {\r
+\r
+ /** Size of this descriptor in bytes. */\r
+ uint8_t bLength;\r
+ /** Descriptor type (USBGenericDescriptor_DEVICE). */\r
+ uint8_t bDescriptorType;\r
+ /** USB specification release number in BCD format. */\r
+ uint16_t bcdUSB;\r
+ /** Device class code. */\r
+ uint8_t bDeviceClass;\r
+ /** Device subclass code. */\r
+ uint8_t bDeviceSubClass;\r
+ /** Device protocol code. */\r
+ uint8_t bDeviceProtocol;\r
+ /** Maximum packet size of endpoint 0 (in bytes). */\r
+ uint8_t bMaxPacketSize0;\r
+ /** Vendor ID. */\r
+ uint16_t idVendor;\r
+ /** Product ID. */\r
+ uint16_t idProduct;\r
+ /** Device release number in BCD format. */\r
+ uint16_t bcdDevice;\r
+ /** Index of the manufacturer string descriptor. */\r
+ uint8_t iManufacturer;\r
+ /** Index of the product string descriptor. */\r
+ uint8_t iProduct;\r
+ /** Index of the serial number string descriptor. */\r
+ uint8_t iSerialNumber;\r
+ /** Number of possible configurations for the device. */\r
+ uint8_t bNumConfigurations;\r
+\r
+} __attribute__ ((__packed__)) USBDeviceDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef USBOtgDescriptor\r
+ * \brief USB On-The-Go descriptor struct.\r
+ */\r
+typedef struct _USBOtgDescriptor {\r
+\r
+ /** Size of this descriptor in bytes. */\r
+ uint8_t bLength;\r
+ /** Descriptor type (USBGenericDescriptor_OTG). */\r
+ uint8_t bDescriptorType;\r
+ /** Attribute Fields D7?: Reserved D1: HNP support D0: SRP support */\r
+ uint8_t bmAttributes;\r
+\r
+} __attribute__ ((__packed__)) USBOtgDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef USBDeviceQualifierDescriptor\r
+ * \brief Alternate device descriptor indicating the capabilities of the device\r
+ * in full-speed, if currently in high-speed; or in high-speed, if it is\r
+ * currently in full-speed. Only relevant for devices supporting the\r
+ * high-speed mode.\r
+ */\r
+typedef struct _USBDeviceQualifierDescriptor {\r
+\r
+ /** Size of the descriptor in bytes. */\r
+ uint8_t bLength;\r
+ /** Descriptor type (USBDESC_DEVICE_QUALIFIER or "USB device types"). */\r
+ uint8_t bDescriptorType;\r
+ /** USB specification release number (in BCD format). */\r
+ uint16_t bcdUSB;\r
+ /** Device class code. */\r
+ uint8_t bDeviceClass;\r
+ /** Device subclass code. */\r
+ uint8_t bDeviceSubClass;\r
+ /** Device protocol code. */\r
+ uint8_t bDeviceProtocol;\r
+ /** Maximum packet size of endpoint 0. */\r
+ uint8_t bMaxPacketSize0;\r
+ /** Number of possible configurations for the device. */\r
+ uint8_t bNumConfigurations;\r
+ /** Reserved. */\r
+ uint8_t bReserved;\r
+\r
+} __attribute__ ((__packed__)) USBDeviceQualifierDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef USBConfigurationDescriptor\r
+ * \brief USB standard configuration descriptor structure.\r
+ */\r
+typedef struct _USBConfigurationDescriptor {\r
+\r
+ /** Size of the descriptor in bytes. */\r
+ uint8_t bLength;\r
+ /** Descriptor type\r
+ (USBDESC_CONFIGURATION of \ref usb_desc_type USB Descriptor types). */\r
+ uint8_t bDescriptorType;\r
+ /** Length of all descriptors returned along with this configuration\r
+ descriptor. */\r
+ uint16_t wTotalLength;\r
+ /** Number of interfaces in this configuration. */\r
+ uint8_t bNumInterfaces;\r
+ /** Value for selecting this configuration. */\r
+ uint8_t bConfigurationValue;\r
+ /** Index of the configuration string descriptor. */\r
+ uint8_t iConfiguration;\r
+ /** Configuration characteristics. */\r
+ uint8_t bmAttributes;\r
+ /** Maximum power consumption of the device when in this configuration. */\r
+ uint8_t bMaxPower;\r
+\r
+} __attribute__ ((__packed__)) USBConfigurationDescriptor; /* GCC*/\r
+\r
+/**\r
+ * \typedef USBInterfaceAssociationDescriptor\r
+ * \brief\r
+ */\r
+typedef struct _USBInterfaceAssociationDescriptor {\r
+\r
+ unsigned char bLength;\r
+ unsigned char bDescriptorType;\r
+ unsigned char bFirstInterface;\r
+ unsigned char bInterfaceCount;\r
+ unsigned char bFunctionClass;\r
+ unsigned char bFunctionSubClass;\r
+ unsigned char bFunctionProtocol;\r
+ unsigned char iFunction;\r
+} __attribute__ ((__packed__)) USBInterfaceAssociationDescriptor; /* GCC*/\r
+\r
+/**\r
+ * \typedef USBInterfaceDescriptor\r
+ * \brief USB standard interface descriptor structure.\r
+ */\r
+typedef struct _USBInterfaceDescriptor {\r
+\r
+ /** Size of the descriptor in bytes. */\r
+ uint8_t bLength;\r
+ /** Descriptor type (USBGenericDescriptor_INTERFACE). */\r
+ uint8_t bDescriptorType;\r
+ /** Number of the interface in its configuration. */\r
+ uint8_t bInterfaceNumber;\r
+ /** Value to select this alternate interface setting. */\r
+ uint8_t bAlternateSetting;\r
+ /** Number of endpoints used by the inteface (excluding endpoint 0). */\r
+ uint8_t bNumEndpoints;\r
+ /** Interface class code. */\r
+ uint8_t bInterfaceClass;\r
+ /** Interface subclass code. */\r
+ uint8_t bInterfaceSubClass;\r
+ /** Interface protocol code. */\r
+ uint8_t bInterfaceProtocol;\r
+ /** Index of the interface string descriptor. */\r
+ uint8_t iInterface;\r
+\r
+} __attribute__ ((__packed__)) USBInterfaceDescriptor; /* GCC */\r
+\r
+/**\r
+ * \typedef USBEndpointDescriptor\r
+ * \brief USB standard endpoint descriptor structure.\r
+ */\r
+typedef struct _USBEndpointDescriptor {\r
+\r
+ /** Size of the descriptor in bytes. */\r
+ uint8_t bLength;\r
+ /** Descriptor type (\ref USBGenericDescriptor_ENDPOINT). */\r
+ uint8_t bDescriptorType;\r
+ /** Address and direction of the endpoint. */\r
+ uint8_t bEndpointAddress;\r
+ /** Endpoint type and additional characteristics\r
+ (for isochronous endpoints). */\r
+ uint8_t bmAttributes;\r
+ /** Maximum packet size (in bytes) of the endpoint. */\r
+ uint16_t wMaxPacketSize;\r
+ /** Polling rate of the endpoint. */\r
+ uint8_t bInterval;\r
+\r
+} __attribute__ ((__packed__)) USBEndpointDescriptor; /* GCC*/\r
+\r
+\r
+#pragma pack()\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Exported Functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+extern uint32_t USBGenericDescriptor_GetLength(\r
+ const USBGenericDescriptor *descriptor);\r
+\r
+extern uint8_t USBGenericDescriptor_GetType(\r
+ const USBGenericDescriptor *descriptor);\r
+\r
+extern USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(\r
+ const USBGenericDescriptor *descriptor);\r
+\r
+extern USBGenericDescriptor *USBGenericDescriptor_Parse(\r
+ const USBGenericDescriptor * descriptor,\r
+ uint32_t totalLength,\r
+ USBDescriptorParseFunction parseFunction,\r
+ void * parseArg);\r
+\r
+\r
+extern uint32_t USBConfigurationDescriptor_GetTotalLength(\r
+ const USBConfigurationDescriptor *configuration);\r
+\r
+extern uint8_t USBConfigurationDescriptor_GetNumInterfaces(\r
+ const USBConfigurationDescriptor *configuration);\r
+\r
+extern uint8_t USBConfigurationDescriptor_IsSelfPowered(\r
+ const USBConfigurationDescriptor *configuration);\r
+\r
+extern void USBConfigurationDescriptor_Parse(\r
+ const USBConfigurationDescriptor *configuration,\r
+ USBInterfaceDescriptor **interfaces,\r
+ USBEndpointDescriptor **endpoints,\r
+ USBGenericDescriptor **others);\r
+\r
+extern uint8_t USBEndpointDescriptor_GetNumber(\r
+ const USBEndpointDescriptor *endpoint);\r
+\r
+extern uint8_t USBEndpointDescriptor_GetDirection(\r
+ const USBEndpointDescriptor *endpoint);\r
+\r
+extern uint8_t USBEndpointDescriptor_GetType(\r
+ const USBEndpointDescriptor *endpoint);\r
+\r
+extern uint16_t USBEndpointDescriptor_GetMaxPacketSize(\r
+ const USBEndpointDescriptor *endpoint);\r
+\r
+extern uint8_t USBEndpointDescriptor_GetInterval(\r
+ const USBEndpointDescriptor *endpoint);\r
+\r
+\r
+/** @}*/\r
+/**@}*/\r
+#endif /* #ifndef _USBDESCRIPTORS_H_ */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support\r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2008, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/**\r
+ * \file\r
+ *\r
+ * \par Purpose\r
+ *\r
+ * Standard output methods for reporting debug information, warnings and\r
+ * errors, which can be easily be turned on/off.\r
+ *\r
+ * \par Usage\r
+ * -# Initialize the debug message port in application, for stdio printf().\r
+ * -# Uses the TRACE_DEBUG(), TRACE_INFO(), TRACE_WARNING(), TRACE_ERROR()\r
+ * TRACE_FATAL() macros to output traces throughout the program.\r
+ * -# Each type of trace has a level : Debug 5, Info 4, Warning 3, Error 2\r
+ * and Fatal 1. Disable a group of traces by changing the value of\r
+ * TRACE_LEVEL during compilation; traces with a level bigger than TRACE_LEVEL\r
+ * are not generated. To generate no trace, use the reserved value 0.\r
+ * -# Trace disabling can be static or dynamic. If dynamic disabling is selected\r
+ * the trace level can be modified in runtime. If static disabling is selected\r
+ * the disabled traces are not compiled.\r
+ *\r
+ * \par traceLevels Trace level description\r
+ * -# TRACE_DEBUG (5): Traces whose only purpose is for debugging the program,\r
+ * and which do not produce meaningful information otherwise.\r
+ * -# TRACE_INFO (4): Informational trace about the program execution. Should\r
+ * enable the user to see the execution flow.\r
+ * -# TRACE_WARNING (3): Indicates that a minor error has happened. In most case\r
+ * it can be discarded safely; it may even be expected.\r
+ * -# TRACE_ERROR (2): Indicates an error which may not stop the program execution,\r
+ * but which indicates there is a problem with the code.\r
+ * -# TRACE_FATAL (1): Indicates a major error which prevents the program from going\r
+ * any further.\r
+ */\r
+\r
+#ifndef _USBLIB_TRACE_H\r
+#define _USBLIB_TRACE_H\r
+\r
+/*\r
+ * Headers\r
+ */\r
+\r
+#include <stdio.h>\r
+\r
+/*\r
+ * Global Definitions\r
+ */\r
+\r
+/** Softpack Version */\r
+#define USBLIB_VERSION "0.1"\r
+\r
+#define TRACE_LEVEL_DEBUG 5\r
+#define TRACE_LEVEL_INFO 4\r
+#define TRACE_LEVEL_WARNING 3\r
+#define TRACE_LEVEL_ERROR 2\r
+#define TRACE_LEVEL_FATAL 1\r
+#define TRACE_LEVEL_NO_TRACE 0\r
+\r
+/* By default, all traces are output except the debug one. */\r
+#if !defined(TRACE_LEVEL)\r
+#define TRACE_LEVEL TRACE_LEVEL_INFO\r
+#endif\r
+\r
+/* By default, trace level is static (not dynamic) */\r
+#if !defined(DYN_TRACES)\r
+#define DYN_TRACES 0\r
+#endif\r
+\r
+#if defined(NOTRACE)\r
+#error "Error: NOTRACE has to be not defined !"\r
+#endif\r
+\r
+#undef NOTRACE\r
+#if (DYN_TRACES==0)\r
+ #if (TRACE_LEVEL == TRACE_LEVEL_NO_TRACE)\r
+ #define NOTRACE\r
+ #endif\r
+#endif\r
+\r
+\r
+\r
+/* ------------------------------------------------------------------------------\r
+ * Global Macros\r
+ * ------------------------------------------------------------------------------\r
+ */\r
+\r
+#ifndef DYNTRACE\r
+#define DYNTRACE 0\r
+#endif\r
+\r
+\r
+/**\r
+ * Outputs a formatted string using 'printf' if the log level is high\r
+ * enough. Can be disabled by defining TRACE_LEVEL=0 during compilation.\r
+ * \param ... Additional parameters depending on formatted string.\r
+ */\r
+#if defined(NOTRACE)\r
+\r
+/* Empty macro */\r
+#define TRACE_DEBUG(...) { }\r
+#define TRACE_INFO(...) { }\r
+#define TRACE_WARNING(...) { }\r
+#define TRACE_ERROR(...) { }\r
+#define TRACE_FATAL(...) { while(1); }\r
+\r
+#define TRACE_DEBUG_WP(...) { }\r
+#define TRACE_INFO_WP(...) { }\r
+#define TRACE_WARNING_WP(...) { }\r
+#define TRACE_ERROR_WP(...) { }\r
+#define TRACE_FATAL_WP(...) { while(1); }\r
+\r
+#elif (DYN_TRACES == 1)\r
+\r
+/* Trace output depends on dwTraceLevel value */\r
+#define TRACE_DEBUG(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf("-D- " __VA_ARGS__); } }\r
+#define TRACE_INFO(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf("-I- " __VA_ARGS__); } }\r
+#define TRACE_WARNING(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf("-W- " __VA_ARGS__); } }\r
+#define TRACE_ERROR(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf("-E- " __VA_ARGS__); } }\r
+#define TRACE_FATAL(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf("-F- " __VA_ARGS__); while(1); } }\r
+\r
+#define TRACE_DEBUG_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_DEBUG) { printf(__VA_ARGS__); } }\r
+#define TRACE_INFO_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_INFO) { printf(__VA_ARGS__); } }\r
+#define TRACE_WARNING_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_WARNING) { printf(__VA_ARGS__); } }\r
+#define TRACE_ERROR_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_ERROR) { printf(__VA_ARGS__); } }\r
+#define TRACE_FATAL_WP(...) { if (dwTraceLevel >= TRACE_LEVEL_FATAL) { printf(__VA_ARGS__); while(1); } }\r
+\r
+#else\r
+\r
+/* Trace compilation depends on TRACE_LEVEL value */\r
+#if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)\r
+#define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); }\r
+#define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); }\r
+#else\r
+#define TRACE_DEBUG(...) { }\r
+#define TRACE_DEBUG_WP(...) { }\r
+#endif\r
+\r
+#if (TRACE_LEVEL >= TRACE_LEVEL_INFO)\r
+#define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); }\r
+#define TRACE_INFO_WP(...) { printf(__VA_ARGS__); }\r
+#else\r
+#define TRACE_INFO(...) { }\r
+#define TRACE_INFO_WP(...) { }\r
+#endif\r
+\r
+#if (TRACE_LEVEL >= TRACE_LEVEL_WARNING)\r
+#define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); }\r
+#define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); }\r
+#else\r
+#define TRACE_WARNING(...) { }\r
+#define TRACE_WARNING_WP(...) { }\r
+#endif\r
+\r
+#if (TRACE_LEVEL >= TRACE_LEVEL_ERROR)\r
+#define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); }\r
+#define TRACE_ERROR_WP(...) { printf(__VA_ARGS__); }\r
+#else\r
+#define TRACE_ERROR(...) { }\r
+#define TRACE_ERROR_WP(...) { }\r
+#endif\r
+\r
+#if (TRACE_LEVEL >= TRACE_LEVEL_FATAL)\r
+#define TRACE_FATAL(...) { printf("-F- " __VA_ARGS__); while(1); }\r
+#define TRACE_FATAL_WP(...) { printf(__VA_ARGS__); while(1); }\r
+#else\r
+#define TRACE_FATAL(...) { while(1); }\r
+#define TRACE_FATAL_WP(...) { while(1); }\r
+#endif\r
+\r
+#endif\r
+\r
+\r
+/**\r
+ * Exported variables\r
+ */\r
+/** Depending on DYN_TRACES, dwTraceLevel is a modifable runtime variable or a define */\r
+#if !defined(NOTRACE) && (DYN_TRACES == 1)\r
+ extern uint32_t dwTraceLevel ;\r
+#endif\r
+\r
+#endif /* #ifndef _USBLIB_TRACE_H */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * Definitions for USB Lib compiling.\r
+ */\r
+\r
+#ifndef USBLIB_TYPES_H\r
+#define USBLIB_TYPES_H\r
+/*----------------------------------------------------------------------------\r
+ * Includes\r
+ *----------------------------------------------------------------------------*/\r
+\r
+#include <stdint.h>\r
+\r
+/*----------------------------------------------------------------------------\r
+ * Defines\r
+ *----------------------------------------------------------------------------*/\r
+\r
+/* Define WEAK attribute */\r
+#ifndef WEAK\r
+#if defined ( __CC_ARM )\r
+ #define WEAK __attribute__ ((weak))\r
+#elif defined ( __ICCARM__ )\r
+ #define WEAK __weak\r
+#elif defined ( __GNUC__ )\r
+ #define WEAK __attribute__ ((weak))\r
+#endif\r
+#endif\r
+\r
+/** USB status ReturnCode */\r
+typedef enum _USBRC {\r
+ USBRC_OK = 0, /**< Operation was successful */\r
+ USBRC_SUCCESS = 0, /**< Operation was successful */\r
+ /* Bool codes */\r
+ USBRC_FALSE = 0, /**< As boolean TRUE */\r
+ USBRC_TRUE = 1, /**< As boolean FALSE */\r
+ /* Error codes */ \r
+ USBRC_BUSY, /**< EP/Device is already busy */\r
+ USBRC_ABORTED, /**< Operation aborted due to error or stall */\r
+ USBRC_CANCELED, /**< Operation canceled by user */\r
+ USBRC_RESET, /**< Operation aborted due to init/reset/un-configure */\r
+ USBRC_PARTIAL_DONE,/**< Part of operation successfully done */\r
+ USBRC_FINISHED, /**< All operation successfully done and terminate */\r
+\r
+ USBRC_PARAM_ERR, /**< Failed due to parameter error */\r
+ USBRC_STATE_ERR, /**< Failed due to state error */\r
+ USBRC_ERROR, /**< General error */\r
+\r
+ USBRC_SW_NOT_SUPPORTED = 0xFD, /**< Failed due to SW not supported */\r
+ USBRC_HW_NOT_SUPPORTED = 0xFE /**< Failed due to HW not supported */\r
+} USBRC;\r
+ \r
+#endif /* #define USBLIB_TYPES_H */\r
+\r
--- /dev/null
+/* ----------------------------------------------------------------------------\r
+ * ATMEL Microcontroller Software Support \r
+ * ----------------------------------------------------------------------------\r
+ * Copyright (c) 2010, Atmel Corporation\r
+ *\r
+ * All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions are met:\r
+ *\r
+ * - Redistributions of source code must retain the above copyright notice,\r
+ * this list of conditions and the disclaimer below.\r
+ *\r
+ * Atmel's name may not be used to endorse or promote products derived from\r
+ * this software without specific prior written permission.\r
+ *\r
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ----------------------------------------------------------------------------\r
+ */\r
+\r
+/** \file\r
+ * \section Purpose\r
+ * \r
+ * Definitions and methods for USB request structures described by the\r
+ * USB specification.\r
+ * \r
+ * \section Usage\r
+ * \r
+ */\r
+\r
+#ifndef _USBREQUESTS_H_\r
+#define _USBREQUESTS_H_\r
+/** \addtogroup usb_general\r
+ * @{\r
+ * \addtogroup usb_request USB Requests\r
+ * @{\r
+ */\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Headers\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/* These headers were introduced in C99 by working group\r
+ * ISO/IEC JTC1/SC22/WG14.\r
+ */\r
+#include <stdint.h>\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Definitions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/*----------- Generic Request ------------*/\r
+\r
+/** \addtogroup usb_request_define USB Generic Request definitions\r
+ * @{\r
+ * This section lists the codes of USB generic request.\r
+ * \r
+ * - \ref usb_request_code USB Request codes\r
+ * - \ref USBGenericRequest_GETSTATUS\r
+ * - \ref USBGenericRequest_CLEARFEATURE\r
+ * - \ref USBGenericRequest_SETFEATURE\r
+ * - \ref USBGenericRequest_SETADDRESS\r
+ * - \ref USBGenericRequest_GETDESCRIPTOR\r
+ * - \ref USBGenericRequest_SETDESCRIPTOR\r
+ * - \ref USBGenericRequest_GETCONFIGURATION\r
+ * - \ref USBGenericRequest_SETCONFIGURATION\r
+ * - \ref USBGenericRequest_GETINTERFACE\r
+ * - \ref USBGenericRequest_SETINTERFACE\r
+ * - \ref USBGenericRequest_SYNCHFRAME\r
+ * \r
+ * - \ref usb_request_recipient USB Request Recipients\r
+ * - \ref USBGenericRequest_DEVICE\r
+ * - \ref USBGenericRequest_INTERFACE\r
+ * - \ref USBGenericRequest_ENDPOINT\r
+ * - \ref USBGenericRequest_OTHER\r
+ * \r
+ * - \ref usb_request_type USB Request Types\r
+ * - \ref USBGenericRequest_STANDARD\r
+ * - \ref USBGenericRequest_CLASS\r
+ * - \ref USBGenericRequest_VENDOR\r
+ * \r
+ * - \ref usb_request_dir USB Request Directions\r
+ * - \ref USBGenericRequest_IN\r
+ * - \ref USBGenericRequest_OUT\r
+ */\r
+\r
+/** \addtogroup usb_request_code USB Request codes\r
+ * @{\r
+ * This section lists the USB generic request codes.\r
+ * - \ref USBGenericRequest_GETSTATUS\r
+ * - \ref USBGenericRequest_CLEARFEATURE\r
+ * - \ref USBGenericRequest_SETFEATURE\r
+ * - \ref USBGenericRequest_SETADDRESS\r
+ * - \ref USBGenericRequest_GETDESCRIPTOR\r
+ * - \ref USBGenericRequest_SETDESCRIPTOR\r
+ * - \ref USBGenericRequest_GETCONFIGURATION\r
+ * - \ref USBGenericRequest_SETCONFIGURATION\r
+ * - \ref USBGenericRequest_GETINTERFACE\r
+ * - \ref USBGenericRequest_SETINTERFACE\r
+ * - \ref USBGenericRequest_SYNCHFRAME\r
+ */\r
+/** GET_STATUS request code. */\r
+#define USBGenericRequest_GETSTATUS 0\r
+/** CLEAR_FEATURE request code. */\r
+#define USBGenericRequest_CLEARFEATURE 1\r
+/** SET_FEATURE request code. */\r
+#define USBGenericRequest_SETFEATURE 3\r
+/** SET_ADDRESS request code. */\r
+#define USBGenericRequest_SETADDRESS 5\r
+/** GET_DESCRIPTOR request code. */\r
+#define USBGenericRequest_GETDESCRIPTOR 6\r
+/** SET_DESCRIPTOR request code. */\r
+#define USBGenericRequest_SETDESCRIPTOR 7\r
+/** GET_CONFIGURATION request code. */\r
+#define USBGenericRequest_GETCONFIGURATION 8\r
+/** SET_CONFIGURATION request code. */\r
+#define USBGenericRequest_SETCONFIGURATION 9\r
+/** GET_INTERFACE request code. */\r
+#define USBGenericRequest_GETINTERFACE 10\r
+/** SET_INTERFACE request code. */\r
+#define USBGenericRequest_SETINTERFACE 11\r
+/** SYNCH_FRAME request code. */\r
+#define USBGenericRequest_SYNCHFRAME 12\r
+/** @}*/\r
+\r
+/** \addtogroup usb_request_recipient USB Request Recipients\r
+ * @{\r
+ * This section lists codes of USB request recipients.\r
+ * - \ref USBGenericRequest_DEVICE\r
+ * - \ref USBGenericRequest_INTERFACE\r
+ * - \ref USBGenericRequest_ENDPOINT\r
+ * - \ref USBGenericRequest_OTHER\r
+ */\r
+/** Recipient is the whole device. */\r
+#define USBGenericRequest_DEVICE 0\r
+/** Recipient is an interface. */\r
+#define USBGenericRequest_INTERFACE 1\r
+/** Recipient is an endpoint. */\r
+#define USBGenericRequest_ENDPOINT 2\r
+/** Recipient is another entity. */\r
+#define USBGenericRequest_OTHER 3\r
+/** @}*/\r
+\r
+/** \addtogroup usb_request_type USB Request Types\r
+ * @{\r
+ * This section lists codes of USB request types.\r
+ * - \ref USBGenericRequest_STANDARD\r
+ * - \ref USBGenericRequest_CLASS\r
+ * - \ref USBGenericRequest_VENDOR\r
+ */\r
+/** Request is standard. */\r
+#define USBGenericRequest_STANDARD 0\r
+/** Request is class-specific. */\r
+#define USBGenericRequest_CLASS 1\r
+/** Request is vendor-specific. */\r
+#define USBGenericRequest_VENDOR 2\r
+/** @}*/\r
+\r
+/** \addtogroup usb_request_dir USB Request Directions\r
+ * @{\r
+ * This section lists codes of USB request directions.\r
+ * - \ref USBGenericRequest_IN\r
+ * - \ref USBGenericRequest_OUT\r
+ */\r
+/** Transfer occurs from device to the host. */\r
+#define USBGenericRequest_OUT 0\r
+/** Transfer occurs from the host to the device. */\r
+#define USBGenericRequest_IN 1\r
+/** @}*/\r
+/** @}*/\r
+\r
+\r
+/*----------- Feature Request ------------*/\r
+\r
+/** \addtogroup usb_feature_def USB Feature Request Definitions\r
+ * @{\r
+ * This section lists codes of USB Feature Request\r
+ *\r
+ * - \ref usb_feature_sel USB Feature selectors\r
+ * - \ref USBFeatureRequest_ENDPOINTHALT\r
+ * - \ref USBFeatureRequest_DEVICEREMOTEWAKEUP\r
+ * - \ref USBFeatureRequest_TESTMODE\r
+ *\r
+ * - \ref usb_test_sel USB Test mode selectors\r
+ * - \ref USBFeatureRequest_TESTJ\r
+ * - \ref USBFeatureRequest_TESTK\r
+ * - \ref USBFeatureRequest_TESTSE0NAK\r
+ * - \ref USBFeatureRequest_TESTPACKET\r
+ * - \ref USBFeatureRequest_TESTFORCEENABLE\r
+ * - \ref USBFeatureRequest_TESTSENDZLP\r
+ */\r
+\r
+/** \addtogroup usb_feature_sel USB Feature selectors\r
+ * @{\r
+ * This section lists codes of USB feature selectors.\r
+ * - \ref USBFeatureRequest_ENDPOINTHALT\r
+ * - \ref USBFeatureRequest_DEVICEREMOTEWAKEUP\r
+ * - \ref USBFeatureRequest_TESTMODE\r
+ */\r
+/** Halt feature of an endpoint. */\r
+#define USBFeatureRequest_ENDPOINTHALT 0\r
+/** Remote wake-up feature of the device. */\r
+#define USBFeatureRequest_DEVICEREMOTEWAKEUP 1\r
+/** Test mode of the device. */\r
+#define USBFeatureRequest_TESTMODE 2\r
+/** OTG set feature */\r
+#define USBFeatureRequest_OTG 0x0B\r
+/** OTG b_hnp_enable */\r
+#define USBFeatureRequest_OTG_B_HNP_ENABLE 3\r
+/** OTG a_hnp_support */\r
+#define USBFeatureRequest_OTG_A_HNP_SUPPORT 4\r
+/** OTG a_alt_hnp_support */\r
+#define USBFeatureRequest_OTG_A_ALT_HNP_SUPPORT 5\r
+/** @}*/\r
+\r
+/** \addtogroup usb_test_sel USB Test mode selectors\r
+ * @{\r
+ * This section lists codes of USB high speed test mode selectors.\r
+ * - \ref USBFeatureRequest_TESTJ\r
+ * - \ref USBFeatureRequest_TESTK\r
+ * - \ref USBFeatureRequest_TESTSE0NAK\r
+ * - \ref USBFeatureRequest_TESTPACKET\r
+ * - \ref USBFeatureRequest_TESTFORCEENABLE\r
+ * - \ref USBFeatureRequest_TESTSENDZLP\r
+ */\r
+\r
+/** Tests the high-output drive level on the D+ line. */\r
+#define USBFeatureRequest_TESTJ 1\r
+/** Tests the high-output drive level on the D- line. */\r
+#define USBFeatureRequest_TESTK 2\r
+/** Tests the output impedance, low-level output voltage and loading\r
+ characteristics. */\r
+#define USBFeatureRequest_TESTSE0NAK 3\r
+/** Tests rise and fall times, eye patterns and jitter. */\r
+#define USBFeatureRequest_TESTPACKET 4\r
+/** Tests the hub disconnect detection. */\r
+#define USBFeatureRequest_TESTFORCEENABLE 5\r
+/** Send a ZLP in Test Mode. */\r
+#define USBFeatureRequest_TESTSENDZLP 6\r
+/** @}*/\r
+/** @}*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Types\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/* \r
+ * Function types\r
+ */\r
+\r
+/* \r
+ * Descriptor structs types\r
+ */\r
+#pragma pack(1)\r
+#if defined ( __CC_ARM ) /* Keil ¦ÌVision 4 */\r
+#elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */\r
+#define __attribute__(...)\r
+#elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */\r
+#endif\r
+\r
+/**\r
+ * Generic USB SETUP request sent over Control endpoints.\r
+ */\r
+typedef struct {\r
+\r
+ /** Type of request\r
+ * \sa usb_request_recipient "USB Request Recipients"\r
+ * \sa usb_request_type "USB Request Types"\r
+ * \sa usb_request_dir "USB Request Directions" */\r
+ uint8_t bmRequestType:8;\r
+ /** Request code\r
+ * \sa usb_request_code "USB Request Codes" */\r
+ uint8_t bRequest:8;\r
+ /** Request-specific value parameter. */\r
+ uint16_t wValue:16;\r
+ /** Request-specific index parameter. */\r
+ uint16_t wIndex:16;\r
+ /** Expected length (in bytes) of the data phase. */\r
+ uint16_t wLength:16;\r
+\r
+} USBGenericRequest;\r
+\r
+#pragma pack()\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Exported Functions\r
+ *---------------------------------------------------------------------------*/\r
+\r
+extern uint8_t USBGenericRequest_GetType(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t USBGenericRequest_GetRequest(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint16_t USBGenericRequest_GetValue(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint16_t USBGenericRequest_GetIndex(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint16_t USBGenericRequest_GetLength(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t USBGenericRequest_GetEndpointNumber(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t USBGenericRequest_GetRecipient(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t USBGenericRequest_GetDirection(\r
+ const USBGenericRequest *request);\r
+\r
+\r
+extern uint8_t USBGetDescriptorRequest_GetDescriptorType(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t USBGetDescriptorRequest_GetDescriptorIndex(\r
+ const USBGenericRequest *request);\r
+\r
+\r
+extern uint8_t USBSetAddressRequest_GetAddress(\r
+ const USBGenericRequest *request);\r
+\r
+\r
+extern uint8_t USBSetConfigurationRequest_GetConfiguration(\r
+ const USBGenericRequest *request);\r
+\r
+\r
+extern uint8_t USBInterfaceRequest_GetInterface(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t USBInterfaceRequest_GetAlternateSetting(\r
+ const USBGenericRequest *request);\r
+\r
+\r
+extern uint8_t USBFeatureRequest_GetFeatureSelector(\r
+ const USBGenericRequest *request);\r
+\r
+extern uint8_t USBFeatureRequest_GetTestSelector(\r
+ const USBGenericRequest *request);\r
+\r
+/** @}*/\r
+/**@}*/\r
+#endif /* #ifndef _USBREQUESTS_H_ */\r
+\r
--- /dev/null
+/*\r
+ FreeRTOS V8.0.1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+ All rights reserved\r
+\r
+ VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS provides completely free yet professionally developed, *\r
+ * robust, strictly quality controlled, supported, and cross *\r
+ * platform software that has become a de facto standard. *\r
+ * *\r
+ * Help yourself get started quickly and support the FreeRTOS *\r
+ * project by purchasing a FreeRTOS tutorial book, reference *\r
+ * manual, or both from: http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * Thank you! *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ This file is part of the FreeRTOS distribution.\r
+\r
+ FreeRTOS is free software; you can redistribute it and/or modify it under\r
+ the terms of the GNU General Public License (version 2) as published by the\r
+ Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+ >>! NOTE: The modification to the GPL is included to allow you to !<<\r
+ >>! distribute a combined work that includes FreeRTOS without being !<<\r
+ >>! obliged to provide the source code for proprietary components !<<\r
+ >>! outside of the FreeRTOS kernel. !<<\r
+\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ FOR A PARTICULAR PURPOSE. Full license text is available from the following\r
+ link: http://www.freertos.org/a00114.html\r
+\r
+ 1 tab == 4 spaces!\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * Having a problem? Start by reading the FAQ "My application does *\r
+ * not run, what could be wrong?" *\r
+ * *\r
+ * http://www.FreeRTOS.org/FAQHelp.html *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+ license and Real Time Engineers Ltd. contact details.\r
+\r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+ compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+ Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS\r
+ licenses offer ticketed support, indemnification and middleware.\r
+\r
+ http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+ engineered and independently SIL3 certified version for use in safety and\r
+ mission critical applications that require provable dependability.\r
+\r
+ 1 tab == 4 spaces!\r
+*/\r
+\r
+/*\r
+ * NOTE: This file uses a third party USB CDC driver.\r
+ */\r
+\r
+/* Standard includes. */\r
+#include "string.h"\r
+#include "stdio.h"\r
+\r
+/* FreeRTOS includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "event_groups.h"\r
+\r
+/* Example includes. */\r
+#include "FreeRTOS_CLI.h"\r
+\r
+/* Library includes. */\r
+#include "board.h"\r
+#include "chip.h"\r
+#include "USBD.h"\r
+#include "CDCDSerialDriver.h"\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Dimensions the buffer into which input characters are placed. */\r
+#define cmdMAX_INPUT_SIZE 50\r
+\r
+/* DEL acts as a backspace. */\r
+#define cmdASCII_DEL ( 0x7F )\r
+\r
+/* The bits in the event group used to signal USB interrupt events to this\r
+task. */\r
+#define cmdRX_COMPLETE_BIT ( 0x01 )\r
+#define cmdTX_COMPLETE_BIT ( 0x02 )\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * The task that implements the command console processing.\r
+ */\r
+static void prvCDCCommandConsoleTask( void *pvParameters );\r
+\r
+/*\r
+ * Initialise the USB hardware and driver.\r
+ */\r
+static void prvCDCInit( void );\r
+\r
+/*\r
+ * Handler installed on the VBUS pin to detect connect() and disconnect()\r
+ * events.\r
+ */\r
+static void prvVBusISRHandler( const Pin *pxPin );\r
+\r
+/*\r
+ * USB handler defined by the driver, installed after the CDC driver has been\r
+ * initialised.\r
+ */\r
+extern void USBD_IrqHandler( void );\r
+\r
+/*\r
+ * The function that creates the CLI task.\r
+ */\r
+void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority );\r
+\r
+/*\r
+ * Send xDataLength bytes from pcData to the CDC port.\r
+ */\r
+static void prvCDCSend( const char *pcData, size_t xDataLenth );\r
+\r
+/*\r
+ * Initiate a receive into the Rx buffer from the CDC port, then wait for a\r
+ * period for characters to be received.\r
+ */\r
+static void prvCDCGetChar( void );\r
+\r
+/*\r
+ * Configure VBus pins and interrupts, and check for connection.\r
+ */\r
+static void prvConfigureVBus( void );\r
+\r
+/*\r
+ * Callback which is invoked when a CDC read completes. This callback is\r
+ * passed as a parameter to the CDC receive function.\r
+ */\r
+static void prvCDCDataReceivedCallback( uint32_t ulUnused, uint8_t ucStatus, uint32_t ulBytesReceived, uint32_t ulBytesRemaining );\r
+\r
+/*\r
+ * Callback which is invoked when a CDC write completes. This callback is\r
+ * passed as a parameter to the CDC send function.\r
+ */\r
+static void prvCDCDataTransmittedCallback( uint32_t ulUnused, uint8_t ucStatus, uint32_t ulBytesSent, uint32_t ulBytesRemaining );\r
+\r
+/*\r
+ * Keep trying to initiate an Rx until it is started successfully\r
+ */\r
+static void prvStartRx( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Const messages output by the command console. */\r
+static const char * const pcWelcomeMessage = "FreeRTOS command server.\r\nType Help to view a list of registered commands.\r\n\r\n>";\r
+static const char * const pcEndOfOutputMessage = "\r\n[Press ENTER to execute the previous command again]\r\n>";\r
+static const char * const pcNewLine = "\r\n";\r
+\r
+/* Buffer into which received characters are placed. */\r
+static char pcRxBuffer[ cmdMAX_INPUT_SIZE ];\r
+\r
+/* The number of bytes in pcRxBuffer that have not yet been read. */\r
+static uint32_t ulBytesAvailable = 0;\r
+\r
+/* Used to unblock the task when bytes are received and when bytes have\r
+completed sending. */\r
+static EventGroupHandle_t xCDCEventBits;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vUARTCommandConsoleStart( uint16_t usStackSize, UBaseType_t uxPriority )\r
+{\r
+ /* Event group used to indicate that bytes are available in the Rx buffer\r
+ or that bytes have finished sending. */\r
+ xCDCEventBits = xEventGroupCreate();\r
+ configASSERT( xCDCEventBits );\r
+\r
+ /* Create the task that handles the console itself. */\r
+ xTaskCreate( prvCDCCommandConsoleTask, /* The task that implements the command console. */\r
+ "CLI", /* Text name assigned to the task. This is just to assist debugging. The kernel does not use this name itself. */\r
+ usStackSize, /* The size of the stack allocated to the task. */\r
+ NULL, /* The parameter is not used, so NULL is passed. */\r
+ uxPriority, /* The priority allocated to the task. */\r
+ NULL ); /* A handle is not required, so just pass NULL. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCDCCommandConsoleTask( void *pvParameters )\r
+{\r
+uint8_t ucInputIndex = 0;\r
+char *pcOutputString, cRxedChar;\r
+static char cInputString[ cmdMAX_INPUT_SIZE ], cLastInputString[ cmdMAX_INPUT_SIZE ];\r
+BaseType_t xReturned;\r
+uint32_t ulBufferIndex = 0;\r
+\r
+ ( void ) pvParameters;\r
+\r
+ /* Obtain the address of the output buffer. Note there is no mutual\r
+ exclusion on this buffer as it is assumed only one command console interface\r
+ will be used at any one time. */\r
+ pcOutputString = FreeRTOS_CLIGetOutputBuffer();\r
+\r
+ /* Initialise the CDC driver. */\r
+ prvCDCInit();\r
+\r
+ /* Start receiving into the buffer. */\r
+ prvStartRx();\r
+\r
+ /* Send the welcome message. */\r
+ prvCDCSend( pcWelcomeMessage, strlen( pcWelcomeMessage ) );\r
+\r
+ for( ;; )\r
+ {\r
+ /* Wait for my characters to be available. */\r
+ prvCDCGetChar();\r
+\r
+ /* Process the bytes char for char on the assumption that as input comes\r
+ from typing it is unlikely that more than a single byte will be received\r
+ at a time anyway. */\r
+ while( ulBytesAvailable > 0 )\r
+ {\r
+ /* Read next byte from the rx buffer. */\r
+ cRxedChar = pcRxBuffer[ ulBufferIndex ];\r
+\r
+ taskENTER_CRITICAL();\r
+ {\r
+ ulBytesAvailable--;\r
+ }\r
+ taskEXIT_CRITICAL();\r
+\r
+ /* Echo the character back. */\r
+ prvCDCSend( &cRxedChar, sizeof( cRxedChar ) );\r
+\r
+ /* Was it the end of the line? */\r
+ if( cRxedChar == '\n' || cRxedChar == '\r' )\r
+ {\r
+ /* Just to space the output from the input. */\r
+ prvCDCSend( pcNewLine, strlen( pcNewLine ) );\r
+\r
+ /* See if the command is empty, indicating that the last command\r
+ is to be executed again. */\r
+ if( ucInputIndex == 0 )\r
+ {\r
+ /* Copy the last command back into the input string. */\r
+ strcpy( cInputString, cLastInputString );\r
+ }\r
+\r
+ /* Pass the received command to the command interpreter. The\r
+ command interpreter is called repeatedly until it returns\r
+ pdFALSE (indicating there is no more output) as it might\r
+ generate more than one string. */\r
+ do\r
+ {\r
+ /* Get the next output string from the command interpreter. */\r
+ xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );\r
+\r
+ /* Write the generated string to the UART. */\r
+ prvCDCSend( pcOutputString, strlen( pcOutputString ) );\r
+\r
+ } while( xReturned != pdFALSE );\r
+\r
+ /* All the strings generated by the input command have been\r
+ sent. Clear the input string ready to receive the next command.\r
+ Remember the command that was just processed first in case it is\r
+ to be processed again. */\r
+ strcpy( cLastInputString, cInputString );\r
+ ucInputIndex = 0;\r
+ memset( cInputString, 0x00, cmdMAX_INPUT_SIZE );\r
+\r
+ prvCDCSend( pcEndOfOutputMessage, strlen( pcEndOfOutputMessage ) );\r
+ }\r
+ else\r
+ {\r
+ if( cRxedChar == '\r' )\r
+ {\r
+ /* Ignore the character. */\r
+ }\r
+ else if( ( cRxedChar == '\b' ) || ( cRxedChar == cmdASCII_DEL ) )\r
+ {\r
+ /* Backspace was pressed. Erase the last character in the\r
+ string - if any. */\r
+ if( ucInputIndex > 0 )\r
+ {\r
+ ucInputIndex--;\r
+ cInputString[ ucInputIndex ] = '\0';\r
+ }\r
+ }\r
+ else\r
+ {\r
+ /* A character was entered. Add it to the string entered so\r
+ far. When a \n is entered the complete string will be\r
+ passed to the command interpreter. */\r
+ if( ( cRxedChar >= ' ' ) && ( cRxedChar <= '~' ) )\r
+ {\r
+ if( ucInputIndex < cmdMAX_INPUT_SIZE )\r
+ {\r
+ cInputString[ ucInputIndex ] = cRxedChar;\r
+ ucInputIndex++;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Move onto the next byte the next time around. */\r
+ ulBufferIndex++;\r
+ if( ulBufferIndex >= cmdMAX_INPUT_SIZE )\r
+ {\r
+ ulBufferIndex = 0;\r
+ }\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCDCInit( void )\r
+{\r
+extern WEAK const USBDDriverDescriptors cdcdSerialDriverDescriptors;\r
+\r
+ /* If they are present, configure Vbus & Wake-up pins */\r
+ PIO_InitializeInterrupts( 0 );\r
+\r
+ /* CDC serial driver initialization */\r
+ CDCDSerialDriver_Initialize( &cdcdSerialDriverDescriptors );\r
+\r
+ /* Configure VBus pins and interrupts, and check for connection. */\r
+ prvConfigureVBus();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCDCSend( const char *pcData, size_t xDataLength )\r
+{\r
+const TickType_t xTransferCompleteDelay = pdMS_TO_TICKS( 500UL );\r
+\r
+ ( void ) pcData;\r
+ ( void ) xDataLength;\r
+\r
+ if( xDataLength > 0 )\r
+ {\r
+ if( CDCDSerialDriver_Write( ( void * ) pcData, xDataLength, ( TransferCallback ) prvCDCDataTransmittedCallback, 0 ) == USBD_STATUS_SUCCESS )\r
+ {\r
+ /* Wait for the transfer to complete. */\r
+ xEventGroupWaitBits( xCDCEventBits,\r
+ cmdTX_COMPLETE_BIT, /* The bit to wait for. */\r
+ pdTRUE, /* Clear the bit before exiting the function. */\r
+ pdFALSE, /* Only need to wait for one bit anyway. */\r
+ xTransferCompleteDelay ); /* The maximum time to wait for the event. */\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvStartRx( void )\r
+{\r
+const TickType_t xFailedReadDelay = pdMS_TO_TICKS( 150UL );\r
+\r
+ while( CDCDSerialDriver_Read( pcRxBuffer, cmdMAX_INPUT_SIZE, ( TransferCallback ) prvCDCDataReceivedCallback, 0 ) != USBD_STATUS_SUCCESS )\r
+ {\r
+ /* Maybe the CDC is not connected. */\r
+ vTaskDelay( xFailedReadDelay );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCDCGetChar( void )\r
+{\r
+const TickType_t xTransferCompleteDelay = pdMS_TO_TICKS( 750UL );\r
+\r
+ if( ulBytesAvailable == 0 )\r
+ {\r
+ /* Wait for a transfer to complete. */\r
+ xEventGroupWaitBits( xCDCEventBits,\r
+ cmdRX_COMPLETE_BIT, /* The bit to wait for. */\r
+ pdTRUE, /* Clear the bit before exiting the function. */\r
+ pdFALSE, /* Only need to wait for one bit anyway. */\r
+ xTransferCompleteDelay ); /* The maximum time to wait for the event. */\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvVBusISRHandler( const Pin *pxPin )\r
+{\r
+ /* NOTE: As this was written for the XPlained board, which is powered\r
+ through the USB and cannot be on without the USB connected, this function\r
+ has not been exercised. */\r
+\r
+ /* Check current level on VBus to detect a connect/disconnect. */\r
+ if( PIO_Get( pxPin ) != 0 )\r
+ {\r
+ USBD_Connect();\r
+ }\r
+ else\r
+ {\r
+ USBD_Disconnect();\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCDCDataReceivedCallback( uint32_t ulUnused, uint8_t ucStatus, uint32_t ulBytesReceived, uint32_t ulBytesRemaining )\r
+{\r
+BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
+static uint32_t ulNextRxPosition = 0;\r
+\r
+ ( void ) ulUnused;\r
+ ( void ) ucStatus;\r
+ ( void ) ulBytesRemaining;\r
+\r
+ /* If bytes were received then store the number of bytes placed into the Rx\r
+ buffer. */\r
+ if( ucStatus == USBD_STATUS_SUCCESS )\r
+ {\r
+ ulBytesAvailable += ulBytesReceived;\r
+\r
+ /* Restart the Rx position from a buffer position past the newly\r
+ received data. */\r
+ ulNextRxPosition += ulBytesReceived;\r
+\r
+ if( ulNextRxPosition >= cmdMAX_INPUT_SIZE )\r
+ {\r
+ ulNextRxPosition = 0;\r
+ }\r
+ CDCDSerialDriver_Read( pcRxBuffer + ulNextRxPosition, cmdMAX_INPUT_SIZE - ulNextRxPosition, ( TransferCallback ) prvCDCDataReceivedCallback, 0 );\r
+\r
+ /* Ensure the task knows new data is available. */\r
+ xEventGroupSetBitsFromISR( xCDCEventBits, cmdRX_COMPLETE_BIT, &xHigherPriorityTaskWoken );\r
+ portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCDCDataTransmittedCallback( uint32_t ulUnused, uint8_t ucStatus, uint32_t ulBytesSent, uint32_t ulBytesRemaining )\r
+{\r
+BaseType_t xHigherPriorityTaskWoken = pdFALSE;\r
+\r
+ ( void ) ulUnused;\r
+ ( void ) ucStatus;\r
+ ( void ) ulBytesRemaining;\r
+ ( void ) ulBytesSent;\r
+\r
+ xEventGroupSetBitsFromISR( xCDCEventBits, cmdTX_COMPLETE_BIT, &xHigherPriorityTaskWoken );\r
+ portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvConfigureVBus( void )\r
+{\r
+const Pin xVBusPin = PIN_USB_VBUS;\r
+\r
+ /* Configure PIO to generate an interrupt on status change. */\r
+ PIO_Configure( &xVBusPin, 1 );\r
+ PIO_ConfigureIt( &xVBusPin, prvVBusISRHandler );\r
+ PIO_EnableIt( &xVBusPin );\r
+\r
+ /* Check current level on VBus */\r
+ if( PIO_Get( &xVBusPin ) != pdFALSE )\r
+ {\r
+ /* if VBUS present, force the connect */\r
+ USBD_Connect();\r
+ }\r
+ else\r
+ {\r
+ USBD_Disconnect();\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void USBDCallbacks_Initialized( void )\r
+{\r
+ /* CDC specific re-implementation of weak callback function. Invoked after\r
+ the USB driver has been initialised. By default, configures the UDP/UDPHS\r
+ interrupt. */\r
+ IRQ_ConfigureIT( ID_UDPHS, 0, USBD_IrqHandler );\r
+ IRQ_EnableIT( ID_UDPHS );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void USBDDriverCallbacks_ConfigurationChanged( uint8_t ucConfigNumber )\r
+{\r
+ /* CDC specific re-implementation of weak callback function. Invoked when\r
+ the configuration of the device changes. Parse used endpoints. */\r
+ CDCDSerialDriver_ConfigurationChangedHandler( ucConfigNumber );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void USBDCallbacks_RequestReceived( const USBGenericRequest *pxRequest )\r
+{\r
+ /* CDC specific re-implementation of weak callback function. Invoked when\r
+ a new SETUP request is received from the host. */\r
+ CDCDSerialDriver_RequestHandler( pxRequest );\r
+}\r
+/*-----------------------------------------------------------*/\r
#define configFPU_D32 0\r
\r
#define configPIT_PIVR ( *( ( volatile uint32_t * ) 0xFFFFFE38UL ) )\r
+#define configINTERRUPT_VECTOR_ADDRESS 0xFFFFF010UL\r
+#define configEOI_ADDRESS 0xFFFFF038UL\r
#define configCLEAR_TICK_INTERRUPT() ( void ) configPIT_PIVR /* Read PIT_PIVR to clear interrupt. */\r
\r
/* Prevent C code being included in assembly files when the IAR compiler is\r
/* Library includes. */\r
#include "board.h"\r
\r
+/*\r
+ * The FreeRTOS tick handler. This function must be installed as the handler\r
+ * for the timer used to generate the tick interrupt. Note that the interrupt\r
+ * generated by the PIT is shared by other system peripherals, so if the PIT is\r
+ * used for Tick generation then FreeRTOS_Tick_Handler() can only be installed\r
+ * directly as the PIT handler if no other system interrupts need to be\r
+ * serviced. If system interrupts other than the PIT need to be serviced then\r
+ * install System_Handler() as the PIT interrupt handler in place of\r
+ * FreeRTOS_Tick_Handler() and add additional interrupt processing into the\r
+ * implementation of System_Handler().\r
+ */\r
+extern void FreeRTOS_Tick_Handler( void );\r
+static void System_Handler( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+static void System_Handler( void )\r
+{\r
+ /* See the comments above the function prototype in this file. */\r
+ FreeRTOS_Tick_Handler();\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
/*\r
* The application must provide a function that configures a peripheral to\r
* create the FreeRTOS tick interrupt, then define configSETUP_TICK_INTERRUPT()\r
*/\r
void vConfigureTickInterrupt( void )\r
{\r
-extern void FreeRTOS_Tick_Handler( void );\r
-\r
/* NOTE: The PIT interrupt is cleared by the configCLEAR_TICK_INTERRUPT()\r
macro in FreeRTOSConfig.h. */\r
\r
/* Enable the PIT clock. */\r
PMC->PMC_PCER0 = 1 << ID_PIT;\r
- \r
+\r
/* Initialize the PIT to the desired frequency - specified in uS. */\r
PIT_Init( 1000000UL / configTICK_RATE_HZ, BOARD_MCK / 1000000 );\r
- \r
- /* Configure interrupt on PIT */\r
-#warning This is on the system interrupt and other interrupts may need processing to.\r
+\r
+ /* Configure interrupt on PIT. Note this is on the system interrupt, which\r
+ is shared with other system peripherals, so System_Handler() must be\r
+ installed in place of FreeRTOS_Tick_Handler() if other system handlers are\r
+ required. */\r
IRQ_ConfigureIT( ID_PIT, 0, FreeRTOS_Tick_Handler );\r
+ /* See commend directly above IRQ_ConfigureIT( ID_PIT, 0, System_Handler ); */\r
IRQ_EnableIT( ID_PIT );\r
PIT_EnableIT();\r
- \r
+\r
/* Enable the pit. */\r
PIT_Enable();\r
+\r
+ /* Prevent compiler warnings in the case where System_Handler() is not used\r
+ as the handler. See the comments above the System_Handler() function\r
+ prototype at the top of this file. */\r
+ ( void ) System_Handler;\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
/* Start the tasks that implements the command console on the UART, as\r
described above. */\r
-//_RB_ vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );\r
+ vUARTCommandConsoleStart( mainUART_COMMAND_CONSOLE_STACK_SIZE, mainUART_COMMAND_CONSOLE_TASK_PRIORITY );\r
\r
/* Register the standard CLI commands. */\r
-//_RB_ vRegisterSampleCLICommands();\r
+// vRegisterSampleCLICommands();\r
\r
/* Create the register check tasks, as described at the top of this file */\r
xTaskCreate( prvRegTestTaskEntry1, "Reg1", configMINIMAL_STACK_SIZE, mainREG_TEST_TASK_1_PARAMETER, tskIDLE_PRIORITY, NULL );\r
</option>\r
<option>\r
<name>CCDiagSuppress</name>\r
- <state></state>\r
+ <state>Pa131</state>\r
</option>\r
<option>\r
<name>CCDiagRemark</name>\r
<state>$PROJ_DIR$\..\Common\include</state>\r
<state>$PROJ_DIR$\Full_Demo</state>\r
<state>$PROJ_DIR$\..\..\..\FreeRTOS-Plus\Source\FreeRTOS-Plus-CLI</state>\r
+ <state>$PROJ_DIR$\AtmelFiles\usb\device</state>\r
+ <state>$PROJ_DIR$\AtmelFiles\usb\include</state>\r
</option>\r
<option>\r
<name>CCStdIncCheck</name>\r
</option>\r
<option>\r
<name>IInterwork2</name>\r
- <state>0</state>\r
+ <state>1</state>\r
</option>\r
<option>\r
<name>IProcessorMode2</name>\r
<file>\r
<name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\source\aic.c</name>\r
</file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\cp15\cp15.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\cp15\cp15_asm_iar.s</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\source\mmu.c</name>\r
+ </file>\r
<file>\r
<name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\source\pio.c</name>\r
</file>\r
<file>\r
<name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\source\tc.c</name>\r
</file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\source\USBD_HAL.c</name>\r
+ </file>\r
<file>\r
<name>$PROJ_DIR$\AtmelFiles\libchip_sama5d3x\source\wdt.c</name>\r
</file>\r
</group>\r
+ <group>\r
+ <name>usb</name>\r
+ <group>\r
+ <name>common</name>\r
+ <group>\r
+ <name>cdc</name>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\common\cdc\CDCLineCoding.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\common\cdc\CDCSetControlLineStateRequest.c</name>\r
+ </file>\r
+ </group>\r
+ <group>\r
+ <name>core</name>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\common\core\USBDescriptors.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\common\core\USBRequests.c</name>\r
+ </file>\r
+ </group>\r
+ </group>\r
+ <group>\r
+ <name>device</name>\r
+ <group>\r
+ <name>cdc-serial</name>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\cdc-serial\CDCDSerial.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\cdc-serial\CDCDSerial_Callbacks.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\cdc-serial\CDCDSerialDriver.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\cdc-serial\CDCDSerialPort.c</name>\r
+ </file>\r
+ </group>\r
+ <group>\r
+ <name>core</name>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\core\USBD.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\core\USBDCallbacks.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\core\USBDDriver.c</name>\r
+ </file>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\device\core\USBDDriverCallbacks.c</name>\r
+ </file>\r
+ </group>\r
+ </group>\r
+ <file>\r
+ <name>$PROJ_DIR$\AtmelFiles\usb\USBDDriverDescriptors.c</name>\r
+ </file>\r
+ </group>\r
</group>\r
<group>\r
<name>Blinky Demo</name>\r
<file>\r
<name>$PROJ_DIR$\atmel_main.c</name>\r
</file>\r
+ <file>\r
+ <name>$PROJ_DIR$\CDCCommandConsole.c</name>\r
+ </file>\r
<file>\r
<name>$PROJ_DIR$\cstartup_with_FreeRTOS_vectors.s</name>\r
</file>\r
//------------------------------------------------------------------------------\r
// Definitions\r
//------------------------------------------------------------------------------\r
-//_RB_ These definitions can go.\r
-#define AIC 0xFFFFF000\r
-#define AIC_IVR 0x10\r
-#define AIC_EOICR 0x38\r
\r
#define ARM_MODE_ABT 0x17\r
#define ARM_MODE_FIQ 0x11\r
\r
/*-----------------------------------------------------------*/\r
\r
+#warning Try re-using the main stack.\r
int main( void )\r
{\r
/* Configure the hardware ready to run the demo. */\r
\r
static void prvSetupHardware( void )\r
{\r
+ /* Disable watchdog */\r
+ WDT_Disable( WDT );\r
+\r
/* Set protect mode in the AIC for easier debugging. */\r
AIC->AIC_DCR |= AIC_DCR_PROT;\r
\r
\r
\r
<item>500</item><item>20</item></col-widths>\r
- <DisasmHistory/>\r
+ <DisasmHistory><item>0x00302750</item></DisasmHistory>\r
\r
\r
<PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><ShowCodeCoverage>1</ShowCodeCoverage><ShowInstrProfiling>1</ShowInstrProfiling></Disassembly>\r
- <Register><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Register><WATCH_1><expressions><item>xTickCount</item><item></item></expressions><col-names><item>Expression</item><item>Location</item><item>Type</item><item>Value</item></col-names><col-widths><item>100</item><item>150</item><item>100</item><item>100</item></col-widths><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></WATCH_1><CallStack><PreferedWindows><Position>1</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Frame</item><item>_I0</item></col-names><col-widths><item>400</item><item>20</item></col-widths></CallStack><Breakpoints><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Breakpoint</item><item>_I0</item></col-names><col-widths><item>500</item><item>35</item></col-widths></Breakpoints></Static>\r
+ <Register><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Register><WATCH_1><expressions><item></item></expressions><col-names><item>Expression</item><item>Location</item><item>Type</item><item>Value</item></col-names><col-widths><item>207</item><item>150</item><item>100</item><item>294</item></col-widths><PreferedWindows><Position>2</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></WATCH_1><CallStack><PreferedWindows><Position>1</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Frame</item><item>_I0</item></col-names><col-widths><item>400</item><item>20</item></col-widths></CallStack><Breakpoints><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows><col-names><item>Breakpoint</item><item>_I0</item></col-names><col-widths><item>500</item><item>35</item></col-widths></Breakpoints><Find-in-Files><ColumnWidth0>497</ColumnWidth0><ColumnWidth1>82</ColumnWidth1><ColumnWidth2>746</ColumnWidth2><ColumnWidth3>331</ColumnWidth3></Find-in-Files></Static>\r
<Windows>\r
\r
\r
\r
- <Wnd3>\r
+ <Wnd1>\r
<Tabs>\r
<Tab>\r
<Identity>TabID-13925-23874</Identity>\r
<Factory>Build</Factory>\r
<Session/>\r
</Tab>\r
- </Tabs>\r
+ <Tab><Identity>TabID-21109-11091</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs>\r
\r
- <SelectedTab>0</SelectedTab></Wnd3><Wnd4>\r
+ <SelectedTab>0</SelectedTab></Wnd1><Wnd2>\r
<Tabs>\r
<Tab>\r
<Identity>TabID-24673-23877</Identity>\r
</Tab>\r
</Tabs>\r
\r
- <SelectedTab>0</SelectedTab></Wnd4><Wnd5><Tabs><Tab><Identity>TabID-23907-13802</Identity><TabName>Disassembly</TabName><Factory>Disassembly</Factory><Session/></Tab></Tabs><SelectedTab>0</SelectedTab></Wnd5></Windows>\r
+ <SelectedTab>0</SelectedTab></Wnd2></Windows>\r
<Editor>\r
\r
\r
\r
\r
- <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>134</YPos2><SelStart2>14916</SelStart2><SelEnd2>14916</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\timers.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>405</YPos2><SelStart2>17615</SelStart2><SelEnd2>17615</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\port.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>280</YPos2><SelStart2>12519</SelStart2><SelEnd2>12519</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\reg_test.S</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>102</YPos2><SelStart2>5571</SelStart2><SelEnd2>5571</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\portASM.s</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>113</YPos2><SelStart2>4976</SelStart2><SelEnd2>4979</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\portASM.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>99</YPos2><SelStart2>3</SelStart2><SelEnd2>3</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\FreeRTOSConfig.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>104</YPos2><SelStart2>6016</SelStart2><SelEnd2>6016</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>109</YPos2><SelStart2>5963</SelStart2><SelEnd2>5963</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Common\Minimal\EventGroupsDemo.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>960</YPos2><SelStart2>34411</SelStart2><SelEnd2>34411</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\event_groups.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>55</YPos2><SelStart2>4726</SelStart2><SelEnd2>4756</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
+ <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\CDCCommandConsole.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>397</YPos2><SelStart2>14920</SelStart2><SelEnd2>14920</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>110</YPos2><SelStart2>6002</SelStart2><SelEnd2>6002</SelEnd2></Tab><ActiveTab>1</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\port.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>288</YPos2><SelStart2>12369</SelStart2><SelEnd2>12369</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
<Positions>\r
\r
\r
\r
\r
\r
- <Top><Row0><Sizes><Toolbar-00D7DC28><key>iaridepm.enu1</key></Toolbar-00D7DC28></Sizes></Row0><Row1><Sizes><Toolbar-142E0530><key>debuggergui.enu1</key></Toolbar-142E0530></Sizes></Row1></Top><Left><Row0><Sizes><Wnd4><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>332</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>198810</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd4></Sizes></Row0></Left><Right><Row0><Sizes><Wnd5><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>198</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd5></Sizes></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
+ <Top><Row0><Sizes><Toolbar-00C8A108><key>iaridepm.enu1</key></Toolbar-00C8A108></Sizes></Row0><Row1><Sizes><Toolbar-14AD33B8><key>debuggergui.enu1</key></Toolbar-14AD33B8></Sizes></Row1></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>718</Bottom><Right>332</Right><x>-2</x><y>-2</y><xscreen>200</xscreen><yscreen>200</yscreen><sizeHorzCX>119048</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>198810</sizeVertCX><sizeVertCY>731707</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>198</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>200</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>203252</sizeHorzCY><sizeVertCX>119048</sizeVertCX><sizeVertCY>203252</sizeVertCY></Rect></Wnd1></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
</Desktop>\r
</Project>\r
\r
FillEnabled=0\r
OverflowWarningsEnabled=1\r
WarningThreshold=90\r
-SpWarningsEnabled=1\r
+SpWarningsEnabled=0\r
WarnLogOnly=1\r
UseTrigger=1\r
TriggerName=main\r
Watch1=_ 0 "" 0 "" 0 "" 0 "" 0 0 0 0\r
CStepIntDis=_ 0\r
[DebugChecksum]\r
-Checksum=2132507383\r
+Checksum=1771823120\r
[Exceptions]\r
StopOnUncaught=_ 0\r
StopOnThrow=_ 0\r
\r
\r
\r
- <Column0>382</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>\r
+ <Column0>278</Column0><Column1>27</Column1><Column2>27</Column2><Column3>27</Column3></ColumnWidths>\r
</Workspace>\r
<CRunMessageRules>\r
<col-names>\r
\r
\r
<ColumnWidth0>20</ColumnWidth0><ColumnWidth1>1216</ColumnWidth1><ColumnWidth2>324</ColumnWidth2><ColumnWidth3>81</ColumnWidth3></Build>\r
- <Debug-Log><ColumnWidth0>18</ColumnWidth0><ColumnWidth1>1624</ColumnWidth1></Debug-Log><TerminalIO/><Select-Ambiguous-Definitions><ColumnWidth0>552</ColumnWidth0><ColumnWidth1>78</ColumnWidth1><ColumnWidth2>946</ColumnWidth2></Select-Ambiguous-Definitions><Find-in-Files><ColumnWidth0>497</ColumnWidth0><ColumnWidth1>82</ColumnWidth1><ColumnWidth2>746</ColumnWidth2><ColumnWidth3>331</ColumnWidth3></Find-in-Files></Static>\r
+ <Debug-Log><ColumnWidth0>18</ColumnWidth0><ColumnWidth1>1624</ColumnWidth1></Debug-Log><TerminalIO/><Select-Ambiguous-Definitions><ColumnWidth0>552</ColumnWidth0><ColumnWidth1>78</ColumnWidth1><ColumnWidth2>946</ColumnWidth2></Select-Ambiguous-Definitions><Find-in-Files><ColumnWidth0>497</ColumnWidth0><ColumnWidth1>82</ColumnWidth1><ColumnWidth2>746</ColumnWidth2><ColumnWidth3>331</ColumnWidth3></Find-in-Files><Breakpoints><col-names><item>Breakpoint</item><item>_I0</item></col-names><col-widths><item>500</item><item>35</item></col-widths><PreferedWindows><Position>3</Position><ScreenPosX>0</ScreenPosX><ScreenPosY>0</ScreenPosY><Windows/></PreferedWindows></Breakpoints></Static>\r
<Windows>\r
\r
\r
- <Wnd1>\r
+ <Wnd2>\r
<Tabs>\r
<Tab>\r
<Identity>TabID-22351-19008</Identity>\r
<Factory>Workspace</Factory>\r
<Session>\r
\r
- <NodeDict><ExpandedNode>RTOSDemo</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS Source</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS Source/portable</ExpandedNode><ExpandedNode>RTOSDemo/Full Demo</ExpandedNode></NodeDict></Session>\r
+ <NodeDict><ExpandedNode>RTOSDemo</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS Source</ExpandedNode><ExpandedNode>RTOSDemo/FreeRTOS Source/event_groups.c</ExpandedNode></NodeDict></Session>\r
</Tab>\r
</Tabs>\r
\r
- <SelectedTab>0</SelectedTab></Wnd1><Wnd2>\r
+ <SelectedTab>0</SelectedTab></Wnd2><Wnd3>\r
<Tabs>\r
<Tab>\r
<Identity>TabID-21076-19237</Identity>\r
</Tab>\r
<Tab><Identity>TabID-23502-23081</Identity><TabName>Debug Log</TabName><Factory>Debug-Log</Factory><Session/></Tab><Tab><Identity>TabID-24431-23894</Identity><TabName>Ambiguous Definitions</TabName><Factory>Select-Ambiguous-Definitions</Factory><Session/></Tab><Tab><Identity>TabID-9033-6116</Identity><TabName>Find in Files</TabName><Factory>Find-in-Files</Factory><Session/></Tab></Tabs>\r
\r
- <SelectedTab>0</SelectedTab></Wnd2></Windows>\r
+ <SelectedTab>0</SelectedTab></Wnd3></Windows>\r
<Editor>\r
\r
\r
\r
\r
- <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\main_full.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>134</YPos2><SelStart2>14916</SelStart2><SelEnd2>14916</SelEnd2></Tab><ActiveTab>0</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\timers.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>405</YPos2><SelStart2>17615</SelStart2><SelEnd2>17615</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\port.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>280</YPos2><SelStart2>12519</SelStart2><SelEnd2>12519</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\Full_Demo\reg_test.S</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>102</YPos2><SelStart2>5571</SelStart2><SelEnd2>5571</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\portASM.s</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>113</YPos2><SelStart2>4976</SelStart2><SelEnd2>4979</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\portASM.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>99</YPos2><SelStart2>3</SelStart2><SelEnd2>3</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\FreeRTOSConfig.h</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>104</YPos2><SelStart2>6016</SelStart2><SelEnd2>6016</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>109</YPos2><SelStart2>5963</SelStart2><SelEnd2>5963</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\Common\Minimal\EventGroupsDemo.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>960</YPos2><SelStart2>34411</SelStart2><SelEnd2>34411</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\event_groups.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>55</YPos2><SelStart2>4726</SelStart2><SelEnd2>4756</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
+ <Pane><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\CDCCommandConsole.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>397</YPos2><SelStart2>14920</SelStart2><SelEnd2>14920</SelEnd2></Tab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\main.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>110</YPos2><SelStart2>6002</SelStart2><SelEnd2>6002</SelEnd2></Tab><ActiveTab>1</ActiveTab><Tab><Factory>TextEditor</Factory><Filename>$WS_DIR$\..\..\Source\portable\IAR\ARM_CA5_No_GIC\port.c</Filename><XPos>0</XPos><YPos>0</YPos><SelStart>0</SelStart><SelEnd>0</SelEnd><XPos2>0</XPos2><YPos2>288</YPos2><SelStart2>12369</SelStart2><SelEnd2>12369</SelEnd2></Tab></Pane><ActivePane>0</ActivePane><Sizes><Pane><X>1000000</X><Y>1000000</Y></Pane></Sizes><SplitMode>1</SplitMode></Editor>\r
<Positions>\r
\r
\r
\r
\r
\r
- <Top><Row0><Sizes><Toolbar-00D7DC28><key>iaridepm.enu1</key></Toolbar-00D7DC28></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd1><Rect><Top>-2</Top><Left>-2</Left><Bottom>721</Bottom><Right>456</Right><x>-2</x><y>-2</y><xscreen>190</xscreen><yscreen>170</yscreen><sizeHorzCX>113095</sizeHorzCX><sizeHorzCY>172764</sizeHorzCY><sizeVertCX>272619</sizeVertCX><sizeVertCY>734756</sizeVertCY></Rect></Wnd1></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>219</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>221</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>224593</sizeHorzCY><sizeVertCX>113095</sizeVertCX><sizeVertCY>172764</sizeVertCY></Rect></Wnd2></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
+ <Top><Row0><Sizes><Toolbar-00C8A108><key>iaridepm.enu1</key></Toolbar-00C8A108></Sizes></Row0><Row1><Sizes/></Row1></Top><Left><Row0><Sizes><Wnd2><Rect><Top>-2</Top><Left>-2</Left><Bottom>698</Bottom><Right>352</Right><x>-2</x><y>-2</y><xscreen>190</xscreen><yscreen>170</yscreen><sizeHorzCX>113095</sizeHorzCX><sizeHorzCY>172764</sizeHorzCY><sizeVertCX>210714</sizeVertCX><sizeVertCY>711382</sizeVertCY></Rect></Wnd2></Sizes></Row0></Left><Right><Row0><Sizes/></Row0></Right><Bottom><Row0><Sizes><Wnd3><Rect><Top>-2</Top><Left>-2</Left><Bottom>242</Bottom><Right>1682</Right><x>-2</x><y>-2</y><xscreen>1684</xscreen><yscreen>244</yscreen><sizeHorzCX>1002381</sizeHorzCX><sizeHorzCY>247967</sizeHorzCY><sizeVertCX>113095</sizeVertCX><sizeVertCY>172764</sizeVertCY></Rect></Wnd3></Sizes></Row0></Bottom><Float><Sizes/></Float></Positions>\r
</Desktop>\r
</Workspace>\r
\r