/***************************************************************************** * Copyright (C) 2008 * ProbeStar Telematics, LLC * All Rights Reserved. Proprietary and Confidential. *============================================================================ * Multiplatform Embedded Data Types and Conversion * Checksum and CRC Routines *****************************************************************************/ /* prevent multiple inclusions */ #ifndef _EMBLIB_H_ #define _EMBLIB_H_ /***************************************************************************** * includes *****************************************************************************/ #include "embtypes.h" /***************************************************************************** * defines *****************************************************************************/ /***************************************************************************** * macros *****************************************************************************/ /* useful one to have */ #define bin2bcd(d) (((((d)/10)<<4|(d)%10))) #define bcd2bin(b) ((((b)>>4)*10)+((b)&0xf)) /***************************************************************************** * structs & typedefs *****************************************************************************/ /***************************************************************************** * global constants *****************************************************************************/ /***************************************************************************** * global variables *****************************************************************************/ /***************************************************************************** * C function prototypes *****************************************************************************/ /* export C functions to C++ */ #ifdef __cplusplus extern "C" { #endif int chomp(char *s); void base64(const unsigned char *in, char *out, int len); int unbase64(const char *in, unsigned char *out, int max); extern BYTE doCheckSum( const BYTE *pbyData, BYTE nBytes ); extern WORD doCheckSumW( const WORD *pwData, WORD nBytes ); extern BYTE doCRC8( BYTE byCrc, BYTE byData ); extern BYTE strCRC8( BYTE *pbyData, WORD nBytes, BYTE byInit ); extern WORD doCRC16( WORD wCrc, BYTE byData ); extern WORD strCRC16( BYTE *pbyData, WORD nBytes, WORD wInit ); short InterpolateShortTable( const short *psTbl, BYTE nPairs, short sData ); long InterpolateLongTable( const long *plTbl, BYTE nPairs, long lData ); BYTE reverseByteBits(BYTE b); #ifdef __cplusplus } #endif #endif