//数据转换函数
//WORD to BYTE
void CICONV::SetWordToByte(WORD wCardData, BYTE & cbCardData)
{
BYTE cbColor = wCardData >> 8;
if (cbColor == 4)
{
cbCardData = 0x40|((wCardData & 0x000f) + 0x0d);//注意优先级问题
}
else
{
cbCardData = (cbColor<<4)|(wCardData&0x000f);
}
}
void CICONV::SetWordToByte(WORD wCardData_[], BYTE cbCardData_[], BYTE cbCount)
{
for(int i=0; i<cbCount; i++)
{
SetWordToByte(wCardData_[i], cbCardData_[i]);
}
}
//BYTE to WORD
void CICONV::SetByteToWord(BYTE cbCardData, WORD & wCardData)
{
BYTE cbColor = cbCardData >> 4;
if (cbColor == 4)
{
wCardData = 0x0400 | ((cbCardData & 0x0F) - 0x0D);
}
else
{
wCardData = (cbColor<<8) | (cbCardData&0x0f);
}
}
void CICONV::SetByteToWord(BYTE cbCardData_[], WORD wCardData_[], BYTE cbCount)
{
for(int i=0; i<cbCount; i++)
{
SetByteToWord(cbCardData_[i], wCardData_[i]);
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
时间: 2024-10-11 20:00:38