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

📄 public.h

📁 AVR mega16的单片机程序
💻 H
字号:
#ifndef _PUBLIC_INCLUDED
#define _PUBLIC_INCLUDED

/* 工作需频率选择 */
#define  M_8000    1
#define  M_110592  2
#define  M_73728   3

#define CYC  M_73728
//#define CYC  110592M
//#define CYC  M_8000

#define  DEBUG 0
#define delay 0x0400
#define uchar unsigned char
#define uint  unsigned int
#define FALSE            0
#define TRUE             1
#define OVER            -1
#define LED_ON        PORTC |= (1<<PC7)
#define LED_OFF       PORTC &= ~(1<<PC7)
#define DOG_H         PORTB |= (1<<PB4) //PB4
#define DOG_L         PORTB &= ~(1<<PB4) //PB4
#define CS_HOST       DDRC |=(1<<PC1);DDRC |=(1<<PC0);PORTC &= ~(1<<PC1);PORTC |= (1<<PC0) //PC1
#define CS_DEVICE     DDRC |=(1<<PC0);DDRC |=(1<<PC1);PORTC &= ~(1<<PC0);PORTC |= (1<<PC1) //PC0



#define OBFA_H    PORTC |= (1<<PC6);    // PC7
#define OBFA_L    PORTC &= ~(1<<PC6); // PC7
#define OBFA      (PINC & 0x40)       // PC7

#define ACKA_H  PORTB |= (1<<PB5) ;   //PC6
#define ACKA_L  PORTB &= ~(1<<PB5) ;   //PC6
#define ACKA      (PINB & 0x20)      // PC6

#define IBFA_H    PORTD |= (1<<PD3);    // PC5
#define IBFA_L    PORTD &= ~(1<<PD3);  // PC5
#define IBFA      (PIND & 0x08)       // PC5

#define STBA_H  PORTB |= (1<<PB6) ;  //PC4
#define STBA_L  PORTB &= ~(1<<PB6) ; //PC4
#define STBA      (PINB & 0x40)     // PC4


#define INTRA_H  PORTD |= (1<<PD2) ;  //PC3
#define INTRA_L  PORTD &= ~(1<<PD2);  //PC3
#define INTRA     (PIND & 0x04)     // PC3


#define PC2_H  PORTB |= (1<<PB7) ;  //PC2
#define PC2_L  PORTB &= ~(1<<PB7);  //PC2
#define PC2_IN      (PINB & 0x80)    // PC2

#define USART_RX_BUFFER_SIZE 64     /* 2,4,8,16,32,64,128 or 256 bytes */
#define USART_TX_BUFFER_SIZE 64     /* 2,4,8,16,32,64,128 or 256 bytes */
#define USART_RX_BUFFER_MASK ( USART_RX_BUFFER_SIZE - 1 )
#define USART_TX_BUFFER_MASK ( USART_TX_BUFFER_SIZE - 1 )
#if ( USART_RX_BUFFER_SIZE & USART_RX_BUFFER_MASK )
	#error RX buffer size is not a power of 2
#endif
#if ( USART_TX_BUFFER_SIZE & USART_TX_BUFFER_MASK )
	#error TX buffer size is not a power of 2
#endif
extern unsigned char USART_RxBuf[USART_RX_BUFFER_SIZE];
extern unsigned char USART_RxHead;
extern unsigned char USART_RxTail;
extern uchar LED_Mode     ;
extern uchar Rec_Data     ; //收到host的中断请求
extern uint  Over_Timer  ; //超时计数
extern uchar Send_Enable ; // 50Ms定时发送到标记
extern uchar time_100ms  ; // 100Ms定时计数器
extern uchar time_50ms   ; // 50Ms定时计数器
extern uchar time_10ms   ; // 10Ms定时计数器
extern uchar Work_Mode   ; // 工作模式标记
extern  uchar Send_Mode   ; // 发送方式标记
extern  uchar Send_Over   ; // 发送超时标记
extern  uchar Send_DataBuf[16] ; // 数据发送缓冲
extern  uchar Read_DataBuf[16] ; // 读入数据缓冲

extern void EEPROM_write(unsigned int uiAddress, unsigned char ucData);
extern unsigned char EEPROM_read(unsigned int uiAddress);
extern uchar AscToHex(uchar h,uchar l) ;
extern uint HexToAsc(uchar data);
extern void Send_String(uchar * str);
extern void USART_Transmit( unsigned char data );
extern void  itostr(uchar *str,uint l);
extern void LED_Disp(void);
extern void Delay(void);
#endif

⌨️ 快捷键说明

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