1 /* ----------------------------------------------------------------------------
\r
2 * ATMEL Microcontroller Software Support
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2008, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
31 * Title: CDCDSerialDriver implementation
\r
34 * Implementation of the CDCDSerialDriver class methods.
\r
37 /** \addtogroup usbd_cdc
\r
41 /*------------------------------------------------------------------------------
\r
43 *------------------------------------------------------------------------------*/
\r
45 #include "CDCDSerialDriver.h"
\r
47 #include <USBLib_Trace.h>
\r
48 #include <USBDDriver.h>
\r
49 #include <USBD_HAL.h>
\r
51 /*------------------------------------------------------------------------------
\r
53 *------------------------------------------------------------------------------*/
\r
55 /*------------------------------------------------------------------------------
\r
56 * Internal variables
\r
57 *------------------------------------------------------------------------------*/
\r
59 /*------------------------------------------------------------------------------
\r
60 * Internal functions
\r
61 *------------------------------------------------------------------------------*/
\r
63 /*------------------------------------------------------------------------------
\r
64 * Exported functions
\r
65 *------------------------------------------------------------------------------*/
\r
68 * Initializes the USB Device CDC serial driver & USBD Driver.
\r
69 * \param pDescriptors Pointer to Descriptors list for CDC Serial Device.
\r
71 void CDCDSerialDriver_Initialize(const USBDDriverDescriptors *pDescriptors)
\r
73 USBDDriver *pUsbd = USBD_GetDriver();
\r
75 /* Initialize the standard driver */
\r
76 USBDDriver_Initialize(pUsbd,
\r
78 0); /* Multiple settings for interfaces not supported */
\r
80 CDCDSerial_Initialize(pUsbd, CDCDSerialDriver_CC_INTERFACE);
\r
82 /* Initialize the USB driver */
\r
87 * Invoked whenever the active configuration of device is changed by the
\r
89 * \param cfgnum Configuration number.
\r
91 void CDCDSerialDriver_ConfigurationChangedHandler(uint8_t cfgnum)
\r
93 USBDDriver *pUsbd = USBD_GetDriver();
\r
94 USBConfigurationDescriptor *pDesc;
\r
96 pDesc = USBDDriver_GetCfgDescriptors(pUsbd, cfgnum);
\r
97 CDCDSerial_ConfigureFunction((USBGenericDescriptor *)pDesc,
\r
98 pDesc->wTotalLength);
\r
103 * Handles CDC-specific SETUP requests. Should be called from a
\r
104 * re-implementation of USBDCallbacks_RequestReceived() method.
\r
105 * \param request Pointer to a USBGenericRequest instance.
\r
107 void CDCDSerialDriver_RequestHandler(const USBGenericRequest *request)
\r
109 USBDDriver *pUsbd = USBD_GetDriver();
\r
110 TRACE_INFO_WP("NewReq ");
\r
111 if (CDCDSerial_RequestHandler(request))
\r
112 USBDDriver_RequestHandler(pUsbd, request);
\r