Christina Quast | b123d74 | 2014-12-23 13:03:36 +0100 | [diff] [blame^] | 1 | /* ---------------------------------------------------------------------------- |
| 2 | * ATMEL Microcontroller Software Support |
| 3 | * ---------------------------------------------------------------------------- |
| 4 | * Copyright (c) 2008, Atmel Corporation |
| 5 | * |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
| 11 | * - Redistributions of source code must retain the above copyright notice, |
| 12 | * this list of conditions and the disclaimer below. |
| 13 | * |
| 14 | * Atmel's name may not be used to endorse or promote products derived from |
| 15 | * this software without specific prior written permission. |
| 16 | * |
| 17 | * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR |
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE |
| 20 | * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
| 23 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 24 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 25 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 26 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * ---------------------------------------------------------------------------- |
| 28 | */ |
| 29 | |
| 30 | /** |
| 31 | * \file |
| 32 | * |
| 33 | * \section Purpose |
| 34 | * |
| 35 | * Definitions and methods for USB composite device implement. |
| 36 | * |
| 37 | */ |
| 38 | |
| 39 | #ifndef DUALCDCDDRIVER_H |
| 40 | #define DUALCDCDDRIVER_H |
| 41 | /** \addtogroup usbd_composite_cdccdc |
| 42 | *@{ |
| 43 | */ |
| 44 | |
| 45 | /*--------------------------------------------------------------------------- |
| 46 | * Headers |
| 47 | *---------------------------------------------------------------------------*/ |
| 48 | |
| 49 | #include <USBRequests.h> |
| 50 | #include <CDCDescriptors.h> |
| 51 | |
| 52 | #include <USBD.h> |
| 53 | #include <CDCDSerialPort.h> |
| 54 | |
| 55 | |
| 56 | /*--------------------------------------------------------------------------- |
| 57 | * Defines |
| 58 | *---------------------------------------------------------------------------*/ |
| 59 | |
| 60 | /** \addtogroup usbd_composite_cdccdc_desc |
| 61 | * The driver uses these interface numbers in configuration descriptor. |
| 62 | * @{ |
| 63 | */ |
| 64 | /** Number of interfaces of the device */ |
| 65 | #define DUALCDCDDriverDescriptors_NUMINTERFACE 4 |
| 66 | /** Number of the CDC0 interface. */ |
| 67 | #define DUALCDCDDriverDescriptors_INTERFACENUM0 0 |
| 68 | /** Number of the CDC1 interface. */ |
| 69 | #define DUALCDCDDriverDescriptors_INTERFACENUM1 2 |
| 70 | /** @}*/ |
| 71 | |
| 72 | /*--------------------------------------------------------------------------- |
| 73 | * Types |
| 74 | *---------------------------------------------------------------------------*/ |
| 75 | |
| 76 | #ifdef __ICCARM__ /* IAR */ |
| 77 | #pragma pack(1) /* IAR */ |
| 78 | #define __attribute__(...) /* IAR */ |
| 79 | #endif /* IAR */ |
| 80 | |
| 81 | /** |
| 82 | * \typedef DualCdcDriverConfigurationDescriptors |
| 83 | * \brief Configuration descriptor list for a device implementing a |
| 84 | * dual CDC serial composite driver. |
| 85 | */ |
| 86 | typedef struct _DualCdcDriverConfigurationDescriptors { |
| 87 | |
| 88 | /** Standard configuration descriptor. */ |
| 89 | USBConfigurationDescriptor configuration; |
| 90 | |
| 91 | /* --- CDC 0 */ |
| 92 | /** IAD 0 */ |
| 93 | USBInterfaceAssociationDescriptor cdcIAD0; |
| 94 | /** Communication interface descriptor */ |
| 95 | USBInterfaceDescriptor cdcCommunication0; |
| 96 | /** CDC header functional descriptor. */ |
| 97 | CDCHeaderDescriptor cdcHeader0; |
| 98 | /** CDC call management functional descriptor. */ |
| 99 | CDCCallManagementDescriptor cdcCallManagement0; |
| 100 | /** CDC abstract control management functional descriptor. */ |
| 101 | CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0; |
| 102 | /** CDC union functional descriptor (with one slave interface). */ |
| 103 | CDCUnionDescriptor cdcUnion0; |
| 104 | /** Notification endpoint descriptor. */ |
| 105 | USBEndpointDescriptor cdcNotification0; |
| 106 | /** Data interface descriptor. */ |
| 107 | USBInterfaceDescriptor cdcData0; |
| 108 | /** Data OUT endpoint descriptor. */ |
| 109 | USBEndpointDescriptor cdcDataOut0; |
| 110 | /** Data IN endpoint descriptor. */ |
| 111 | USBEndpointDescriptor cdcDataIn0; |
| 112 | |
| 113 | /* --- CDC 1 */ |
| 114 | /** IAD 1 */ |
| 115 | USBInterfaceAssociationDescriptor cdcIAD1; |
| 116 | /** Communication interface descriptor */ |
| 117 | USBInterfaceDescriptor cdcCommunication1; |
| 118 | /** CDC header functional descriptor. */ |
| 119 | CDCHeaderDescriptor cdcHeader1; |
| 120 | /** CDC call management functional descriptor. */ |
| 121 | CDCCallManagementDescriptor cdcCallManagement1; |
| 122 | /** CDC abstract control management functional descriptor. */ |
| 123 | CDCAbstractControlManagementDescriptor cdcAbstractControlManagement1; |
| 124 | /** CDC union functional descriptor (with one slave interface). */ |
| 125 | CDCUnionDescriptor cdcUnion1; |
| 126 | /** Notification endpoint descriptor. */ |
| 127 | USBEndpointDescriptor cdcNotification1; |
| 128 | /** Data interface descriptor. */ |
| 129 | USBInterfaceDescriptor cdcData1; |
| 130 | /** Data OUT endpoint descriptor. */ |
| 131 | USBEndpointDescriptor cdcDataOut1; |
| 132 | /** Data IN endpoint descriptor. */ |
| 133 | USBEndpointDescriptor cdcDataIn1; |
| 134 | |
| 135 | } __attribute__ ((packed)) DualCdcDriverConfigurationDescriptors; |
| 136 | |
| 137 | #ifdef __ICCARM__ /* IAR */ |
| 138 | #pragma pack() /* IAR */ |
| 139 | #endif /* IAR */ |
| 140 | |
| 141 | /*--------------------------------------------------------------------------- |
| 142 | * Exported functions |
| 143 | *---------------------------------------------------------------------------*/ |
| 144 | |
| 145 | /* -DUALCDC */ |
| 146 | extern void DUALCDCDDriver_Initialize( |
| 147 | const USBDDriverDescriptors* pDescriptors); |
| 148 | |
| 149 | extern void DUALCDCDDriver_ConfigurationChangeHandler(uint8_t cfgnum); |
| 150 | |
| 151 | extern void DUALCDCDDriver_RequestHandler(const USBGenericRequest *request); |
| 152 | |
| 153 | extern CDCDSerialPort* DUALCDCDDriver_GetSerialPort(uint32_t port); |
| 154 | |
| 155 | /**@}*/ |
| 156 | #endif /* #ifndef DUALCDCDDRIVER_H */ |
| 157 | |