blob: 6f01f1abcfbdf448fc17018760d6dcf2745cedc5 [file] [log] [blame]
Christina Quastb123d742014-12-23 13:03:36 +01001/* ----------------------------------------------------------------------------
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 CDCMSD device implement.
36 *
37 * \section Usage
38 *
39 * -# Initialize USB function specified driver ( for MSD currently )
40 * - MSDDFunctionDriver_Initialize
41 *
42 * -# Initialize USB CDCMSD driver and USB driver
43 * - CDCMSDDDriver_Initialize
44 *
45 * -# Handle and dispach USB requests
46 * - CDCMSDDDriver_RequestHandler
47 *
48 * -# Try starting a remote wake-up sequence
49 * - CDCMSDDDriver_RemoteWakeUp
50 */
51
52#ifndef CDCMSDDDRIVER_H
53#define CDCMSDDDRIVER_H
54/** \addtogroup usbd_composite_cdcmsd
55 *@{
56 */
57
58/*---------------------------------------------------------------------------
59 * Headers
60 *---------------------------------------------------------------------------*/
61
62#include <USBRequests.h>
63#include <CDCDescriptors.h>
64#include <MSDescriptors.h>
65#include <MSDLun.h>
66#include <USBD.h>
67#include <USBDDriver.h>
68
69/*---------------------------------------------------------------------------
70 * Consts
71 *---------------------------------------------------------------------------*/
72
73/** \addtogroup usbd_cdc_msd_desc USB CDC(Serial) + MS Descriptors define
74 * @{
75 */
76/** Number of interfaces of the device */
77#define CDCMSDDriverDescriptors_NUMINTERFACE 3
78/** Number of the CDC interface. */
79#define CDCMSDDriverDescriptors_CDC_INTERFACE 0
80/** Number of the HID interface. */
81#define CDCMSDDriverDescriptors_MSD_INTERFACE 2
82/** @}*/
83
84
85/*---------------------------------------------------------------------------
86 * Types
87 *---------------------------------------------------------------------------*/
88
89#ifdef __ICCARM__ /* IAR */
90#pragma pack(1) /* IAR */
91#define __attribute__(...) /* IAR */
92#endif /* IAR */
93
94/**
95 * \typedef CDCMSDDriverConfigurationDescriptors
96 * \brief Configuration descriptor list for a device implementing
97 * a CDCMSD driver.
98 */
99typedef struct _CDCMSDDriverConfigurationDescriptors {
100
101 /** Standard configuration descriptor. */
102 USBConfigurationDescriptor configuration;
103
104 /* --- CDC 0 */
105 /** IAD 0 */
106 USBInterfaceAssociationDescriptor cdcIAD0;
107 /** Communication interface descriptor */
108 USBInterfaceDescriptor cdcCommunication0;
109 /** CDC header functional descriptor. */
110 CDCHeaderDescriptor cdcHeader0;
111 /** CDC call management functional descriptor. */
112 CDCCallManagementDescriptor cdcCallManagement0;
113 /** CDC abstract control management functional descriptor. */
114 CDCAbstractControlManagementDescriptor cdcAbstractControlManagement0;
115 /** CDC union functional descriptor (with one slave interface). */
116 CDCUnionDescriptor cdcUnion0;
117 /** Notification endpoint descriptor. */
118 USBEndpointDescriptor cdcNotification0;
119 /** Data interface descriptor. */
120 USBInterfaceDescriptor cdcData0;
121 /** Data OUT endpoint descriptor. */
122 USBEndpointDescriptor cdcDataOut0;
123 /** Data IN endpoint descriptor. */
124 USBEndpointDescriptor cdcDataIn0;
125
126 /* --- MSD */
127 /** Mass storage interface descriptor. */
128 USBInterfaceDescriptor msdInterface;
129 /** Bulk-out endpoint descriptor. */
130 USBEndpointDescriptor msdBulkOut;
131 /** Bulk-in endpoint descriptor. */
132 USBEndpointDescriptor msdBulkIn;
133
134} __attribute__ ((packed)) CDCMSDDriverConfigurationDescriptors;
135
136#ifdef __ICCARM__ /* IAR */
137#pragma pack() /* IAR */
138#endif /* IAR */
139
140/*---------------------------------------------------------------------------
141 * Exported functions
142 *---------------------------------------------------------------------------*/
143
144/* -CDCMSD */
145extern void CDCMSDDriver_Initialize(
146 const USBDDriverDescriptors *pDescriptors,
147 MSDLun *pLuns, unsigned char numLuns);
148
149extern void CDCMSDDriver_ConfigurationChangedHandler(unsigned char cfgnum);
150
151extern void CDCMSDDriver_RequestHandler(const USBGenericRequest *request);
152
153/**@}*/
154#endif /* #ifndef CDCMSDDDRIVER_H */
155