📄 port.h
字号:
# define Read_PA0 ((PINA<<7)>>7)
# define Read_PA1 ((PINA<<6)>>7)
# define Read_PA2 ((PINA<<5)>>7)
# define Read_PA3 ((PINA<<4)>>7)
# define Read_PA4 ((PINA<<3)>>7)
# define Read_PA5 ((PINA<<2)>>7)
# define Read_PA6 ((PINA<<1)>>7)
# define Read_PA7 (PINA>>7)
# define Read_PB0 ((PINB<<7)>>7)
# define Read_PB1 ((PINB<<6)>>7)
# define Read_PB2 ((PINB<<5)>>7)
# define Read_PB3 ((PINB<<4)>>7)
# define Read_PB4 ((PINB<<3)>>7)
# define Read_PB5 ((PINB<<2)>>7)
# define Read_PB6 ((PINB<<1)>>7)
# define Read_PB7 (PINB>>7)
# define Read_PC0 ((PINC<<7)>>7)
# define Read_PC1 ((PINC<<6)>>7)
# define Read_PC2 ((PINC<<5)>>7)
# define Read_PC3 ((PINC<<4)>>7)
# define Read_PC4 ((PINC<<3)>>7)
# define Read_PC5 ((PINC<<2)>>7)
# define Read_PC6 ((PINC<<1)>>7)
# define Read_PC7 (PINC>>7)
# define Read_PD0 ((PIND<<7)>>7)
# define Read_PD1 ((PIND<<6)>>7)
# define Read_PD2 ((PIND<<5)>>7)
# define Read_PD3 ((PIND<<4)>>7)
# define Read_PD4 ((PIND<<3)>>7)
# define Read_PD5 ((PIND<<2)>>7)
# define Read_PD6 ((PIND<<1)>>7)
# define Read_PD7 (PIND>>7)
/****************************
* 高级端口宏定义 *
****************************/
struct PORTBIT
{
unsigned Bit0:1;
unsigned Bit1:1;
unsigned Bit2:1;
unsigned Bit3:1;
unsigned Bit4:1;
unsigned Bit5:1;
unsigned Bit6:1;
unsigned Bit7:1;
}*PORTA_BIT,*PORTB_BIT,*PORTC_BIT,*PORTD_BIT;
/***********************************************************
* 函数说明:高级端口扩展初始化 *
***********************************************************/
void PORTDefine(void)
{
PORTA_BIT = ( struct PORTBIT *)0x3b;
PORTB_BIT = ( struct PORTBIT *)0x38;
PORTC_BIT = ( struct PORTBIT *)0x35;
PORTD_BIT = ( struct PORTBIT *)0x32;
UBRR=0x33;
UCSRB=0x18;
}
# define _PA0 (*PORTA_BIT).Bit0
# define _PA1 (*PORTA_BIT).Bit1
# define _PA2 (*PORTA_BIT).Bit2
# define _PA3 (*PORTA_BIT).Bit3
# define _PA4 (*PORTA_BIT).Bit4
# define _PA5 (*PORTA_BIT).Bit5
# define _PA6 (*PORTA_BIT).Bit6
# define _PA7 (*PORTA_BIT).Bit7
# define _PB0 (*PORTB_BIT).Bit0
# define _PB1 (*PORTB_BIT).Bit1
# define _PB2 (*PORTB_BIT).Bit2
# define _PB3 (*PORTB_BIT).Bit3
# define _PB4 (*PORTB_BIT).Bit4
# define _PB5 (*PORTB_BIT).Bit5
# define _PB6 (*PORTB_BIT).Bit6
# define _PB7 (*PORTB_BIT).Bit7
# define _PC0 (*PORTC_BIT).Bit0
# define _PC1 (*PORTC_BIT).Bit1
# define _PC2 (*PORTC_BIT).Bit2
# define _PC3 (*PORTC_BIT).Bit3
# define _PC4 (*PORTC_BIT).Bit4
# define _PC5 (*PORTC_BIT).Bit5
# define _PC6 (*PORTC_BIT).Bit6
# define _PC7 (*PORTC_BIT).Bit7
# define _PD0 (*PORTD_BIT).Bit0
# define _PD1 (*PORTD_BIT).Bit1
# define _PD2 (*PORTD_BIT).Bit2
# define _PD3 (*PORTD_BIT).Bit3
# define _PD4 (*PORTD_BIT).Bit4
# define _PD5 (*PORTD_BIT).Bit5
# define _PD6 (*PORTD_BIT).Bit6
# define _PD7 (*PORTD_BIT).Bit7
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -