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

📄 quickref.htm

📁 嵌入式系统基础课件
💻 HTM
📖 第 1 页 / 共 5 页
字号:
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'>OSMemGet()</span><span
style='color:black'> returns a pointer to the allocated memory block if one is
available. If no memory block is available from the memory partition, </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemGet()</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=OSMemPut>OSMemPut</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>        INT8U OSMemPut(OS_MEM *pmem, void *pblk);</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'>OSMemPut()</span><span
style='color:black'> returns a memory block to a memory partition. It is
assumed that you will return the memory block to the appropriate memory
partition.</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>pmem</b></span><span style='color:black'> is
a pointer to the memory partition control block that is returned to your
application from the </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSMemCreate()</span><span style='color:black'> call.</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>pblk</b></span><span
style='color:black'> is a pointer to the memory block to be returned to the
memory partition.</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'>OSMemPut()</span><span
style='color:black'> returns one of the following 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 a memory block was available and returned to your
application.</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_MEM_FULL</span><span
style='color:black'> if the memory partition could not accept more memory
blocks. This is surely an indication that something is wrong because you are
returning more memory blocks than you obtained using </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSMemGet()</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'>.</span></p>

<p class=Heading><a name=OSMemQuery>OSMemQuery</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>        INT8U OSMemQuery(OS_MEM *pmem, OS_MEM_DATA *pdata);</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'>OSMemQuery()</span><span
style='color:black'> obtains information about a memory partition. Basically,
this function returns the same information found in the </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_MEM</span><span
style='color:black'> data structure, but in a new data structure called </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OS_MEM_DATA</span><span
style='color:black'>. </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OS_MEM_DATA</span><span style='color:black'> also contains an
additional field that indicates the number of memory blocks in use.</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'>pmem</span><span
style='color:black'> is a pointer to the memory partition control block that is
returned to your application from the OSMemCreate() call.</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'>pdata</span><span style='color:black'> is a pointer to a data
structure of type OS_MEM_DATA, which contains the following fields:</span></p>

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

<pre>
void   *OSAddr;     /* Points to beginning address of the memory partition      */
void   *OSFreeList; /* Points to beginning of the free list of memory blocks    */
INT32U  OSBlkSize;  /* Size (in bytes) of each memory block                     */
INT32U  OSNBlks;    /* Total number of blocks in the partition                  */
INT32U  OSNFree;    /* Number of memory blocks free                             */
INT32U  OSNUsed;    /* Number of memory blocks used                             */
</pre>

<p class=MsoNormal style='line-height:12.5pt;text-autospace:none'>&nbsp;</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'>OSMemQuery()</span><span
style='color:black'> always returns </span><span style='font-size:9.0pt;
font-family:"Courier New";color:black'>OS_NO_ERR</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=OSQAccept>OSQAccept</a>()</p>

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

<p class=Prototype>        void *OSQAccept(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'>OSQAccept()</span><span
style='color:black'> checks to see if a message is available in the desired
message queue. Unlike </span><span style='font-size:9.0pt;font-family:"Courier New";
color:black'>OSQPend(), OSQAccept()</span><span style='color:black'> does not
suspend the calling task if a message is not available. If a message is
available, it is extracted from the queue and returned to your application.
This call is typically used by ISRs because an ISR is not allowed to wait for
messages at a 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>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 message queue from which the message
is received. This pointer is returned to your application when the message
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: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 message queue does not contain a message.</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=OSQCreate>OSQCreate</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 *OSQCreate(void **start, INT8U size);</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'>OSQCreate()
</span><span style='color:black'>creates a message queue. A message queue
allows tasks or ISRs to send pointer-sized variables (messages) to one or more
tasks. The meaning of the messages sent are application specific.</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'>start</span><span
style='color:black'> is the base address of the message storage area. A message
storage area is declared as an array of pointers to voids.</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'>size</span><span style='color:black'> is the size (in number of
entries) of the message storage area.</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'>OSQCreate()</span><span
style='color:black'> returns a pointer to the event control block allocated to
the queue. If no event control block is available, </span><span
style='font-size:9.0pt;font-family:"Courier New";color:black'>OSQCreate()</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=OSQFlush>OSQFlush</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>        INT8U *OSQFlush(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'>OSQFlush()</span><span
style='color:black'> empties the contents of the message queue and eliminates
all the messages sent to the queue. This function takes the same amount of time
to execute whether tasks are waiting on the queue (and thus no messages are
present) or the queue contains one or more messages.</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 message queue. This pointer is returned to your application
when the message queue is created [see </span><span style='font-size:9.0pt;
font-family:"Courier New";color:black'>OSQCreate()</span><span

⌨️ 快捷键说明

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