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

📄 time.c

📁 Intel PXA270的bootloader程序,在linux环境下运行的.
💻 C
字号:
#include <hardware.h>#include <time.h>static unsigned long msecond_boundary;static int udelay_init(void);bool time_init(void){	udelay_init();	RCNR = 0;	OSCR = 0;	return true;}time_t time(time_t *t){	*t = RCNR;		// 1 Hz	return *t;}clock_t clock(void){	return OSCR;	// 3.6864 MHz}/* * 100000 : a / 3686400 s = x : 1 / 1000 s * x = 3686400 * 100000 / (1000 * a) * x = 368640000 / a */static int udelay_init(void){	unsigned long i, diff;	OSCR = 0;	for (i=0; i < 100000; i++);	diff = OSCR;	msecond_boundary = 368640000 / diff;	//printf("udelay : msecond_boundary : %d [0x%08lx]\n", msecond_boundary, msecond_boundary);	return 0;}void udelay(unsigned long usecs){	unsigned long i;	for (i=0; i < msecond_boundary * usecs / 1000; i++);	return;}void mdelay(unsigned long msecs){	while (msecs-- > 0)		udelay(1000);	return;}

⌨️ 快捷键说明

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