aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2012-05-20 17:09:39 +0000
committerDean Camera <dean@fourwalledcubicle.com>2012-05-20 17:09:39 +0000
commit5833b27f80f4b6b10f5765468f5863e57b97a65a (patch)
treea8df9f72605f3f069fa42a67d35ba6874cc0144d /Projects/AVRISP-MKII
parent32cfb8cf4f56f45ddfc50a6b2803ac98496c2c0b (diff)
downloadlufa-5833b27f80f4b6b10f5765468f5863e57b97a65a.tar.gz
lufa-5833b27f80f4b6b10f5765468f5863e57b97a65a.tar.bz2
lufa-5833b27f80f4b6b10f5765468f5863e57b97a65a.zip
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.
Diffstat (limited to 'Projects/AVRISP-MKII')
-rw-r--r--Projects/AVRISP-MKII/AVRISP-MKII.c21
-rw-r--r--Projects/AVRISP-MKII/AVRISP-MKII.h8
-rw-r--r--Projects/AVRISP-MKII/AVRISPDescriptors.c (renamed from Projects/AVRISP-MKII/Descriptors.c)48
-rw-r--r--Projects/AVRISP-MKII/AVRISPDescriptors.h (renamed from Projects/AVRISP-MKII/Descriptors.h)12
-rw-r--r--Projects/AVRISP-MKII/Lib/V2Protocol.h2
-rw-r--r--Projects/AVRISP-MKII/makefile2
6 files changed, 60 insertions, 33 deletions
diff --git a/Projects/AVRISP-MKII/AVRISP-MKII.c b/Projects/AVRISP-MKII/AVRISP-MKII.c
index 236a2a878..71b6da7cd 100644
--- a/Projects/AVRISP-MKII/AVRISP-MKII.c
+++ b/Projects/AVRISP-MKII/AVRISP-MKII.c
@@ -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);
+}
+
diff --git a/Projects/AVRISP-MKII/AVRISP-MKII.h b/Projects/AVRISP-MKII/AVRISP-MKII.h
index 217030524..87cfacef0 100644
--- a/Projects/AVRISP-MKII/AVRISP-MKII.h
+++ b/Projects/AVRISP-MKII/AVRISP-MKII.h
@@ -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
diff --git a/Projects/AVRISP-MKII/Descriptors.c b/Projects/AVRISP-MKII/AVRISPDescriptors.c
index 0a43dc902..f3381e121 100644
--- a/Projects/AVRISP-MKII/Descriptors.c
+++ b/Projects/AVRISP-MKII/AVRISPDescriptors.c
@@ -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;
}
diff --git a/Projects/AVRISP-MKII/Descriptors.h b/Projects/AVRISP-MKII/AVRISPDescriptors.h
index 675291afb..2779e0839 100644
--- a/Projects/AVRISP-MKII/Descriptors.h
+++ b/Projects/AVRISP-MKII/AVRISPDescriptors.h
@@ -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);
diff --git a/Projects/AVRISP-MKII/Lib/V2Protocol.h b/Projects/AVRISP-MKII/Lib/V2Protocol.h
index dca97cb2a..a730aa296 100644
--- a/Projects/AVRISP-MKII/Lib/V2Protocol.h
+++ b/Projects/AVRISP-MKII/Lib/V2Protocol.h
@@ -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"
diff --git a/Projects/AVRISP-MKII/makefile b/Projects/AVRISP-MKII/makefile
index cf1e99515..a336ebd26 100644
--- a/Projects/AVRISP-MKII/makefile
+++ b/Projects/AVRISP-MKII/makefile
@@ -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 \