Alter the XPLAINBridge and AVRISP-MKII clone projects so that the descriptors from the AVRISP-MKII clone project can be directly used in the XPLAINBridge project. Add support for RESET_TOGGLES_LIBUSB_COMPAT option in the XPLAINBridge project.

This commit is contained in:
Dean Camera 2012-05-20 17:09:39 +00:00
parent 32cfb8cf4f
commit 5833b27f80
15 changed files with 108 additions and 356 deletions

View file

@ -131,3 +131,24 @@ void AVRISP_Task(void)
}
}
/** 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.
*
* \param[in] wValue Descriptor type and index to retrieve
* \param[in] wIndex Sub-index to retrieve (such as a localized string language)
* \param[out] DescriptorAddress Address of the retrieved descriptor
* \param[out] DescriptorMemorySpace Memory space that the descriptor is stored in
*
* \return Length of the retrieved descriptor in bytes, or NO_DESCRIPTOR if the descriptor was not found
*/
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress,
uint8_t* DescriptorMemorySpace)
{
return AVRISP_GetDescriptor(wValue, wIndex, DescriptorAddress, DescriptorMemorySpace);
}

View file

@ -50,7 +50,7 @@
#include <LUFA/Drivers/Peripheral/ADC.h>
#endif
#include "Descriptors.h"
#include "AVRISPDescriptors.h"
#include "Lib/V2Protocol.h"
/* Macros: */
@ -79,6 +79,12 @@
void EVENT_USB_Device_Connect(void);
void EVENT_USB_Device_Disconnect(void);
void EVENT_USB_Device_ConfigurationChanged(void);
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress,
uint8_t* const DescriptorMemorySpace)
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3) ATTR_NON_NULL_PTR_ARG(4);
#endif

View file

@ -35,7 +35,7 @@
* the device's capabilities and functions.
*/
#include "Descriptors.h"
#include "AVRISPDescriptors.h"
#if defined(RESET_TOGGLES_LIBUSB_COMPAT) || defined(__DOXYGEN__)
static bool AVRISP_NeedCompatibilitySwitch ATTR_NO_INIT;
@ -52,7 +52,7 @@
* number of device configurations. The descriptor is read out by the USB host when the enumeration
* process begins.
*/
const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
const USB_Descriptor_Device_t PROGMEM AVRISP_DeviceDescriptor =
{
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
@ -79,13 +79,13 @@ const 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 ConfigurationDescriptor =
AVRISP_USB_Descriptor_Configuration_t AVRISP_ConfigurationDescriptor =
{
.Config =
{
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
.TotalConfigurationSize = sizeof(AVRISP_USB_Descriptor_Configuration_t),
.TotalInterfaces = 1,
.ConfigurationNumber = 1,
@ -141,7 +141,7 @@ USB_Descriptor_Configuration_t 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.
*/
const USB_Descriptor_String_t PROGMEM LanguageString =
const USB_Descriptor_String_t PROGMEM AVRISP_LanguageString =
{
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
@ -152,7 +152,7 @@ const 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.
*/
const USB_Descriptor_String_t PROGMEM ManufacturerString =
const USB_Descriptor_String_t PROGMEM AVRISP_ManufacturerString =
{
.Header = {.Size = USB_STRING_LEN(5), .Type = DTYPE_String},
@ -163,7 +163,7 @@ const 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.
*/
const USB_Descriptor_String_t PROGMEM ProductString =
const USB_Descriptor_String_t PROGMEM AVRISP_ProductString =
{
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
@ -173,7 +173,7 @@ const USB_Descriptor_String_t PROGMEM ProductString =
/** Serial number string. This is a Unicode string containing the device's unique serial number, expressed as a
* series of uppercase hexadecimal digits.
*/
const USB_Descriptor_String_t PROGMEM SerialString =
const USB_Descriptor_String_t PROGMEM AVRISP_SerialString =
{
.Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
@ -186,10 +186,10 @@ const USB_Descriptor_String_t PROGMEM SerialString =
* 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,
const void** const DescriptorAddress,
uint8_t* DescriptorMemorySpace)
uint16_t AVRISP_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress,
uint8_t* DescriptorMemorySpace)
{
const uint8_t DescriptorType = (wValue >> 8);
const uint8_t DescriptorNumber = (wValue & 0xFF);
@ -202,36 +202,36 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
switch (DescriptorType)
{
case DTYPE_Device:
Address = &DeviceDescriptor;
Address = &AVRISP_DeviceDescriptor;
Size = sizeof(USB_Descriptor_Device_t);
break;
case DTYPE_Configuration:
*DescriptorMemorySpace = MEMSPACE_RAM;
#if defined(RESET_TOGGLES_LIBUSB_COMPAT)
ConfigurationDescriptor.AVRISP_DataInEndpoint.EndpointAddress = AVRISP_CurrDataINEndpointAddress;
AVRISP_ConfigurationDescriptor.AVRISP_DataInEndpoint.EndpointAddress = AVRISP_CurrDataINEndpointAddress;
#endif
Address = &ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
Address = &AVRISP_ConfigurationDescriptor;
Size = sizeof(AVRISP_USB_Descriptor_Configuration_t);
break;
case DTYPE_String:
switch (DescriptorNumber)
{
case 0x00:
Address = &LanguageString;
Size = pgm_read_byte(&LanguageString.Header.Size);
Address = &AVRISP_LanguageString;
Size = pgm_read_byte(&AVRISP_LanguageString.Header.Size);
break;
case 0x01:
Address = &ManufacturerString;
Size = pgm_read_byte(&ManufacturerString.Header.Size);
Address = &AVRISP_ManufacturerString;
Size = pgm_read_byte(&AVRISP_ManufacturerString.Header.Size);
break;
case 0x02:
Address = &ProductString;
Size = pgm_read_byte(&ProductString.Header.Size);
Address = &AVRISP_ProductString;
Size = pgm_read_byte(&AVRISP_ProductString.Header.Size);
break;
case 0x03:
Address = &SerialString;
Size = pgm_read_byte(&SerialString.Header.Size);
Address = &AVRISP_SerialString;
Size = pgm_read_byte(&AVRISP_SerialString.Header.Size);
break;
}

View file

@ -82,7 +82,7 @@
USB_Descriptor_Interface_t AVRISP_Interface;
USB_Descriptor_Endpoint_t AVRISP_DataInEndpoint;
USB_Descriptor_Endpoint_t AVRISP_DataOutEndpoint;
} USB_Descriptor_Configuration_t;
} AVRISP_USB_Descriptor_Configuration_t;
/* External Variables: */
#if defined(RESET_TOGGLES_LIBUSB_COMPAT)
@ -90,11 +90,11 @@
#endif
/* Function Prototypes: */
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress,
uint8_t* const DescriptorMemorySpace)
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3) ATTR_NON_NULL_PTR_ARG(4);
uint16_t AVRISP_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress,
uint8_t* const DescriptorMemorySpace)
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3) ATTR_NON_NULL_PTR_ARG(4);
#if defined(RESET_TOGGLES_LIBUSB_COMPAT)
void CheckExternalReset(void) ATTR_NAKED ATTR_INIT_SECTION(3);

View file

@ -43,7 +43,7 @@
#include <LUFA/Drivers/USB/USB.h>
#include "../Descriptors.h"
#include "../AVRISPDescriptors.h"
#include "V2ProtocolConstants.h"
#include "V2ProtocolParams.h"
#include "ISP/ISPProtocol.h"

View file

@ -154,7 +154,7 @@ include $(LUFA_PATH)/LUFA/makefile
# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c \
Descriptors.c \
AVRISPDescriptors.c \
Lib/V2Protocol.c \
Lib/V2ProtocolParams.c \
Lib/ISP/ISPProtocol.c \