还是需要记录系统启动的状态,否则无法准确估计,导致Start之前的Sys.Sleep有问题

This commit is contained in:
nnhy 2015-10-08 12:05:06 +00:00
parent 057a2a5f39
commit b14ff9cdd2
2 changed files with 5 additions and 1 deletions

View File

@ -218,6 +218,7 @@ TSys::TSys()
Interrupt.Init();
#endif
Started = false;
OnStart = NULL;
}
@ -493,6 +494,7 @@ bool TSys::SetTaskPeriod(uint taskid, int period)
void TSys::Start()
{
Started = true;
#if DEBUG
//AddTask(ShowTime, NULL, 2000000, 2000000);
#endif
@ -509,7 +511,7 @@ void TSys::Start()
void TimeSleep(uint us)
{
// 在这段时间里面,去处理一下别的任务
if(Sys.Clock > 0 && us != 0 && us >= 50)
if(Sys.Started && us != 0 && us >= 50)
{
TaskScheduler* sc = Task::Scheduler();
// 记录当前正在执行任务

2
Sys.h
View File

@ -124,6 +124,8 @@ public:
bool SetTask(uint taskid, bool enable, int msNextTime = -1);
// 改变任务周期
bool SetTaskPeriod(uint taskid, int period);
bool Started;
void Start(); // 开始系统大循环
Func OnStart;
};