ADS124S08 Example C Code  1.0.0
Macros | Functions
crc.h File Reference

Header definition for CRC implementations. More...

#include <stdbool.h>
#include <stdint.h>
Include dependency graph for crc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CRC_LOOKUP
 
#define CRC8
 
#define CRCWORD   uint8_t
 
#define CRC_INITIAL_SEED   ((CRCWORD) 0x00)
 
#define CRC_POLYNOMIAL   ((CRCWORD) 0x07)
 

Functions

void initCRC (void)
 initCRC() Initializes CRC module and creates lookup table (if using lookup method) More...
 
uint8_t getCRC (const uint8_t dataBytes[], uint8_t numberBytes, uint8_t initialValue)
 getCRC() Performs CRC lookup or calculation More...
 

Detailed Description

Header definition for CRC implementations.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

#define CRC8
#define CRC_INITIAL_SEED   ((CRCWORD) 0x00)
#define CRC_LOOKUP
#define CRC_POLYNOMIAL   ((CRCWORD) 0x07)
#define CRCWORD   uint8_t

Function Documentation

uint8_t getCRC ( const uint8_t  dataBytes[],
uint8_t  numberBytes,
uint8_t  initialValue 
)

getCRC() Performs CRC lookup or calculation

Parameters
[in]dataBytespointer to the data array
[in]numberBytesnumber of bytes in array to process
[in]initialValueCRC initial seed value or partial result of previous CRC calculation
Returns
CRCWORD of the calculation
1 // To calculate the CRC of a 3-byte message call:
2 CRCWORD crc = getCRC(data, 3, CRC_INITIAL_SEED);
3 
4 // To test a 4-byte message with a CRC byte call:
5 bool error = (bool) getCRC(data, 4, CRC_INITIAL_SEED);

Here is the call graph for this function:

void initCRC ( void  )

initCRC() Initializes CRC module and creates lookup table (if using lookup method)

Returns
None

Here is the call graph for this function: