diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h index 9d64403bcefc8736668db09f94840d8b51117995..6a9356bbb0c759d1508ee377409f6f2abf624366 100644 --- a/LUFA/Common/Common.h +++ b/LUFA/Common/Common.h @@ -232,6 +232,15 @@ * assembly output in an unexpected manner on sections of code that are ordering-specific. */ #define GCC_MEMORY_BARRIER() __asm__ __volatile__("" ::: "memory"); + + /** Evaluates to boolean true if the specified value can be determined at compile time to be a constant value + * when compiling under GCC. + * + * \param[in] x Value to check compile time constantness of. + * + * \return Boolean true if the given value is known to be a compile time constant. + */ + #define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x) #if !defined(ISR) || defined(__DOXYGEN__) /** Macro for the definition of interrupt service routines, so that the compiler can insert the required @@ -273,10 +282,11 @@ * * \param[in] Milliseconds Number of milliseconds to delay */ + static inline void Delay_MS(uint8_t Milliseconds) ATTR_ALWAYS_INLINE; static inline void Delay_MS(uint8_t Milliseconds) { #if (ARCH == ARCH_AVR8) - if (__builtin_constant_p(Milliseconds)) + if (GCC_IS_COMPILE_CONST(Milliseconds)) { _delay_ms(Milliseconds); } diff --git a/LUFA/Common/Endianness.h b/LUFA/Common/Endianness.h index f7bc33677bd372e00d2622d723585859450d8190..ef8c1a788426daaa3395c2b0ec0bc5e465708f2b 100644 --- a/LUFA/Common/Endianness.h +++ b/LUFA/Common/Endianness.h @@ -74,7 +74,7 @@ * * \ingroup Group_ByteSwapping * - * \param[in] x 16-bit value whose byte ordering is to be swapped. + * \param[in] x 16-bit value whose byte ordering is to be swapped. * * \return Input value with the byte ordering reversed. */ @@ -87,7 +87,7 @@ * * \ingroup Group_ByteSwapping * - * \param[in] x 32-bit value whose byte ordering is to be swapped. + * \param[in] x 32-bit value whose byte ordering is to be swapped. * * \return Input value with the byte ordering reversed. */ @@ -440,24 +440,24 @@ * * \ingroup Group_ByteSwapping * - * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed. - * \param[in] Bytes Length of the data in bytes. + * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed. + * \param[in] Length Length of the data in bytes. */ - static inline void SwapEndian_n(void* Data, - uint8_t Bytes) ATTR_NON_NULL_PTR_ARG(1); - static inline void SwapEndian_n(void* Data, - uint8_t Bytes) + static inline void SwapEndian_n(void* const Data, + uint8_t Length) ATTR_NON_NULL_PTR_ARG(1); + static inline void SwapEndian_n(void* const Data, + uint8_t Length) { uint8_t* CurrDataPos = (uint8_t*)Data; - while (Bytes > 1) + while (Length > 1) { uint8_t Temp = *CurrDataPos; - *CurrDataPos = *(CurrDataPos + Bytes - 1); - *(CurrDataPos + Bytes - 1) = Temp; + *CurrDataPos = *(CurrDataPos + Length - 1); + *(CurrDataPos + Length - 1) = Temp; CurrDataPos++; - Bytes -= 2; + Length -= 2; } } diff --git a/LUFA/Drivers/USB/Class/Common/HIDParser.c b/LUFA/Drivers/USB/Class/Common/HIDParser.c index f6c48fdad862a89cc04053ff950b3d899b63d4d2..20fceab6475a38d9a10a416391044aae305a7c11 100644 --- a/LUFA/Drivers/USB/Class/Common/HIDParser.c +++ b/LUFA/Drivers/USB/Class/Common/HIDParser.c @@ -61,12 +61,12 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData, switch (HIDReportItem & HID_RI_DATA_SIZE_MASK) { case HID_RI_DATA_BITS_32: - ReportItemData = *((uint32_t*)ReportData); + ReportItemData = le32_to_cpu(*((uint32_t*)ReportData)); ReportSize -= 4; ReportData += 4; break; case HID_RI_DATA_BITS_16: - ReportItemData = *((uint16_t*)ReportData); + ReportItemData = le16_to_cpu(*((uint16_t*)ReportData)); ReportSize -= 2; ReportData += 2; break; diff --git a/LUFA/Drivers/USB/Class/Device/Audio.c b/LUFA/Drivers/USB/Class/Device/Audio.c index 986e73f9c8e1bd8261b401a3af5a49e6d4151cc6..f18db7456043064a12e08a2d1b72e37d716a8895 100644 --- a/LUFA/Drivers/USB/Class/Device/Audio.c +++ b/LUFA/Drivers/USB/Class/Device/Audio.c @@ -88,9 +88,7 @@ bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioIn } if (!(Endpoint_ConfigureEndpoint(EndpointNum, Type, Direction, Size, ENDPOINT_BANK_DOUBLE))) - { - return false; - } + return false; } return true; diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index 47f58b27d4a5bf54d49fc3eb51a21dee879e676c..f88c2f1b2ae4e0d2c545293336df1bdce9781f6c 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -137,6 +137,7 @@ /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host) * the frame number is incremented by one. */ + static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline uint16_t USB_Device_GetFrameNumber(void) { return UDFNUM; @@ -191,7 +192,7 @@ UDADDR |= (1 << ADDEN); } - static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE; + static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline bool USB_Device_IsAddressSet(void) { return (UDADDR & (1 << ADDEN)); diff --git a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h index 166a49c7d42ee472bd2688816eaeb60c598a6776..1727da0d84adac5cb56add57b5f986ba7e6cb3c5 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h @@ -394,6 +394,7 @@ * * \return Total number of busy banks in the selected endpoint. */ + static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline uint8_t Endpoint_GetBusyBanks(void) { return (UESTA0X & (0x03 << NBUSYBK0)); diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h index 2bf13cd26c31775bb6262403d484cf5e83bc59b8..836c83b678c4d2b46c1338dc58fcec2097fc6e98 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h @@ -140,6 +140,7 @@ /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended) * the frame number is incremented by one. */ + static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t USB_Host_GetFrameNumber(void) { return UHFNUM; diff --git a/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h index a79033753b6d02a4d7a3d8dfc592e7d5fa55e2a2..fda145c1e82e2e19a3e9eb5523f378835fc5d3d6 100644 --- a/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h @@ -93,7 +93,7 @@ * * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise */ - static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_ALWAYS_INLINE; + static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool USB_OTG_Device_IsSendingHNP(void) { return ((OTGCON & (1 << HNPREQ)) ? true : false); diff --git a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h index 2e89f6de405567731e76b0dd63830a2e31e3998f..8022a812a580f72abc4b43ec0355b31d96feda59 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h @@ -273,7 +273,7 @@ * * \return The current pipe token, as a \c PIPE_TOKEN_* mask. */ - static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Pipe_GetPipeToken(void) { return (UPCFG0X & (0x03 << PTOKEN0)); @@ -433,6 +433,7 @@ * * \return Total number of busy banks in the selected pipe. */ + static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Pipe_GetBusyBanks(void) { return (UPSTAX & (0x03 << NBUSYBK0)); diff --git a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h index 2a029bf08023dc1c640f93055460f94b29b092ff..ed74098568b757ee3e449b5e51138ef63a921860 100644 --- a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h @@ -127,6 +127,7 @@ /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host) * the frame number is incremented by one. */ + static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline uint16_t USB_Device_GetFrameNumber(void) { return AVR32_USBB.UDFNUM.fnum; @@ -179,7 +180,7 @@ AVR32_USBB.UDCON.adden = true; } - static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE; + static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline bool USB_Device_IsAddressSet(void) { return AVR32_USBB.UDCON.adden; diff --git a/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h b/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h index 43e432b0450f2ed498acfd45303be1dbe9106127..4f31a0d86b624c9006cb49e757ed0c8c375145dd 100644 --- a/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h @@ -402,6 +402,7 @@ * * \return Total number of busy banks in the selected endpoint. */ + static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; static inline uint8_t Endpoint_GetBusyBanks(void) { return (&AVR32_USBB.UESTA0)[USB_SelectedEndpoint].nbusybk; diff --git a/LUFA/Drivers/USB/Core/UC3/Host_UC3.h b/LUFA/Drivers/USB/Core/UC3/Host_UC3.h index 4d08a4c9872b592f6ec9718e42e11a275a03044f..6040eb32b8978ea273992fc31a38442d8e4e54c2 100644 --- a/LUFA/Drivers/USB/Core/UC3/Host_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Host_UC3.h @@ -141,6 +141,7 @@ /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended) * the frame number is incremented by one. */ + static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint16_t USB_Host_GetFrameNumber(void) { return AVR32_USBB_UHFNUM; diff --git a/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h b/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h index 7edfb3e1bc6ac621769e689c54192b88a8192f26..bda3e8e2c84b775c7b12bf082c9739e6aeb9f0d6 100644 --- a/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h @@ -284,7 +284,7 @@ * * \return The current pipe token, as a \c PIPE_TOKEN_* mask. */ - static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE; + static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Pipe_GetPipeToken(void) { return (&AVR32_USBB.UPCFG0)[USB_SelectedPipe].ptoken; @@ -451,6 +451,7 @@ * * \return Total number of busy banks in the selected pipe. */ + static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Pipe_GetBusyBanks(void) { return (&AVR32_USBB.UPSTA0)[USB_SelectedPipe].nbusybk; diff --git a/LUFA/Drivers/USB/Core/USBTask.h b/LUFA/Drivers/USB/Core/USBTask.h index 267c7e08e4bf1fbfb617c4e5768942f3c652ff5f..30231bf16ce5e5279d52ea591421167710d959aa 100644 --- a/LUFA/Drivers/USB/Core/USBTask.h +++ b/LUFA/Drivers/USB/Core/USBTask.h @@ -191,7 +191,7 @@ /* Macros: */ #define HOST_TASK_NONBLOCK_WAIT(Duration, NextState) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \ WaitMSRemaining = (Duration); \ - PostWaitState = (NextState); }MACROE + PostWaitState = (NextState); }MACROE #endif /* Disable C linkage for C++ Compilers: */