SAMV71 Xplained Ultra Software Package 1.4

CDCHIDDDriver.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2014, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /**
00031  * \file
00032  *
00033  * \section Purpose
00034  *
00035  *   Definitions and methods for USB composite device implement.
00036  * 
00037  * \section Usage
00038  * 
00039  * -# Initialize USB function specified driver ( for MSD currently )
00040  *  - MSDDFunctionDriver_Initialize()
00041  *
00042  * -# Initialize USB composite driver and USB driver
00043  *  - CDCHIDDDriver_Initialize()
00044  *
00045  * -# Handle and dispatch USB requests
00046  *  - CDCHIDDDriver_RequestHandler()
00047  *
00048  * -# Try starting a remote wake-up sequence
00049  *  - CDCHIDDDriver_RemoteWakeUp()
00050  */
00051 
00052 #ifndef CDCHIDDDRIVER_H
00053 #define CDCHIDDDRIVER_H
00054 /** \addtogroup usbd_composite_cdchid
00055  *@{
00056  */
00057 
00058 /*---------------------------------------------------------------------------
00059  *         Headers
00060  *---------------------------------------------------------------------------*/
00061 
00062 #include <USBRequests.h>
00063 #include <CDCDescriptors.h>
00064 #include <HIDDescriptors.h>
00065 #include "USBD.h"
00066 #include <USBDDriver.h>
00067 
00068 /*---------------------------------------------------------------------------
00069  *         Definitions
00070  *---------------------------------------------------------------------------*/
00071 
00072 /** \addtogroup usbd_cdc_hid_desc USB CDC(Serial) + HID(Kbd) Descriptors define
00073  *      @{
00074  */
00075 /** Number of interfaces of the device */
00076 #define CDCHIDDDriverDescriptors_NUMINTERFACE       3
00077 /** Number of the CDC interface. */
00078 #define CDCHIDDDriverDescriptors_CDC_INTERFACE      0
00079 /** Number of the HID interface. */
00080 #define CDCHIDDDriverDescriptors_HID_INTERFACE      2
00081 /**     @}*/
00082 
00083 /*---------------------------------------------------------------------------
00084  *         Types
00085  *---------------------------------------------------------------------------*/
00086 #pragma pack(1)
00087 #if defined   ( __CC_ARM   ) /* Keil ¦̀Vision 4 */
00088 #elif defined ( __ICCARM__ ) /* IAR Ewarm */
00089 #define __attribute__(...)
00090 #define __packed__  packed
00091 #elif defined (  __GNUC__  ) /* GCC CS3 */
00092 #define __packed__  aligned(1)
00093 #endif
00094 /**
00095  * \typedef CdcHidDriverConfigurationDescriptors
00096  * \brief Configuration descriptor list for a device implementing a
00097  *        composite driver.
00098  */
00099 typedef struct _CdcHidDriverConfigurationDescriptors {
00100 
00101     /** Standard configuration descriptor. */
00102     USBConfigurationDescriptor configuration;
00103 
00104     /* --- CDC 0 */
00105     /** IAD 0 */
00106     USBInterfaceAssociationDescriptor cdcIAD0;
00107     /** Communication interface descriptor */
00108     USBInterfaceDescriptor cdcCommunication0;
00109     /** CDC header functional descriptor. */
00110     CDCHeaderDescriptor cdcHeader0;
00111     /** CDC call management functional descriptor. */
00112     CDCCallManagementDescriptor cdcCallManagement0;
00113     /** CDC abstract control management functional descriptor. */
00114     CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
00115     /** CDC union functional descriptor (with one slave interface). */
00116     CDCUnionDescriptor cdcUnion0;
00117     /** Notification endpoint descriptor. */
00118     USBEndpointDescriptor cdcNotification0;
00119     /** Data interface descriptor. */
00120     USBInterfaceDescriptor cdcData0;
00121     /** Data OUT endpoint descriptor. */
00122     USBEndpointDescriptor cdcDataOut0;
00123     /** Data IN endpoint descriptor. */
00124     USBEndpointDescriptor cdcDataIn0;
00125 
00126     /* --- HID */
00127     USBInterfaceDescriptor hidInterface;
00128     HIDDescriptor1 hid;
00129     USBEndpointDescriptor hidInterruptIn;
00130     USBEndpointDescriptor hidInterruptOut;
00131 
00132 } __attribute__ ((__packed__)) CdcHidDriverConfigurationDescriptors;
00133 
00134 #pragma pack()
00135 
00136 /*---------------------------------------------------------------------------
00137  *         Exported functions
00138  *---------------------------------------------------------------------------*/
00139 
00140 /* -CDCHID */
00141 extern void CDCHIDDDriver_Initialize(
00142     const USBDDriverDescriptors * pDescriptors);
00143 
00144 extern void CDCHIDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);
00145 
00146 extern void CDCHIDDDriver_RequestHandler(const USBGenericRequest *request);
00147 
00148 extern void CDCHIDDDriver_RemoteWakeUp(void);
00149 
00150 /**@}*/
00151 #endif //#ifndef CDCHIDDDRIVER_H
00152 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines