?? types.h
字號:
/*--------------------------------------------------------------------
TYPES.H
--------------------------------------------------------------------
Copyright (C) 1998-2000 Vector Informatik GmbH, Stuttgart
Function: Main header for CANopen slave
--------------------------------------------------------------------*/
#ifndef _TYPES_H_
#define _TYPES_H_
/*--------------------------------------------------------------------*/
/* basic definitions (do not change) */
/*--------------------------------------------------------------------*/
#ifndef TRUE
# define TRUE 1 /*!< It's true in boolean operations. */
#endif
#ifndef FALSE
# define FALSE 0 /*!< It's false in boolean operations. */
#endif
#define ON 1 /*!< Use it to set flags. */
#define OFF 0 /*!< Use it to reset flags. */
#define OK 1 /*!< Return value for success in binary functions. */
#define FAULT 0 /*!< Return value for failure in binary functions. */
#define NO_ERR 0 /*!< Return value for success. */
#define BUSY_ERR 1 /*!< Return value if resource temporary not available. */
#define WAIT_ERR 2 /*!< Return value for service delayed. */
#define RANGE_ERR 3 /*!< Return value for out or range. */
#define VALUE_TOO_HIGH_ERR 100 /*!< Return value for parameter to high. */
#define ID_BUSY 200 /*!< Return value for allready used identifier. */
#define _BIG_ENDIAN 1
#define _LITTLE_ENDIAN (!_BIG_ENDIAN) /*!< little endian is set automatically */
/*--------------------------------------------------------------------*/
/* macros */
/*--------------------------------------------------------------------*/
/*! return maximum of A and B */
#define MAX(A, B) ((A) > (B) ? (A) : (B))
/*! return first data byte of a message */
#define MESSAGE_DB0(index) (tCanMsgBuffer[(index)].tMsg.bDb[0])
/*! return pointer to a massage */
#define MESSAGE_PTR(index) (&tCanMsgBuffer[(index)].tMsg)
/*! return a data byte of a message */
#define MESSAGE_DB(index, i) (tCanMsgBuffer[(index)].tMsg.bDb[(i)])
/*! substitute memory copy */
#define MemCpy(a, b, c) memcpy(a, b, c)
/*--------------------------------------------------------------------*/
/* type definitions */
/*--------------------------------------------------------------------*/
typedef unsigned char BOOLEAN; /*!< 1 bit basic type */
typedef unsigned char BYTE; /*!< 8 bits basic type */
typedef unsigned short WORD; /*!< 16 bits basic type */
typedef unsigned long DWORD; /*!< 32 bits basic type */
typedef unsigned char UBYTE;
typedef unsigned int UWORD;
typedef unsigned long ULONG;
typedef signed char SBYTE;
//typedef signed int SWORD; //重復定義 SWORD
typedef signed long SLONG;
typedef union
{
UWORD wData;
struct
{
UBYTE bLsb;
UBYTE bMsb;
}Bytes;
}CWORD;//Converted word structure
typedef union
{
ULONG lData;
struct
{
UBYTE b0; /*!< low word / least significant byte */
UBYTE b1; /*!< low word / most significant byte */
UBYTE b2; /*!< high word / least significant byte */
UBYTE b3; /*!< high word / most significant byte */
}Bytes;
}CLONG;//Converted long word structure
/*! 64 bits basic type */
typedef struct {
unsigned long hw; /*!< most significant double */
unsigned long lw; /*!< least significant double */
}
QWORD;
/*!
two bytes structure
*/
typedef struct {
#if _BIG_ENDIAN == 0
BYTE lb; /*!< least significant byte */
BYTE mb; /*!< most significant byte */
#else
BYTE mb; /*!< most significant byte */
BYTE lb; /*!< least significant byte */
#endif /* _BIG_ENDIAN */
}
DBYTE;
/*!
two byte structure for machine independent word conversion
*/
typedef union {
WORD wc; /*!< word */
DBYTE bc; /*!< two single bytes */
}
WBYTE;
/*!
four bytes structure
*/
typedef struct {
#if _BIG_ENDIAN == 0
BYTE b0; /*!< low word / least significant byte */
BYTE b1; /*!< low word / most significant byte */
BYTE b2; /*!< high word / least significant byte */
BYTE b3; /*!< high word / most significant byte */
#else
BYTE b3; /*!< high word / most significant byte */
BYTE b2; /*!< high word / least significant byte */
BYTE b1; /*!< low word / most significant byte */
BYTE b0; /*!< low word / least significant byte */
#endif /* _BIG_ENDIAN == 1 */
}
FOURBYTE;
/*!
four byte structure for machine independent long conversion
*/
typedef union {
DWORD dw; /*!< long value */
FOURBYTE fb; /*!< splitted long value */
}
QBYTE;
/*--------------------------------------------------------------------*/
/* documentation */
/*--------------------------------------------------------------------*/
/*!
\file
\brief THis header includes all relevant typdefs an defines for global use
*/
#endif /*_TYPES_H*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -