数据转换宏

#define LB(x) ((unsigned char)(x))
#define HB(x) ((unsigned char)(x>>8))
#define DEC2BCD(x)   ((((x/10)<<4)&0xf0) |((x%10)&0x0f) )
#define BCD2DEC(x)   ((((x>>4)&0x0f)*10)+(x&0x0f))
#define BCD2BIN(n)   (((((n) >> 4) & 0x0F) * 10) + ((n) & 0x0F))
#define LE2BE32(x)   ((((u32)x>>24)&0xff)|(((u32)x>>8)&0xff00)|(((u32)x<<8)&0xff0000)|(((u32)x<<24)&0xff000000))
#define GETHH(x)     (((u32)x>>24)&0xff)
#define GETHL(x)     (((u32)x>>16)&0xff)
#define GETLH(x)     (((u32)x>>8)&0xff)
#define GETLL(x)     (((u32)x>>0)&0xff)
#define WORD(lb, hb) (((lb) & 0xff) | (((unsigned short)(hb) << 8)& 0xff00 ))
#define DWORD(lw, hw) (((lw) & 0xffff) | ((unsigned long int)((hw) & 0xffff) << 16))


#define GetWord(lb,hb) (((((unsigned short)(hb))<<8)&0xff00) + ((lb)&0xff))
#define GetDWord(lb,mlb,mhb,hb) ((((unsigned int)(hb)<<24)&0xff000000) + (((unsigned int)(mhb)<<16)&0xff0000)+ (((unsigned int)(mlb)<<8)&0xff00)+ ((unsigned int)(lb)&0xff))
#define GetLWord(dw) ((dw) & 0xffff)
#define GetHWord(dw) (((dw) >> 16) & 0xffff)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值