📄 type.h
字号:
//-----------------------------------------------------------------------------
// File: type.h
// Contents: FUSB constants, macros, datatypes,
// function prototypes.
//
// $Archive: /FUSB/.. $
// $Date: 10/15/08 $
// $Revision: 1.0 $
//
//
#ifndef _TYPE_H
#define _TYPE_H
#define _M8051EW
typedef unsigned char u8;
#ifdef _M8051EW
typedef unsigned int u16;
/*-----------------------------------------------------------------------------
Macros
-----------------------------------------------------------------------------*/
#define BYTE_TO_WORD(high, low) (((u16)(high) << 8) + (low))
#define BYTE_TO_DWORD(high3, high2, high1, high0)\
(((high3) << 24) + ((high2) << 16) + ((high1) << 8) + (high0))
#else // _ARM
typedef unsigned short u16;
typedef unsigned int u32;
#define BYTE_TO_DWORD(high3, high2, high1, high0)\
(((high3) << 24) + ((high2) << 16) + ((high1) << 8) + (high0))
#define BYTE_TO_WORD(high, low) (((high) << 8) + (low))
#endif //#ifdef _M8051EW
#define GET_HIGH(word) (((word) & 0xff00)>>8)
#define GET_LOW(word) ((word) & 0x00ff)
// get 1 bit from the byte beginnig the n-th bit, n: 7 6 5 4 3 2 1 0
#define BIT1(byte, n) (( (byte) >> n ) & 0x01)
// get 2 bits from the byte beginnig the n-th bit, n: 7 6 5 4 3 2 1
#define BIT2(byte, n) (( (byte) >> (n - 1) ) & 0x03)
// get 3 bits from the byte beginnig the n-th bit, n: 7 6 5 4 3 2
#define BIT3(byte, n) (( (byte) >> (n - 2) ) & 0x07)
// get 4 bits from the byte beginnig the n-th bit, n: 7 6 5 4 3
#define BIT4(byte, n) (( (byte) >> (n - 3) ) & 0x0f)
// get 5 bits from the byte beginnig the n-th bit, n: 7 6 5 4
#define BIT5(byte, n) (( (byte) >> (n - 4) ) & 0x1f)
// get 6 bits from the byte beginnig the n-th bit, n: 7 6 5
#define BIT6(byte, n) (( (byte) >> (n - 5) ) & 0x3f)
// get 7 bits from the byte beginnig the n-th bit, n: 7 6
#define BIT7(byte, n) (( (byte) >> (n - 6) ) & 0x7f)
// put 1 bit to the byte beginning the n-th, n : 7, 6, 5, 4, 3, 2, 1, 0.
#define BYTE1(bit1, n) ((bit1 & 0x01) << n)
// put 2 bit to the byte beginning the n-th, n : 7, 6, 5, 4, 3, 2, 1.
#define BYTE2(bit2, n) ((bit2 & 0x03) << (n - 1))
// put 3 bit to the byte beginning the n-th, n : 7, 6, 5, 4, 3, 2.
#define BYTE3(bit3, n) ((bit3 & 0x07) << (n - 2))
// put 4 bit to the byte beginning the n-th, n : 7, 6, 5, 4, 3.
#define BYTE4(bit4, n) ((bit4 & 0x0f) << (n - 3))
// put 5 bit to the byte beginning the n-th, n : 7, 6, 5, 4.
#define BYTE5(bit5, n) ((bit5 & 0x1f) << (n - 4))
// put 6 bit to the byte beginning the n-th, n : 7, 6, 5.
#define BYTE6(bit6, n) ((bit6 & 0x3f) << (n - 5))
// put 7 bit the byte beginning the n-th, n : 7, 6.
#define BYTE7(bit7, n) ((bit7 & 0x7f) << (n - 6))
// postion == 3, 2, 1, 0
#define GET_BYTE(dword, position) ((dword >> ((position) * 8)) & 0xff)
//#define BYTE_TO_WORD(high, low) (((high) << 8) + (low))
#endif // end #ifndef _TYPE_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -