AVR的端口 手册还是没看懂,某实例中这些端口定义怎么改
电路是基于M168/328的单片机,
一个有SPI外设连接的8路控制的例子, 端口想自己重新编排一下发现有点难
//-------------------------------
#define GIO 6 //D6
#define GDI 5 //D5
#define GLK 4 //D4
#define GCS 2 //D2
//-------------------------------
#define sind A0
#define SSS1_OUT 3 //(D3)
#define SSS2_OUT 7 //(D7)
#define SSS3_OUT 8 //(B0)
#define SSS4_OUT 9 //(B1)
#define SSS5_OUT 10 //(B2)
#define SSS6_OUT 11 //(B3)
#define SSS7_OUT 12 //(B4)
#define SSS8_OUT 13 //(B5)
//-------------------------------
#defineGCS_on PORTD |= 0x04 //D2
#defineGCS_off PORTD &= 0xFB //D2
#defineGLK_on PORTD |= 0x10//D4
#defineGLK_off PORTD &= 0xEF//D4
#defineGDI_on PORTD |= 0x20//D5
#defineGDI_off PORTD &= 0xDF //D5
#defineGIO_on PORTD |=0x40 //D6
//-------------------------------
#defineGIO_1 (PIND & 0x40) == 0x40 //D6
#defineGIO_0 (PIND & 0x40) == 0x00 //D6
#defineGDI_1 (PIND & 0x20) == 0x20 //D5
#defineGDI_0 (PIND & 0x20) == 0x00 //D5
//-------------------------------
#define RED_LED A3
#define Red_LED_ONPORTC |= _BV(3);
#define Red_LED_OFFPORTC &= ~_BV(3);
//-------------------------------
#define SSS1_OUT_HIGH PORTD |= _BV(3) //(D3)
#define SSS2_OUT_HIGH PORTD |= _BV(7) //(D7)
#define SSS3_OUT_HIGH PORTB |= _BV(0) //(B0)
#define SSS4_OUT_HIGH PORTB |= _BV(1) //(B1)
#define SSS5_OUT_HIGH PORTB |= _BV(2) //(B2)
#define SSS6_OUT_HIGH PORTB |= _BV(3) //(B3)
#define SSS7_OUT_HIGH PORTB |= _BV(4) //(B4)
#define SSS8_OUT_HIGH PORTB |= _BV(5) //(B5)
==================================================
SSS1~8是输出控制信号,
2、4、5、6 是连接外设的,这几个口想换成:
10、12、11、9
SSS1~8是控制信号引脚想换成:
D1~D8
请教应该怎么改?
页:
[1]