misc.c

来自「eCos/RedBoot for勤研ARM AnywhereII(4510) 含」· C语言 代码 · 共 51 行

C
51
字号
//========================================================================
//
//    misc.c
//
//    ARM misc functions
//
//========================================================================
//==========================================================================
//#####DESCRIPTIONBEGIN####
//
// Author(s):    Sonys <sonys@163.com>
// Contributors: 
// Date:         2004-06-17
// Purpose:      
// Description:  I modified this from STRONG LED example
//
// Copyright (C) 2004 DevBone Software 
// All rights reserved.
//####DESCRIPTIONEND####
//==========================================================================
/* WATCHDOG */
#define rWTCON		(*(volatile unsigned *)(0x1d30000))
#define rWTDAT		(*(volatile unsigned *)0x1d30004)
#define rWTCNT		(*(volatile unsigned *)0x1d30008)
#define MCLK			64000000

void Delay(int time)
{
	static int DelayLoopCount = 400;
	int i,adjust=0;
	if(time==0)
	{
		time=200;
		adjust=1;
		DelayLoopCount=400;
		rWTCON=((MCLK/1000000-1)<<8)|(2<<3);
		rWTDAT=0xffff;    rWTCNT=0xffff;   
		rWTCON=((MCLK/1000000-1)<<8)|(2<<3)|(1<<5);
	}

	for(;time>0;time--)
		for(i=0;i<DelayLoopCount;i++);
			if(adjust==1)
			{
				rWTCON=((MCLK/1000000-1)<<8)|(2<<3);
				i=0xffff-rWTCNT;
				DelayLoopCount=8000000/(i*64);
			}
}

⌨️ 快捷键说明

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