📄 main.c
字号:
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\def.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\drv\flash.h"
#include "..\inc\download.h"
#include "..\inc\cache.h"
#include "..\inc\lcd320.h"
#include "..\inc\tchScr.h"
#include "..\inc\Netcfg.h"
#include "..\inc\biosfunc.h"
#include "drv/zlg7289.h"
#include "drv/ADC-S3C44B0.h"
#include "drv/RTC-S3C44B0.h"
#include "drv/IIS-S3C44B0.h"
#include "drv/DAC-Max504.h"
#include "drv/KeyBoard.h"
#include "drv/MotorCtrl.h"
#include "drv/MCP2510.h"
#include "../inc/drv/exio.h"
#include "d12/d12ci.h"
#include "d12/usb.h"
#include "d12/isr.h"
#include "fat16/file.h"
//#include <stdio.h>
volatile unsigned int err=0;
extern unsigned char *downPt;
extern unsigned int fileSize;
void Isr_Init(void);
void __irq Uerror(void);
static void (*run)(void)=(void (*)(void))DOWNLOAD_ADDRESS;
/*------------------------Bios function-------------------------------------*/
void LCD_Test()
{
Uart_Printf("\nPlease look at LCD.");
Uart_Printf("\nPress any key return.");
LCD_printf("Hello.\n");
LCD_printf("This is LCD text Mode\n");
LCD_printf("Please wait.....\n");
LCD_printf("Then show LCD gray bar.\n");
LCD_printf("Press any key return.\n");
Delay(20000);
LCD_TestShow();
Uart_Getch(0);
}
void FormatNandFlash()
{
Uart_Printf("\nWaring: You will lost all of data in Nand Flash!");
Uart_Printf("\nAre you sure?[y/n]");
if(Uart_Getch(0)=='y')
Format_Fat12Media();
}
void EnterUsbDisk()
{
Set_UartLoopFunc(USB_Loop);
reconnect_USB();
Uart_Printf("\nEntering USB Disk state,please waiting...");
}
void BootSystem()
{
Boot(NULL);
}
Bios_function LCD_Test_func={
LCD_Test,
"Test LCD",
'l',
"Lcdtest",
NULL
};
Bios_function LED_Test_func={
Zlg7289_Test,
"Test LED",
'e',
"LEDtest",
NULL
};
Bios_function Format_func={
FormatNandFlash,
"Format Nand Flash To FAT",
'o',
"format",
NULL
};
Bios_function Mifconfig_func={
SetNetWork,
"Show and Set Net address",
'n',
"mifconfig",
NULL
};
Bios_function EnterUSB_func={
EnterUsbDisk,
"Enter USB Disk",
'u',
"usbstart",
NULL
};
Bios_function ADTest_func={
ADTest,
"Enter Test ADC Mode",
'a',
"testad",
NULL
};
Bios_function KeyTest_func={
Key_Test,
"Enter Test Key Mode",
'k',
"testkey",
NULL
};
Bios_function TchScr_func={
TchScr_Test,
"Test Touch pad",
's',
"testtp",
NULL
};
Bios_function TchScrSet_func={
SetTouchScr,
"Set Touch pad Mode",
'h',
"settp",
NULL
};
Bios_function DATest_func={
DA_Test,
"Enter Test DA Mode",
'd',
"testDA",
NULL
};
Bios_function RTCTest_func={
RTC_Test,
"Enter RTC Test Mode",
't',
"time",
NULL
};
Bios_function AudioTest_func={
Audio_Test,
"Enter Audio Test Mode",
'i',
"audio",
NULL
};
Bios_function MotorTest_func={
Motor_Test,
"Enter Motor Test Mode",
'm',
"motor",
NULL
};
Bios_function CAN_func={
CAN_Test,
"Enter CAN bus Test Mode",
'c',
"can",
NULL
};
Bios_function boot_func={
BootSystem,
"Boot default system",
'b',
"boot",
NULL
};
extern Bios_function Flash_Tools_func;
Bios_function* sysfunc[]={&Flash_Tools_func, &LCD_Test_func, &Format_func, &Mifconfig_func,
&EnterUSB_func, &LED_Test_func, &KeyTest_func, &TchScr_func,
&TchScrSet_func, &ADTest_func, &DATest_func, &RTCTest_func,
&AudioTest_func, &MotorTest_func, &CAN_func, &boot_func};
#define SYSFUNCNUM (sizeof(sysfunc)/sizeof(Bios_function*))
/*------------------------Bios function end-------------------------------------*/
void ShowShellMenu()
{
int i,j;
Uart_Printf("\n*--------------------------Shell Menu-----------------------------------*");
for(i=0;i<SYSFUNCNUM;i++){
Uart_Printf("\n* %c >>%s",sysfunc[i]->MenuAcc,sysfunc[i]->pShellMenu);
for(j=51-strlen(sysfunc[i]->pShellMenu);j>0;j--) //补齐空格
Uart_SendByte(0, ' ');
Uart_SendByte(0, '*');
}
Uart_Printf("\n*-----------------------------------------------------------------------*");
}
void Main(void)
{
float Version=2.00;
int i;//memError=0;
char aa;
U32 mode;
int x,y;
rSYSCFG=CACHECFG; // Using 8KB Cache//
Port_Init();
Set_D12CLK();//set clk 12M
Isr_Init();
Uart_Init(0,115200);
init_SIO();
Delay(100);
downPt=(unsigned char *)DOWNLOAD_ADDRESS;
/*******************************/
/* Cache test */
/*******************************/
for(i=0;i<100;i++)
Uart_SendByte(0,0xff);
Uart_Printf("\nBIOS start:OK!");
Delay(100);
LCD_Init();
LCD_printf("Testing Cache...");
if(Test_Cache()){
Uart_Printf("\nCache Test:OK!");
LCD_printf("Cache Test:OK!\n");
}
else{
Uart_Printf("\nCache Test:FAIL!");
LCD_printf("Cache Test:FAIL!\n");
for(;;);
}
Flash_Reset();
if(Check_Flash_Id()==KM29U128_ID)
{
Uart_Printf("\nKM29U128T is found.");
LCD_printf("KM29U128T is found.\n");
}
else
{
Uart_Printf("\nKM29U128T is not found.");
LCD_printf("KM29U128T is not found.\n");
}
Uart_Printf("\n*************************************************************************");
Uart_Printf("\n* UpNet-ARM3000 Bootloader Ver %1.2f *",Version);
Uart_Printf("\n* COM:115.2kbps,8Bit,NP,UART0 *");
Uart_Printf("\n* Build Time: 2003-07-25 *");
Uart_Printf("\n*-----------------------------------------------------------------------*");
LCD_printf("******************************\n");
LCD_printf("* Embeded Controller *\n");
LCD_printf("* BIOS ver 1.1 *\n");
LCD_printf("* Copyright 2002-2007 *\n");
LCD_printf("* By Up-tech *\n");
LCD_printf("* Build Time: 2002-7-30 *\n");
LCD_printf("******************************\n");
LCD_printf("Enter BIOS test mode\n");
LCD_printf("press any key\n");
//Delay(8000);
//if(!IsKeyDown()){ //无按键按下,正常引导系统
// Uart_Printf("\nAuto Boot\n");
// Boot(NULL);
// for(;;);
//}
//有按键按下,进入BIOS 测试状态
LCD_printf("Enter the Embedded System BIOS\n");
EnterUsbDisk();
for(;;)
{
// Delay(10000);
ShowShellMenu();
aa=Uart_Getch(0);
for(i=0;i<SYSFUNCNUM;i++){
if(sysfunc[i]->MenuAcc == aa)
sysfunc[i]->func();
}
// Uart_Printf("\n* F(f)>>Flash Rom Tools *");
// Uart_Printf("\n* R(r)>>Enter USB Disk *");
// Uart_Printf("\n* L(l)>>LCD test *");
// Uart_Printf("\n* O(o) >>Format Media To FAT *");
// Uart_Printf("\n* 1 >>Run Demo1.bin *");
// Uart_Printf("\n* K(k)>>KeyBoard Test *");
// Uart_Printf("\n* T(t)>>Touch Screent Test *");
// Uart_Printf("\n* S(s)>>Set touch Screen *");
// Uart_Printf("\n* N(n)>>Show and Set Net address *");
// Uart_Printf("\n*-----------------------------------------------------------------------*");
/* aa= Uart_Getch(0);
switch(aa)
{
case 'f':
case 'F':
Flash_Tools();
break;
case 'r':
case 'R':
reconnect_USB();
// Delay(10000);//it should be delay a long time for pc software stable
Uart_Printf("\nEntering USB Disk state,please waiting...");
for(;;){
if (bEPPflags.bits.setup_packet){
DISABLE;
bEPPflags.bits.setup_packet = 0;
ENABLE;
control_handler();
//D12SUSPD = 1;
D12SUSPD=D12SUSPD_OFF;
} // if setup_packet
}
break;
case 'l':
case 'L':
Uart_Printf("\nPlease look at LCD.");
Uart_Printf("\nPress any key return.");
LCD_printf("Hello.\n");
LCD_printf("This is LCD text Mode\n");
LCD_printf("Please wait.....\n");
LCD_printf("Then show LCD gray bar.\n");
LCD_printf("Press any key return.\n");
Delay(20000);
LCD_TestShow();
Uart_Getch(0);
break;
case 'O':
case 'o':
Format_Fat16Media();
break;
case '1':
LOAD_DEMO1_CODE();
break;
case 'k':
case 'K':
Uart_Printf("\n");
Uart_Printf("press any key get the scan number\n");
while(1){
U32 getkey=GetKey();
static U8 key[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
Uart_SendByte(0,key[getkey]);
}
break;
case 't':
case 'T':
Uart_Printf("\n");
TchScr_init();
Uart_Printf("please touch the screen\n");
for(;;){
mode=TchScr_GetOSXY(&x, &y);
switch(mode){
case TCHSCR_ACTION_CLICK:
Uart_Printf("Action=click:x=%d,\ty=%d\n",x,y);
break;
case TCHSCR_ACTION_DBCLICK:
Uart_Printf("Action=double click:x=%d,\ty=%d\n",x,y);
break;
case TCHSCR_ACTION_DOWN:
Uart_Printf("Action=down:x=%d,\ty=%d\n",x,y);
break;
case TCHSCR_ACTION_UP:
Uart_Printf("Action=up:x=%d,\ty=%d\n",x,y);
break;
case TCHSCR_ACTION_MOVE:
Uart_Printf("Action=move:x=%d,\ty=%d\n",x,y);
break;
}
Delay(1000);
}
break;
case 's':
case 'S':
TchScr_init();
SetTouchScr();
break;
case 'n':
case 'N':
SetNetWork();
break;
}*/
}
}
void Isr_Init(void)
{
rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable //
rINTMOD=0x0; //All=IRQ mode//
// rINTMSK=~(BIT_EINT0 | BIT_GLOBAL); //Default value=0x7ffffff//
//pISR_FIQ,pISR_IRQ must be initialized//
pISR_EINT0=(unsigned)usb_isr;
rI_ISPC=BIT_EINT0;
}
void __irq Uerror(void)
{
rI_ISPC=BIT_UERR01 ; //clear pending bits,Default value=0x0000000//
err++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -