beautypg.com

PNI TCM 5 User Manual

Page 46

background image

PNI Sensor Corporation

Doc #1007537 r12

TCM3 & TCM5 User Manual- Sept 2011

Page 46

kBaudRate,

// 14 – UInt8

// Mounting Reference IDs

kMountedStandard = 1, // 1

kMountedXUp,

// 2

kMountedYUp,

// 3

kMountedStdPlus90, // 4

kMountedStdPlus180, // 5

kMountedStdPlus270, // 6

// Result IDs

kErrNone = 0,

// 0

kErrSave,

// 1

};

// function to calculate CRC-16

UInt16 CRC(void * data, UInt32 len)

{

UInt8 * dataPtr = (UInt8 *)data;

UInt32 index = 0;

// Update the CRC for transmitted and received data using

// the CCITT 16bit algorithm (X^16 + X^12 + X^5 + 1).

UInt16 crc = 0;

while(len--)

{

crc = (unsigned char)(crc >> 8) | (crc << 8);

crc ^= dataPtr[index++];

crc ^= (unsigned char)(crc & 0xff) >> 4;

crc ^= (crc << 8) << 4;

crc ^= ((crc & 0xff) << 4) << 1;

}

return crc;

}

This manual is related to the following products: