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

📄 quickref.htm

📁 嵌入式系统基础课件
💻 HTM
📖 第 1 页 / 共 5 页
字号:
style='color:black'>].</span></p>

<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Return Value</b></span></p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQFlush()</span><span
style='color:black'> returns one of the following codes:</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_NO_ERR</span><span
style='color:black'> if the message queue was flushed.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_ERR_EVENT_TYPE</span><span
style='color:black'> if you attempted to flush an object other than a message
queue.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&nbsp;</span></p>

<p class=Heading><a name=OSQPend>OSQPend</a>()</p>

<p class=MsoNormal style='line-height:11.0pt;text-autospace:none'><span
style='font-size:9.0pt;font-family:"Courier New";color:black'><b>&nbsp;</b></span></p>

<p class=Prototype>        void *OSQPend(OS_EVENT *pevent, INT16U timeout,
INT8U *err);</p>

<p class=MsoNormal style='line-height:6.0pt;text-autospace:none'>&nbsp;</p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPend()</span><span
style='color:black'> is used when a task wants to receive messages from a
queue. The messages are sent to the task either by an ISR or by another task.
The messages received are pointer-sized variables, and their use is application
specific. If a at least one message is present at the queue when </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPend()</span><span
style='color:black'> is called, the message is retrieved and returned to the
caller. If no message is present at the queue, </span><span style='font-size:
9.0pt;font-family:"Courier New";color:black'>OSQPend()</span><span
style='color:black'> suspends the current task until either a message is
received or a user-specified timeout expires. If a message is sent to the queue
and multiple tasks are waiting for such a message, then MicroC/OS-II resumes
the highest priority task that is waiting. A pended task that has been
suspended with </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSTaskSuspend()</span><span style='color:black'> can receive a
message. However, the task remains suspended until it is resumed by calling </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSTaskResume().</span></p>

<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Arguments</b></span></p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='color:black'><b>pevent</b></span><span style='color:black'>
is a pointer to the queue from which the messages are received. This pointer is
returned to your application when the queue is created [see </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQCreate()</span><span
style='color:black'>].</span></p>

<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='color:black'><b>timeout</b></span><span
style='color:black'> allows the task to resume execution if a message is not
received from the mailbox within the specified number of clock ticks. A timeout
value of 0 indicates that the task wants to wait forever for the message. The
maximum timeout is 65,535 clock ticks. The timeout value is not synchronized
with the clock tick. The timeout count starts decrementing on the next clock
tick, which could potentially occur immediately.</span></p>

<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='color:black'><b>err</b></span><span
style='color:black'> is a pointer to a variable used to hold an error code. </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPend()</span><span
style='color:black'> sets *err to one of the following:</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_NO_ERR</span><span
style='color:black'> if a message was received.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_TIMEOUT </span><span
style='color:black'>if a message was not received within the specified timeout.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_ERR_PEND_ISR</span><span
style='color:black'> if you called this function from an ISR and
MicroC/OS-II would have to suspend it. In general, you should not call </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPend()</span><span
style='color:black'> from an ISR. MicroC/OS-II checks for this situation
anyway.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_ERR_EVENT_TYPE</span><span
style='color:black'> pevent is not pointing to a message queue.</span></p>

<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Return Value</b></span></p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPend()</span><span
style='color:black'> returns a message sent by either a task or an ISR, and
*err is set to </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OS_NO_ERR</span><span style='color:black'>. If a timeout occurs, </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPend()</span><span
style='color:black'> returns a NULL pointer and sets *err to </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_TIMEOUT</span><span
style='color:black'>.</span></p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='color:black'>&nbsp;</span></p>

<p class=Heading><a name=OSQPost>OSQPos</a>t()</p>

<p class=MsoNormal style='line-height:11.0pt;text-autospace:none'><span
style='font-size:9.0pt;color:black'><b>&nbsp;</b></span></p>

<p class=Prototype>        INT8U OSQPost(OS_EVENT *pevent, void *msg);</p>

<p class=MsoNormal style='line-height:6.0pt;text-autospace:none'>&nbsp;</p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPost()</span><span
style='color:black'> sends a message to a task through a queue. A message is a
pointer-sized variable, and its use is application specific. If the message
queue is full, an error code is returned to the caller. In this case, </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPost()</span><span
style='color:black'> immediately returns to its caller, and the message is not
placed in the queue. If any task is waiting for a message at the queue, the
highest priority task receives the message. If the task waiting for the message
has a higher priority than the task sending the message, the higher priority
task resumes and the task sending the message is suspended; that is, a context
switch occurs. Message queues are first-in-first-out (FIFO), which means that
the first message sent is the first message received.</span></p>

<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Arguments</b></span></p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>pevent</span><span
style='color:black'> is a pointer to the queue into which the message is
deposited. This pointer is returned to your application when the queue is
created [see </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSQCreate()</span><span style='color:black'>].</span></p>

<p class=MsoNormal style='margin-top:7.0pt;text-align:justify;line-height:12.0pt;
text-autospace:none'><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>msg</span><span style='color:black'> is the actual message sent to
the task. msg is a pointer-sized variable and is application specific. You must
never post a NULL pointer.</span></p>

<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Return Value</b></span></p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPost()</span><span
style='color:black'> returns one of two error codes:</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_NO_ERR</span><span
style='color:black'> if the message was deposited in the queue.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_Q_FULL</span><span
style='color:black'> if the queue was already full.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&#8226;&nbsp;&nbsp; </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_ERR_EVENT_TYPE</span><span
style='color:black'>  pevent is not pointing to a message queue.</span></p>

<p class=MsoNormal style='margin-top:3.0pt;margin-right:0in;margin-bottom:3.0pt;
margin-left:.2in;text-align:justify;text-indent:-.2in;line-height:12.0pt;
tab-stops:.2in;text-autospace:none'><span style='color:black'>&nbsp;</span></p>

<p class=Heading><a name=OSQPostFront>OSQPostFront</a>()</p>

<p class=Prototype>&nbsp;</p>

<p class=Prototype>        INT8U OSQPostFront(OS_EVENT *pevent, void *msg);</p>

<p class=MsoNormal style='line-height:6.0pt;text-autospace:none'>&nbsp;</p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPostFront()</span><span
style='color:black'> sends a message to a task through a queue. </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQPostFront()</span><span
style='color:black'> behaves very much like </span><span style='font-size:9.0pt;
font-family:"Courier New";color:black'>OSQPost(),</span><span style='color:
black'> except that the message is inserted at the front of the queue. This
means that </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSQPostFront()</span><span style='color:black'> makes the message
queue behave like a last-in-first-out (LIFO) queue instead of a
first-in-first-out (FIFO) queue. The message is a pointer-sized variable, and
its use is application specific. If the message queue is full, an error code is
returned to the caller. </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSQPostFront()</span><span style='color:black'> immediately
returns to its caller and the message is not placed in the queue. If any tasks
are waiting for a message at the queue, the highest priority task receives the
message. If the task waiting for the message has a higher priority than the
task sending the message, the higher priority task is resumed and the task
sending the message is suspended; that is, a context switch occurs.</span></p>

<p class=MsoNormal style='margin-top:14.0pt;margin-right:0in;margin-bottom:
7.0pt;margin-left:0in;text-align:justify;line-height:14.0pt;text-autospace:
none'><span style='color:black'><b>Arguments</b></span></p>

<p class=MsoNormal style='text-align:justify;line-height:12.0pt;text-autospace:
none'><span style='color:black'><b>pevent</b></span><span style='color:black'>
is a pointer to the queue into which the message is deposited. This pointer is
returned to your application when the queue is cre

⌨️ 快捷键说明

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