Aceinna IMU383 Series User Manual page 81

Hide thumbs Also See for IMU383 Series:
Table of Contents

Advertisement

IMU383ZA Series User's Manual
________________________________________________________________________
}
/* fill out result of parsing in structure */
result->packet_type = peekWord(queue_ptr, 2);
result->length
= peekByte(queue_ptr, 4);
result->crc
= packetCRC;
for(counter=0; counter < result->length; counter++)
{
result->data[counter] = peekByte(queue_ptr, 5+counter);
}
Pop(queue_ptr, dataLength+7);
return 1;
}
/*******************************************************************************
* FUNCTION: calcCRC calculates a 2-byte CRC on serial data using
*
CRC-CCITT 16-bit standard maintained by the ITU
*
(International Telecommunications Union).
* ARGUMENTS: queue_ptr is pointer to queue holding area to be CRCed
*
startIndex is offset into buffer where to begin CRC calculation
*
num is offset into buffer where to stop CRC calculation
* RETURNS:
2-byte CRC
*******************************************************************************/
unsigned short calcCRC(QUEUE_TYPE *queue_ptr, unsigned int startIndex, unsigned int num)
{
unsigned int i=0, j=0;
unsigned short crc=0x1D0F; //non-augmented initial value equivalent to augmented
initial value 0xFFFF
for (i=0; i<num; i+=1) {
crc ^= peekByte(queue_ptr, startIndex+i) << 8;
for(j=0;j<8;j+=1) {
if(crc & 0x8000) crc = (crc << 1) ^ 0x1021;
else crc = crc << 1;
}
}
return crc;
}
/*******************************************************************************
Doc# 7430-1398-01
Downloaded From
Oneyac.com
Page 73

Advertisement

Table of Contents
loading

Related Products for Aceinna IMU383 Series

This manual is also suitable for:

Imu383za seriesImu383za-400

Table of Contents