⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 typedef.h

📁 采用四端法测试欧姆电阻
💻 H
字号:
#ifndef _TYPEDEF_H_
#define _TYPEDEF_H_


#ifndef NULL
#define NULL    ((void *) 0)
#endif

#ifndef EOF
#define EOF     (-1)
#endif


#ifndef TRUE
#define TRUE  1
#endif

#ifndef FALSE
#define FALSE 0
#endif





/*~
******************************************************************************
defines
******************************************************************************
~*/

#define BIT0 0x0001
#define BIT1 0x0002
#define BIT2 0x0004
#define BIT3 0x0008
#define BIT4 0x0010
#define BIT5 0x0020
#define BIT6 0x0040
#define BIT7 0x0080
#define BIT8 0x0100
#define BIT9 0x0200
#define BITA 0x0400
#define BITB 0x0800
#define BITC 0x1000
#define BITD 0x2000
#define BITE 0x4000
#define BITF 0x8000


/*~
******************************************************************************
typedef
******************************************************************************
~*/
typedef unsigned char  ubyte;    	/* 1 byte unsigned; prefix: ub */
typedef signed char    sbyte;    	/* 1 byte signed;   prefix: sb */
typedef unsigned int   uint;   		/* 2 byte unsigned; prefix: us */
typedef signed int     sint;   		/* 2 byte signed;   prefix: ss */
typedef unsigned long  ulong;    	/* 4 byte unsigned; prefix: ul */
typedef signed long    slong;    	/* 4 byte signed;   prefix: sl */


/*~
******************************************************************************
macros
******************************************************************************
~*/
/* ubyte as part of a longer type */
#define UB0(Data) (*((ubyte *)&(Data)))
#define UB1(Data) (*((ubyte *)&(Data) + 1))
#define UB2(Data) (*((ubyte *)&(Data) + 2))
#define UB3(Data) (*((ubyte *)&(Data) + 3))

/* ushort as part of a longer type */
#define US0(Data) (*((ushort *)&(Data)))
#define US1(Data) (*((ushort *)&(Data) + 1))



struct _BITS
{
	unsigned b0:1;
	unsigned b1:1;
	unsigned b2:1;
	unsigned b3:1;
	unsigned b4:1;
	unsigned b5:1;
	unsigned b6:1;
	unsigned b7:1;
};


union _UINT8							
{
	ubyte  byte;	
	struct _BITS bits;
};

struct _INT16
{
	ubyte  B0;
	ubyte  B1;
};

union _UINT16
{
	unsigned int word;
	struct _INT16 bytes;
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -