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

📄 lib.h

📁 简易风盘控器程序 AVR GCC MEGA8
💻 H
字号:
/**************** (c) 2004 STMicroelectronics *********************************
PROJECT  :
COMPILER :

MODULE  :  lib.h
VERSION :  1.0.0

CREATION DATE :

AUTHOR :

DESCRIPTION :
******************************************************************************/
#ifndef LIB_H
#define LIB_H

/*--------------------------STANDARD TYPE DEFINITION-------------------------*/
typedef unsigned char u8;       /* unsigned 8 bit  */
typedef signed char   s8;       /* signed 8 bit    */
typedef unsigned int  u16;      /* unsigned 16 bit */
typedef signed int    s16;      /* signed 16 bit   */
typedef unsigned long u32;      /* unsigned 32 bit */
typedef signed long   s32;      /* signed 32 bit   */
typedef u8 BOOLEAN;             /* Boolean         */

#define U8_MAX      ((u8)255)
#define S8_MAX      ((s8)127)
#define S8_MIN      ((s8)-128)
#define U16_MAX     ((u16)65535)
#define S16_MAX     ((s16)32767)
#define S16_MIN     ((s16)-32768)
#define U32_MAX     ((u32)4294967295)
#define S32_MAX     ((s32)2147483647)
#define S32_MIN     ((s32)-2147483648)
#define FALSE       ((BOOLEAN)0x00)
#define TRUE        (!(FALSE))

typedef union {       /* unsigned 16 bit type for 8 & 16 */
    u16 w_form;       /* bit accesses: 16> var.w_form    */
    struct {          /* 8> var.b_form.high/low          */
      u8 high, low;
    } b_form;
} TwoBytes;

/*--------------------------STANDARD MACRO DEFINITION-------------------------*/
#define Dim(x) (sizeof(x) / sizeof(x[0]))   /*Nbr of elements in array x[]    */
#define ABS(x) ((x) >= 0) ? (x) : -(x)      /* Absolute value of expression   */
/*--------------------------------BIT ACCESSES--------------------------------*/
#define SetBit(VAR,Pb)       ( (VAR) |= (1<<(Pb)) )
#define ClrBit(VAR,Pb)       ( (VAR) &= ((1<<(Pb))^255) )
#define NotBit(VAR,Pb)       ( (VAR) ^= (1<<Pb) )
#define ValBit(VAR,Pb)       ( (VAR) & (1<<Pb) )

#define AffBit(VAR,Pb,Val)   ((Val)? (VAR |= (1<<(Pb))) : (VAR &= ((1<<(Pb))^255)))
#define MskBit(Dest,Msk,Src) ( Dest = (Msk & Src) | ((~Msk) & Dest) )

#ifndef WDR
#define WDR() 	asm("wdr")
#define SEI()	asm("sei")
#define CLI()	asm("cli")
#define NOP()	asm("nop")
#define _WDR() 	asm("wdr")
#define _SEI()	asm("sei")
#define _CLI()	asm("cli")
#define _NOP()	asm("nop")
#endif

#ifndef BIT
#define BIT(x)	(1 << (x))
#endif

#endif
/*** (c) 2001 STMicroelectronics ****************** END OF FILE ***************/

⌨️ 快捷键说明

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