/*************************************CopyRight(c)************************************************ ** 江西吕布科技有限公司 ** www.lvbu.wang ************************************************************************************************** **Filename: **Version: **Author: **Date: **Description: ** ************************************************************************************************** **Version: **Modifier: **Datemodified: **Description: ** **************************************************************************************************/ #ifndef LVBU_COMMON_H #define LVBU_COMMON_H #ifdef __cplusplus extern "C" { #endif /********************************************************************* * Include */ /********************************************************************* * Macros */ /** The upper 8 bits of a 32 bit value */ //lint -emacro(572,MSB_32) // Suppress warning 572 "Excessive shift value" #define MSB_32(a) (((a) & 0xFF000000) >> 24) /** The lower 8 bits (of a 32 bit value) */ #define LSB_32(a) ((a) & 0x000000FF) /** The upper 8 bits of a 16 bit value */ //lint -emacro(572,MSB_16) // Suppress warning 572 "Excessive shift value" #define MSB_16(a) (((a) & 0xFF00) >> 8) /** The lower 8 bits (of a 16 bit value) */ #define LSB_16(a) ((a) & 0x00FF) /** Leaves the minimum of the two 32-bit arguments */ /*lint -emacro(506, MIN) */ /* Suppress "Constant value Boolean */ #define MIN(a, b) ((a) < (b) ? (a) : (b)) /** Leaves the maximum of the two 32-bit arguments */ /*lint -emacro(506, MAX) */ /* Suppress "Constant value Boolean */ #define MAX(a, b) ((a) < (b) ? (b) : (a)) #define STRINGIFY_(val) #val /** Converts a macro argument into a character constant. */ #define STRINGIFY(val) STRINGIFY_(val) /** Counts number of elements inside the array */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) /**@brief Set a bit in the uint32 word. * * @param[in] W Word whose bit is being set. * @param[in] B Bit number in the word to be set. */ #define SET_BIT(W, B) ((W) |= (uint32_t)(1U << (B))) /**@brief Clears a bit in the uint32 word. * * @param[in] W Word whose bit is to be cleared. * @param[in] B Bit number in the word to be cleared. */ #define CLR_BIT(W, B) ((W) &= (~(uint32_t)(1U << (B)))) /**@brief Checks if a bit is set. * * @param[in] W Word whose bit is to be checked. * @param[in] B Bit number in the word to be checked. * * @retval 1 if bit is set. * @retval 0 if bit is not set. */ #define IS_SET(W, B) (((W) >> (B)) & 1) /********************************************************************* * Constants */ /********************************************************************* * Typedefs */ /********************************************************************* * Global Variables */ /********************************************************************* * Global Functions */ /********************************************************************* * External Variables */ /********************************************************************* * External Functions */ /********************************************************************* * Local Vriables */ /********************************************************************* * Local Functions */ int stringLength (const char *string); unsigned char str_cmp(unsigned char *p1,unsigned char *p2,unsigned char len); #ifdef __cplusplus } #endif #endif /* LVBU_COMMON_H */