www.pudn.com > hf44b0_TEST.rar > 44blib.c
/************************************************ * NAME : 44BLIB.C * * Version : 17.APR.00 * ************************************************/ #include "..\inc\44b.h" #include "..\inc\44blib.h" #include "..\inc\def.h" #include "..\inc\option.h" #include#include #include #include #include #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 extern char Image$$RW$$Limit[]; void *mallocPt=Image$$RW$$Limit; int atoi(const char *str) { int i,j=0; for( i = 0;str[i]!='\0';i++) { j=j*10+( str[i] - '0'); } return j; } /************************* SYSTEM *************************/ static int delayLoopCount=400; 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); // 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 0); //to align 4byte if( (int)mallocPt > HEAPEND ) { mallocPt=returnPt; return NULL; } return returnPt; } void free(void *pt) { mallocPt=pt; } void Cache_Flush(void) { int i,saveSyscfg; saveSyscfg=rSYSCFG; rSYSCFG=SYSCFG_0KB; for(i=0x10004000;i<0x10004800;i+=16) { *((int *)i)=0x0; } rSYSCFG=saveSyscfg; } /************************* 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) { // int i; rWTCON=((MCLK/1000000-1)<<8); return (0xffff-rWTCNT); }