Speed up bit-banged USART code in the AVRISP project.
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / StdDescriptors.h
index 2862944..9b46c09 100644 (file)
                        #endif\r
                        \r
                        /** Macro to calculate the power value for the device descriptor, from a given number of milliamps. */\r
-                       #define USB_CONFIG_POWER_MA(mA)           (mA >> 1)\r
+                       #define USB_CONFIG_POWER_MA(mA)           ((mA) >> 1)\r
 \r
                        /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.\r
                         *  Should be used in string descriptor's headers for giving the string descriptor's byte length.\r
                         */\r
-                       #define USB_STRING_LEN(str)               (sizeof(USB_Descriptor_Header_t) + (str << 1))\r
+                       #define USB_STRING_LEN(str)               (sizeof(USB_Descriptor_Header_t) + ((str) << 1))\r
                        \r
                        /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded\r
                         *  Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the\r
        /* Private Interface - For use in library only: */\r
        #if !defined(__DOXYGEN__)\r
                /* Macros: */\r
-                       #define VERSION_TENS(x)                   (int)(x / 10)\r
-                       #define VERSION_ONES(x)                   (int)(x - (10 * VERSION_TENS(x)))\r
-                       #define VERSION_TENTHS(x)                 (int)((x - (int)x) * 10)\r
-                       #define VERSION_HUNDREDTHS(x)             (int)(((x - (int)x) * 100) - (10 * VERSION_TENTHS(x)))\r
+                       #define VERSION_TENS(x)                   (int)((x) / 10)\r
+                       #define VERSION_ONES(x)                   (int)((x) - (10 * VERSION_TENS(x)))\r
+                       #define VERSION_TENTHS(x)                 (int)(((x) - (int)(x)) * 10)\r
+                       #define VERSION_HUNDREDTHS(x)             (int)((((x) - (int)(x)) * 100) - (10 * VERSION_TENTHS(x)))\r
        #endif\r
        \r
        /* Disable C linkage for C++ Compilers: */\r