📄 ucosii.cpp
字号:
/////////////////////////////////////////////////////////////////////
// Quantum Framework uCOS-II port (C++ version)
// Copyright (c) 2007 Violent.Wei
// All Rights Reserved.
/////////////////////////////////////////////////////////////////////
#include "qassert.h"
#include "port.h"
DEFINE_THIS_FILE;
//...................................................................
const char *QF::getVersion()
{
return "QF/RTK32 version 2.1.0";
}
//...................................................................
void QF::osInit()
{
OSInit();
}
//...................................................................
void QF::osCleanup()
{
ASSERT(0); // should not run here!
}
//...................................................................
void QF::background()
{
ASSERT(0); // uCOSII does not support background processing
}
//...................................................................
void QActive::run()
{
QHsm::init(); // execute initial transition
for (;;)
{
QEvent *e;
INT8U err;
e = (QEvent*)OSQPend(myEqueue, 0, &err);
ASSERT(err == OS_NO_ERR);
dispatch(e); // dispatch evt to the statechart
QF::propagate(e); // propagate to the next subscriber
}
}
//...................................................................
static void run(void *a)
{
((QActive *)a)->run();
}
// start ............................................................
int QActive::start(unsigned prio, QEvent *qSto[], unsigned qLen,
int stkSto[], unsigned stkLen)
{
myPrio = prio;
QF::add(this); // make QF aware of this active object
REQUIRE(stkSto != 0);
REQUIRE(qSto != 0);
REQUIRE(prio <= OS_MAX_TASKS);
myEqueue = OSQCreate((void**)qSto, qLen);
if (!myEqueue)
{
return 0; // failed to create uCOSII queue -- return error
}
myThread = prio;
if (OSTaskCreate(::run,
(void*)this,
(OS_STK*)stkSto,
prio) != OS_NO_ERR)
{
return 0; // failed to create uCOSII queue -- return error
}
return !0; // return success
}
// stop .............................................................
void QActive::stop()
{
QF::remove(this);
OSTaskDel(myThread);
}
//...................................................................
int QActive::enqueue(QEvent *e)
{
return !OSQPost(myEqueue, e);
}
//...................................................................
void QActive::postFIFO(QEvent *e)
{
REQUIRE(e->useNum == 0); // event must not be in use
ALLEGE(!OSQPost(myEqueue, e));
}
//...................................................................
void QActive::postLIFO(QEvent *e)
{
REQUIRE(e->useNum == 0); // event must not be in use
ALLEGE(!OSQPostFront(myEqueue, e));
}
/////////////////////////////////////////////////////////////////////
// NOTE01:
// NOTE02:
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -