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

📄 global.h

📁 用MEGA8实现4路红外调制发射接收的源码
💻 H
字号:
/**********************************************************************
* System Name		DOOR
* Header Name		global.h
* Version	Date		Editor		Modification
* 1.0		2007/05/09	周斌		做成
**********************************************************************/

#ifndef _USER_GLOBAL_H_
#define _USER_GLOBAL_H_


typedef unsigned char UCHAR;
typedef unsigned int UINT;
typedef unsigned long ULONG;
typedef unsigned char BOOL;

#define BIT(x)	(1<<(x))
#define NOP()	asm("nop")
#define WDR() 	asm("wdr")	//WATCH DOG RESET

#define SUCESS 1
#define FAIL 0

#define TRUE 1
#define FALSE 0

#define ON 1
#define OFF 0
#define NEG 2




UCHAR my_address;	//本机地址


/**********************************************
*串口指令格式:|STX|--TXT--|ETX|BCC|
***********************************************/
#define STX 0x02 //帧头
#define ETX 0x03 //帧尾
#define EOT 0x04
#define ENQ 0x05
#define ACK 0x06
#define NAK 0x15
#define ESC 0x1B


volatile UCHAR error_code;	//错误代码
//错误代码定义
#define ERROR_NOMAL 	0	//正常
#define ERROR_UART0_TX	1	//异常,串口0,(发送缓存溢出)
#define ERROR_UART0_RX	2	//异常,串口0,(接收缓存溢出)
#define ERROR_UART1_TX	3
#define ERROR_UART1_RX	4
#define ERROR_UART2_TX	5
#define ERROR_UART2_RX	6
#define ERROR_UART3_TX	7
#define ERROR_UART3_RX	8

//uart波特率
	//
	#define BAUD_19200 	1
	#define BAUD_38400 	2
	#define BAUD_115200 3
	//
	#define UBRR_H_7M_19200 	0x00
	#define UBRR_L_7M_19200 	0x17
	//
	#define UBRR_H_7M_38400 	0x00
	#define UBRR_L_7M_38400 	0x0b
	//
	#define UBRR_H_7M_115200 	0x00
	#define UBRR_L_7M_115200 	0x03

//uart波特率配置表,不使用倍速模式
#define UBRR_H_14M_300 		0x0B
#define UBRR_L_14M_300 		0xFF
//
#define UBRR_H_14M_600 		0x05
#define UBRR_L_14M_600 		0xFF
//
#define UBRR_H_14M_900 		0x03
#define UBRR_L_14M_900 		0xFF
//
#define UBRR_H_14M_1200 	0x02
#define UBRR_L_14M_1200 	0xFF
//
#define UBRR_H_14M_2400 	0x01
#define UBRR_L_14M_2400 	0x7F
//
#define UBRR_H_14M_4800 	0x00
#define UBRR_L_14M_4800 	0xBF
//
#define UBRR_H_14M_9600 	0x00
#define UBRR_L_14M_9600 	0x5F
//
#define UBRR_H_14M_14400 	0x00
#define UBRR_L_14M_14400 	0x3F
//
#define UBRR_H_14M_19200 	0x00
#define UBRR_L_14M_19200 	0x2F
//
#define UBRR_H_14M_28800 	0x00
#define UBRR_L_14M_28800 	0x1F
//
#define UBRR_H_14M_38400 	0x00
#define UBRR_L_14M_38400 	0x17
//
#define UBRR_H_14M_57600 	0x00
#define UBRR_L_14M_57600 	0x0F
//
#define UBRR_H_14M_76800 	0x00
#define UBRR_L_14M_76800 	0x0B
//
#define UBRR_H_14M_115200 	0x00
#define UBRR_L_14M_115200 	0x07
//
#define UBRR_H_14M_128000 	0x00
#define UBRR_L_14M_128000 	0x06
//
#define UBRR_H_14M_256000 	0x00
#define UBRR_L_14M_256000 	0x02


#define SETBIT(a, b)     ( a |=   b)  //调用方式 SETBIT(COM_6_PORT,(BIT(1)+BIT(5)+BIT(0)));
#define CLRBIT(a, b)     ( a &= ~ b)  //调用方式 CLRBIT(COM_6_PORT,(BIT(1)+BIT(5)+BIT(0)));
#define NEGBIT(a, b)      a ^= 0x01<<b
#define GETBIT(a, b)     ((a >> b) & 0x01)
//
#endif

⌨️ 快捷键说明

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