/***************************************************************************** * 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 _EMBTYPES_H_ #define _EMBTYPES_H_ /***************************************************************************** * includes *****************************************************************************/ #ifdef __linux__ #include #endif /***************************************************************************** * defines *****************************************************************************/ #ifndef NULL #define NULL 0 #endif #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef ON #define ON 1 #define OFF 0 #endif #ifdef __linux__ /* take out those keywords */ #define interrupt #define near #define far #endif /***************************************************************************** * macros *****************************************************************************/ /***************************************************************************** * structs & typedefs *****************************************************************************/ // data types #ifdef __linux__ typedef unsigned char bit; #else typedef bit BOOL; #endif // ProbeStar Standard typedef signed char CHAR; typedef signed short SHORT; typedef signed int INT; typedef signed long LONG; typedef signed long long LLONG; typedef unsigned char BYTE; typedef unsigned short WORD; typedef unsigned int UINT; typedef unsigned long DWORD; typedef unsigned long long QWORD; typedef signed char int8; typedef signed short int16; typedef signed long int32; typedef signed long long int64; typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned long uint32; typedef unsigned long long uint64; typedef signed char S8; typedef signed short S16; typedef signed long S32; typedef signed long long S64; typedef unsigned char U8; typedef unsigned short U16; typedef unsigned long U32; typedef unsigned long long U64; #ifdef BIG_ENDIAN typedef union { WORD w; SHORT s; struct { BYTE h; BYTE l; } b; BYTE c[2]; } __attribute__((__packed__)) short_word; typedef union { DWORD dw; LONG l; struct { WORD h; WORD l; } w; short s[2]; struct { short_word h; short_word l; } sw; struct { BYTE hh; BYTE hl; BYTE lh; BYTE ll; } b; BYTE c[4]; } __attribute__((__packed__)) long_dword; typedef union { QWORD qw; LLONG ll; struct { DWORD h; DWORD l; } dw; long l[2]; struct { WORD hh; WORD hl; WORD lh; WORD ll; } w; short s[4]; struct { short_word hh; short_word hl; short_word lh; short_word ll; } sw; struct { BYTE hhh; BYTE hhl; BYTE hlh; BYTE hll; BYTE lhh; BYTE lhl; BYTE llh; BYTE lll; } b; BYTE c[8]; } __attribute__((__packed__)) llong_qword; #elif defined(LITTLE_ENDIAN) // new typedef union { WORD w; SHORT s; struct { BYTE l; BYTE h; } b; BYTE c[2]; } __attribute__((__packed__)) short_word; typedef union { DWORD dw; LONG l; struct { WORD l; WORD h; } w; short s[2]; struct { short_word l; short_word h; } sw; struct { BYTE ll; BYTE lh; BYTE hl; BYTE hh; } b; BYTE c[4]; } __attribute__((__packed__)) long dword; typedef union { QWORD qw; LLONG ll; struct { DWORD l; DWORD h; } dw; long l[2]; struct { WORD ll; WORD lh; WORD hl; WORD hh; } w; short s[4]; struct { short_word ll; short_word lh; short_word hl; short_word hh; } sw; struct { BYTE lll; BYTE llh; BYTE lhl; BYTE lhh; BYTE hll; BYTE hlh; BYTE hhl; BYTE hhh; } b; BYTE c[8]; } __attribute__((__packed__)) llong_qword; #endif typedef union { BYTE byte; struct { unsigned b0:1; unsigned b1:1; unsigned b2:1; unsigned b3:1; unsigned b4:1; unsigned b5:1; unsigned b6:1; unsigned b7:1; } bits; } byte_bits; /***************************************************************************** * global constants *****************************************************************************/ /***************************************************************************** * global variables *****************************************************************************/ /***************************************************************************** * C function prototypes *****************************************************************************/ #endif