📄 clock.c
字号:
/*
; ---------------------------------------------------------------------
; File: clock.c
;
; uC/OS Real-time multitasking kernel for the MIPS processor.
;
; Interrupt test - uses loop in main() to print out a clock display
;
; 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;
/*
; ---------------------------------------------------------------
* Main function.
; ---------------------------------------------------------------
*/
int
main(int argc, char **argv)
{
uint milliseconds;
uint seconds;
uint minutes;
uint hours;
ENTER_CRITICAL();
CPUInit();
EXIT_CRITICAL();
for( ;; ) {
milliseconds = OSTimeGet();
seconds = milliseconds/20;
minutes = seconds/60;
hours = minutes/60;
milliseconds -= seconds * 20;
seconds -= minutes * 60;
minutes -= hours * 60;
printf( "%d:%d:%d.%d\r", hours, minutes, seconds, milliseconds);
}
} /* main */
void OSTimeTick()
{
OSTime++;
}
OSIntExit()
{
OSIntNesting--;
return( FALSE );
}
uint OSTimeGet()
{
return( OSTime );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -