⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chips.c

📁 可以兼容MS-DOS的文件系统和指令的S3C2410平台的DOS部分源代码,加以修改可以使用在S3C2440 S3C44B0等ARM7、ARM9上
💻 C
字号:
/*************************************Seekfor Embedded DOS v1.0***************************************************
 ******                   ***          *****                                    ******     ****     ****** v1.0
**   **                    **         **  **                                     **  **   **  **   **   ** 
**   **                    **         **                                         **   ** **    **  **   ** 
**                         **         **                                         **   ** **    **  **      
 **       *****    *****   ** ****  *******   *****  ********            *****   **   ** **    **   **     
  ***    **   **  **   **  ** **      **     **   **   *** **           **   **  **   ** **    **    ***   
    **   *******  *******  ****       **     **   **   **               *******  **   ** **    **      **  
     **  **       **       *****      **     **   **   **               **       **   ** **    **       ** 
**   **  **       **       ** **      **     **   **   **               **       **   ** **    **  **   ** 
**   **  **   **  **   **  **  **     **     **   **   **               **   **  **  **   **  **   **   ** 
******    *****    *****  ********  ******    *****  ******              *****  ******     ****    ******  
<1)基本描述
	Seekfor Embedded DOS v1.0是嵌入式的一个类DOS操作系统,支持FAT16/FAT32.
<2)文件描述
	文件名:chips.c
	功能:S3C2410 CPU初始化
<3>如需更新版本软件,请联系:
	QQ:82054357
	Mail:Seek_for@163.com
	MSN:sfrad32@hotmail.com
**************************************************************************************************************/
#ifndef __CHIPS_C__
#define __CHIPS_C__
#include "dos.h"


static void PORT_init()
{
	/*PORT A:全部保留为系统地址使用*/
	rGPACON=0x007fffff;
	/*PORT B:GPB.0,GPB.1是LED,其他保留为系统所用*/
	rGPBCON=0x2aaaa5;
	rGPBDAT=0x3ff;/*LED灭*/
	rGPBUP=0x0000;/*允许上拉*/

	/*PORT C:全部保留为LCD使用*/
    rGPCUP=0xffffffff;
 	rGPCCON=0xaaaaaaaa;
	/*PORT D:全部保留为LCD使用*/
    rGPDUP=0xffffffff;
 	rGPDCON=0xaaaaaaaa;

 	/*PORT E:全部保留为第三功能*/
	rGPECON=0xAA9016AA;
	/*PORT F:GPF.0~GPF.2,为按键,其他保留为第三功能*/
	rGPFCON=0xaa80;
	/*PORT G:GPG.5按键,其他保留为第三功能*/
	rGPGCON=0xAAAAA2AA;
	/*PORT H:全部是系统保留功能*/
	rGPHCON=0x002aaaaa;
}

static void UART_init()
{
	int div=(CPU_FREQUENCY/COM1_CBR/64)-1;
	rULCON0=0x03;
	rULCON1=0x03;
	rULCON2=0x03;
	rUCON0=0x05;
	rUCON1=0x05;
	rUCON2=0x05;
	rUFCON0=0x00;
	rUFCON1=0x00;
	rUFCON2=0x00;
	rUBRDIV0=div;
	div=(CPU_FREQUENCY/COM2_CBR/64)-1;
	rUBRDIV1=div;
	div=(CPU_FREQUENCY/COM3_CBR/64)-1;
	rUBRDIV2=div;
}

static void NAND_init()
{
	rNFCONF=0x8777;
	rNFCMD=0xff;
}

static void RTC_init()
{
	date sys_date;
	time sys_time;
	rRTCCON=0x01;
	getdate(&sys_date);
	gettime(&sys_time);
	if(sys_date.da_year>2099||sys_date.da_mon>12||sys_date.da_day>31||sys_time.ti_hour>23||sys_time.ti_min>59||sys_time.ti_sec>59)
	{
		rBCDYEAR=0x06;
		rBCDMON=0x01;
		rBCDDATE=0x01;
		rBCDHOUR=0x00;
		rBCDMIN=0x00;
		rBCDSEC=0x00;
	}
}


static void TIMER_init()
{
	rTCFG0=(PERSCALER<<8)|PERSCALER;
	rTCFG1=0x00;/*所有定时器mux分频是1/2*/
}


void Devices_init()
{
#if(SUPPORT_COM1==1)
	Device_install("COM1:",READABLE|WRITEABLE|SHARE_READ|SHARE_WRITE,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)COM1_Read,(DEVICE_WRITE)COM1_Write,(DEVICE_ESCAPE)0);
#endif
#if(SUPPORT_COM2==1)
	Device_install("COM2:",READABLE|WRITEABLE|SHARE_READ|SHARE_WRITE,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)COM2_Read,(DEVICE_WRITE)COM2_Write,(DEVICE_ESCAPE)0);
#endif
#if(SUPPORT_COM3==1)
	Device_install("COM3:",READABLE|WRITEABLE|SHARE_READ|SHARE_WRITE,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)COM3_Read,(DEVICE_WRITE)COM3_Write,(DEVICE_ESCAPE)0);
#endif
#if(SUPPORT_KBD==1)
	Device_install("KBD:",READABLE|SHARE_READ,	(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)KBD_Read,(DEVICE_WRITE)0,(DEVICE_ESCAPE)0);
#endif	
#if(SUPPORT_LED==1)
	Device_install("LED:",WRITEABLE|SHARE_WRITE,(DEVICE_OPEN)LED_Open,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)LED_Read,(DEVICE_WRITE)LED_Write,(DEVICE_ESCAPE)0);
#endif
#if(SUPPORT_TIMER0==1)
	Device_install("TIMER0:",WRITEABLE|READABLE|SHARE_READ,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)TIMER0_Read,(DEVICE_WRITE)TIMER0_Write,(DEVICE_ESCAPE)TIMER0_Escape);
#endif
#if(SUPPORT_TIMER1==1)
	Device_install("TIMER1:",WRITEABLE|READABLE|SHARE_READ,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)TIMER1_Read,(DEVICE_WRITE)TIMER1_Write,(DEVICE_ESCAPE)TIMER1_Escape);
#endif
#if(SUPPORT_TIMER2==1)
	Device_install("TIMER2:",WRITEABLE|READABLE|SHARE_READ,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)TIMER2_Read,(DEVICE_WRITE)TIMER2_Write,(DEVICE_ESCAPE)TIMER2_Escape);
#endif
#if(SUPPORT_TIMER3==1)
	Device_install("TIMER3:",WRITEABLE|READABLE|SHARE_READ,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)TIMER3_Read,(DEVICE_WRITE)TIMER3_Write,(DEVICE_ESCAPE)TIMER3_Escape);
#endif
#if(SUPPORT_TIMER4==1)
	Device_install("TIMER4:",READABLE|SHARE_READ,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)TIMER4_Read,(DEVICE_WRITE)0,(DEVICE_ESCAPE)TIMER4_Escape);
#endif
#if(SUPPORT_I2S==1)
	Device_install("I2S:",WRITEABLE,(DEVICE_OPEN)Device_CommonOpen,(DEVICE_CLOSE)Device_CommonClose,(DEVICE_READ)0,(DEVICE_WRITE)I2S_Write,(DEVICE_ESCAPE)0);	
#endif
}

static void FAT_init()
{
#if(SUPPORT_SD==1)
	void SD_init();
#endif
#if(SUPPORT_NAND==1)
	FORMAT_PARAMS nand_fmt=NAND_PARMS;
#endif
#if(SUPPORT_NAND==1)
	if(!FAT_install(nand_fmt.dwStart,nand_fmt.lpfnErase,nand_fmt.lpfnRead,nand_fmt.lpfnWrite,nand_fmt.user_data))
	{
		FAT_format((DRIVER_INFO*)0,&nand_fmt);
		FAT_install(nand_fmt.dwStart,nand_fmt.lpfnErase,nand_fmt.lpfnRead,nand_fmt.lpfnWrite,nand_fmt.user_data);
	}
#endif

#if(SUPPORT_SD==1)
	SD_init();
#endif

#if(SUPPORT_NOR==1)

#endif	

#if(SUPPORT_HD==1)

#endif

}

extern void MMU_InvalidateICache();
extern void MMU_InvalidateDCache();
extern void	MMU_EnableDCache();
extern void MMU_EnableICache();

void CACHE_ENABLE()
{
	MMU_EnableDCache();
	MMU_EnableICache();
}
void CACHE_CLEAR()
{	
	MMU_InvalidateDCache();
	MMU_InvalidateICache();
}

void S3C2410_init()
{
	CACHE_ENABLE();
	PORT_init();
	NAND_init();
	UART_init();
	RTC_init();
	TIMER_init();
#if(SUPPORT_I2S==1)
	I2S_init(0x03);
#endif
	FAT_init();	
	Devices_init();
	INTERRUPT_init();
#if(SUPPORT_GRAPHICS==1)
	LCD_init();
#endif
}
















#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -