?? 44blib.c
字號:
/*
*************************************************************************
* Copyright (c) 2003, The Lab of Embedded System and Net Security,WHUT..
* All rights reserved.
*
* Filename: 44blib.c
* Discription: This file provides some board operation.
*
* version: 1.0
* Author: Qiu Yanfei <qyfhm@tom.com>
* Accomplished Date: 2004/7/10 16:31:00
*************************************************************************
*/
#include "44breg.h"
#include "def.h"
#include "option.h"
#define LIB_GLOBALS
#include "44blib.h"
extern char Image$$RW$$Limit[];
volatile unsigned char *downPt;
unsigned int fileSize;
void *mallocPt=Image$$RW$$Limit;
#define STACKSIZE 0xa00 //SVC satck size(do not use user stack)//
#define HEAPEND (_ISR_STARTADDRESS-STACKSIZE-0x500) // = 0xc7ff000//
//SVC Stack Area:0xc(e)7ff000-0xc(e)7ffaff//
//--------------------------------SYSTEM---------------------------------//
static int delayLoopCount=400;
void Delay(int time)
{
int i,adjust=0;
if(time==0)
{
time=200;
adjust=1;
delayLoopCount=400;
rWTCON=((MCLK/1000000-1)<<8)|(2<<3); // 1M/64,Watch-dog,nRESET,interrupt disable//
rWTDAT=0xffff;
rWTCNT=0xffff;
rWTCON=((MCLK/1000000-1)<<8)|(2<<3)|(1<<5); // 1M/64,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; // 1count/16us?????????//
delayLoopCount=8000000/(i*64); //400*100/(i*64/200) //
}
}
//------------------------PORTS------------------------------//
void Port_Init(void)
{
//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 */
/* A24 A23 A22 A21 A20 A19 A18 A17 A16 A0 */
/* 1 1 1 1 1 1 1 1 1 1 */
rPCONA = 0x1ff;
// 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 */
/* EXT NIC USB IDE SMC NC NC Sdram Sdram Sdram Sdram */
/* 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 */
rPDATB = 0x3ff;
rPCONB = 0x3ff;
//PORT C GROUP
//BUSWIDTH=16 */
/* PC15 14 13 12 11 10 9 8 */
/* I I RXD1 TXD1 I I I I */
/* NC NC Uart1 Uart1 NC NC NC NC */
/* 00 00 11 11 00 00 00 00 */
/* PC7 6 5 4 3 2 1 0 */
/* I I I I I I I I */
/* VD4 VD5 VD6 VD7 SMCALE SMCCLE SMCCE SMCRB*/
/* 00 00 00 00 01 01 01 00 */
rPDATC = 0xffff; //All IO is high
rPCONC = 0x0f00ff54;
rPUPC = 0x3000; //PULL UP RESISTOR should be enabled to I/O
//PORT D GROUP
/* PORT D GROUP(I/O OR LCD) */
/* BIT7 6 5 4 3 2 1 0 */
/* VF VM VLINE VCLK VD3 VD2 VD1 VD0 */
/* 00 00 00 00 00 00 00 00 */
rPDATD= 0xff;
rPCOND= 0xaaaa;
rPUPD = 0x0;
//These pins must be set only after CPU's internal LCD controller is enable
//PORT E GROUP
/* Bit 8 7 6 5 4 3 2 1 0 */
/* LcdBL LED4 LED5 LED6 LED7 BEEP RXD0 TXD0 LcdDisp */
/* 01 01 01 01 01 01 10 10 01 */
rPDATE = 0x1ff;
rPCONE = 0x16569; //PE6 used as TOUT3 0x15569;
rPUPE = 0x6;
//PORT F GROUP
/* Bit8 7 6 5 4 3 2 1 0 */
/* IISCLK IISDI IISDO IISLRCK Input Input Input IICSDA IICSCL */
/* 100 100 100 100 00 00 00 10 10 */
rPDATF = 0x0;
rPCONF = 0x24900a;
rPUPF = 0x1e3;
//PORT G GROUP
/* BIT7 6 5 4 3 2 1 0 */
/* INT7 INT6 INT5 INT4 INT3 INT2 INT1 INT0 */
/* S3 S4 S5 S6 NIC EXT IDE USB */
/* 11 11 11 11 11 11 11 11 */
rPDATG = 0xff;
rPCONG = 0xffff;
rPUPG = 0x0; //should be enabled
rSPUCR = 0x7; //D15-D0 pull-up disable
rSYSCFG = CACHECFG;
/*定義非Cache區*/
rNCACHBE0 = ((Non_Cache_End>>12)<<16) | (Non_Cache_Start>>12);
/*所有的外部硬件中斷為低電平觸發*/
rEXTINT = 0x0 | (4<<4) | (4<<8) | (4<<12);//0;
//Misc
//USBN9603's A0 pin -> CPU's A1
//IDE's CS0 -> CPU's A2
//IDE's CS1 -> CPU's A1
//IDE's A2 -> CPU's A3
//IDE's A1 -> CPU's A5
//IDE's A0 -> CPU's A4
}
/******************** S3C44B0X EV. BOARD LED **********************/
void Led_Display(int LedStatus)
{
if((LedStatus&0x01)==0x01)
rPDATE=rPDATE&0x17f;
else
rPDATE=rPDATE|0x80;
if((LedStatus&0x02)==0x02)
rPDATE=rPDATE&0x1bf;
else
rPDATE=rPDATE|0x40;
if((LedStatus&0x04)==0x04)
rPDATE=rPDATE&0x1df;
else
rPDATE=rPDATE|0x20;
if((LedStatus&0x08)==0x08)
rPDATE=rPDATE&0x1ef;
else
rPDATE=rPDATE|0x10;
}
/************************* Timer ********************************/
void Timer_Start(int divider) //0:16us,1:32us 2:64us 3:128us
{
rWTCON=((MCLK/1000000-1)<<8)|(divider<<3);
rWTDAT=0xffff;
rWTCNT=0xffff;
// 1/16/(65+1),nRESET & interrupt disable
rWTCON=((MCLK/1000000-1)<<8)|(divider<<3)|(1<<5);
}
int Timer_Stop(void)
{
rWTCON=((MCLK/1000000-1)<<8);
return (0xffff-rWTCNT);
}
void Beep(int BeepStatus)
{
if (BeepStatus==0)
rPDATE=rPDATE|0x8;
else
rPDATE=rPDATE&0x1f7;
}
/************************* PLL ********************************/
void ChangePllValue(int mdiv,int pdiv,int sdiv)
{
rPLLCON = (mdiv<<12) | (pdiv<<4) | sdiv;
}
/************************* General Library **********************/
void * malloc(unsigned nbyte)
/*Very simple; Use malloc() & free() like Stack*/
{
void *returnPt = mallocPt;
mallocPt = (int *)mallocPt+nbyte/4+((nbyte%4)>0); //to align 4byte
if( (int)mallocPt > HEAPEND )
{
mallocPt = returnPt;
return NULL;
}
return returnPt;
}
void free(void *pt)
{
mallocPt = pt;
}
void Cache_Init(unsigned int cachesizecfg)
{
rSYSCFG = cachesizecfg;
}
void Cache_Flush(void)
{
int i,saveSyscfg;
saveSyscfg = rSYSCFG;
rSYSCFG=SYSCFG_0KB;
for(i=0x10004000;i<0x10004800;i+=16)
{
*((int *)i)=0x0;
}
rSYSCFG = saveSyscfg;
}
void No_Cachemem(unsigned int start,unsigned int end)
{
rNCACHBE1 = (((end>>12) + 1)<<16) | (start>>12);
}
void Clear_Nocahchemem(void)
{
rNCACHBE1 = 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -