数据格式转换

extern "C" {
#if 0
static u8 hextobcd(u8 val)
{
val=val%100;
return (val/10*16+val%10);
}
static u8 bcdtohex(u8 val)
{
return val/16*10+val%16;
}
#endif
static u16 bcdtohex16(u16 val)
{
u8 vh,vl;
vh=val>>8;
vl=val&0xff;
return((u16)bcdtohex(vh)*100+bcdtohex(vl));
}
static u16 hextobcd16(u16 val)
{
u8 vh,vl;
if(val>10000)
val=val%10000;
vh=val/100;
vl=val%100;
return ((u16)hextobcd(vh)*256+hextobcd(vl));
}