Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
USBDevice_Types.h
00001 /* Copyright (c) 2010-2011 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef USBDEVICE_TYPES_H 00020 #define USBDEVICE_TYPES_H 00021 00022 /* Standard requests */ 00023 #define GET_STATUS (0) 00024 #define CLEAR_FEATURE (1) 00025 #define SET_FEATURE (3) 00026 #define SET_ADDRESS (5) 00027 #define GET_DESCRIPTOR (6) 00028 #define SET_DESCRIPTOR (7) 00029 #define GET_CONFIGURATION (8) 00030 #define SET_CONFIGURATION (9) 00031 #define GET_INTERFACE (10) 00032 #define SET_INTERFACE (11) 00033 00034 /* bmRequestType.dataTransferDirection */ 00035 #define HOST_TO_DEVICE (0) 00036 #define DEVICE_TO_HOST (1) 00037 00038 /* bmRequestType.Type*/ 00039 #define STANDARD_TYPE (0) 00040 #define CLASS_TYPE (1) 00041 #define VENDOR_TYPE (2) 00042 #define RESERVED_TYPE (3) 00043 00044 /* bmRequestType.Recipient */ 00045 #define DEVICE_RECIPIENT (0) 00046 #define INTERFACE_RECIPIENT (1) 00047 #define ENDPOINT_RECIPIENT (2) 00048 #define OTHER_RECIPIENT (3) 00049 00050 /* Descriptors */ 00051 #define DESCRIPTOR_TYPE(wValue) (wValue >> 8) 00052 #define DESCRIPTOR_INDEX(wValue) (wValue & 0xff) 00053 00054 typedef struct { 00055 struct { 00056 uint8_t dataTransferDirection; 00057 uint8_t Type; 00058 uint8_t Recipient; 00059 } bmRequestType; 00060 uint8_t bRequest; 00061 uint16_t wValue; 00062 uint16_t wIndex; 00063 uint16_t wLength; 00064 } SETUP_PACKET; 00065 00066 typedef struct { 00067 SETUP_PACKET setup; 00068 uint8_t *ptr; 00069 uint32_t remaining; 00070 uint8_t direction; 00071 bool zlp; 00072 bool notify; 00073 } CONTROL_TRANSFER; 00074 00075 typedef enum {ATTACHED, POWERED, DEFAULT, ADDRESS, CONFIGURED} DEVICE_STATE; 00076 00077 typedef struct { 00078 volatile DEVICE_STATE state; 00079 uint8_t configuration; 00080 bool suspended; 00081 } USB_DEVICE; 00082 00083 #endif
Generated on Sun Jul 17 2022 08:25:33 by 1.7.2