diff options
Diffstat (limited to 'lib/lufa/Projects/RelayBoard/Descriptors.c')
| -rw-r--r-- | lib/lufa/Projects/RelayBoard/Descriptors.c | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/lib/lufa/Projects/RelayBoard/Descriptors.c b/lib/lufa/Projects/RelayBoard/Descriptors.c deleted file mode 100644 index 635e2ca7d..000000000 --- a/lib/lufa/Projects/RelayBoard/Descriptors.c +++ /dev/null | |||
| @@ -1,188 +0,0 @@ | |||
| 1 | /* | ||
| 2 | LUFA Library | ||
| 3 | Copyright (C) Dean Camera, 2017. | ||
| 4 | |||
| 5 | dean [at] fourwalledcubicle [dot] com | ||
| 6 | www.lufa-lib.org | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | Copyright 2010 OBinou (obconseil [at] gmail [dot] com) | ||
| 11 | Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||
| 12 | |||
| 13 | Permission to use, copy, modify, distribute, and sell this | ||
| 14 | software and its documentation for any purpose is hereby granted | ||
| 15 | without fee, provided that the above copyright notice appear in | ||
| 16 | all copies and that both that the copyright notice and this | ||
| 17 | permission notice and warranty disclaimer appear in supporting | ||
| 18 | documentation, and that the name of the author not be used in | ||
| 19 | advertising or publicity pertaining to distribution of the | ||
| 20 | software without specific, written prior permission. | ||
| 21 | |||
| 22 | The author disclaims all warranties with regard to this | ||
| 23 | software, including all implied warranties of merchantability | ||
| 24 | and fitness. In no event shall the author be liable for any | ||
| 25 | special, indirect or consequential damages or any damages | ||
| 26 | whatsoever resulting from loss of use, data or profits, whether | ||
| 27 | in an action of contract, negligence or other tortious action, | ||
| 28 | arising out of or in connection with the use or performance of | ||
| 29 | this software. | ||
| 30 | */ | ||
| 31 | |||
| 32 | /** \file | ||
| 33 | * | ||
| 34 | * USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||
| 35 | * computer-readable structures which the host requests upon device enumeration, to determine | ||
| 36 | * the device's capabilities and functions. | ||
| 37 | */ | ||
| 38 | |||
| 39 | #include "Descriptors.h" | ||
| 40 | |||
| 41 | /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||
| 42 | * device characteristics, including the supported USB version, control endpoint size and the | ||
| 43 | * number of device configurations. The descriptor is read out by the USB host when the enumeration | ||
| 44 | * process begins. | ||
| 45 | */ | ||
| 46 | const USB_Descriptor_Device_t PROGMEM RelayBoard_DeviceDescriptor = | ||
| 47 | { | ||
| 48 | .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||
| 49 | |||
| 50 | .USBSpecification = VERSION_BCD(1,1,0), | ||
| 51 | .Class = USB_CSCP_VendorSpecificClass, | ||
| 52 | .SubClass = USB_CSCP_NoDeviceSubclass, | ||
| 53 | .Protocol = USB_CSCP_NoDeviceProtocol, | ||
| 54 | |||
| 55 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, | ||
| 56 | |||
| 57 | .VendorID = 0x04B4, | ||
| 58 | .ProductID = 0xFD11, | ||
| 59 | .ReleaseNumber = VERSION_BCD(2,0,0), | ||
| 60 | |||
| 61 | .ManufacturerStrIndex = STRING_ID_Manufacturer, | ||
| 62 | .ProductStrIndex = STRING_ID_Product, | ||
| 63 | .SerialNumStrIndex = STRING_ID_Serial, | ||
| 64 | |||
| 65 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||
| 66 | }; | ||
| 67 | |||
| 68 | /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||
| 69 | * of the device in one of its supported configurations, including information about any device interfaces | ||
| 70 | * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||
| 71 | * a configuration so that the host may correctly communicate with the USB device. | ||
| 72 | */ | ||
| 73 | const USB_Descriptor_Configuration_t PROGMEM RelayBoard_ConfigurationDescriptor = | ||
| 74 | { | ||
| 75 | .Config = | ||
| 76 | { | ||
| 77 | .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||
| 78 | |||
| 79 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||
| 80 | .TotalInterfaces = 1, | ||
| 81 | |||
| 82 | .ConfigurationNumber = 1, | ||
| 83 | .ConfigurationStrIndex = NO_DESCRIPTOR, | ||
| 84 | |||
| 85 | .ConfigAttributes = USB_CONFIG_ATTR_RESERVED, | ||
| 86 | |||
| 87 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(500) | ||
| 88 | }, | ||
| 89 | |||
| 90 | .RelayBoardInterface = | ||
| 91 | { | ||
| 92 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||
| 93 | |||
| 94 | .InterfaceNumber = INTERFACE_ID_RelayBoard, | ||
| 95 | .AlternateSetting = 0, | ||
| 96 | |||
| 97 | .TotalEndpoints = 0, | ||
| 98 | |||
| 99 | .Class = USB_CSCP_VendorSpecificClass, | ||
| 100 | .SubClass = 0x00, | ||
| 101 | .Protocol = 0x00, | ||
| 102 | |||
| 103 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 104 | }, | ||
| 105 | }; | ||
| 106 | |||
| 107 | /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||
| 108 | * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||
| 109 | * via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||
| 110 | */ | ||
| 111 | const USB_Descriptor_String_t PROGMEM RelayBoard_LanguageString = | ||
| 112 | { | ||
| 113 | .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||
| 114 | |||
| 115 | .UnicodeString = {LANGUAGE_ID_ENG} | ||
| 116 | }; | ||
| 117 | |||
| 118 | /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||
| 119 | * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||
| 120 | * Descriptor. | ||
| 121 | */ | ||
| 122 | const USB_Descriptor_String_t PROGMEM RelayBoard_ManufacturerString = USB_STRING_DESCRIPTOR(L"SISPM"); | ||
| 123 | |||
| 124 | /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||
| 125 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||
| 126 | * Descriptor. | ||
| 127 | */ | ||
| 128 | const USB_Descriptor_String_t PROGMEM RelayBoard_ProductString = USB_STRING_DESCRIPTOR(L"RelayBoard"); | ||
| 129 | |||
| 130 | /** Serial number string. This is a Unicode string containing the device's unique serial number, expressed as a | ||
| 131 | * series of uppercase hexadecimal digits. | ||
| 132 | */ | ||
| 133 | const USB_Descriptor_String_t PROGMEM RelayBoard_SerialString = USB_STRING_DESCRIPTOR(L"00001"); | ||
| 134 | |||
| 135 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||
| 136 | * documentation) by the application code so that the address and size of a requested descriptor can be given | ||
| 137 | * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||
| 138 | * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||
| 139 | * USB host. | ||
| 140 | */ | ||
| 141 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||
| 142 | const uint16_t wIndex, | ||
| 143 | const void** const DescriptorAddress) | ||
| 144 | { | ||
| 145 | const uint8_t DescriptorType = (wValue >> 8); | ||
| 146 | const uint8_t DescriptorNumber = (wValue & 0xFF); | ||
| 147 | |||
| 148 | const void* Address = NULL; | ||
| 149 | uint16_t Size = NO_DESCRIPTOR; | ||
| 150 | |||
| 151 | switch (DescriptorType) | ||
| 152 | { | ||
| 153 | case DTYPE_Device: | ||
| 154 | Address = &RelayBoard_DeviceDescriptor; | ||
| 155 | Size = sizeof(USB_Descriptor_Device_t); | ||
| 156 | break; | ||
| 157 | case DTYPE_Configuration: | ||
| 158 | Address = &RelayBoard_ConfigurationDescriptor; | ||
| 159 | Size = sizeof(USB_Descriptor_Configuration_t); | ||
| 160 | break; | ||
| 161 | case DTYPE_String: | ||
| 162 | switch (DescriptorNumber) | ||
| 163 | { | ||
| 164 | case STRING_ID_Language: | ||
| 165 | Address = &RelayBoard_LanguageString; | ||
| 166 | Size = pgm_read_byte(&RelayBoard_LanguageString.Header.Size); | ||
| 167 | break; | ||
| 168 | case STRING_ID_Manufacturer: | ||
| 169 | Address = &RelayBoard_ManufacturerString; | ||
| 170 | Size = pgm_read_byte(&RelayBoard_ManufacturerString.Header.Size); | ||
| 171 | break; | ||
| 172 | case STRING_ID_Product: | ||
| 173 | Address = &RelayBoard_ProductString; | ||
| 174 | Size = pgm_read_byte(&RelayBoard_ProductString.Header.Size); | ||
| 175 | break; | ||
| 176 | case STRING_ID_Serial: | ||
| 177 | Address = &RelayBoard_SerialString; | ||
| 178 | Size = pgm_read_byte(&RelayBoard_SerialString.Header.Size); | ||
| 179 | break; | ||
| 180 | } | ||
| 181 | |||
| 182 | break; | ||
| 183 | } | ||
| 184 | |||
| 185 | *DescriptorAddress = Address; | ||
| 186 | return Size; | ||
| 187 | } | ||
| 188 | |||
