time.c

来自「SMDK2440 boot code, base on vivi」· C语言 代码 · 共 71 行

C
71
字号
/* * vivi/lib/time.c: Simple timers * * Author:	Janghoon Lyu * Created:	August 05, 2002 * Copyright:	MIZI Research, Inc. * * All Rights Reserved * * $Date: 2003/08/14 09:48:13 $ * $Revision: 1.7 $ * $Id: time.c,v 1.7 2003/08/14 09:48:13 nandy Exp $ * */#include <config.h>#include <time.h>#include <vstring.h>#include <command.h>extern void arch_udelay(unsigned int usec);extern void arch_mdelay(unsigned int msec);void udelay(unsigned int usec){	arch_udelay(usec);}void mdelay(unsigned int msec){	arch_mdelay(msec);}#if 0void command_sleep(int argc, const char **argv){	int len;	unsigned int sec;	char buf[10];	char unit;	if ((argc != 2) || (strncmp(argv[1], "help", 4) == 0)) {		printk("Usage:\n");		printk("  sleep <sec> -- 1m == mili 1u == micro 1s == secon\n");		return;	}	len = strlen(argv[1]);	strncpy(buf, argv[1], len-1);	buf[len-1] = '\0';	strncpy(&unit, argv[1]+(len-1), 1);	sec = (unsigned int)simple_strtoul(buf, NULL, 0);	if (strncmp("s", (char *)&unit, 1) == 0) {		printk("sleep %d seconds\n", sec);		mdelay(sec * 1000);	} else if (strncmp("m", (char *)&unit, 1) == 0) {		printk("sleep %d mili-seconds\n", sec);		mdelay(sec);	} else if (strncmp("u", (char *)&unit, 1) == 0) {		printk("sleep %d micro-seconds\n", sec);		udelay(sec);	}}user_command_t sleep_cmd = {	"sleep",	command_sleep,	NULL};#endif

⌨️ 快捷键说明

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