00001 /* ---------------------------------------------------------------------------- */ 00002 /* Atmel Microcontroller Software Support */ 00003 /* SAM Software Package License */ 00004 /* ---------------------------------------------------------------------------- */ 00005 /* Copyright (c) 2015, Atmel Corporation */ 00006 /* */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without */ 00010 /* modification, are permitted provided that the following condition is met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, */ 00013 /* this list of conditions and the disclaimer below. */ 00014 /* */ 00015 /* Atmel's name may not be used to endorse or promote products derived from */ 00016 /* this software without specific prior written permission. */ 00017 /* */ 00018 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ 00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ 00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ 00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ 00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ 00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00028 /* ---------------------------------------------------------------------------- */ 00029 00030 /** \file 00031 * Definition of a class for implementing a USB device 00032 * CDC EEM function. 00033 */ 00034 00035 #ifndef _CDCDEEMPORT_H_ 00036 #define _CDCDEEMPORT_H_ 00037 00038 /*------------------------------------------------------------------------------ 00039 * Headers 00040 *------------------------------------------------------------------------------*/ 00041 00042 /* These headers were introduced in C99 00043 by working group ISO/IEC JTC1/SC22/WG14. */ 00044 #include <stdint.h> 00045 00046 #include <USBRequests.h> 00047 #include <CDCRequests.h> 00048 #include <CDCNotifications.h> 00049 #include "USBD.h" 00050 #include <USBDDriver.h> 00051 00052 /** \addtogroup usbd_cdc 00053 *@{ 00054 */ 00055 00056 /*------------------------------------------------------------------------------ 00057 * Defines 00058 *------------------------------------------------------------------------------*/ 00059 00060 /** \addtogroup usbd_cdc_eem_desc USB Device EEM Port Descriptor Values 00061 * @{ 00062 */ 00063 /** Default CDC interrupt endpoints max packat size (8). */ 00064 #define CDCDEEMPort_INTERRUPT_MAXPACKETSIZE 8 00065 /** Default CDC interrupt endpoint polling rate of High Speed (16ms). */ 00066 #define CDCDEEMPort_INTERRUPT_INTERVAL_HS 8 00067 /** Default CDC interrupt endpoint polling rate of Full Speed (16ms). */ 00068 #define CDCDEEMPort_INTERRUPT_INTERVAL_FS 16 00069 /** Default CDC bulk endpoints max packat size (512, for HS actually). */ 00070 #define CDCDEEMPort_BULK_MAXPACKETSIZE_HS 512 00071 /** Default CDC bulk endpoints max packat size (64, for FS actually). */ 00072 #define CDCDEEMPort_BULK_MAXPACKETSIZE_FS 64 00073 /** @}*/ 00074 00075 /*------------------------------------------------------------------------------ 00076 * Types 00077 *------------------------------------------------------------------------------*/ 00078 00079 /** 00080 * Struct for USB CDC EEM port function. 00081 */ 00082 typedef struct _CDCDEEMPort { 00083 /** USB Driver for the %device */ 00084 USBDDriver *pUsbd; 00085 /** USB starting interface index */ 00086 uint8_t bInterfaceNdx; 00087 /** USB number of interfaces */ 00088 uint8_t bNumInterface; 00089 /** USB bulk IN endpoint address */ 00090 uint8_t bBulkInPIPE; 00091 /** USB bulk OUT endpoint address */ 00092 uint8_t bBulkOutPIPE; 00093 /** Max packet size for OUT endpoint */ 00094 uint32_t wBulkOutMaxPacketSize; 00095 } CDCDEEMPort; 00096 00097 /*------------------------------------------------------------------------------ 00098 * Functions 00099 *------------------------------------------------------------------------------*/ 00100 00101 extern void CDCDEEMPort_Initialize(CDCDEEMPort *pCdcd, 00102 USBDDriver *pUsbd, 00103 uint8_t firstInterface, 00104 uint8_t numInterface); 00105 00106 extern USBGenericDescriptor * CDCDEEMPort_ParseInterfaces( 00107 CDCDEEMPort * pCdcd, 00108 USBGenericDescriptor * pDescriptors, uint32_t dwLength); 00109 00110 extern uint32_t CDCDEEMPort_RequestHandler( 00111 CDCDEEMPort *pCdcd, 00112 const USBGenericRequest *pRequest); 00113 00114 extern uint32_t CDCDEEMPort_Write( 00115 const CDCDEEMPort *pCdcd, 00116 void *pData, uint32_t dwSize, 00117 TransferCallback fCallback, void* pArg); 00118 00119 extern uint32_t CDCDEEMPort_Read( 00120 const CDCDEEMPort *pCdcd, 00121 void *pData, uint32_t dwSize, 00122 TransferCallback fCallback, void* pArg); 00123 00124 /**@}*/ 00125 #endif /* #ifndef _CDCDEEMPORT_H_ */