SAMV71 Xplained Ultra Software Package 1.5

HIDDMouseDriver.h

Go to the documentation of this file.
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  *
00032  * \section Purpose
00033  *
00034  * Definition of methods for using a HID mouse device driver.
00035  *
00036  * \section Usage
00037  *
00038  * -# Re-implement the USBDCallbacks_RequestReceived callback to forward
00039  *    requests to HIDDMouseDriver_RequestHandler. This is done
00040  *    automatically unless the NOAUTOCALLBACK symbol is defined during
00041  *    compilation.
00042  * -# Initialize the driver using HIDDMouseDriver_Initialize. The
00043  *    USB driver is automatically initialized by this method.
00044  * -# Call the HIDDMouseDriver_ChangePoints method when one or more
00045  *    keys are pressed/released.
00046  */
00047 
00048 #ifndef HIDDKEYBOARDDRIVER_H
00049 #define HIDDKEYBOARDDRIVER_H
00050 
00051 /** \addtogroup usbd_hid_mouse
00052  *@{
00053  */
00054 
00055 /*------------------------------------------------------------------------------
00056  *         Headers
00057  *------------------------------------------------------------------------------*/
00058 
00059 #include <USBRequests.h>
00060 
00061 #include <HIDDescriptors.h>
00062 #include <HIDRequests.h>
00063 
00064 #include <USBDDriver.h>
00065 
00066 /*------------------------------------------------------------------------------
00067  *         Definitions
00068  *------------------------------------------------------------------------------*/
00069 
00070 /** \addtogroup usbd_hid_mouse_button_bitmaps HID Mouse Button bitmaps
00071  *      @{
00072  * \section Bits
00073  * - HIDDMouse_LEFT_BUTTON
00074  * - HIDDMouse_RIGHT_BUTTON
00075  * - HIDDMouse_MIDDLE_BUTTON
00076  */
00077 
00078 /** Left mouse button */
00079 #define HIDDMouse_LEFT_BUTTON   (1 << 0)
00080 /** Right mouse button */
00081 #define HIDDMouse_RIGHT_BUTTON  (1 << 1)
00082 /** Middle mouse button */
00083 #define HIDDMouse_MIDDLE_BUTTON (1 << 2)
00084 /**      @}*/
00085 
00086 /** Size of the report descriptor in bytes. */
00087 #define HIDDMouseDriver_REPORTDESCRIPTORSIZE              50
00088 
00089 /*------------------------------------------------------------------------------
00090  *         Types
00091  *------------------------------------------------------------------------------*/
00092 #pragma pack(1)
00093 #if defined   ( __CC_ARM   ) /* Keil ¦̀Vision 4 */
00094 #elif defined ( __ICCARM__ ) /* IAR Ewarm */
00095 #define __attribute__(...)
00096 #define __packed__  packed
00097 #elif defined (  __GNUC__  ) /* GCC CS3 */
00098 #define __packed__  aligned(1)
00099 #endif
00100 
00101 /**
00102  * \typedef HIDDMouseDriverConfigurationDescriptors
00103  * \brief List of descriptors that make up the configuration descriptors of a
00104  *        device using the HID Mouse driver.
00105  */
00106 typedef struct _HIDDMouseDriverConfigurationDescriptors {
00107 
00108     /** Configuration descriptor. */
00109     USBConfigurationDescriptor configuration;
00110     /** Interface descriptor. */
00111     USBInterfaceDescriptor interface;
00112     /** HID descriptor. */
00113     HIDDescriptor1 hid;
00114     /** Interrupt IN endpoint descriptor. */
00115     USBEndpointDescriptor interruptIn;
00116 
00117 } __attribute__ ((__packed__)) HIDDMouseDriverConfigurationDescriptors;
00118 
00119 /**
00120  * \typedef HIDDMouseInputReport
00121  * \brief HID input report data struct used by the Mouse driver to notify the
00122  *        host of pressed keys.
00123  */
00124 typedef struct _HIDDMouseInputReport {
00125 
00126     uint8_t bmButtons;          /**< Bitmap state of three mouse buttons. */
00127     int8_t  bX;                 /**< Pointer displacement along the X axis. */
00128     int8_t  bY;                 /**< Pointer displacement along the Y axis. */
00129 } __attribute__ ((__packed__)) HIDDMouseInputReport; /* GCC */
00130 
00131 #pragma pack()
00132 
00133 /*------------------------------------------------------------------------------
00134  *         Exported functions
00135  *------------------------------------------------------------------------------*/
00136 
00137 extern void HIDDMouseDriver_Initialize(const USBDDriverDescriptors *pDescriptors);
00138 
00139 extern void HIDDMouseDriver_ConfigurationChangedHandler(uint8_t cfgnum);
00140 
00141 extern void HIDDMouseDriver_RequestHandler(const USBGenericRequest *request);
00142 
00143 extern uint8_t HIDDMouseDriver_ChangePoints(uint8_t bmButtons,
00144                                             int8_t deltaX,
00145                                             int8_t deltaY);
00146 
00147 extern void HIDDMouseDriver_RemoteWakeUp(void);
00148 
00149 /**@}*/
00150 
00151 #endif /*#ifndef HIDDKEYBOARDDRIVER_H */
00152 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines