📄 flash_main.c
字号:
//====================================================================
// File Name : flash_main.c
// Function : S3C2440 Test Main Menu
// Program : Terminator
// Date : July 1, 2008
// Version : 0.0
// History
// 0.0 : Programming start (July 1,2008) ->
//====================================================================
#include <stdlib.h>
#include <string.h>
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "mmu.h"
#include "Nand.h"
#include "DownLoader.h"
#if USE_MAIN
#include <stdio.h>
#endif
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
extern void Calc_Clock(int print_msg);
extern U32 Mdiv, Pdiv, Sdiv, Fclk, Hclk, Pclk, Hdivn, Pdivn, Hclk_Ratio, Pclk_Ratio, Ref_Cnt;
void xmain(void)
{
int i;
// GPIO port init.
Port_Init();
Led_Display(0xf);
// MMU init. I/D cache on.
MMU_Init();
Led_Display(0x1);
Calc_Clock(0);
Isr_Init();
Uart_Init(Pclk, 115200);
Uart_Select(1);
Uart_TxEmpty(1);
// timer setting for delay 100us unit.
//Check whether or not the POWER_OFF wake-up.
//Delay(0); //calibrate Delay()
// Set I/O strength control.
//rDSC0 = (0<<31)|(0x3<<8)|(0xff<<0);
rDSC0 = (0<<31)|(0x0<<8)|(0x00<<0);
// nEN_DSC [31] : 0:I/O drive strength enable, 1:Disable
// DSC_ADR [9:8] : Addr drive strength, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_DATA [7:0] : DATA drive strength, 0:12mA, 1:10mA, 2:8mA, 3:6mA
//rDSC1 = (0x3<<28)|(0x3<<26)|(0xfffff<<0);
rDSC1 = (0x0<<28)|(0x0<<26)|(0x00000<<0);
// DSC_SCK1 [29:28] : SCLK1, 0:16mA, 1:12mA, 2:8mA, 3:6mA
// DSC_SCK0 [27:26] : SCLK0, 0:16mA, 1:12mA, 2:8mA, 3:6mA
// DSC_SCKE [25:24] : SCLKE, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_SDR [23:22] : nRAS/nCAS, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_NFC [21:20] : Nand flash(nFCE,nFRE,nFWE,CLE,ALE), 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_BE [19:18] : nBE[3:0], 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_WOE [17:16] : nBE[3:0], 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS7 [15:14] : nGCS7, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS6 [13:12] : nGCS6, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS5 [11:10] : nGCS5, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS4 [9:8] : nGCS4, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS3 [7:6] : nGCS3, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS2 [5:4] : nGCS2, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS1 [3:2] : nGCS1, 0:10mA, 1:8mA, 2:6mA, 3:4mA
// DSC_CS0 [1:0] : nGCS0, 0:10mA, 1:8mA, 2:6mA, 3:4mA
while(1)
{
Uart_Printf("DownLoader File(-1 to exit):");
i = Uart_GetIntNum();
if(i==-1) break;
DownLoader();
}
Test_NAND();
}
//===================================================================
void Isr_Init(void)
{
pISR_UNDEF = (unsigned)HaltUndef;
pISR_SWI = (unsigned)HaltSwi;
pISR_PABORT = (unsigned)HaltPabort;
pISR_DABORT = (unsigned)HaltDabort;
rINTMOD = 0x0; //All=IRQ mode
// rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMSK = BIT_ALLMSK; //All interrupt is masked.
rINTSUBMSK = BIT_SUB_ALLMSK; //All sub-interrupt is masked. <- April 01, 2002 SOP
// rINTSUBMSK = ~(BIT_SUB_RXD0); //Enable Rx0 Default value=0x7ff
// rINTMSK = ~(BIT_UART0); //Enable UART0 Default value=0xffffffff
// pISR_UART0=(unsigned)RxInt; //pISR_FIQ,pISR_IRQ must be initialized
}
//===================================================================
void HaltUndef(void)
{
Uart_Printf("Undefined instruction exception.\n");
while(1);
}
//===================================================================
void HaltSwi(void)
{
#if !SEMIHOSTING
Uart_Printf("SWI exception!!!\n");
while(1);
#endif
}
//===================================================================
void HaltPabort(void)
{
Uart_Printf("Pabort exception.\n");
while(1);
}
//===================================================================
void HaltDabort(void)
{
Uart_Printf("Dabort exception.\n");
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -