|
1 /* |
|
2 This file is part of CanFestival, a library implementing CanOpen Stack. |
|
3 |
|
4 Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
5 |
|
6 See COPYING file for copyrights details. |
|
7 |
|
8 This library is free software; you can redistribute it and/or |
|
9 modify it under the terms of the GNU Lesser General Public |
|
10 License as published by the Free Software Foundation; either |
|
11 version 2.1 of the License, or (at your option) any later version. |
|
12 |
|
13 This library is distributed in the hope that it will be useful, |
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 Lesser General Public License for more details. |
|
17 |
|
18 You should have received a copy of the GNU Lesser General Public |
|
19 License along with this library; if not, write to the Free Software |
|
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 */ |
|
22 |
|
23 #ifndef __APPLICFG_WIN32__ |
|
24 #define __APPLICFG_WIN32__ |
|
25 |
|
26 #include <windows.h> |
|
27 #include <string.h> |
|
28 #include <stdio.h> |
|
29 |
|
30 // Define the architecture : little_endian or big_endian |
|
31 // ----------------------------------------------------- |
|
32 // Test : |
|
33 // UNS32 v = 0x1234ABCD; |
|
34 // char *data = &v; |
|
35 // |
|
36 // Result for a little_endian architecture : |
|
37 // data[0] = 0xCD; |
|
38 // data[1] = 0xAB; |
|
39 // data[2] = 0x34; |
|
40 // data[3] = 0x12; |
|
41 // |
|
42 // Result for a big_endian architecture : |
|
43 // data[0] = 0x12; |
|
44 // data[1] = 0x34; |
|
45 // data[2] = 0xAB; |
|
46 // data[3] = 0xCD; |
|
47 |
|
48 // Integers |
|
49 #define INTEGER8 char |
|
50 #define INTEGER16 short |
|
51 #define INTEGER24 long |
|
52 #define INTEGER32 long |
|
53 #define INTEGER40 long long |
|
54 #define INTEGER48 long long |
|
55 #define INTEGER56 long long |
|
56 #define INTEGER64 long long |
|
57 |
|
58 // Unsigned integers |
|
59 #define UNS8 unsigned char |
|
60 #define UNS16 unsigned short |
|
61 #define UNS32 unsigned long |
|
62 #define UNS24 unsigned long |
|
63 #define UNS40 unsigned long long |
|
64 #define UNS48 unsigned long long |
|
65 #define UNS56 unsigned long long |
|
66 #define UNS64 unsigned long long |
|
67 |
|
68 // Reals |
|
69 #define REAL32 float |
|
70 #define REAL64 double |
|
71 |
|
72 // Custom integer types sizes |
|
73 #define sizeof_INTEGER24 3 |
|
74 #define sizeof_INTEGER40 5 |
|
75 #define sizeof_INTEGER48 6 |
|
76 #define sizeof_INTEGER56 7 |
|
77 |
|
78 #define sizeof_UNS24 3 |
|
79 #define sizeof_UNS40 5 |
|
80 #define sizeof_UNS48 6 |
|
81 #define sizeof_UNS56 7 |
|
82 |
|
83 // Non integral integers conversion macros |
|
84 #define INT24_2_32(a) (a <= 0x7FFFFF ? a : a|0xFF000000) |
|
85 #define INT40_2_64(a) (a <= 0x0000007FFFFFFFFF ? a : a|0xFFFFFF0000000000) |
|
86 #define INT48_2_64(a) (a <= 0x00007FFFFFFFFFFF ? a : a|0xFFFF000000000000) |
|
87 #define INT56_2_64(a) (a <= 0x007FFFFFFFFFFFFF ? a : a|0xFF00000000000000) |
|
88 |
|
89 #define INT32_2_24(a) (a&0x00FFFFFF) |
|
90 #define INT64_2_40(a) (a&0x000000FFFFFFFFFF) |
|
91 #define INT64_2_48(a) (a&0x0000FFFFFFFFFFFF) |
|
92 #define INT64_2_56(a) (a&0x00FFFFFFFFFFFFFF) |
|
93 |
|
94 /// Definition of error and warning macros |
|
95 // -------------------------------------- |
|
96 |
|
97 #ifdef UNICODE |
|
98 #define CANFESTIVAL_DEBUG_MSG(num, str, val)\ |
|
99 {wchar_t msg[300];\ |
|
100 unsigned long value = val;\ |
|
101 swprintf(msg,L"%s(%d) : 0x%X %s 0x%X\n",__FILE__, __LINE__,num, str, value);\ |
|
102 OutputDebugString(msg);} |
|
103 #else |
|
104 #define CANFESTIVAL_DEBUG_MSG(num, str, val)\ |
|
105 {char msg[300];\ |
|
106 unsigned long value = val;\ |
|
107 sprintf(msg,"%s(%d) : 0x%X %s 0x%X\n",__FILE__, __LINE__,num, str, value);\ |
|
108 OutputDebugString(msg);} |
|
109 #endif |
|
110 |
|
111 /// Definition of MSG_WAR |
|
112 // --------------------- |
|
113 #ifdef DEBUG_WAR_CONSOLE_ON |
|
114 #define MSG_WAR(num, str, val) CANFESTIVAL_DEBUG_MSG(num, str, val) |
|
115 #else |
|
116 # define MSG_WAR(num, str, val) |
|
117 #endif |
|
118 |
|
119 /// Definition of MSG_ERR |
|
120 // --------------------- |
|
121 #ifdef DEBUG_ERR_CONSOLE_ON |
|
122 # define MSG_ERR(num, str, val) CANFESTIVAL_DEBUG_MSG(num, str, val) |
|
123 #else |
|
124 # define MSG_ERR(num, str, val) |
|
125 #endif |
|
126 |
|
127 |
|
128 |
|
129 typedef void* CAN_HANDLE; |
|
130 |
|
131 typedef void* CAN_PORT; |
|
132 |
|
133 #endif // __APPLICFG_WIN32__ |