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

📄 macro.h

📁 NoteBook Docking Power and Audio Switch Control using Atmel AT89S51 Chip Program by C language Com
💻 H
字号:
/***************           XXXXXX CONFIDENTIAL           ****************/
/***************                                       ****************/
/*************** Description : MACROs used for Docking ****************/
/***************               devices                 ****************/
/***************                                       ****************/
/***************     Company : XXXXXXTek Inc.            ****************/
/***************  Programmer : Steven Chu              ****************/
/***************        Date : 03/26/2007              ****************/
/**********************************************************************/

#ifndef _H_MACRO_
#define _H_MACRO_

//===================================================================
//  MACRO : Enable and Disable All Interrupt
//===================================================================
#define MEnableINT()            (EA = 1)
#define MDisableINT()           (EA = 0)

//===================================================================
//  MACRO : Enable and Disable Decoder/Encoder Interrupt
//===================================================================
#define MEnableDINT()           (EX0 = 1)
#define MDisableDINT()          (EX0 = 0)
#define MDINT_PTLOW()           (PX0 = 0)
#define MDINT_PTHIGH()          (PX0 = 1)
#define MEnableEINT()           (EX1 = 1)
#define MDisableEINT()          (EX1 = 0)
#define MEINT_PTLOW()           (PX1 = 0)
#define MEINT_PTHIGH()          (PX1 = 1)

//===================================================================
//  MACRO : Set Interrupt is level (not edge)
//===================================================================
#define MLevelINT()             (IT1 = 0)

//===================================================================
//  MACRO : Enable and Disable Timer0/Timer1/Timer2 Interrupt/Counter
//===================================================================
#define MEnableTimer0()         (ET0 = 1)
#define MDisableTimer0()        (ET0 = 0)
#define MTrgTimer0Cnt()         (TR0 = 1)
#define MStopTimer0Cnt()        (TR0 = 0)
#define MTIMER0_PTLOW()         (PT0 = 0)
#define MTIMER0_PTHIGH()        (PT0 = 1)

#define MEnableTimer1()         (ET1 = 1)
#define MDisableTimer1()        (ET1 = 0)
#define MTrgTimer1Cnt()         (TR1 = 1)
#define MStopTimer1Cnt()        (TR1 = 0)
#define MTIMER1_PTLOW()         (PT1 = 0)
#define MTIMER1_PTHIGH()        (PT1 = 1)

#define MEnableTimer2()         (ET2 = 1)
#define MDisableTimer2()        (ET2 = 0)
#define MTrgTimer2Cnt()         (TR2 = 1)
#define MStopTimer2Cnt()        (TR2 = 0)
#define MTIMER2_PTLOW()         (PT2 = 0)
#define MTIMER2_PTHIGH()        (PT2 = 1)

//===================================================================
//  MACRO : Byte/Word Access
//===================================================================
// HIGH BYTE FIRST
#define bHiByte(arg)            (* (BYTE *)&(arg))
#define bLoByte(arg)            (*((BYTE *)&(arg) + 1))

#define bExHiByte(arg)          (*((BYTE *)&(arg) + 2))
#define bExLoByte(arg)          (*((BYTE *)&(arg) + 3))

#define bcHiByte(arg)           (* (BYTE code *)&(arg))
#define bcLoByte(arg)           (*((BYTE code *)&(arg) + 1))

#define wHiWord(arg)            (* (WORD *)&(arg))
#define wLoWord(arg)            (*((WORD *)&(arg) + 1))

//===================================================================
//  MACRO : Read All Switch(Port 1) status
//===================================================================
#define ReadSwStatus()    (_bAllKeyStatus = P1)

//=====================================================================
//  MACRO : Turn All LED ON/OFF
//=====================================================================
#ifdef LED_DEBUG
  #define PWRLEDOn()      ( )
  #define PWRLEDOff()     ( )
  #define MuteLEDOn()     ( )
  #define MuteLEDOff()    ( )
  #define VolUpLEDOn()    ( )
  #define VolUpLEDOff()   ( )
  #define VolDwnLEDOn()   ( )
  #define VolDwnLEDOff()  ( )
#else
  #define PWRLEDOn()      (P2 &= (~0x01))          // Power       LED ON                
  #define PWRLEDOff()     (P2 |= 0x01)             // Power       LED OFF               
  #define MuteLEDOn()     (P2 &= (~0x02))          // Mute        LED ON                
  #define MuteLEDOff()    (P2 |= 0x02)             // Mute        LED OFF               
  #define VolUpLEDOn()    (P2 &= (~0x04))          // Volume Up   LED ON                
  #define VolUpLEDOff()   (P2 |= 0x04)             // Volume Up   LED OFF               
  #define VolDnLEDOn()    (P2 &= (~0x08))          // Volume Down LED ON                
  #define VolDnLEDOff()   (P2 |= 0x08)             // Volume Down LED OFF      
  #define ExpCardLEDOn()  (P0 &= (~0x01))          // ExpressCard Connect LED ON
  #define ExpCardLEDOff() (P0 |= 0x01)             // ExpressCard Connect LED OFF
#endif                                                                     
                                                                           
//=====================================================================    
//  MACRO : Docking Function Control                                       
//=====================================================================    
#define SetPowerOn()      (P2 |= 0x10)     // Power       function control ON   
#define SetPowerOff()     (P2 &= (~0x10))  // Power       function control OFF  
#define SetMuteOn()       (P2 &= (~0x20))  // Mute        function control ON   
#define SetMuteOff()      (P2 |= 0x20)     // Mute        function control OFF  
#define SetVolUp()        (P2 &= (~0x40))  // Volume Up   function control ON   
#define ClrVolUp()        (P2 |= 0x40)     // Volume Up   function control OFF  
#define SetVolDn()        (P2 &= (~0x80))  // Volume Down function control ON   
#define ClrVolDn()        (P2 |= 0x80)     // Volume Down function control OFF  
                                   
//=====================================================================    
//  MACRO : Set Switch Port(P1) High                                      
//=====================================================================    
#define SetPort0High()    (P0 = 0xFF)
#define SetPort1High()    (P1 = 0xFF)

#endif

⌨️ 快捷键说明

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