📄 wfunlib.c
字号:
/**************************************************************************
NAME:WFUNLIB.C
copyright:wzz at Qingdao University 2008
**************************************************************************/
#include "..\inc\WOPTIONS.h"
/**************************************************************************************************/
void Port_Init(void)//add by eric rong
{
//CAUTION:Follow the configuration order for setting the ports.
// 1) setting value
// 2) setting control register
// 3) configure pull-up resistor.
//16bit data bus configuration
// PORT A GROUP
/* BIT 9 8 7 6 5 4 3 2 1 0 */
/* ADDR24 ADDR23 ADDR22 ADDR21 ADDR20 ADDR19 ADDR18 ADDR17 ADDR16 ADDR0 */
/* 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 */
rPCONA = 0x3ff;
// PORT B GROUP
/* BIT 10 9 8 7 6 5 4 3 2 1 0*/
/* /CS5 /CS4 /CS3 /CS2 /CS1 nWBE3 nWBE2 /SRAS /SCAS SCLK SCKE*/
/* rtl8019 (Reserve)(Reserve)FLASH D12 Out Out Sdram Sdram Sdram Sdram*/
/* 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1*/
rPDATB = 0x7ff;
rPCONB = 0x7cf;
//PORT C GROUP
//BUSWIDTH=16*/
/* PC 15 14 13 12 11 10 9 8 */
/* O O RXD1 TXD1 O O O O*/
/* Nand-CE UDA-CE Uart1 Uart1 NandCLE NandALE L3DATA L3CLK*/
/* 01 01 11 11 01 01 01 01 */
/* PC 7 6 5 4 3 2 1 0*/
/* O O O I IISCLK IISDI IISDO IISLRCK*/
/* VD4 VD5 VD6 VD7 [ for UDA1341 ]*/
/* 11 11 11 11 11 11 11 11*/
rPDATC = 0x3fff; //All IO is high
rPCONC = 0x5f55ffff;
rPUPC = 0x3000; //PULL UP RESISTOR should be enabled to I/O
//PORT D GROUP for LCD
/*BIT 7 6 5 4 3 2 1 0*/
/* VF VM VLINE VCLK VD3 VD2 VD1 VD0*/
/* 10 10 10 10 10 10 10 10*/
rPDATD= 0xff;
rPCOND= 0xaaaa;
rPUPD = 0x0;
//PORT E GROUP
/* Bit 8 7 6 5 4 3 2 1 0 */
/* CODECLK TOUT4 TOUT3 TOUT2 TOUT1 TOUT0 RXD0 TXD0 SMRB(I) */
/* 10 10 10 10 10 10 10 10 00 */
rPDATE = 0x1ff;
rPCONE = 0x028;
rPUPE = 0x106;
//PORT F GROUP
/* Bit 8 7 6 5 4 3 2 1 0*/
/* SIOCLK SIORxD 7843CS SIOTxD [Input(DMA) ] Output IICSDA IICSCL*/
/* 011 011 001 011 00 00 01 10 10*/
rPDATF = 0x1fb; //GPF2=0
rPCONF = 0x1B2C1A; //0x9241A;
rPUPF = 0x3;
//PORT G GROUP
/*BIT 7 6 5 4 3 2 1 0*/
/* INT7 INT6 INT5 INT4 INT3 INT2 INT1 INT0*/
/* 11 11 00 11 11 11 11 11*/
// ~tch ~~input for bios
rPDATG = 0xff;
rPCONG = 0xf3ff;
rPUPG = 0x0; //should be enabled
rSPUCR=0x7; //D15-D0 pull-up disable
/*定义非Cache区*/
//NCACHBE0=(((unsigned int)Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);
/*所有的外部硬件中断为低电平触发*/
//EXTINT=0x0;
}
/**************************************************************************************************/
static int delayLoopCount=400;
//1S=1,000,000 uS
//t_watchdog = 1/( MCLK / (Prescaler value + 1) / Division_factor )
//Prescaler=MCLK/1000000-1
//t_watchdog=1/1000000/(1/64) s=64 us
void Delay(int time)
// time=0: adjust the Delay function by WatchDog timer.//
// time>0: the number of loop time//
// 100us resolution.//
{
int i,adjust=0;
if(time==0)
{
time=200;
adjust=1;
delayLoopCount=400;
rWTCON=((MCLK/1000000-1)<<8)|(2<<3); // 64us,Watch-dog,nRESET,interrupt disable//
rWTDAT=0xffff;
rWTCNT=0xffff;
rWTCON=((MCLK/1000000-1)<<8)|(2<<3)|(1<<5); // 64us,Watch-dog enable,nRESET,interrupt disable //
}
for(;time>0;time--)
for(i=0;i<delayLoopCount;i++);
if(adjust==1)
{
rWTCON=((MCLK/1000000-1)<<8)|(2<<3);
i=0xffff-rWTCNT; /*aim at 100us*/
delayLoopCount=8000000/(i*64); /* (200*400):(64us*i)=(1*delayLoopCount):100us*/
} /*delayLoopCount=200*400*100*/
}
/**************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -