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

📄 macros._h

📁 单片机中的中断处理模块
💻 _H
字号:
#ifndef __MACROS_H
#define __MACROS_H	1

#include "stdtypes.h"

/* FOR ATMEL AVR and TINY AVR ONLY! */

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

#if defined(_AVR) && !defined(flash)
#define flash	const		/* IAR compatibility */
#endif

#ifndef C_task
#define C_task
#endif

#define _asm	asm			/* old style */

#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")

#ifdef _AVR
/* Serial Port Macros
 * for 4 Mhz crystal!
 * 
 * USE THE APPBUILDER for UART initialization!!!
 */
#define BAUD9600	25
#define BAUD19K		12

#define UART_TRANSMIT_ON()	UCR |= 0x8
#define UART_TRANSMIT_OFF()	UCR &= ~0x8
#define UART_RECEIVE_ON()	UCR |= 0x10
#define UART_RECEIVE_OFF()	UCR &= ~0x10

#define COMPRESS_DISABLE		NOCC_START()
#define COMPRESS_REENABLE		NOCC_END()

#define NOCC_START()	asm(".nocc_start")
#define NOCC_END()	asm(".nocc_end")

void _StackCheck(void);
void _StackOverflowed(char);




// 定义一个寄存器(Register)或端口(Port)的八个位 
   typedef struct _bit_struct 
      { 
                    UNS8 bit0 : 1 ; 
                    UNS8 bit1 : 1 ; 
                    UNS8 bit2 : 1 ; 
                    UNS8 bit3 : 1 ; 
                    UNS8 bit4 : 1 ; 
                    UNS8 bit5 : 1 ; 
                    UNS8 bit7 : 1 ; 
                    UNS8 bit6 : 1 ; 
      }bit_field; 

 //定义一个宏,用来得到每一位的值 
  #define GET_BITFIELD(addr) (*((volatile  bit_field *) (addr))) 

#endif

#endif

⌨️ 快捷键说明

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