etisserant@145: /* etisserant@145: This file is part of CanFestival, a library implementing CanOpen Stack. etisserant@145: etisserant@145: Copyright (C): Edouard TISSERANT and Francis DUPIN etisserant@145: etisserant@145: See COPYING file for copyrights details. etisserant@145: etisserant@145: This library is free software; you can redistribute it and/or etisserant@145: modify it under the terms of the GNU Lesser General Public etisserant@145: License as published by the Free Software Foundation; either etisserant@145: version 2.1 of the License, or (at your option) any later version. etisserant@145: etisserant@145: This library is distributed in the hope that it will be useful, etisserant@145: but WITHOUT ANY WARRANTY; without even the implied warranty of etisserant@145: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU etisserant@145: Lesser General Public License for more details. etisserant@145: etisserant@145: You should have received a copy of the GNU Lesser General Public etisserant@145: License along with this library; if not, write to the Free Software etisserant@145: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA etisserant@145: */ etisserant@145: etisserant@145: #ifndef __APPLICFG_WIN32__ etisserant@145: #define __APPLICFG_WIN32__ etisserant@145: etisserant@145: #include etisserant@145: #include etisserant@145: #include etisserant@145: etisserant@145: // Define the architecture : little_endian or big_endian etisserant@145: // ----------------------------------------------------- etisserant@145: // Test : etisserant@145: // UNS32 v = 0x1234ABCD; etisserant@145: // char *data = &v; etisserant@145: // etisserant@145: // Result for a little_endian architecture : etisserant@145: // data[0] = 0xCD; etisserant@145: // data[1] = 0xAB; etisserant@145: // data[2] = 0x34; etisserant@145: // data[3] = 0x12; etisserant@145: // etisserant@145: // Result for a big_endian architecture : etisserant@145: // data[0] = 0x12; etisserant@145: // data[1] = 0x34; etisserant@145: // data[2] = 0xAB; etisserant@145: // data[3] = 0xCD; etisserant@145: etisserant@145: // Integers etisserant@145: #define INTEGER8 char etisserant@145: #define INTEGER16 short etisserant@145: #define INTEGER24 long etisserant@145: #define INTEGER32 long etisserant@145: #define INTEGER40 long long etisserant@145: #define INTEGER48 long long etisserant@145: #define INTEGER56 long long etisserant@145: #define INTEGER64 long long etisserant@145: etisserant@145: // Unsigned integers etisserant@145: #define UNS8 unsigned char etisserant@145: #define UNS16 unsigned short etisserant@145: #define UNS32 unsigned long etisserant@145: #define UNS24 unsigned long etisserant@145: #define UNS40 unsigned long long etisserant@145: #define UNS48 unsigned long long etisserant@145: #define UNS56 unsigned long long etisserant@145: #define UNS64 unsigned long long etisserant@145: etisserant@145: // Reals etisserant@145: #define REAL32 float etisserant@145: #define REAL64 double etisserant@145: etisserant@145: // Custom integer types sizes etisserant@145: #define sizeof_INTEGER24 3 etisserant@145: #define sizeof_INTEGER40 5 etisserant@145: #define sizeof_INTEGER48 6 etisserant@145: #define sizeof_INTEGER56 7 etisserant@145: etisserant@145: #define sizeof_UNS24 3 etisserant@145: #define sizeof_UNS40 5 etisserant@145: #define sizeof_UNS48 6 etisserant@145: #define sizeof_UNS56 7 etisserant@145: etisserant@145: // Non integral integers conversion macros etisserant@145: #define INT24_2_32(a) (a <= 0x7FFFFF ? a : a|0xFF000000) etisserant@145: #define INT40_2_64(a) (a <= 0x0000007FFFFFFFFF ? a : a|0xFFFFFF0000000000) etisserant@145: #define INT48_2_64(a) (a <= 0x00007FFFFFFFFFFF ? a : a|0xFFFF000000000000) etisserant@145: #define INT56_2_64(a) (a <= 0x007FFFFFFFFFFFFF ? a : a|0xFF00000000000000) etisserant@145: etisserant@145: #define INT32_2_24(a) (a&0x00FFFFFF) etisserant@145: #define INT64_2_40(a) (a&0x000000FFFFFFFFFF) etisserant@145: #define INT64_2_48(a) (a&0x0000FFFFFFFFFFFF) etisserant@145: #define INT64_2_56(a) (a&0x00FFFFFFFFFFFFFF) etisserant@145: etisserant@145: /// Definition of error and warning macros etisserant@145: // -------------------------------------- etisserant@145: Christian@637: #ifndef _MSC_VER Edouard@662: #define MSG(...) \ Edouard@662: do{printf(__VA_ARGS__);fflush(stdout);}while(0) Christian@637: #elif (_MSC_VER >= 1400) Christian@637: //Visual Studio 2005 and above etisserant@145: #ifdef UNICODE etisserant@396: #define MSG(...) \ etisserant@396: do{wchar_t msg[300];\ etisserant@396: swprintf(msg,L##__VA_ARGS__);\ etisserant@396: OutputDebugString(msg);}while(0) etisserant@145: #else etisserant@396: #define MSG(...) \ hacking@684: do{char msg[300];\ etisserant@396: sprintf(msg,##__VA_ARGS__);\ etisserant@396: OutputDebugString(msg);}while(0) Christian@637: #endif Christian@637: #else //(_MSC_VER < 1400) Christian@637: //For Visual Studio 2003 and below, without VA_ARGS Christian@637: #ifdef UNICODE Christian@637: #define MSG(text) \ Christian@637: do{wchar_t msg[300];\ Christian@637: vswprintf(msg,L##text);\ Christian@637: OutputDebugString(msg);}while(0) Christian@637: #else Christian@637: #define MSG(text) \ Christian@637: do{printf text;fflush(stdout);}while(0) Christian@637: #endif Christian@637: Christian@637: #endif //_MSC_VER Christian@637: etisserant@396: #define CANFESTIVAL_DEBUG_MSG(num, str, val)\ etisserant@396: {unsigned long value = val;\ Christian@637: MSG(("%s(%d) : 0x%X %s 0x%lX\n",__FILE__, __LINE__,num, str, value)); \ etisserant@396: } etisserant@145: hacking@684: #define CANFESTIVAL_DEBUG_DRV_MSG(...)\ hacking@684: MSG(__VA_ARGS__); hacking@684: etisserant@145: /// Definition of MSG_WAR etisserant@145: // --------------------- etisserant@145: #ifdef DEBUG_WAR_CONSOLE_ON etisserant@145: #define MSG_WAR(num, str, val) CANFESTIVAL_DEBUG_MSG(num, str, val) etisserant@145: #else etisserant@145: # define MSG_WAR(num, str, val) etisserant@145: #endif etisserant@145: etisserant@145: /// Definition of MSG_ERR etisserant@145: // --------------------- etisserant@145: #ifdef DEBUG_ERR_CONSOLE_ON etisserant@145: # define MSG_ERR(num, str, val) CANFESTIVAL_DEBUG_MSG(num, str, val) etisserant@145: #else etisserant@145: # define MSG_ERR(num, str, val) etisserant@145: #endif etisserant@145: hacking@684: #ifdef DEBUG_ERR_DRIVER_CONSOLE_ON hacking@684: # define MSG_ERR_DRV(...) CANFESTIVAL_DEBUG_DRV_MSG(__VA_ARGS__) hacking@684: #else hacking@684: # define MSG_ERR_DRV(...) hacking@684: #endif etisserant@145: etisserant@145: etisserant@145: typedef void* CAN_HANDLE; etisserant@145: etisserant@145: typedef void* CAN_PORT; etisserant@145: etisserant@145: #endif // __APPLICFG_WIN32__