Mark build test makefiles as being incompatible with parallel make builds, as they...
[pub/USBasp.git] / Projects / AVRISP-MKII / AVRISP-MKII.c
index eaf04cb..c4623fd 100644 (file)
@@ -72,6 +72,11 @@ void SetupHardware(void)
 
        /* Hardware Initialization */
        LEDs_Init();
+       #if defined(RESET_TOGGLES_LIBUSB_COMPAT)
+       UpdateCurrentCompatibilityMode();
+       #endif
+
+       /* USB Stack Initialization */
        USB_Init();
 }
 
@@ -92,12 +97,12 @@ void EVENT_USB_Device_ConfigurationChanged(void)
 {
        bool ConfigSuccess = true;
 
-       /* Setup AVRISP Data Endpoint(s) */
+       /* Setup AVRISP Data OUT endpoint */
        ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_OUT_EPADDR, EP_TYPE_BULK, AVRISP_DATA_EPSIZE, 1);
 
-       #if defined(LIBUSB_DRIVER_COMPAT)
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_IN_EPADDR, EP_TYPE_BULK, AVRISP_DATA_EPSIZE, 1);
-       #endif
+       /* Setup AVRISP Data IN endpoint if it is using a physically different endpoint */
+       if ((AVRISP_DATA_IN_EPADDR & ENDPOINT_EPNUM_MASK) != (AVRISP_DATA_OUT_EPADDR & ENDPOINT_EPNUM_MASK))
+         ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_IN_EPADDR, EP_TYPE_BULK, AVRISP_DATA_EPSIZE, 1);
 
        /* Indicate endpoint configuration success or failure */
        LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
@@ -126,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);
+}
+