nico@207: nico@207:
nico@207:00001 /* nico@207: 00002 This file is part of CanFestival, a library implementing CanOpen Stack. nico@207: 00003 nico@207: 00004 Copyright (C): Edouard TISSERANT and Francis DUPIN nico@207: 00005 nico@207: 00006 See COPYING file for copyrights details. nico@207: 00007 nico@207: 00008 This library is free software; you can redistribute it and/or nico@207: 00009 modify it under the terms of the GNU Lesser General Public nico@207: 00010 License as published by the Free Software Foundation; either nico@207: 00011 version 2.1 of the License, or (at your option) any later version. nico@207: 00012 nico@207: 00013 This library is distributed in the hope that it will be useful, nico@207: 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of nico@207: 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nico@207: 00016 Lesser General Public License for more details. nico@207: 00017 nico@207: 00018 You should have received a copy of the GNU Lesser General Public nico@207: 00019 License along with this library; if not, write to the Free Software nico@207: 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA nico@207: 00021 */ nico@207: 00022 nico@207: 00023 #ifndef __APPLICFG_WIN32__ nico@207: 00024 #define __APPLICFG_WIN32__ nico@207: 00025 nico@207: 00026 #include <windows.h> nico@207: 00027 #include <string.h> nico@207: 00028 #include <stdio.h> nico@207: 00029 nico@207: 00030 // Define the architecture : little_endian or big_endian nico@207: 00031 // ----------------------------------------------------- nico@207: 00032 // Test : nico@207: 00033 // UNS32 v = 0x1234ABCD; nico@207: 00034 // char *data = &v; nico@207: 00035 // nico@207: 00036 // Result for a little_endian architecture : nico@207: 00037 // data[0] = 0xCD; nico@207: 00038 // data[1] = 0xAB; nico@207: 00039 // data[2] = 0x34; nico@207: 00040 // data[3] = 0x12; nico@207: 00041 // nico@207: 00042 // Result for a big_endian architecture : nico@207: 00043 // data[0] = 0x12; nico@207: 00044 // data[1] = 0x34; nico@207: 00045 // data[2] = 0xAB; nico@207: 00046 // data[3] = 0xCD; nico@207: 00047 nico@207: 00048 // Integers nico@207: 00049 #define INTEGER8 char nico@207: 00050 #define INTEGER16 short nico@207: 00051 #define INTEGER24 long nico@207: 00052 #define INTEGER32 long nico@207: 00053 #define INTEGER40 long long nico@207: 00054 #define INTEGER48 long long nico@207: 00055 #define INTEGER56 long long nico@207: 00056 #define INTEGER64 long long nico@207: 00057 nico@207: 00058 // Unsigned integers nico@207: 00059 #define UNS8 unsigned char nico@207: 00060 #define UNS16 unsigned short nico@207: 00061 #define UNS32 unsigned long nico@207: 00062 #define UNS24 unsigned long nico@207: 00063 #define UNS40 unsigned long long nico@207: 00064 #define UNS48 unsigned long long nico@207: 00065 #define UNS56 unsigned long long nico@207: 00066 #define UNS64 unsigned long long nico@207: 00067 nico@207: 00068 // Reals nico@207: 00069 #define REAL32 float nico@207: 00070 #define REAL64 double nico@207: 00071 nico@207: 00072 // Custom integer types sizes nico@207: 00073 #define sizeof_INTEGER24 3 nico@207: 00074 #define sizeof_INTEGER40 5 nico@207: 00075 #define sizeof_INTEGER48 6 nico@207: 00076 #define sizeof_INTEGER56 7 nico@207: 00077 nico@207: 00078 #define sizeof_UNS24 3 nico@207: 00079 #define sizeof_UNS40 5 nico@207: 00080 #define sizeof_UNS48 6 nico@207: 00081 #define sizeof_UNS56 7 nico@207: 00082 nico@207: 00083 // Non integral integers conversion macros nico@207: 00084 #define INT24_2_32(a) (a <= 0x7FFFFF ? a : a|0xFF000000) nico@207: 00085 #define INT40_2_64(a) (a <= 0x0000007FFFFFFFFF ? a : a|0xFFFFFF0000000000) nico@207: 00086 #define INT48_2_64(a) (a <= 0x00007FFFFFFFFFFF ? a : a|0xFFFF000000000000) nico@207: 00087 #define INT56_2_64(a) (a <= 0x007FFFFFFFFFFFFF ? a : a|0xFF00000000000000) nico@207: 00088 nico@207: 00089 #define INT32_2_24(a) (a&0x00FFFFFF) nico@207: 00090 #define INT64_2_40(a) (a&0x000000FFFFFFFFFF) nico@207: 00091 #define INT64_2_48(a) (a&0x0000FFFFFFFFFFFF) nico@207: 00092 #define INT64_2_56(a) (a&0x00FFFFFFFFFFFFFF) nico@207: 00093 nico@207: 00095 // -------------------------------------- nico@207: 00096 nico@207: 00097 #ifdef UNICODE nico@207: 00098 #define CANFESTIVAL_DEBUG_MSG(num, str, val)\ nico@207: 00099 {wchar_t msg[300];\ nico@207: 00100 unsigned long value = val;\ nico@207: 00101 swprintf(msg,L"%s(%d) : 0x%X %s 0x%X\n",__FILE__, __LINE__,num, str, value);\ nico@207: 00102 OutputDebugString(msg);} nico@207: 00103 #else nico@207: 00104 #define CANFESTIVAL_DEBUG_MSG(num, str, val)\ nico@207: 00105 {char msg[300];\ nico@207: 00106 unsigned long value = val;\ nico@207: 00107 sprintf(msg,"%s(%d) : 0x%X %s 0x%X\n",__FILE__, __LINE__,num, str, value);\ nico@207: 00108 OutputDebugString(msg);} nico@207: 00109 #endif nico@207: 00110 nico@207: 00112 // --------------------- nico@207: 00113 #ifdef DEBUG_WAR_CONSOLE_ON nico@207: 00114 #define MSG_WAR(num, str, val) CANFESTIVAL_DEBUG_MSG(num, str, val) nico@207: 00115 #else nico@207: 00116 # define MSG_WAR(num, str, val) nico@207: 00117 #endif nico@207: 00118 nico@207: 00120 // --------------------- nico@207: 00121 #ifdef DEBUG_ERR_CONSOLE_ON nico@207: 00122 # define MSG_ERR(num, str, val) CANFESTIVAL_DEBUG_MSG(num, str, val) nico@207: 00123 #else nico@207: 00124 # define MSG_ERR(num, str, val) nico@207: 00125 #endif nico@207: 00126 nico@207: 00127 nico@207: 00128 nico@207: 00129 typedef void* CAN_HANDLE; nico@207: 00130 nico@207: 00131 typedef void* CAN_PORT; nico@207: 00132 nico@207: 00133 #endif // __APPLICFG_WIN32__ nico@207: