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

📄 common.c

📁 RC531
💻 C
字号:
#include "MyLib.h"
#include <stdlib.h>

extern void ENABLE_DCACHE(void);
extern void IIC_init(void);
void Switch_init(void);

void Sys_init(void)				// Copy 256KB HZK to SDRAM
{
	PageTable_init();
//	MyMemcpy32((U32*)0xA0040000, (U32*)0x40000, 0x40000);
	ENABLE_DCACHE();
	CPU_setspeed(400);
}

void Sys_init2(void)				// Copy 512KB program to SDRAM
{
	PageTable_init();
	MyMemcpy32((U32*)0xA0000000, (U32*)0, 0x80000);
	ENABLE_DCACHE();
	CPU_setspeed(400);
}

void Dev_init(U32 mode)
{
	U8 MyPhy[6];
	GPDR2=0x8000;					// Set GPIO[79]=output(nCS3)
	GAFR2_L|=0x80000000;			// bit31=1
	GAFR2_L&=~0x40000000;		// bit30=0	Set GPIO[79]=nCS3=DM9000_CS
	PSSR=0x20;						// Enable all GPIO input pins
	BT232_init();
	//HW232_init();
	//FF232_init();
	MyPhy[0]=0x02;  MyPhy[1]=0x04;  MyPhy[2]=0x06;
	MyPhy[3]=0x08;  MyPhy[4]=0x0A;  MyPhy[5]=0x0E;
	DM9000_SetPhy(MyPhy);
	DM9000_init();
	Arp_init();
//	LCD_init();
	Switch_init();
//	GPSR0|=0x10;				// RS232/485 mode
	if(mode){
		Delay_us(200000);
		IIC_init();
	}
	CPU_setspeed(400);
}

void Switch_init(void)
{
	GPDR0|=0x10;					// Control=GPIO[4]
}

void Switch_mode(U32 mode)
{
	if(mode){
		GPSR0=0x10;				// RS232/485 mode
	}else{
		GPCR0=0x10;				// Ethernet mode
	}
}

⌨️ 快捷键说明

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