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

📄 initport.c

📁 S3C2410学习的基础资料 大部分实验源码及工程
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*********************************************************************************************************
* 文件: InitPort.C
* 描述: 初始化所有 I/O 口.
* 编写: bobey
*********************************************************************************************************
*/
#define   Global_Def   

#include  "Includes.H"

void Init_Port (void)
{
// Configure the pins of port A
#define		GPA22		1	// 0 = Output 1 = nFCE
#define		GPA21		1	// 0 = Output 1 = nRSTOUT (nRSTOUT = nRESET & nWDTRST & SW_RESET(MISCCR[16]))
#define		GPA20		1	// 0 = Output 1 = nFRE
#define		GPA19		1	// 0 = Output 1 = nFWE
#define		GPA18		1	// 0 = Output 1 = ALE
#define		GPA17		1	// 0 = Output 1 = CLE
#define		GPA16		1	// 0 = Output 1 = nGCS5
#define		GPA15		1	// 0 = Output 1 = nGCS4
#define		GPA14		1	// 0 = Output 1 = nGCS3
#define		GPA13		1	// 0 = Output 1 = nGCS2
#define		GPA12		1	// 0 = Output 1 = nGCS1
#define		GPA11		1	// 0 = Output 1 = ADDR26
#define		GPA10		1	// 0 = Output 1 = ADDR25
#define		GPA9		1	// 0 = Output 1 = ADDR24
#define		GPA8		1	// 0 = Output 1 = ADDR23
#define		GPA7		1	// 0 = Output 1 = ADDR22
#define		GPA6		1	// 0 = Output 1 = ADDR21
#define		GPA5		1	// 0 = Output 1 = ADDR20
#define		GPA4		1	// 0 = Output 1 = ADDR19
#define		GPA3		1	// 0 = Output 1 = ADDR18
#define		GPA2		1	// 0 = Output 1 = ADDR17
#define		GPA1		1	// 0 = Output 1 = ADDR16
#define		GPA0		1	// 0 = Output 1 = ADDR0
	rGPACON = \
		(GPA22<<22)+(GPA21<<21)+(GPA20<<20)+(GPA19<<19)+(GPA18<<18)+(GPA17<<17)+(GPA16<<16)+ \
		(GPA15<<15)+(GPA14<<14)+(GPA13<<13)+(GPA12<<12)+(GPA11<<11)+(GPA10<<10)+(GPA9<<9)+(GPA8<<8)+ \
		(GPA7<<7)+(GPA6<<6)+(GPA5<<5)+(GPA4<<4)+(GPA3<<3)+(GPA2<<2)+(GPA1<<1)+(GPA0<<0);
	rGPADAT  = 0x00000000;

// PORT B CONTROL REGISTERS.
#define		GPB10		0	// 00 = Input 01 = Output	10 = nXDREQ0 11 = reserved
#define		GPB9		1	// 00 = Input 01 = Output	10 = nXDACK0 11 = reserved
#define		GPB8		0	// 00 = Input 01 = Output	10 = nXDREQ1 11 = Reserved
#define		GPB7		1	// 00 = Input 01 = Output	10 = nXDACK1 11 = Reserved
#define		GPB6		0	// 00 = Input 01 = Output	10 = nXBREQ 11 = reserved
#define		GPB5		1	// 00 = Input 01 = Output	10 = nXBACK 11 = reserved
#define		GPB4		1	// 00 = Input 01 = Output	10 = TCLK0 11 = reserved
#define		GPB3		1	// 00 = Input 01 = Output	10 = TOUT3 11 = reserved
#define		GPB2		1	// 00 = Input 01 = Output	10 = TOUT2 11 = reserved
#define		GPB1		1	// 00 = Input 01 = Output	10 = TOUT1 11 = reserved
#define		GPB0		1	// 00 = Input 01 = Output	10 = TOUT0 11 = reserved
	rGPBCON = (GPB10<<20)+(GPB9<<18)+(GPB8<<16)+ \
			(GPB7<<14)+(GPB6<<12)+(GPB5<<10)+(GPB4<<8)+(GPB3<<6)+(GPB2<<4)+(GPB1<<2)+(GPB0<<0);
	rGPBDAT  = 0x00000000;
    rGPBUP  = 0x000007ff;   // The pull up function is disabled GPB[10:0]

// PORT C CONTROL REGISTERS
#define		GPC15		2	// 00 = Input 01 = Output	10 = VD[7] 11 = Reserved
#define		GPC14		2	// 00 = Input 01 = Output	10 = VD[6] 11 = Reserved
#define		GPC13		2	// 00 = Input 01 = Output	10 = VD[5] 11 = Reserved
#define		GPC12		2	// 00 = Input 01 = Output	10 = VD[4] 11 = Reserved
#define		GPC11		2	// 00 = Input 01 = Output	10 = VD[3] 11 = Reserved
#define		GPC10		2	// 00 = Input 01 = Output	10 = VD[2] 11 = Reserved
#define		GPC9		2	// 00 = Input 01 = Output	10 = VD[1] 11 = Reserved
#define		GPC8		2	// 00 = Input 01 = Output	10 = VD[0] 11 = Reserved
#define		GPC7		2	// 00 = Input 01 = Output	10 = LCDVF2 11 = Reserved
#define		GPC6		2	// 00 = Input 01 = Output	10 = LCDVF1 11 = Reserved
#define		GPC5		2	// 00 = Input 01 = Output	10 = LCDVF0 11 = Reserved
#define		GPC4		2	// 00 = Input 01 = Output	10 = VM 11 = Reserved
#define		GPC3		2	// 00 = Input 01 = Output	10 = VFRAME 11 = Reserved
#define		GPC2		2	// 00 = Input 01 = Output	10 = VLINE 11 = Reserved
#define		GPC1		2	// 00 = Input 01 = Output	10 = VCLK 11 = Reserved
#define		GPC0		2	// 00 = Input 01 = Output	10 = LEND 11 = Reserved
    rGPCCON = ((INT32U)GPC15<<30)+(GPC14<<28)+(GPC13<<26)+(GPC12<<24)+(GPC11<<22)+(GPC10<<20)+(GPC9<<18)+(GPC8<<16)+ \
			(GPC7<<14)+(GPC6<<12)+(GPC5<<10)+(GPC4<<8)+(GPC3<<6)+(GPC2<<4)+(GPC1<<2)+(GPC0<<0);
	rGPCDAT = 0x00000000;
	rGPCUP  = 0x0000ffff;   // The pull up function is disabled GPC[15:0] 

// PORT D CONTROL REGISTERS
#define		GPD15		2	// 00 = Input 01 = Output	10 = VD23 11 = nSS0
#define		GPD14		2	// 00 = Input 01 = Output	10 = VD22 11 = nSS1
#define		GPD13		2	// 00 = Input 01 = Output	10 = VD21 11 = Reserved
#define		GPD12		2	// 00 = Input 01 = Output	10 = VD20 11 = Reserved
#define		GPD11		2	// 00 = Input 01 = Output	10 = VD19 11 = Reserved
#define		GPD10		2	// 00 = Input 01 = Output	10 = VD18 11 = Reserved
#define		GPD9		2	// 00 = Input 01 = Output	10 = VD17 11 = Reserved
#define		GPD8		2	// 00 = Input 01 = Output	10 = VD16 11 = Reserved
#define		GPD7		2	// 00 = Input 01 = Output	10 = VD15 11 = Reserved
#define		GPD6		2	// 00 = Input 01 = Output	10 = VD14 11 = Reserved
#define		GPD5		2	// 00 = Input 01 = Output	10 = VD13 11 = Reserved
#define		GPD4		2	// 00 = Input 01 = Output	10 = VD12 11 = Reserved
#define		GPD3		2	// 00 = Input 01 = Output	10 = VD11 11 = Reserved
#define		GPD2		2	// 00 = Input 01 = Output	10 = VD10 11 = Reserved
#define		GPD1		2	// 00 = Input 01 = Output	10 = VD9 11 = Reserved
#define		GPD0		2	// 00 = Input 01 = Output	10 = VD8 11 = Reserved
	rGPDCON = ((INT32U)GPD15<<30)+(GPD14<<28)+(GPD13<<26)+(GPD12<<24)+(GPD11<<22)+(GPD10<<20)+(GPD9<<18)+(GPD8<<16)+ \
			(GPD7<<14)+(GPD6<<12)+(GPD5<<10)+(GPD4<<8)+(GPD3<<6)+(GPD2<<4)+(GPD1<<2)+(GPD0<<0);
	rGPDDAT = 0x00000000;
	rGPDUP  = 0x0000ffff;  // The pull up function is disabled GPD[15:0]

// PORT E CONTROL REGISTERS
#define		GPE15		2	// 00 = Input 01 = Output (open drain output)	10 = IICSDA 11 = Reserved
#define		GPE14		2	// 00 = Input 01 = Output (open drain output)	10 = IICSCL 11 = Reserved
#define		GPE13		2	// 00 = Input 01 = Output	10 = SPICLK0 11 = Reserved
#define		GPE12		2	// 00 = Input 01 = Output	10 = SPIMOSI0 11 = Reserved
#define		GPE11		2	// 00 = Input 01 = Output	10 = SPIMISO0 11 = Reserved
#define		GPE10		2	// 00 = Input 01 = Output	10 = SDDAT3 11 = Reserved
#define		GPE9		2	// 00 = Input 01 = Output	10 = SDDAT2 11 = Reserved
#define		GPE8		2	// 00 = Input 01 = Output	10 = SDDAT1 11 = Reserved
#define		GPE7		2	// 00 = Input 01 = Output	10 = SDDAT0 11 = Reserved
#define		GPE6		2	// 00 = Input 01 = Output	10 = SDCMD 11 = Reserved
#define		GPE5		2	// 00 = Input 01 = Output	10 = SDCLK 11 = Reserved
#define		GPE4		2	// 00 = Input 01 = Output	10 = I2SSDO 11 = I2SSDI
#define		GPE3		2	// 00 = Input 01 = Output	10 = I2SSDI 11 = nSS0
#define		GPE2		2	// 00 = Input 01 = Output	10 = CDCLK 11 = Reserved
#define		GPE1		2	// 00 = Input 01 = Output	10 = I2SSCLK 11 = Reserved
#define		GPE0		2	// 00 = Input 01 = Output	10 = I2SLRCK 11 = Reserved
	rGPECON = ((INT32U)GPE15<<30)+(GPE14<<28)+(GPE13<<26)+(GPE12<<24)+(GPE11<<22)+(GPE10<<20)+(GPE9<<18)+(GPE8<<16)+ \
			(GPE7<<14)+(GPE6<<12)+(GPE5<<10)+(GPE4<<8)+(GPE3<<6)+(GPE2<<4)+(GPE1<<2)+(GPE0<<0);
	rGPEUP  = 0x0000ffff;   // The pull up function is disabled GPE[15:0]

// PORT F CONTROL REGISTERS
#define		GPF7		1	// 00 = Input 01 = Output	10 = EINT7 11 = Reserved
#define		GPF6		1	// 00 = Input 01 = Output	10 = EINT6 11 = Reserved
#define		GPF5		1	// 00 = Input 01 = Output	10 = EINT5 11 = Reserved
#define		GPF4		2	// 00 = Input 01 = Output	10 = EINT4 11 = Reserved
#define		GPF3		2	// 00 = Input 01 = Output	10 = EINT3 11 = Reserved
#define		GPF2		2	// 00 = Input 01 = Output	10 = EINT2 11 = Reserved
#define		GPF1		2	// 00 = Input 01 = Output	10 = EINT1 11 = Reserved
#define		GPF0		2	// 00 = Input 01 = Output	10 = EINT0 11 = Reserved
	rGPFCON = (GPF7<<14)+(GPF6<<12)+(GPF5<<10)+(GPF4<<8)+(GPF3<<6)+(GPF2<<4)+(GPF1<<2)+(GPF0<<0);
	rGPFDAT = 0x00f0;
    rGPFUP  = 0x00ff;       // The pull up function is disabled GPF[7:0]

// PORT G CONTROL REGISTERS
#define		GPG15		3	// 00 = Input 01 = Output	10 = EINT23 11 = nYPON
#define		GPG14		3	// 00 = Input 01 = Output	10 = EINT22 11 = YMON
#define		GPG13		3	// 00 = Input 01 = Output	10 = EINT21 11 = nXPON
#define		GPG12		3	// 00 = Input 01 = Output	10 = EINT20 11 = XMON
#define		GPG11		2	// 00 = Input 01 = Output	10 = EINT19 11 = TCLK1
#define		GPG10		1	// 00 = Input 01 = Output	10 = EINT18 11 = Reserved
#define		GPG9		1	// 00 = Input 01 = Output	10 = EINT17 11 = Reserved
#define		GPG8		1	// 00 = Input 01 = Output	10 = EINT16 11 = Reserved
#define		GPG7		3	// 00 = Input 01 = Output	10 = EINT15 11 = SPICLK1
#define		GPG6		3	// 00 = Input 01 = Output	10 = EINT14 11 = SPIMOSI1
#define		GPG5		3	// 00 = Input 01 = Output	10 = EINT13 11 = SPIMISO1
#define		GPG4		1	// 00 = Input 01 = Output	10 = EINT12 11 = LCD_PWREN
#define		GPG3		2	// 00 = Input 01 = Output	10 = EINT11 11 = nSS1
#define		GPG2		3	// 00 = Input 01 = Output	10 = EINT10 11 = nSS0
#define		GPG1		2	// 00 = Input 01 = Output	10 = EINT9 11 = Reserved
#define		GPG0		2	// 00 = Input 01 = Output	10 = EINT8 11 = Reserved
	rGPGCON = ((INT32U)GPG15<<30)+(GPG14<<28)+(GPG13<<26)+(GPG12<<24)+(GPG11<<22)+(GPG10<<20)+(GPG9<<18)+(GPG8<<16)+ \
			(GPG7<<14)+(GPG6<<12)+(GPG5<<10)+(GPG4<<8)+(GPG3<<6)+(GPG2<<4)+(GPG1<<2)+(GPG0<<0);
    rGPGDAT = 0x00000000;
    rGPGUP  = 0x0000ffff;   // The pull up function is disabled GPG[15:0]

// PORT H CONTROL REGISTERS
#define		GPH10		2	// 00 = Input 01 = Output	10 = CLKOUT1 11 = Reserved

⌨️ 快捷键说明

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