📄 main.c
字号:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "..\target\option.h"
#include "..\target\44b.h"
#include "..\target\44blib.h"
#include "..\target\def.h"
#include "..\inc\uart.h"
#include "..\inc\adc.h"
#include "..\inc\ps2key.h"
#include "..\inc\rtc.h"
#include "..\inc\timer.h"
#include "..\inc\IIC.h"
#include "..\inc\eint.h"
#include "..\inc\cache.h"
#include "..\inc\power.h"
#include "..\inc\uda1341.h"
#include "..\inc\zdma.h"
#include "..\inc\sl811.h"
#include "..\inc\flashrom.h" //nor flash
#include "..\inc\D12Def.h"
#define WR_sdram(addr,dat) *((volatile unsigned short *)(addr))=(unsigned short)dat
#define RD_sdram(addr) *((volatile unsigned short *)(addr))
//#define BEGINADDR 0x0df00000 //32MB
#define BEGINADDR 0x0c7f0000 //8MB
/////////////////20071214 读NOR FLASH ID
#define _WR(ulADDR,usDATA) *((volatile INT16U *)(ulADDR<<1))=(INT16U)usDATA //the addr should be shifted
#define _RD(ulADDR) (*((volatile INT16U *)(ulADDR<<1)))
#define _RESET() _WR(0x0,0xf0f0)
#define SeqAddr1 (0x5555)
#define SeqCom1 (0xaa)
#define SeqAddr2 (0x2aaa)
#define SeqCom2 (0x55)
#define SoftIdEntry (0x90)
#define ManuIdAddr (0x0000)
#define DevIdAddr (0x0001)
/////////////////////////////20071214 读NOR FLASH ID
void __irq MEint4567Isr(void);
extern void __irq Eint4567Isr(void);
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void sdram_test(void);
extern void rtl8019_test(void);
extern void SL811Main(void);
extern void sdmmc_test(void);
extern void led_test(void);
extern void Datagram_test(void);
extern void udp_draw(void);
volatile char exeLoadedcode=0;
volatile char Mwhich_int=0;
extern char which_int;
unsigned int mycount,mycount1,mycount2,mycount3,mycount4,myremove,rw_flag;
unsigned int error0,error1,error2,error3;
unsigned int mycount5,mycount6,mycount8,mycount9;
unsigned int nor_flash_temp;
void SST39VF160_CheckId(void);
extern void lcd_test(void);
extern void IDE_test(void);
/****************************************************************
* S3C44B0X developer's notes *
****************************************************************
1.
***************************************************************/
void * function[][2]=
{
(void *)play_Udisc, "SL811 Host(FAT16/32) ",
(void *)sl811_slave, "SL811 Slave ",
0,0
};
/*******************main function*************************/
void Main(void)
{
int i,j,k,mck,M_div,P_div,S_val;
unsigned int save_G,save_PG;
int mdiv,pdiv,sdiv;
rSYSCFG=CACHECFG;
//__rt_lib_init(); //for ADS 1.0
mdiv=0x3a;
pdiv=0x3;
sdiv=0x1;
ChangePllValue(mdiv,pdiv,sdiv);
// ChangePllValue(0x3a,0x3,0x1); //10MHZ INPUT
// ChangePllValue(12,0x3,0x1); //10MHZ INPUT 20M OUTPUT
// mck=( (12+8)*10000000 )/( (3+2)*2 );
mck=( (mdiv+8)*10000000 )/( (pdiv+2)*2 );
Port_Init();
Isr_Init();
// Uart_Init(0,115200);
Uart_Init(mck,115200);
//Uart_Init(mck,9600);
//rSBUSCON=(1<<31)|(3<<6)|(2<<4)|(1<<2)|(0); //nBREQ>BDMA>ZDMA>LCD_DMA
for(i=0;i<3;i++)
{
Led_Display1(0x07); //LED点亮/熄灭状态设置
Delay(1000); //延时若干个100us
Led_Display1(0x0);
Delay(1000);
}
Uart_Select(0);
Delay(0); //calibrate Delay()
Beep(0x01);
//Led_Display(0xf);
Uart_Printf("\n---------------------------------------------------------------");
Beep(0x00);
Uart_Printf("\n EUE44B0 V2.0 \n");
Uart_Printf("\n 长沙明伟电子有限公司 www.31dsp.com ");
Uart_Printf("\n 电气电子海洋门户网站 www.eesea.com ");
Uart_Printf("\n 联合推出 \n ");
Uart_Printf("\nConfig: 115.2kbps,8Bit,NP,UART0, rSYSCFG=0x%x MCLK=%dHz",rSYSCFG,mck);
// Uart_Printf("\n---------------------------------------------------------------");
// Uart_Printf("\nS3C44B0X Test Program Ver 2.0 );
/***Wait for LCD test***/
/* rINTCON=0x1;//disable fiq, enable irq
pISR_EINT4567=(int)Eint4567Isr;
Uart_Printf("\nPress Exint4 or Exint5 to enter LCD test!\n");
save_G=rPCONG;
save_PG=rPUPG;
rPCONG=0xffff; //EINT7~0
rPUPG=0x0; //pull up enable
rEXTINT=0x22222222; //Falling edge mode
rINTMSK=~(BIT_GLOBAL|BIT_EINT4567);
Uart_Printf(".");
which_int=0;
i=0;
while((i<12)&&(which_int==0))
{
Delay(1500);
Uart_Printf("...");
i++;
}
if(which_int!=0)
{
switch(which_int)
{
case 1:
( (void (*)(void)) (function[15][0]) )();
break;
case 2:
( (void (*)(void)) (function[14][0]) )();
break;
default:
break;
}
}
*/
nor_flash_temp=0;
while(1)
{
i=0;
Uart_Printf("\n---------------------------------------------------------------");
Uart_Printf("\nThe function list to test :\n");
while(1)
{ //display menu
Uart_Printf("%2d:%s",i+1,function[i][1]);
i++;
if((int)(function[i][0])==0)
{
Uart_Printf("\n");
break;
}
if((i%3)==0)
Uart_Printf("\n");
}
//Led_Display(0x0);
Uart_Printf("\nSelect the function to test?");
i=Uart_GetIntNum();
i--;
Uart_Printf("\n");
if(i>=0 && (i<(sizeof(function)/6)) )
( (void (*)(void)) (function[i][0]) )();
}
}
void Isr_Init(void)
{
pISR_UNDEF=(unsigned)HaltUndef;
pISR_SWI =(unsigned)HaltSwi;
pISR_PABORT=(unsigned)HaltPabort;
pISR_DABORT=(unsigned)HaltDabort;
//rINTCON=0x1; // Vectored Int. IRQ enable,FIQ disable
rINTCON=0x5; // Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; // All=IRQ mode
rINTMSK|=BIT_GLOBAL|BIT_EINT4567;
// rINTMSK=BIT_GLOBAL; // All interrupt is masked.
}
void __irq MEint4567Isr(void)
{
rINTMSK|=(BIT_GLOBAL|BIT_EINT4567);
exeLoadedcode=1;
Mwhich_int=rEXTINTPND;
rEXTINTPND=0x0f; //clear EXTINTPND reg.
rI_ISPC=BIT_EINT4567; //clear pending_bit
rINTMSK&=~(BIT_GLOBAL|BIT_EINT4567);
}
void HaltUndef(void)
{
Uart_Printf("Undefined instruction exception!!!\n");
while(1);
}
void HaltSwi(void)
{
Uart_Printf("SWI exception!!!\n");
while(1);
}
void HaltPabort(void)
{
Uart_Printf("Pabort exception!!!\n");
while(1);
}
void HaltDabort(void)
{
Uart_Printf("Dabort exception!!!\n");
while(1);
}
void sdram_test(void)
{
unsigned int i,j,error;
error=0;
//DelayMs(2);
j=BEGINADDR;
for(i=0;i<1024;i++)
{
WR_sdram(j,0xaa55);
j+=2;
}
j=BEGINADDR;
for(i=0;i<1024;i++)
{
if((RD_sdram(j))!=0xaa55)
error++;
j+=2;
}
if(error==0)
Uart_Printf("SDRAM verify complete! No errors!\n");
else
Uart_Printf("Error:%d\n",error);
}
void SST39VF160_CheckId(void)
{
INT16U usManId,usDevId;
char *usManId1;
char *usDevId1;
char aa;
Uart_Printf("注意:如果程序在FLASH中运行,请勿运行该NORFLASH测试子程序,否则会更改\n");
Uart_Printf("NORFLASH中的内容,进而使程序不能正常启动\n");
Uart_Printf("如果程序是AXD调试状态下,在SDRAM中运行,则可正常使用!\n");
Uart_Printf("--------------------Run this test:Read ID? (Y/N)-----------------------");
// Led_Display(0x0);
aa= Uart_Getch();
if((aa=='Y')||(aa=='y'))
{
_RESET();
// _WR(SeqAddr1,SeqCom1);
// _WR(SeqAddr2,SeqCom2);
// _WR(SeqAddr1,SoftIdEntry);
_WR(0x555,0xaa);
_WR(0x2aa,0x55);
_WR(0x555,0x90);
usManId=_RD(ManuIdAddr);
usDevId=_RD(DevIdAddr);
_RESET();
switch(usManId)
{
case 0x1:
usManId1="AMD";
break;
case 0xbf:
usManId1="SST";
break;
default:
usManId1="No record";
break;
}
switch(usDevId)
{
case 0x236b:
usDevId1="SST39VF6401";
break;
case 0x236d:
usDevId1="SST39VF6401B";
break;
default:
usDevId1="No record";
break;
}
Uart_Printf("\nManufacturer:%s(0x%x)\n",usManId1,usManId);
Uart_Printf("Device ID:%s(0x%x)\n",usDevId1,usDevId);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -