USBMOUSE

Dependents:   ESD_Project_USBMouse

Committer:
priyankapashte
Date:
Sun Dec 13 10:04:36 2015 +0000
Revision:
0:78a4faee5b0f
USBMouse File has been modified;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
priyankapashte 0:78a4faee5b0f 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
priyankapashte 0:78a4faee5b0f 2 *
priyankapashte 0:78a4faee5b0f 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
priyankapashte 0:78a4faee5b0f 4 * and associated documentation files (the "Software"), to deal in the Software without
priyankapashte 0:78a4faee5b0f 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
priyankapashte 0:78a4faee5b0f 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
priyankapashte 0:78a4faee5b0f 7 * Software is furnished to do so, subject to the following conditions:
priyankapashte 0:78a4faee5b0f 8 *
priyankapashte 0:78a4faee5b0f 9 * The above copyright notice and this permission notice shall be included in all copies or
priyankapashte 0:78a4faee5b0f 10 * substantial portions of the Software.
priyankapashte 0:78a4faee5b0f 11 *
priyankapashte 0:78a4faee5b0f 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
priyankapashte 0:78a4faee5b0f 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
priyankapashte 0:78a4faee5b0f 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
priyankapashte 0:78a4faee5b0f 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
priyankapashte 0:78a4faee5b0f 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
priyankapashte 0:78a4faee5b0f 17 */
priyankapashte 0:78a4faee5b0f 18
priyankapashte 0:78a4faee5b0f 19 #ifndef USBDEVICE_TYPES_H
priyankapashte 0:78a4faee5b0f 20 #define USBDEVICE_TYPES_H
priyankapashte 0:78a4faee5b0f 21
priyankapashte 0:78a4faee5b0f 22 /* Standard requests */
priyankapashte 0:78a4faee5b0f 23 #define GET_STATUS (0)
priyankapashte 0:78a4faee5b0f 24 #define CLEAR_FEATURE (1)
priyankapashte 0:78a4faee5b0f 25 #define SET_FEATURE (3)
priyankapashte 0:78a4faee5b0f 26 #define SET_ADDRESS (5)
priyankapashte 0:78a4faee5b0f 27 #define GET_DESCRIPTOR (6)
priyankapashte 0:78a4faee5b0f 28 #define SET_DESCRIPTOR (7)
priyankapashte 0:78a4faee5b0f 29 #define GET_CONFIGURATION (8)
priyankapashte 0:78a4faee5b0f 30 #define SET_CONFIGURATION (9)
priyankapashte 0:78a4faee5b0f 31 #define GET_INTERFACE (10)
priyankapashte 0:78a4faee5b0f 32 #define SET_INTERFACE (11)
priyankapashte 0:78a4faee5b0f 33
priyankapashte 0:78a4faee5b0f 34 /* bmRequestType.dataTransferDirection */
priyankapashte 0:78a4faee5b0f 35 #define HOST_TO_DEVICE (0)
priyankapashte 0:78a4faee5b0f 36 #define DEVICE_TO_HOST (1)
priyankapashte 0:78a4faee5b0f 37
priyankapashte 0:78a4faee5b0f 38 /* bmRequestType.Type*/
priyankapashte 0:78a4faee5b0f 39 #define STANDARD_TYPE (0)
priyankapashte 0:78a4faee5b0f 40 #define CLASS_TYPE (1)
priyankapashte 0:78a4faee5b0f 41 #define VENDOR_TYPE (2)
priyankapashte 0:78a4faee5b0f 42 #define RESERVED_TYPE (3)
priyankapashte 0:78a4faee5b0f 43
priyankapashte 0:78a4faee5b0f 44 /* bmRequestType.Recipient */
priyankapashte 0:78a4faee5b0f 45 #define DEVICE_RECIPIENT (0)
priyankapashte 0:78a4faee5b0f 46 #define INTERFACE_RECIPIENT (1)
priyankapashte 0:78a4faee5b0f 47 #define ENDPOINT_RECIPIENT (2)
priyankapashte 0:78a4faee5b0f 48 #define OTHER_RECIPIENT (3)
priyankapashte 0:78a4faee5b0f 49
priyankapashte 0:78a4faee5b0f 50 /* Descriptors */
priyankapashte 0:78a4faee5b0f 51 #define DESCRIPTOR_TYPE(wValue) (wValue >> 8)
priyankapashte 0:78a4faee5b0f 52 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xff)
priyankapashte 0:78a4faee5b0f 53
priyankapashte 0:78a4faee5b0f 54 typedef struct {
priyankapashte 0:78a4faee5b0f 55 struct {
priyankapashte 0:78a4faee5b0f 56 uint8_t dataTransferDirection;
priyankapashte 0:78a4faee5b0f 57 uint8_t Type;
priyankapashte 0:78a4faee5b0f 58 uint8_t Recipient;
priyankapashte 0:78a4faee5b0f 59 } bmRequestType;
priyankapashte 0:78a4faee5b0f 60 uint8_t bRequest;
priyankapashte 0:78a4faee5b0f 61 uint16_t wValue;
priyankapashte 0:78a4faee5b0f 62 uint16_t wIndex;
priyankapashte 0:78a4faee5b0f 63 uint16_t wLength;
priyankapashte 0:78a4faee5b0f 64 } SETUP_PACKET;
priyankapashte 0:78a4faee5b0f 65
priyankapashte 0:78a4faee5b0f 66 typedef struct {
priyankapashte 0:78a4faee5b0f 67 SETUP_PACKET setup;
priyankapashte 0:78a4faee5b0f 68 uint8_t *ptr;
priyankapashte 0:78a4faee5b0f 69 uint32_t remaining;
priyankapashte 0:78a4faee5b0f 70 uint8_t direction;
priyankapashte 0:78a4faee5b0f 71 bool zlp;
priyankapashte 0:78a4faee5b0f 72 bool notify;
priyankapashte 0:78a4faee5b0f 73 } CONTROL_TRANSFER;
priyankapashte 0:78a4faee5b0f 74
priyankapashte 0:78a4faee5b0f 75 typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE;
priyankapashte 0:78a4faee5b0f 76
priyankapashte 0:78a4faee5b0f 77 typedef struct {
priyankapashte 0:78a4faee5b0f 78 volatile DEVICE_STATE state;
priyankapashte 0:78a4faee5b0f 79 uint8_t configuration;
priyankapashte 0:78a4faee5b0f 80 bool suspended;
priyankapashte 0:78a4faee5b0f 81 } USB_DEVICE;
priyankapashte 0:78a4faee5b0f 82
priyankapashte 0:78a4faee5b0f 83 #endif