#ifndef __TYPE_H_ #define __TYPE_H_ #include #ifndef ULONG #define ULONG unsigned long #endif typedef unsigned char BOOL_T; typedef unsigned char U8_T; typedef signed char S8_T; typedef unsigned short U16_T; typedef signed short S16_T; typedef unsigned int U32_T; typedef signed int S32_T; typedef unsigned long long U64_T; typedef signed long long S64_T; typedef float F32_T; typedef double F64_T; typedef char * STR_T; #ifndef NULL #define NULL (void *)0 #endif typedef enum {ST_FALSE = 0, ST_TRUE = !ST_FALSE} ST_BOOL; typedef enum {CMD_OFF = 0, CMD_ON = !CMD_OFF} E_CMD; //位宏定义 #define BITSET(var,bit) ((var)|=(1UL<<(bit))) // 设置指定位为1 参数:var - 要操作的变量,bit - 位位置(0~31) #define BITCLR(var,bit) ((var)&= ~(1UL<<(bit))) // 清除指定位(设为0) 参数:var - 要操作的变量,bit - 位位置(0~31) #define BITREVER(var,bit) ((var)^= (1UL<<(bit))) // 反转指定位(1变0,0变1) 参数:var - 要操作的变量,bit - 位位置(0~31) #define ISBITSET(var,bit) (((var) & (1UL<<(bit)))==0?0:1) // 检查指定位是否被置1 返回值:非0表示置1,0表示未置1 #define ISBITCLR(var,bit) (((var) & (1UL<<(bit)))==0) // 检查指定位是否为0 返回值:1表示该位为0,0表示该位为1 // 检查是否所有掩码位都被置1 // 参数:msk - 位掩码(如0x03表示bit0和bit1) // 返回值:1表示所有掩码位都为1,0表示不全是1 #define ISMSKSET(var,msk) (((var) & (msk))==(msk)) // 检查是否所有掩码位都为0 // 返回值:1表示所有掩码位都为0,0表示不全是0 #define ISMSKCLR(var,msk) (((var) & (msk))==0) // 检查是否有任意掩码位被置1 // 返回值:非0表示至少1个掩码位为1,0表示全为0 #define ISANYSET(var,msk) ((var) & (msk)) // 检查指定位状态(与ISBITSET功能相同) // 返回值:非0表示置1,0表示未置1 #define CHECKBIT(var,bit) (var & (1UL << bit)) // 交换16位数据的高8位和低8位(字节序转换) // 示例:0x1234 -> 0x3412 #define SWAP(x) (((x & 0xFF00) >> 8) | \ ((x & 0x00FF) << 8)) // 操作宏定义 #define MAX(x,y) ((x>y)?x:y) #define MIN(x,y) ((x> 24)) #endif #ifndef GetHigh16Bits #define GetHigh16Bits(x) ((U8_T)((x & 0xFF0000) >> 16)) #endif #ifndef GetHigh8Bits #define GetHigh8Bits(x) ((U8_T)((x & 0xFF00) >> 8)) #endif #ifndef GetU16Data #define GetU16Data(x,y) (U16_T)((x << 8) + (y)) #endif #ifndef GetU32Data #define GetU32Data(x,y,a,b) (U32_T)((x << 24) + (y << 16) + (a << 8) + (b)) #endif #define WHOLE_PILE (0) #define GUN_A (0) #define GUN_B (1) #define NUM_0 (0) #define NUM_1 (1) #define NUM_2 (2) #define NUM_3 (3) #define NUM_4 (4) #define NUM_5 (5) #define NUM_6 (6) #define NUM_7 (7) #define NUM_8 (8) #define NUM_9 (9) #define NUM_10 (10) #define NUM_15 (15) #define NUM_20 (20) #define NUM_25 (25) #define NUM_30 (30) #define NUM_50 (50) #define NUM_60 (50) #define NUM_100 (100) #define NUM_120 (120) #define NUM_150 (150) #define NUM_200 (200) #define NUM_250 (250) #define NUM_300 (300) #define NUM_500 (500) #define NUM_1000 (1000) #define NUM_2000 (2000) #define NUM_3000 (3000) #define NUM_5000 (5000) #define NUM_10000 (1000*10) #define NUM_20000 (1000*20) #define NUM_30000 (1000*30) #define NUM_50000 (1000*50) #define NUM_60000 (1000*60) #define NUM_4 (4) #define NUM_8 (8) #define NUM_16 (16) #define NUM_24 (24) #define NUM_32 (32) #define NUM_64 (64) #define NUM_128 (128) #define NUM_256 (256) #define NUM_512 (512) #define NUM_1024 (1024) #define NUM_2048 (2048) typedef union { U16_T word; struct { U8_T ucLow; U8_T ucHi; }byte; }WordAlign; typedef struct __Comm_Time__ { U16_T iYear; //年 U8_T ucMonth; //月 U8_T ucDay; //日 U8_T ucHour; //时 U8_T ucMin; //分 U8_T ucSec; //秒 }Comm_Time; // 时区定义(0-25对应UTC-12到UTC+14) typedef enum { TIMEZONE_UTC_MINUS_12 = 0, // UTC-12 TIMEZONE_UTC_MINUS_11 = 1, // UTC-11 TIMEZONE_UTC_MINUS_10 = 2, // UTC-10 TIMEZONE_UTC_MINUS_9 = 3, // UTC-9 TIMEZONE_UTC_MINUS_8 = 4, // UTC-8 TIMEZONE_UTC_MINUS_7 = 5, // UTC-7 TIMEZONE_UTC_MINUS_6 = 6, // UTC-6 TIMEZONE_UTC_MINUS_5 = 7, // UTC-5 TIMEZONE_UTC_MINUS_4 = 8, // UTC-4 TIMEZONE_UTC_MINUS_3 = 9, // UTC-3 TIMEZONE_UTC_MINUS_2 = 10, // UTC-2 TIMEZONE_UTC_MINUS_1 = 11, // UTC-1 TIMEZONE_UTC = 12, // UTC 0 TIMEZONE_UTC_PLUS_1 = 13, // UTC+1 TIMEZONE_UTC_PLUS_2 = 14, // UTC+2 TIMEZONE_UTC_PLUS_3 = 15, // UTC+3 TIMEZONE_UTC_PLUS_4 = 16, // UTC+4 TIMEZONE_UTC_PLUS_5 = 17, // UTC+5 TIMEZONE_UTC_PLUS_6 = 18, // UTC+6 TIMEZONE_UTC_PLUS_7 = 19, // UTC+7 TIMEZONE_UTC_PLUS_8 = 20, // UTC+8(中国) TIMEZONE_UTC_PLUS_9 = 21, // UTC+9(日本) TIMEZONE_UTC_PLUS_10 = 22, // UTC+10 TIMEZONE_UTC_PLUS_11 = 23, // UTC+11 TIMEZONE_UTC_PLUS_12 = 24, // UTC+12 TIMEZONE_UTC_PLUS_13 = 25, // UTC+13 TIMEZONE_UTC_PLUS_14 = 26 // UTC+14 } TIMEZONE_ENUM; extern const char *success; extern const char *failure; #endif