Add missing function attributes to the pipe/endpoint functions for all architectures.
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 12 Apr 2011 03:03:56 +0000 (03:03 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 12 Apr 2011 03:03:56 +0000 (03:03 +0000)
Perform endianness correction in the HID report parser for big-endian platforms.

14 files changed:
LUFA/Common/Common.h
LUFA/Common/Endianness.h
LUFA/Drivers/USB/Class/Common/HIDParser.c
LUFA/Drivers/USB/Class/Device/Audio.c
LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h
LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.h
LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h
LUFA/Drivers/USB/Core/AVR8/OTG_AVR8.h
LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h
LUFA/Drivers/USB/Core/UC3/Device_UC3.h
LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h
LUFA/Drivers/USB/Core/UC3/Host_UC3.h
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h
LUFA/Drivers/USB/Core/USBTask.h

index 9d64403..6a9356b 100644 (file)
                         *  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
                         *
                         *  \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);
                                }
index f7bc336..ef8c1a7 100644 (file)
@@ -74,7 +74,7 @@
                         *\r
                         *  \ingroup Group_ByteSwapping\r
                         *\r
-                        *  \param[in]  x  16-bit value whose byte ordering is to be swapped.\r
+                        *  \param[in] x  16-bit value whose byte ordering is to be swapped.\r
                         *\r
                         *  \return Input value with the byte ordering reversed.\r
                         */\r
@@ -87,7 +87,7 @@
                         *\r
                         *  \ingroup Group_ByteSwapping\r
                         *\r
-                        *  \param[in]  x  32-bit value whose byte ordering is to be swapped.\r
+                        *  \param[in] x  32-bit value whose byte ordering is to be swapped.\r
                         *\r
                         *  \return Input value with the byte ordering reversed.\r
                         */\r
                         *\r
                         *  \ingroup Group_ByteSwapping\r
                         *\r
-                        *  \param[in,out] Data   Pointer to a number containing an even number of bytes to be reversed.\r
-                        *  \param[in]     Bytes  Length of the data in bytes.\r
+                        *  \param[in,out] Data    Pointer to a number containing an even number of bytes to be reversed.\r
+                        *  \param[in]     Length  Length of the data in bytes.\r
                         */\r
-                       static inline void SwapEndian_n(void* Data,\r
-                                                       uint8_t Bytes) ATTR_NON_NULL_PTR_ARG(1);\r
-                       static inline void SwapEndian_n(void* Data,\r
-                                                       uint8_t Bytes)\r
+                       static inline void SwapEndian_n(void* const Data,\r
+                                                       uint8_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+                       static inline void SwapEndian_n(void* const Data,\r
+                                                       uint8_t Length)\r
                        {\r
                                uint8_t* CurrDataPos = (uint8_t*)Data;\r
 \r
-                               while (Bytes > 1)\r
+                               while (Length > 1)\r
                                {\r
                                        uint8_t Temp = *CurrDataPos;\r
-                                       *CurrDataPos = *(CurrDataPos + Bytes - 1);\r
-                                       *(CurrDataPos + Bytes - 1) = Temp;\r
+                                       *CurrDataPos = *(CurrDataPos + Length - 1);\r
+                                       *(CurrDataPos + Length - 1) = Temp;\r
 \r
                                        CurrDataPos++;\r
-                                       Bytes -= 2;\r
+                                       Length -= 2;\r
                                }\r
                        }\r
 \r
index f6c48fd..20fceab 100644 (file)
@@ -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;
index 986e73f..f18db74 100644 (file)
@@ -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;
index 47f58b2..f88c2f1 100644 (file)
                        /** 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;
                                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));
index 166a49c..1727da0 100644 (file)
                         *
                         *  \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));
index 2bf13cd..836c83b 100644 (file)
                        /** 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;
index a790337..fda145c 100644 (file)
@@ -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);
index 2e89f6d..8022a81 100644 (file)
                         *
                         *  \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));
                         *
                         *  \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));
index 2a029bf..ed74098 100644 (file)
                        /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)\r
                         *  the frame number is incremented by one.\r
                         */\r
+                       static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint16_t USB_Device_GetFrameNumber(void)\r
                        {\r
                                return AVR32_USBB.UDFNUM.fnum;\r
                                AVR32_USBB.UDCON.adden = true;\r
                        }\r
 \r
-                       static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE;\r
+                       static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
                        static inline bool USB_Device_IsAddressSet(void)\r
                        {\r
                                return AVR32_USBB.UDCON.adden;\r
index 43e432b..4f31a0d 100644 (file)
                         *\r
                         *  \return Total number of busy banks in the selected endpoint.\r
                         */\r
+                       static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
                        static inline uint8_t Endpoint_GetBusyBanks(void)\r
                        {\r
                                return (&AVR32_USBB.UESTA0)[USB_SelectedEndpoint].nbusybk;\r
index 4d08a4c..6040eb3 100644 (file)
                        /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)\r
                         *  the frame number is incremented by one.\r
                         */\r
+                       static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint16_t USB_Host_GetFrameNumber(void)\r
                        {\r
                                return AVR32_USBB_UHFNUM;\r
index 7edfb3e..bda3e8e 100644 (file)
                         *\r
                         *  \return The current pipe token, as a \c PIPE_TOKEN_* mask.\r
                         */\r
-                       static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE;\r
+                       static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_GetPipeToken(void)\r
                        {\r
                                return (&AVR32_USBB.UPCFG0)[USB_SelectedPipe].ptoken;\r
                         *\r
                         *  \return Total number of busy banks in the selected pipe.\r
                         */\r
+                       static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
                        static inline uint8_t Pipe_GetBusyBanks(void)\r
                        {\r
                                return (&AVR32_USBB.UPSTA0)[USB_SelectedPipe].nbusybk;\r
index 267c7e0..30231bf 100644 (file)
                /* 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: */