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

📄 quickref.htm

📁 嵌入式系统基础课件
💻 HTM
📖 第 1 页 / 共 5 页
字号:

<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'>OSIntExit()</span><span
style='color:black'> notifies MicroC/OS-II that an ISR has completed. This
allows MicroC/OS-II to keep track of interrupt nesting. </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSIntExit()</span><span
style='color:black'> is used in conjunction with </span><span style='font-size:
9.0pt;font-family:"Courier New";color:black'>OSIntEnter().</span><span
style='color:black'> When the last nested interrupt completes, MicroC/OS-II
calls the scheduler to determine if a higher priority task has been made ready
to run, in which case, the interrupt returns to the higher priority task
instead of the interrupted task.</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=OSMboxAccept>OSMboxAccept</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 *OSMboxAccept(OS_EVENT *pevent);</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'>OSMboxAccept()</span><span
style='color:black'> allows you to see if a message is available from the
desired mailbox. Unlike </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxPend(), OSMboxAccept()</span><span style='color:black'> does
not suspend the calling task if a message is not available. If a message is
available, the message is returned to your application and the content of the
mailbox is cleared. This call is typically used by ISRs because an ISR is not
allowed to wait for a message at a mailbox.</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 mailbox from which the message is
received. This pointer is returned to your application when the mailbox is
created [see </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxCreate()</span><span 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='color:black'>A pointer to the message if one is available;
NULL if the mailbox does not contain a message.</span></p>

<p class=Heading><a name=OSMboxCreate>OSMboxCreate</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>        OS_EVENT *OSMboxCreate(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'>OSMboxCreate()</span><span
style='color:black'> creates and initializes a mailbox. A mailbox allows tasks
or ISRs to send a pointer-sized variable (message) to one or more tasks.</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'>msg</span><span
style='color:black'> is used to initialize the contents of the mailbox. The
mailbox is empty when msg is a NULL pointer. The mailbox initially contains a
message when msg is non-NULL.</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='color:black'>A pointer to the event control block allocated
to the mailbox. If no event control block is available, </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMboxCreate()</span><span
style='color:black'> returns a NULL pointer.</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=OSMboxPend>OSMboxPend</a>()</p>

<p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'><b>&nbsp;</b></span></p>

<p class=Prototype>        void *OSMboxPend(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'>OSMboxPend()</span><span
style='color:black'> is used when a task expects to receive a message. The
message is sent to the task either by an ISR or by another task. The message
received is a pointer-sized variable and its use is application specific. If a
message is present in the mailbox when </span><span style='font-size:9.0pt;
font-family:"Courier New";color:black'>OSMboxPend()</span><span
style='color:black'> is called, the message is retrieved, the mailbox is
emptied, and the retrieved message is returned to the caller. If no message is
present in the mailbox, </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxPend()</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 mailbox and multiple tasks are waiting for the
message, MicroC/OS-II resumes the highest priority task waiting to run. 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='font-size:9.0pt;font-family:"Courier New";color:black'>pevent</span><span
style='color:black'> is a pointer to the mailbox from which the message is
received. This pointer is returned to your application when the mailbox is
created [see </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxCreate()</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'>timeout</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 begins
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='font-size:9.0pt;font-family:"Courier New";
color:black'>err</span><span style='color:black'> is a pointer to a variable
that holds an error code. </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxPend()</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
period.</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 has to suspend it. In general, you should not call </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMboxPend()</span><span
style='color:black'> from an ISR, but 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 mailbox.</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'>OSMboxPend()</span><span
style='color:black'> returns the 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 message is not
received within the specified timeout period, the returned message is a NULL
pointer and *err is set 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=OSMboxPost>OSMboxPost</a>()</p>

<p class=MsoNormal><span style='font-size:9.0pt;font-family:"Courier New"'><b>&nbsp;</b></span></p>

<p class=Prototype>        INT8U OSMboxPost(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'>OSMboxPost()</span><span
style='color:black'> sends a message to a task through a mailbox. A message is
a pointer-sized variable and its use is application specific. If a message is
already in the mailbox, an error code is returned indicating that the mailbox
is full. </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxPost()</span><span style='color:black'> then immediately
returns to its caller and the message is not placed in the mailbox. If any task
is waiting for a message at the mailbox, the highest priority task waiting
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. In other words, 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='font-size:9.0pt;font-family:"Courier New";color:black'>pevent</span><span
style='color:black'> is a pointer to the mailbox into which the message is
deposited. This pointer is returned to your application when the mailbox is
created [see </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMboxCreate()</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 because this indicates that the mailbox is empty.</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:

⌨️ 快捷键说明

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