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 | /** \file |
| 31 | * |
| 32 | * \section Purpose |
| 33 | * |
| 34 | * Definitions and methods for USB HID + MSD device implement. |
| 35 | * |
| 36 | * \section Usage |
| 37 | * |
| 38 | * -# Initialize USB function specified driver ( for MSD currently ) |
| 39 | * - MSDDFunctionDriver_Initialize() |
| 40 | * |
| 41 | * -# Initialize USB HIDMSD driver and USB driver |
| 42 | * - HIDMSDDDriver_Initialize() |
| 43 | * |
| 44 | * -# Handle and dispach USB requests |
| 45 | * - HIDMSDDDriver_RequestHandler() |
| 46 | * |
| 47 | * -# Try starting a remote wake-up sequence |
| 48 | * - HIDMSDDDriver_RemoteWakeUp() |
| 49 | */ |
| 50 | |
| 51 | #ifndef HIDMSDDDRIVER_H |
| 52 | #define HIDMSDDDRIVER_H |
| 53 | |
| 54 | /** \addtogroup usbd_composite_hidmsd |
| 55 | *@{ |
| 56 | */ |
| 57 | |
| 58 | /*--------------------------------------------------------------------------- |
| 59 | * Headers |
| 60 | *---------------------------------------------------------------------------*/ |
| 61 | |
| 62 | #include <USBRequests.h> |
| 63 | #include <HIDDescriptors.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_hid_msd_desc USB HID(Kbd) + MSD Descriptors define |
| 74 | * @{ |
| 75 | */ |
| 76 | /** Number of interfaces of the device */ |
| 77 | #define HIDMSDDriverDescriptors_NUMINTERFACE 2 |
| 78 | /** Number of the HID (Keyboard) interface. */ |
| 79 | #define HIDMSDDriverDescriptors_HID_INTERFACE 0 |
| 80 | /** Number of the MSD interface. */ |
| 81 | #define HIDMSDDriverDescriptors_MSD_INTERFACE 1 |
| 82 | /** @}*/ |
| 83 | |
| 84 | /*--------------------------------------------------------------------------- |
| 85 | * Types |
| 86 | *---------------------------------------------------------------------------*/ |
| 87 | |
| 88 | #ifdef __ICCARM__ /* IAR */ |
| 89 | #pragma pack(1) /* IAR */ |
| 90 | #define __attribute__(...) /* IAR */ |
| 91 | #endif /* IAR */ |
| 92 | |
| 93 | /** |
| 94 | * \typedef HidMsdDriverConfigurationDescriptors |
| 95 | * \brief Configuration descriptor list for a device implementing a |
| 96 | * HID MSD composite driver. |
| 97 | */ |
| 98 | typedef struct _HidMsdDriverConfigurationDescriptors { |
| 99 | |
| 100 | /** Standard configuration descriptor. */ |
| 101 | USBConfigurationDescriptor configuration; |
| 102 | |
| 103 | /* --- HID */ |
| 104 | USBInterfaceDescriptor hidInterface; |
| 105 | HIDDescriptor1 hid; |
| 106 | USBEndpointDescriptor hidInterruptIn; |
| 107 | USBEndpointDescriptor hidInterruptOut; |
| 108 | |
| 109 | /* --- MSD */ |
| 110 | /** Mass storage interface descriptor. */ |
| 111 | USBInterfaceDescriptor msdInterface; |
| 112 | /** Bulk-out endpoint descriptor. */ |
| 113 | USBEndpointDescriptor msdBulkOut; |
| 114 | /** Bulk-in endpoint descriptor. */ |
| 115 | USBEndpointDescriptor msdBulkIn; |
| 116 | |
| 117 | } __attribute__ ((packed)) HidMsdDriverConfigurationDescriptors; |
| 118 | |
| 119 | #ifdef __ICCARM__ /* IAR */ |
| 120 | #pragma pack() /* IAR */ |
| 121 | #endif /* IAR */ |
| 122 | |
| 123 | /*--------------------------------------------------------------------------- |
| 124 | * Exported functions |
| 125 | *---------------------------------------------------------------------------*/ |
| 126 | |
| 127 | /* -HIDMSD Composite device */ |
| 128 | extern void HIDMSDDriver_Initialize( |
| 129 | const USBDDriverDescriptors *pDescriptors, |
| 130 | MSDLun *pLuns, uint8_t numLuns); |
| 131 | |
| 132 | extern void HIDMSDDriver_ConfigurationChangedHandler(uint8_t cfgnum); |
| 133 | |
| 134 | extern void HIDMSDDriver_RequestHandler(const USBGenericRequest *request); |
| 135 | |
| 136 | extern void HIDMSDDriver_RemoteWakeUp(void); |
| 137 | |
| 138 | /**@}*/ |
| 139 | #endif //#ifndef HIDMSDDDRIVER_H |
| 140 | |