?? usrinit.c
字號:
/*
* usrInit.c
*
*/
#define CONFIGURE_INIT
#include "system.h"
#include "stdio.h"
extern int testOSClockSet();
extern int testOSClockGet();
extern int testOSClockTick();
extern int testOSTimerCreate();
extern int testOSTimerIdGet();
extern int testOSTimerDelete();
extern int testOSTimerFireAfter();
extern int testOSTimerFireWhen();
extern int testOSTimerReset();
extern int testOSTaskTimerFireAfter();
extern int testOSTaskTimerFireWhen();
static inline unsigned long long
rdtsc(void)
{
/* Return the value of the on-chip cycle counter. */
unsigned long long result;
asm volatile(".byte 0x0F, 0x31" : "=A" (result));
return result;
} /* rdtsc */
/*
* 下面的函數是ReWorks圖形工程所用,如果你寫的是圖形工程,
* 請放開下面的函數注釋,然后把gui_main()放到UserInit()中調用。
* 注意:把定義make_window()所在的頭文件包含進來
*/
/*
void gui_main()
{
Fl_Window* w=make_window();
w->show();
Fl::run();
}
*/
void UserInit(void)
{
/* Add your code here. */
printf("the test of high precision timer:\n");
double oldTime=0;
double newTime=0;
double the_time1;
double the_time2;
double the_time3;
double the_time4;
unsigned32 retTicks;
OSClockGet(OS_TICKS_PER_SECOND_GET,&retTicks);
oldTime = rdtsc();
OSTaskDelay(retTicks);
newTime = rdtsc();
the_time1 = rdtsc();
the_time2 = rdtsc();
the_time3 = rdtsc();
the_time4 = rdtsc();
printf("the current time is [%12.3f]\n",oldTime);
printf("the current time is [%12.3f]\n",newTime);
printf("the current time is [%12.3f]\n",the_time1);
printf("the current time is [%12.3f]\n",the_time2);
printf("the current time is [%12.3f]\n",the_time3);
printf("the current time is [%12.3f]\n",the_time4);
getchar();
testOSClockSet();
getchar();
testOSClockGet();
getchar();
testOSClockTick();
getchar();
testOSTimerCreate();
getchar();
testOSTimerIdGet();
getchar();
testOSTimerDelete();
getchar();
testOSTimerFireAfter();
getchar();
testOSTimerFireWhen();
getchar();
testOSTimerCancel();
getchar();
testOSTimerReset();
getchar();
testOSTaskTimerFireAfter();
getchar();
testOSTaskTimerFireWhen();
getchar();
printf("the timerTest is OK\n");
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -