我看mini2440的eboot的时候,有这么一段
void OEMInitDebugSerial(void)
{
volatile UART0reg *s2440UART0 = (UART0reg *)UART0_BASE;
volatile IOPreg *s2440IOP = (IOPreg *)IOP_BASE;
// Configure port H for UART.
s2440IOP->rGPHCON |= ((2 << 4) | (2 << 6));
s2440IOP->rGPHUP |= (1 << 4) | (1 << 5); // Disable pull-up on TXD1 and RXD1.
........
}
因为不知道什么意思,我查了一下datasheet:
- Port H(GPH): 9-input/output port
Port H Selectable Pin Functions
GPH10 Input/output CLKOUT1 – –
GPH9 Input/output CLKOUT0 – –
GPH8 Input/output UEXTCLK – –
GPH7 Input/output RXD2 nCTS1 –
GPH6 Input/output TXD2 nRTS1 –
GPH5 Input/output RXD1 – –
GPH4 Input/output TXD1 – –
GPH3 Input/output RXD0 – –
GPH2 Input/output TXD0 – –
GPH1 Input/output nRTS0 – –
GPH0 Input/output nCTS0 – –
GPHCON Bit Description
GPH10 [21:20] 00 = Input 01 = Output 10 = CLKOUT1 11 = Reserved
GPH9 [19:18] 00 = Input 01 = Output 10 = CLKOUT0 11 = Reserved
GPH8 [17:16] 00 = Input 01 = Output 10 = UEXTCLK 11 = Reserved
GPH7 [15:14] 00 = Input 01 = Output 10 = RXD[2] 11 = nCTS1
GPH6 [13:12] 00 = Input 01 = Output 10 = TXD[2] 11 = nRTS1
GPH5 [11:10] 00 = Input 01 = Output 10 = RXD[1] 11 = Reserved
GPH4 [9:8] 00 = Input 01 = Output 10 = TXD[1] 11 = Reserved
GPH3 [7:6] 00 = Input 01 = Output 10 = RXD[0] 11 = reserved
GPH2 [5:4] 00 = Input 01 = Output 10 = TXD[0] 11 = Reserved
GPH1 [3:2] 00 = Input 01 = Output 10 = nRTS0 11 = Reserved
GPH0 [1:0] 00 = Input 01 = Output 10 = nCTS0 11 = Reserved
谁能帮我解释一下,
1.既然是个9pin的口,为啥有11个(pin)控制位,而且GPHCON是个32位寄存器,0-21总共用到22个bit,每两个bit设置一个pin?
2.s2440IOP->rGPHCON |= ((2 << 4) | (2 << 6)); 这结果是bit5和bit7置1,是不是说 GPH2 [5:4] = 10, GPH3 [7:6] = 10,那就是pin2和pin3分别用作TXD[0]和RXD[1]。
3. GPHUP Bit Description
GPH[10:0] [10:0] 0: the pull up function attached to to the corresponding port pin is enabled.
1: the pull up function is disabled.
那第二句话s2440IOP->rGPHUP |= (1 << 4) | (1 << 5); 应该是把bit4和bit5置1,的确有可能是Disable pull-up on TXD1 and RXD1. 不过和前一句的配置不匹配啊。前一句并没有配置pin4和pin5.
多谢