📄 44bmon.c
字号:
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\lcd.h"
//99.5.14 : Lcd_Init(), non-cacheable region is added.
//99.5.26 : link address: 0x1800000->0x0
//99.6.30(Ver 0.2): supports 64M DRAM(GCS6)
//99.8.10 : filesize counter: 6digit->7digit
//99.8.27 : support Power Down mode
//00.4.20 : modify for S3C44BOX
#define DOWNLOAD_ADDRESS _RAM_STARTADDRESS
void (*restart)(void)=(void (*)(void))0x0;
void (*run)(void)=(void (*)(void))DOWNLOAD_ADDRESS;
unsigned int (*frameBuffer)[10];
volatile unsigned char *downPt;
void Isr_Init(void);
void Lcd_Init(void);
void __irq Uart0_RxInt(void);
void __irq Uerror(void);
volatile unsigned int err=0;
void Main(void)
{
int i,j;
int memError=0;
unsigned int fileSize;
unsigned short int checkSum=0,dnCS;
// volatile unsigned *pt;
rSYSCFG=CACHECFG;
downPt=(unsigned char *)DOWNLOAD_ADDRESS;
pISR_SWI=(_ISR_STARTADDRESS+0xf0); //for pSOS
Port_Init();
Led_Display(0x0);
Isr_Init();
Uart_Init(0,115200);
Lcd_Init(); //to avoid LCD damage.
Delay(0);
Uart_Select(0); //Select UART0
Uart_Printf("\n\n44bMON Ver 0.01 for S3C44B0X May,2000\n");
Uart_Printf("COM:115.2kbps,8Bit,NP,UART0 <n+6>(4)+(n)+CS(2)\n");
Uart_Printf("DOWNADDR:%x ISR_ADDR:%x SYSCFG:%x \n",DOWNLOAD_ADDRESS,_ISR_STARTADDRESS,rSYSCFG );
Uart_Printf("E-mail:kwtark@sec.samsung.com\n\n");
Uart_Printf("Memory Test(%xh-%xh):WR",
_RAM_STARTADDRESS,(_ISR_STARTADDRESS&0xfff0000));
for(i=_RAM_STARTADDRESS;i<(_ISR_STARTADDRESS&0xfff0000);i+=4)
{
*((volatile unsigned *)i)=i;
}
Uart_Printf("\b\bRD");
for(i=_RAM_STARTADDRESS;i<(_ISR_STARTADDRESS&0xfff0000);i+=4)
{
j=*((volatile unsigned *)i);
if(j!=i)memError=1;
}
if(memError==0)
Uart_Printf("\b\bO.K.\n");
else
Uart_Printf("\b\bFAIL\n");
while(( (unsigned int)downPt-DOWNLOAD_ADDRESS )<4)
{
Led_Display(0xf);
Delay(1000);
Led_Display(0x0);
Delay(1000);
}
fileSize=*((unsigned char *)(DOWNLOAD_ADDRESS+0))+
(*((unsigned char *)(DOWNLOAD_ADDRESS+1))<<8)+
(*((unsigned char *)(DOWNLOAD_ADDRESS+2))<<16)+
(*((unsigned char *)(DOWNLOAD_ADDRESS+3))<<24);
Uart_Printf("\nNow, Downloading... [FILESIZE:%7d( 0)",fileSize);
while(((int)downPt-DOWNLOAD_ADDRESS)<fileSize)
{
Uart_Printf("\b\b\b\b\b\b\b\b%7d)",(int)downPt-DOWNLOAD_ADDRESS);
// Uart_Printf("error=%d\n",err);
}
Uart_Printf("\b\b\b\b\b\b\b\b%7d)\n",(int)downPt-DOWNLOAD_ADDRESS);
for(i=4;i<(fileSize-2);i++)
{
checkSum+=*((unsigned char *)(i+DOWNLOAD_ADDRESS));
}
dnCS=*((unsigned char *)(DOWNLOAD_ADDRESS+fileSize-2))+
(*( (unsigned char *)(DOWNLOAD_ADDRESS+fileSize-1) )<<8);
if(checkSum!=dnCS)
{
Uart_Printf("Checksum Error!!! MEM:%x DN:%x\n",checkSum,dnCS);
restart();
}
Uart_Printf("\nDownload O.K.\n");
for(i=4;i<(fileSize-2);i++) //Move the program from 0x1000004~ to 0x1000000~
{
*((unsigned char *)(i+DOWNLOAD_ADDRESS-4))
=*((unsigned char *)(i+DOWNLOAD_ADDRESS));
}
run();
}
void Isr_Init(void)
{
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; //All=IRQ mode
rINTMSK=~( BIT_URXD0 | BIT_GLOBAL); //Default value=0x7ffffff
// rINTMSK=~( BIT_UERR01 | BIT_URXD0 | BIT_GLOBAL); //Default value=0x7ffffff
/*pISR_FIQ,pISR_IRQ must be initialized*/
pISR_URXD0=(unsigned)Uart0_RxInt;
// pISR_UERR01=(unsigned)Uerror;
}
void __irq Uart0_RxInt(void)
{
rI_ISPC=BIT_URXD0 ; //clear pending bits,Default value=0x0000000
//rI_ISPC; //is needed only when cache=on & wrbuf=on & BSFRD=0
*downPt++=RdURXH0();
}
void __irq Uerror(void)
{
rI_ISPC=BIT_UERR01 ; //clear pending bits,Default value=0x0000000
err++;
// Uart_Printf("UERSTAT=%x\n", rUERSTAT0);
}
void Display_4Gray160x240(void)
{
int i,j;
for(j=0;j<100;j++)
for(i=2;i<10;i++)
{
frameBuffer4[j][i]=0x55aa55aa;
}
for(j=0;j<100;j++)
{
frameBuffer4[j][9]=0x5555ffff;
}
for(j=100;j<240;j++)
for(i=2;i<10;i++)
frameBuffer4[j][i]=0x0;
for(i=2;i<10;i++)
frameBuffer4[100][i]=0xffffffff;
for(i=2;i<10;i++)
frameBuffer4[0][i]=0xffffffff;
}
void Lcd_Init(void)
{
//320x240 1bit/1pixel LCD
int i,j;
if((U32)frameBuffer1==0)
{
frameBuffer1=(unsigned int (*)[SCR_XSIZE/32])malloc(ARRAY_SIZE_MONO);
}
rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
// disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x0<<27) | ( ((U32)frameBuffer1>>22)<<21 ) | M5D((U32)frameBuffer1>>1);
// monochrome, LCDBANK, LCDBASEU
rLCDSADDR2= M5D( (((U32)frameBuffer1+(SCR_XSIZE*LCD_YSIZE/8))>>1) ) | (MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/16) | ( ((SCR_XSIZE-LCD_XSIZE)/16)<<9 );
rLCDCON1=(1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
// enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
for(j=0;j<240;j++)
for(i=0;i<10;i++)
{
if((j%16)<8)
frameBuffer1[j][i]=0xff00ff00;
else
frameBuffer1[j][i]=0x00ff00ff;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -