#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
*/\r
#define USB_CONFIG_ATTR_BUSPOWERED 0x80\r
\r
+ \r
/** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t\r
* descriptor's ConfigAttributes value to indicate that the specified configuration can draw its power\r
* from the device's own power source.\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