yy1717
2021-02-07 cea2a94fc97e79897cdfd217be8250c075974a1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef _DEFS_H_
#define _DEFS_H_
 
#include <cstdint>
#include <cstdbool>
 
#define ENABLE_DEBUG
 
#ifdef ENABLE_DEBUG
 
#define xENABLE_DEBUG_MAIN
#define ENABLE_DEBUG_BT
#define xENABLE_DEBUG_EX_OBD
#define xENABLE_DEBUG_CV520
 
#endif/*ENABLE_DEBUG*/
 
/* takes a byte out of a uint32_t : var - uint32_t,  ByteNum - byte to take out (0 - 3) */
#define BREAK_UINT32( var, ByteNum ) \
          (uint8_t)((uint32_t)(((var) >>((ByteNum) * 8)) & 0x00FF))
 
#define BUILD_UINT32(Byte0, Byte1, Byte2, Byte3) \
          ((uint32_t)((uint32_t)((Byte0) & 0x00FF) \
          + ((uint32_t)((Byte1) & 0x00FF) << 8) \
          + ((uint32_t)((Byte2) & 0x00FF) << 16) \
          + ((uint32_t)((Byte3) & 0x00FF) << 24)))
 
#define BUILD_UINT16(loByte, hiByte) \
          ((uint16_t)(((loByte) & 0x00FF) + (((hiByte) & 0x00FF) << 8)))
 
#define HI_UINT16(a) (((a) >> 8) & 0xFF)
#define LO_UINT16(a) ((a) & 0xFF)
 
#ifndef BV
#define BV(n)      (1ul << (n))
#endif
 
#ifndef ABS
#define ABS(n)     (((n) < 0) ? -(n) : (n))
#endif
 
#ifndef MAX
#define MAX(a, b)   ((a >= b) ? (a) : (b))
#endif
 
#ifndef MIN
#define MIN(a, b)   ((a < b) ? (a) : (b))
#endif
 
const double GLB_EPSILON = 1e-6;
 
//#define htonl(a)    ((((uint32_t)(a) & 0xff000000) >> 24) | \
//                    (((uint32_t)(a) & 0x00ff0000) >> 8) | \
//                    (((uint32_t)(a) & 0x0000ff00) << 8) | \
//                    (((uint32_t)(a) & 0x000000ff) << 24))
//#define htons(a)    ((((uint16_t)(a) & 0xff00) >> 8) | (((uint16_t)(a) & 0x00ff) << 8))
//#define ntohl(a)    htonl(a)
//#define ntohs(a)    htons(a)
 
 
#endif