|
|
|
@ -35,7 +35,7 @@
|
|
|
|
|
* the device's capabilities and functions.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "Descriptors.h"
|
|
|
|
|
#include "USARTDescriptors.h"
|
|
|
|
|
|
|
|
|
|
/* On some devices, there is a factory set internal serial number which can be automatically sent to the host as
|
|
|
|
|
* the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL.
|
|
|
|
@ -54,7 +54,7 @@
|
|
|
|
|
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
|
|
|
|
* process begins.
|
|
|
|
|
*/
|
|
|
|
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|
|
|
|
USB_Descriptor_Device_t PROGMEM USART_DeviceDescriptor =
|
|
|
|
|
{
|
|
|
|
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
|
|
|
|
|
|
|
|
@ -81,13 +81,13 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|
|
|
|
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
|
|
|
|
* a configuration so that the host may correctly communicate with the USB device.
|
|
|
|
|
*/
|
|
|
|
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|
|
|
|
USART_USB_Descriptor_Configuration_t PROGMEM USART_ConfigurationDescriptor =
|
|
|
|
|
{
|
|
|
|
|
.Config =
|
|
|
|
|
{
|
|
|
|
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
|
|
|
|
|
|
|
|
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
|
|
|
|
.TotalConfigurationSize = sizeof(USART_USB_Descriptor_Configuration_t),
|
|
|
|
|
.TotalInterfaces = 2,
|
|
|
|
|
|
|
|
|
|
.ConfigurationNumber = 1,
|
|
|
|
@ -197,7 +197,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|
|
|
|
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
|
|
|
|
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
|
|
|
|
*/
|
|
|
|
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
|
|
|
|
USB_Descriptor_String_t PROGMEM USART_LanguageString =
|
|
|
|
|
{
|
|
|
|
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
|
|
|
|
|
|
|
|
@ -208,7 +208,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
|
|
|
|
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
|
|
|
|
* Descriptor.
|
|
|
|
|
*/
|
|
|
|
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|
|
|
|
USB_Descriptor_String_t PROGMEM USART_ManufacturerString =
|
|
|
|
|
{
|
|
|
|
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
|
|
|
|
|
|
|
|
@ -219,20 +219,14 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|
|
|
|
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
|
|
|
|
* Descriptor.
|
|
|
|
|
*/
|
|
|
|
|
USB_Descriptor_String_t PROGMEM ProductString =
|
|
|
|
|
USB_Descriptor_String_t PROGMEM USART_ProductString =
|
|
|
|
|
{
|
|
|
|
|
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
|
|
|
|
|
|
|
|
|
.UnicodeString = L"LUFA XPLAIN Bridge"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
|
|
|
|
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
|
|
|
|
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
|
|
|
|
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
|
|
|
|
* USB host.
|
|
|
|
|
*/
|
|
|
|
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
|
|
|
|
uint16_t USART_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
|
|
|
|
{
|
|
|
|
|
const uint8_t DescriptorType = (wValue >> 8);
|
|
|
|
|
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
|
|
|
@ -243,27 +237,27 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex,
|
|
|
|
|
switch (DescriptorType)
|
|
|
|
|
{
|
|
|
|
|
case DTYPE_Device:
|
|
|
|
|
Address = (void*)&DeviceDescriptor;
|
|
|
|
|
Address = (void*)&USART_DeviceDescriptor;
|
|
|
|
|
Size = sizeof(USB_Descriptor_Device_t);
|
|
|
|
|
break;
|
|
|
|
|
case DTYPE_Configuration:
|
|
|
|
|
Address = (void*)&ConfigurationDescriptor;
|
|
|
|
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
|
|
|
|
Address = (void*)&USART_ConfigurationDescriptor;
|
|
|
|
|
Size = sizeof(USART_USB_Descriptor_Configuration_t);
|
|
|
|
|
break;
|
|
|
|
|
case DTYPE_String:
|
|
|
|
|
switch (DescriptorNumber)
|
|
|
|
|
{
|
|
|
|
|
case 0x00:
|
|
|
|
|
Address = (void*)&LanguageString;
|
|
|
|
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
|
|
|
|
Address = (void*)&USART_LanguageString;
|
|
|
|
|
Size = pgm_read_byte(&USART_LanguageString.Header.Size);
|
|
|
|
|
break;
|
|
|
|
|
case 0x01:
|
|
|
|
|
Address = (void*)&ManufacturerString;
|
|
|
|
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
|
|
|
|
Address = (void*)&USART_ManufacturerString;
|
|
|
|
|
Size = pgm_read_byte(&USART_ManufacturerString.Header.Size);
|
|
|
|
|
break;
|
|
|
|
|
case 0x02:
|
|
|
|
|
Address = (void*)&ProductString;
|
|
|
|
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
|
|
|
|
Address = (void*)&USART_ProductString;
|
|
|
|
|
Size = pgm_read_byte(&USART_ProductString.Header.Size);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|