10.07.2015 Views

CF2 API Reference (PDF) - Persistor Instruments Inc

CF2 API Reference (PDF) - Persistor Instruments Inc

CF2 API Reference (PDF) - Persistor Instruments Inc

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>CF2</strong> <strong>API</strong> <strong>Reference</strong>Checksums and Cyclic Redundancy Check FunctionsSummary of functionsChecksum vs. CRC Checksums are simple and fast. CRCs provide better error detection but are slower16 bit vs. 32 bit Because the 68332 has a 32 bit CPU, there is virtually no performance penalty associatedwith using the full 32 bit routines.16 bit CRC catches 99.998% of all errors and is appropriate for data blocks up to 4KB.32 bit CRC catches 99.999999977% of all errors and is appropriate for blocks up to 64KB.CheckSum16CheckSum32Use these to compute "on-the-fly" checksums for short data streams (like UARTcharacters). Use checksums where speed and function pointer access are the paramountobjectives.CheckSum16BlockCheckSum32BlockUse these to compute checksums for small data blocks (like the flash). Use checksumswhere speed and function pointer access are the paramount objectives.CRC16CRC32CRC16BlockCRC32BlockUse this routine to compute "on-the-fly" CRCs for data streams of 4kB or less.Use this routine to compute "on-the-fly" CRCs for data streams of 64kB or less.Use this routine to compute CRCs for data blocks of 4kB or less.Use this routine to compute CRCs for data blocks of 64kB or less.CheckSum16 -- Update a running 16 bit checksumDescription:Prototype:Inputs:Returns:Notes:Computes and returns an updated unsigned short checksum derived from an unsigned bytevalue and an unsigned short running checksum. The running checksum is typically zero for thefirst call, and the latest returned value for subsequent calls. The algorithm uses simpleaddition primitives and has deterministic timing.ushort CheckSum16(uchar value, ushort runningSum);value is the next byte to checksumrunningSum is the running checksum from a previous call, usually initialized to zero for thefirst callthe updated checksum, either the final value, or the next value to pass as the running sumCalled automatically at BIOS startupCheckSum16Block -- Compute a 16 bit checksum for a block of dataDescription:Prototype:Inputs:Returns:Notes:Computes and returns an unsigned short checksum on a block of memory. Pass it a pointer tothe start of the block, the number of bytes to compute, and a starting checksum value(typically zero). The algorithm uses simple addition primitives and has deterministic timing.ushort CheckSum16Block(const void *data, ulong len, ushort runningSum);data points to the start of the data block to CRClen is the count in bytes to CRCrunningSum is the running checksum from a previous call, usually initialized to zero for thefirst callthe computed checksumCalled automatically at BIOS startup.PERSISTOR<strong>Instruments</strong> <strong>Inc</strong>.8 of 84<strong>CF2</strong> <strong>API</strong> <strong>Reference</strong>7/19/2005

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!