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

📄 logic.h

📁 利用ATMEGA128芯片的双串口
💻 H
字号:
/* ATmega103 logic.h file 

   Author : Robert Stuart 
   Company : PDL Industries 
   Date of Creation : 6 September 1999
*/
#ifndef _LOGIC_H


#define _HOST	1
//#define _REMOTE 2



/* general defines */
#define fosc			8000000
#define baud			115200
#define xtal			4

#define TRUE		   255
#define UNSIGNED_INT_LIMIT	   0xFFFF
#define CHARACTER_NULL	   0x00

/* enables an unsigned char to be used as a series of booleans */
#define BIT(x)			   (1 << (x))
#define SETBIT(x, y)	   (x |= y)
#define CLEARBIT(x, y)	   (x &= ~y)
#define CHECKBIT(x, y)	   (x & y)
#define MINIMUM(x, y)	   (x < y ? x : y)

/* if true then the eeprom is executing a pervious write and can not be interrupted */
#define EEPROM_BUSY		   (EECR & BIT(EEWE))

/* entering sleep mode */
#define SLEEP()      asm("SLEEP")

/* reset watchdog */
#define WDR()			     asm("WDR")

/* enable global interrupts */
#define SEI()				     (SREG |= BIT(7))

/* disable global interrupts */
#define CLI()				    (SREG &= ~BIT(7))


/* empty Operation */
#define NOP()			asm("nop")

typedef struct TIME_STRUCT{
	unsigned char second;
	unsigned char minute;
	unsigned char hour;
	unsigned char day;
	unsigned char month;
	unsigned char year;
}TIME;


/* constants used for timing */
#define _1SEC		   1000
#define _105SEC    1500
#define _1MS_INTERRUPT	   0xE0C0
#define _600MS		   600
#define _500MS		   500
#define _400MS		   400
#define _300MS		   300
#define _200MS		   200
#define _100MS		   100
#define _150MS		   200
#define _80MS		   80
#define _50MS		   50
#define _30MS		   30
#define _20MS		   20
#define _15MS		   15
#define _10MS		   10
//=============================================================================================================
/* For UART Interrupt */
#define HEX(d)		(d < 10 ? 48 + d : 55 + d)
#define DECIMAL(h)		(h < 58 ? h - 48 : h - 55)

/*For UART communication*/
#define UART1_TRANSMIT_ON	 UCSR1B |= BIT(UDRIE1)
#define UART1_TRANSMIT_OFF	 UCSR1B &= ~BIT(UDRIE1)     //(0<<UDRIE)       2003-11-3
#define UART1_RECEIVE_ON	UCSR1B |=BIT(RXCIE1)
#define UART1_RECEIVE_OFF	UCSR1B &=~BIT(RXCIE1)	      //(0<<RXCIE)	 2003-11-3
#define UART0_TRANSMIT_ON	UCSR0B |= BIT(UDRIE0)
#define UART0_TRANSMIT_OFF	UCSR0B &= ~BIT(UDRIE0)	   //(0<<UDRIE)       2003-11-3
#define UART0_RECEIVE_ON		UCSR0B |= BIT(RXCIE0)
#define UART0_RECEIVE_OFF	UCSR0B &=~BIT(RXCIE0);	    //(0<<RXCIE)       2003-11-3

#define BUFFER_SIZE		10


//=============================================================================
/* Define GPRS MODEM STATUS */
#define STATE_DEVICE_INIT		0
#define STATE_GPRS_START 		1
#define STATE_GPRS_TEST_CSQ		2
#define STATE_GPRS_SET_CONTYPE	3
#define STATE_GPRS_SET_USER		4
#define STATE_GPRS_SET_PWD		5
#define STATE_GPRS_SET_APN		6
#define STATE_GPRS_SET_SRVTYPE	7
#define STATE_GPRS_SET_SRVCONID	8
#define STATE_GPRS_SET_ADDRESS	9
#define STATE_GPRS_CONN_OPEN	10
#define STATE_GPRS_CONN_CLOSE	11
#define STATE_GPRS_CONNECT		12
#define STATE_GPRS_DISCONNECT	13
#define	STATE_GPRS_SHUTDOWN		14
#define STATE_GRPS_CHECKCARD	15
#define STATE_CPRS_GET_SIMID	16
#define STATE_CPRS_SET_CMEE		17

//===========================================================================
/* Define GPRS CONNECTED WORKING STATUS*/
#define	STATE_GPRS_READ_DATA	1
#define STATE_GPRS_WRITE_DATA	2
#define STATE_GPRS_WORKIDLE		3

#endif

⌨️ 快捷键说明

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