// #define UniqID ((UniqID_t*)(0x1FFFF7AC)) typedef union { struct { union { unsigned long XY_BCD;//X and Y coordinates on the wafer expressed in BCD format struct { unsigned short X_BCD; unsigned short Y_BCD; }; }; unsigned char WAF_NUM;//Wafer number (8-bit unsigned number) unsigned char LOT_NUMS[7];//Lot number (ASCII encoded) }; unsigned char mas8[12]; unsigned short mas16[6]; unsigned long mas32[3]; }UniqID_t;
unsigned long long PakUniqID(UniqID_t* ID) { unsigned long long Num; //X_BCD диапазон значений от 0 до 99 Num =((ID->X_BCD)&0x0F); Num+=(((ID->X_BCD)>>4)&0x0F)*10UL; //Y_BCD диапазон значений от 0 до 99 Num+=((ID->Y_BCD)&0x0F)*100ULL; Num+=(((ID->Y_BCD)>>4)&0x0F)*1000UL; //WAF_NUM диапазон значений от 0 до 255 Num+=(ID->WAF_NUM)*10000UL; //LOT_NUMS[] диапазон значений от ' ' до 'Z' unsigned long long num0=1ULL; for(int i=0;i<7;i++) { Num+=(ID->LOT_NUMS[i]-' ')*256ULL*10000ULL*num0; num0=num0*(('Z'+1)-' '); } return Num; }
void UnPakUniqID(UniqID_t* ID, unsigned long long Num)
{
unsigned long long num0=((unsigned long long)(('Z'+1)-' '))*
((unsigned long long)(('Z'+1)-' '))*
((unsigned long long)(('Z'+1)-' '))*
((unsigned long long)(('Z'+1)-' '))*
((unsigned long long)(('Z'+1)-' '))*
((unsigned long long)(('Z'+1)-' '));
for(int i=6;i>=0;i--)
{
ID->LOT_NUMS[i]=' '+Num/(256ULL*10000ULL*num0);
Num=Num%(256ULL*10000ULL*num0);
num0=num0/(('Z'+1)-' ');
}
ID->WAF_NUM=Num/(10000ULL);
Num=Num%(10000ULL);
ID->Y_BCD=((Num/1000ULL)<<4);
Num=Num%(1000ULL);
ID->Y_BCD+=(Num/100ULL);
Num=Num%(100ULL);
ID->X_BCD=((Num/10)<<4);
Num=Num%(10ULL);
ID->X_BCD+=Num;
}
//