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

📄 looptime.c

📁 UC/OS 在SparcLite 上的移植范例
💻 C
字号:
/*
; ---------------------------------------------------------------------------
; File:	looptimer.c
;
; uC/OS Real-time multitasking kernel for the SparcLite processor.
;
; main program: sets up timer 2 for 20/second, times a loop
;
; Created by Brad Denniston, Viewpoint Engineering  (bradd@vpeng.com).;
; ---------------------------------------------------------------------------
*/

#include "ucos.h"
#include "cpu.h"

OS_TCB	*OSTCBCur;
OS_TCB	*OSTCBHighRdy;

static uint OSTime = 0;
static uint	OSIntNesting = 0;

struct hist
{
	uint 	time;
	uint	count;
} history[32];

/*
; ---------------------------------------------------------------------
; main
; ---------------------------------------------------------------------
*/
main()
{
	int		lastTime = 0;
	uint	count = 0;
	int		points = 0;
	uint	time;

	CPUInit();
	printf( "Loop Timer\n" );
	while( count++ < 500000 && points < 20 )
	{
		if( (time = OSTimeGet() ) != lastTime )
		{
			history[points].count = count;
			history[points].time = time;
			points++;
			lastTime = time;
			count = 0;
		}
	}

	printf( "Count is %d, points is %d\n", count, points );
	for( points = 0; points < 20; points++ )	/* run for 5 minutes max */
	{
		printf( "%d: %ld  %d\n", points, history[points].count, 
				history[points].time );
	}
}

void OSTimeTick()
{
	OSTime++;
}

OSIntExit()
{
	OSIntNesting--;
	return( FALSE );
}

uint OSTimeGet()
{
	return( OSTime );
}

⌨️ 快捷键说明

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