diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h index 5635a4ea95118ad709081ab6023f75eb8798bbd5..02fc98fdcc538c23ba70849ba5601da62b400372 100644 --- a/LUFA/Common/Common.h +++ b/LUFA/Common/Common.h @@ -75,6 +75,11 @@ #include "Attributes.h" #include "BoardTypes.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Architecture specific utility includes: */ #if defined(__DOXYGEN__) /** Type define for an unsigned integer the same width as the selected architecture's machine register. @@ -394,6 +399,11 @@ GCC_MEMORY_BARRIER(); } + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Common/Endianness.h b/LUFA/Common/Endianness.h index 115d054f2dac5cb1fcd0a223a383457cb0f64e99..58f8012c144746274220d9be2f023ba21cb59b01 100644 --- a/LUFA/Common/Endianness.h +++ b/LUFA/Common/Endianness.h @@ -56,6 +56,11 @@ #ifndef __LUFA_ENDIANNESS_H__ #define __LUFA_ENDIANNESS_H__ + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_COMMON_H) #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality. @@ -461,6 +466,11 @@ } } + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/Misc/RingBuffer.h b/LUFA/Drivers/Misc/RingBuffer.h index 023cc25c48bc7782e5b4485669323081e6d8fd0d..c9536387164cb0cdd072ad3274be7106cd2d2107 100644 --- a/LUFA/Drivers/Misc/RingBuffer.h +++ b/LUFA/Drivers/Misc/RingBuffer.h @@ -96,6 +96,11 @@ /* Includes: */ #include "../../Common/Common.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Type Defines: */ /** \brief Ring Buffer Management Structure. * @@ -261,6 +266,11 @@ return *Buffer->Out; } + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Class/Common/HID.h b/LUFA/Drivers/USB/Class/Common/HID.h index a860b6569a40cef0fe0ac372adb9c85bb46a7be2..ce28d34e3a34fa8013ce7af195c8dc3a7c6d9179 100644 --- a/LUFA/Drivers/USB/Class/Common/HID.h +++ b/LUFA/Drivers/USB/Class/Common/HID.h @@ -54,6 +54,11 @@ #include "../../Core/StdDescriptors.h" #include "HIDParser.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_HID_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB.h instead. @@ -634,6 +639,11 @@ /** Type define for the data type used to store HID report descriptor elements. */ typedef uint8_t USB_Descriptor_HIDReport_Datatype_t; + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index c98e17cd54906c1eee954fd6d7517f112300afd9..e9696089fe273dd8bf4ca32981605ba241004241 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -54,6 +54,11 @@ #include "../USBInterrupt.h" #include "../Endpoint.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -234,6 +239,11 @@ #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h index e9b92c047be2ee14093d6c938d8cbeeaae918417..03b816e700fa0b8f8d475d980455ae06532a90c6 100644 --- a/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h @@ -51,6 +51,11 @@ /* Includes: */ #include "../../../../Common/Common.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -143,6 +148,11 @@ return ((OTGCON & (1 << HNPREQ)) ? true : false); } + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c index 27eabc3d4a57b5034119961b5b5ae96daf5074f9..4802463f00b4670c62c3ed59b53582d67f610e43 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c @@ -191,7 +191,21 @@ static void USB_Init_Device(void) #if !defined(FIXED_CONTROL_ENDPOINT_SIZE) USB_Descriptor_Device_t* DeviceDescriptorPtr; + + #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \ + !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS)) + uint8_t DescriptorAddressSpace; + if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR) + { + if (DescriptorAddressSpace == MEMSPACE_FLASH) + USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else if (DescriptorAddressSpace == MEMSPACE_EEPROM) + USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size); + else + USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size; + } + #else if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR) { #if defined(USE_RAM_DESCRIPTORS) @@ -201,7 +215,8 @@ static void USB_Init_Device(void) #else USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size); #endif - } + } + #endif #endif #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) diff --git a/LUFA/Drivers/USB/Core/ConfigDescriptor.c b/LUFA/Drivers/USB/Core/ConfigDescriptor.c index a7f4d3ba05cafb2d8579a07c0afe7b1dd1c68850..35a01995d544814fa59c00dded499240786fa8d5 100644 --- a/LUFA/Drivers/USB/Core/ConfigDescriptor.c +++ b/LUFA/Drivers/USB/Core/ConfigDescriptor.c @@ -118,7 +118,7 @@ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem, uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, void** const CurrConfigLoc, - const ConfigComparatorPtr_t const ComparatorRoutine) + ConfigComparatorPtr_t const ComparatorRoutine) { uint8_t ErrorCode; diff --git a/LUFA/Drivers/USB/Core/ConfigDescriptor.h b/LUFA/Drivers/USB/Core/ConfigDescriptor.h index 634dc8ff93ddb046b3c17bf8da2805422b1913d4..85cee466e48546d19543faa82e46200764b12e12 100644 --- a/LUFA/Drivers/USB/Core/ConfigDescriptor.h +++ b/LUFA/Drivers/USB/Core/ConfigDescriptor.h @@ -256,7 +256,7 @@ */ uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem, void** const CurrConfigLoc, - const ConfigComparatorPtr_t const ComparatorRoutine); + ConfigComparatorPtr_t const ComparatorRoutine); /* Inline Functions: */ /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then diff --git a/LUFA/Drivers/USB/Core/Device.h b/LUFA/Drivers/USB/Core/Device.h index 0e8662417b215a26b3831c8edf2f9d20e167a9f5..85fdfacf103f78cacae89980a1189c68a5f166bf 100644 --- a/LUFA/Drivers/USB/Core/Device.h +++ b/LUFA/Drivers/USB/Core/Device.h @@ -56,6 +56,11 @@ #include "USBInterrupt.h" #include "Endpoint.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -141,6 +146,11 @@ #include "UC3/Device_UC3.h" #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/Endpoint.h b/LUFA/Drivers/USB/Core/Endpoint.h index bbd75467f5942a1292d643fc22ff9f84dd7eba26..d61c5b13fc302b6f79e3877ce54a6af371cd613c 100644 --- a/LUFA/Drivers/USB/Core/Endpoint.h +++ b/LUFA/Drivers/USB/Core/Endpoint.h @@ -76,6 +76,11 @@ #include "../../../Common/Common.h" #include "USBMode.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -105,6 +110,11 @@ #include "UC3/Endpoint_UC3.h" #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/EndpointStream.h b/LUFA/Drivers/USB/Core/EndpointStream.h index 54f2d8395b3df8fe1498d6598f9b7590af9861d4..296dfe51feb3e4dadb3f99761e0a2b0464a7cc76 100644 --- a/LUFA/Drivers/USB/Core/EndpointStream.h +++ b/LUFA/Drivers/USB/Core/EndpointStream.h @@ -53,6 +53,11 @@ #include "../../../Common/Common.h" #include "USBMode.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -105,7 +110,12 @@ #elif (ARCH == ARCH_UC3) #include "UC3/EndpointStream_UC3.h" #endif - + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/Host.h b/LUFA/Drivers/USB/Core/Host.h index da8194fe8de9f42477885f1b3b72f05fd41a70db..53a6b9a6ccae49d4468d5c2642dc1d507ff295e0 100644 --- a/LUFA/Drivers/USB/Core/Host.h +++ b/LUFA/Drivers/USB/Core/Host.h @@ -53,6 +53,11 @@ #include "../../../Common/Common.h" #include "USBMode.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -169,6 +174,11 @@ #include "UC3/Host_UC3.h" #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/OTG.h b/LUFA/Drivers/USB/Core/OTG.h index 918b2ca8b3a976b28de46922638fe18e4e18d005..69caa7c59dd6c0d064282bef6c98906ba949a62b 100644 --- a/LUFA/Drivers/USB/Core/OTG.h +++ b/LUFA/Drivers/USB/Core/OTG.h @@ -54,6 +54,11 @@ #include "../../../Common/Common.h" #include "USBMode.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -64,6 +69,11 @@ #include "AVR8/OTG_AVR8.h" #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/Pipe.h b/LUFA/Drivers/USB/Core/Pipe.h index cf99719400522edb079e25576911fc2e4942934b..5f82937f4221722ebd3a77c90d1d9bfee608e7b4 100644 --- a/LUFA/Drivers/USB/Core/Pipe.h +++ b/LUFA/Drivers/USB/Core/Pipe.h @@ -86,6 +86,11 @@ #include "../../../Common/Common.h" #include "USBMode.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -120,6 +125,11 @@ #include "UC3/Pipe_UC3.h" #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/PipeStream.h b/LUFA/Drivers/USB/Core/PipeStream.h index 91f465257ae6510ff6e494fd055d96be8cb58c56..ffb2cd46bbffafe981c3764b271b1ec8b5d1272e 100644 --- a/LUFA/Drivers/USB/Core/PipeStream.h +++ b/LUFA/Drivers/USB/Core/PipeStream.h @@ -88,6 +88,11 @@ #elif (ARCH == ARCH_UC3) #include "UC3/PipeStream_UC3.h" #endif + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif #endif diff --git a/LUFA/Drivers/USB/Core/StdRequestType.h b/LUFA/Drivers/USB/Core/StdRequestType.h index 9a9e6f214872f0a64017ebd6cec1e30d1a2553e4..4b3bf33fbef4ba063594ec3db085cd8aa76e271d 100644 --- a/LUFA/Drivers/USB/Core/StdRequestType.h +++ b/LUFA/Drivers/USB/Core/StdRequestType.h @@ -53,6 +53,11 @@ #include "../../../Common/Common.h" #include "USBMode.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -242,6 +247,11 @@ #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1) #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h index 8bc8188d230a7ea61c922cbe6ea82a67529b1796..22e17464dccab663668d53eb032f91f5bea472c1 100644 --- a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h @@ -54,6 +54,11 @@ #include "../USBInterrupt.h" #include "../Endpoint.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -222,6 +227,11 @@ #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/USBController.h b/LUFA/Drivers/USB/Core/USBController.h index 0568deef6bd3401dff715b7c98bd3afc34ddafb7..ac3b9ca174f9f686d675f79d0f0fd65138cc9b1e 100644 --- a/LUFA/Drivers/USB/Core/USBController.h +++ b/LUFA/Drivers/USB/Core/USBController.h @@ -52,6 +52,11 @@ #include "../../../Common/Common.h" #include "USBMode.h" + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks and Defines: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -64,6 +69,11 @@ #include "UC3/USBController_UC3.h" #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/Drivers/USB/Core/USBInterrupt.h b/LUFA/Drivers/USB/Core/USBInterrupt.h index 3217bda89dd02e0ef4607f95c100a670af116142..c1a2b62270b7f8318d54780218c53eb924f5b9df 100644 --- a/LUFA/Drivers/USB/Core/USBInterrupt.h +++ b/LUFA/Drivers/USB/Core/USBInterrupt.h @@ -44,7 +44,12 @@ /* Includes: */ #include "../../../Common/Common.h" #include "USBMode.h" - + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -57,5 +62,10 @@ #include "UC3/USBInterrupt_UC3.h" #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif diff --git a/LUFA/Drivers/USB/Core/USBMode.h b/LUFA/Drivers/USB/Core/USBMode.h index 4fb65be38ba761932dd26c672fa0baca9ecc6a96..905b5687b429ab76a6120e265741e2dafc5867a0 100644 --- a/LUFA/Drivers/USB/Core/USBMode.h +++ b/LUFA/Drivers/USB/Core/USBMode.h @@ -55,6 +55,11 @@ #ifndef __USBMODE_H__ #define __USBMODE_H__ + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + /* Preprocessor Checks: */ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. @@ -202,6 +207,11 @@ #endif #endif + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + #endif /** @} */ diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 2d7cbb65c231e4bc4eef55ed1059a388bcff43c9..c7c11d9b77006db316225bd00ee04d0b6790147b 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -45,6 +45,9 @@ * - Large number of documentation and code comment corrections (thanks to Andrey from Microsin.ru) * - Fixed possibility of the AVR's SPI interface being pulled out of master mode if the /SS pin is a input and pulled low (thanks * to Andrey from Microsin.ru) + * - Fixed compile error when FIXED_CONTROL_ENDPOINT_SIZE compile time option was disabled, and a USE_*_DESCRIPTORS compile time + * option was not enabled on the AVR8s + * - Fixed lack of C++ compatibility in some internal header files causing compile errors when using LUFA in C++ projects * - Library Applications: * - Fixed incorrect signature in the CDC and DFU class bootloaders for the ATMEGA8U2 * - Fixed KeyboardHost and KeyboardHostWithParser demos displaying incorrect values when numerical keys were pressed