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

📄 typedef.h

📁 这是一个C51写的程序,采用Keil C51 编译开发.本程序生成了一个日历程序,用于不带时钟芯片的单片机系统.
💻 H
字号:
#ifndef  _TYPE_H
#define  _TYPE_H

#define _KEIL_51  
#ifdef  _KEIL_51 
        typedef union 
         {
           unsigned int word;
           struct{
                   unsigned char high;
                   unsigned char low;        /*in Keil_c51 one int value is High::low                          */
                 }bytes;
         } BYTE_WORD ;  
           
#else   
       typedef union 
         {
           unsigned int word;
           struct{
                   unsigned char low;
                   unsigned char high;       /*but some oher complier is low::high */
                 }bytes;					 /*.eg. tasking XA */
         } BYTE_WORD ;  

#endif 

typedef union 
         {
           unsigned long  LONG;
           unsigned int   word_h;		    //高16位
 		   unsigned int   word_l;		    //低16位
           struct{
                   unsigned char byte_4;
                   unsigned char byte_3;       
                   unsigned char byte_2;
                   unsigned char byte_1;   
                 }bytes;
         }LONG_BYTE;   

#define UCHAR  unsigned char 
#define UINT   unsigned int
#define ULONG  unsigned long
#define BOOL   unsigned char

#define uchar  unsigned char 
#define uint   unsigned int
#define ulong  unsigned long
#define bool   unsigned char

#define true    1
#define false   0    

#define TRUE    1
#define FALSE   0    

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

#define   Clear_bit(Value,bit_num)    { (Value) =(Value)& ( ~ ( 1 << (bit_num) ) ); }
#define   Set_bit(Value,bit_num)      { (Value) =(Value)| ( 1 << (bit_num) ); } 
#define   Cpl_bit(Value,bit_num)      { (Value) =(Value)^ ( 1 << (bit_num) ); }  
#define   Bit_is_one(Value,bit_num)   ( (Value) & (1<< (bit_num) ) )
#define   Bit_is_zero(Value,bit_num)  ( !( (Value) & ( 1<< (bit_num) ) ) )
                                      
#define   Max(x,y)                    ( (x)>(y) ? (x) : (y) ) 
#define   Min(x,y)                    ( (x)<(y) ? (x) : (y) )  

#define LongToBin(n) \
(\
((n >> 21) & 0x80) | \
((n >> 18) & 0x40) | \
((n >> 15) & 0x20) | \
((n >> 12) & 0x10) | \
((n >> 9) & 0x08) | \
((n >> 6) & 0x04) | \
((n >> 3) & 0x02) | \
((n ) & 0x01) \
)

#define Bin(n) LongToBin(0x##n##L)

#endif

⌨️ 快捷键说明

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