<ahref="chqueues_8c.html">Go to the documentation of this file.</a><divclass="fragment"><preclass="fragment"><aname="l00001"></a>00001 <spanclass="comment">/*</span>
<aname="l00052"></a>00052 <spanclass="preprocessor">#include "<aclass="code"href="ch_8h.html"title="ChibiOS/RT main include file.">ch.h</a>"</span>
<aname="l00071"></a>00071 iqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a> = iqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a> = iqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a> = bp;
<aname="l00072"></a>00072 iqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a> = bp + size;
<aname="l00074"></a>00074 <aclass="code"href="group__semaphores.html#gafe8fc6155a871074e8017efd908b2c58"title="Initializes a semaphore with the specified counter value.">chSemInit</a>(&iqp-><aclass="code"href="struct_generic_queue.html#a21fa1b28fa19bbb1b036c396b44d9fd5"title="Counter Semaphore.">q_sem</a>, 0);
<aname="l00086"></a><aclass="code"href="group__io__queues.html#ga2252ca3e5d6ee6d8d323d025365aee59">00086</a><spanclass="keywordtype">void</span><aclass="code"href="group__io__queues.html#ga2252ca3e5d6ee6d8d323d025365aee59"title="Resets an input queue.">chIQResetI</a>(<aclass="code"href="struct_generic_queue.html"title="Generic I/O queue structure.">InputQueue</a> *iqp) {
<aname="l00087"></a>00087
<aname="l00088"></a>00088 iqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a> = iqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a> = iqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00089"></a>00089 <aclass="code"href="group__semaphores.html#gae7972b6b22b80ac09bac5a186277ab81"title="Performs a reset operation on the semaphore.">chSemResetI</a>(&iqp-><aclass="code"href="struct_generic_queue.html#a21fa1b28fa19bbb1b036c396b44d9fd5"title="Counter Semaphore.">q_sem</a>, 0);
<aname="l00103"></a><aclass="code"href="group__io__queues.html#ga23b72ba9803de5a20caa84ffd0c193fc">00103</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__io__queues.html#ga23b72ba9803de5a20caa84ffd0c193fc"title="Input queue write.">chIQPutI</a>(<aclass="code"href="struct_generic_queue.html"title="Generic I/O queue structure.">InputQueue</a> *iqp, <aclass="code"href="group___s_t_m8___c_o_r_e.html#gaba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> b) {
<aname="l00104"></a>00104
<aname="l00105"></a>00105 <spanclass="keywordflow">if</span> (<aclass="code"href="group__io__queues.html#ga3b87d6f7e4110c882b13870930db5cbb"title="Evaluates to TRUE if the specified Input Queue is full.">chIQIsFull</a>(iqp))
<aname="l00109"></a>00109 <spanclass="keywordflow">if</span> (iqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a>>= iqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a>)
<aname="l00110"></a>00110 iqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a> = iqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00111"></a>00111 <aclass="code"href="group__semaphores.html#gaca0b70cf495a9cb7569e1cf5b07e2b3d"title="Performs a signal operation on a semaphore.">chSemSignalI</a>(&iqp-><aclass="code"href="struct_generic_queue.html#a21fa1b28fa19bbb1b036c396b44d9fd5"title="Counter Semaphore.">q_sem</a>);
<aname="l00131"></a><aclass="code"href="group__io__queues.html#ga142d0e885ac3a695f5f033a65f49abd0">00131</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__io__queues.html#ga142d0e885ac3a695f5f033a65f49abd0"title="Input queue read with timeout.">chIQGetTimeout</a>(<aclass="code"href="struct_generic_queue.html"title="Generic I/O queue structure.">InputQueue</a> *iqp, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> time) {
<aname="l00133"></a>00133 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00134"></a>00134
<aname="l00135"></a>00135 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00144"></a>00144 b = *iqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a>++;
<aname="l00145"></a>00145 <spanclass="keywordflow">if</span> (iqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a>>= iqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a>)
<aname="l00146"></a>00146 iqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a> = iqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00147"></a>00147
<aname="l00148"></a>00148 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00175"></a>00175 <spanclass="keywordtype">size_t</span> n, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> time) {
<aname="l00183"></a>00183 <spanclass="keywordflow">if</span> (<aclass="code"href="group__io__queues.html#ga01d87285eb173d213eb9849514969d7d"title="Evaluates to TRUE if the specified Input Queue is empty.">chIQIsEmpty</a>(iqp)) {
<aname="l00194"></a>00194 <spanclass="keywordflow">if</span> (iqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a>>= iqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a>)
<aname="l00195"></a>00195 iqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a> = iqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00198"></a>00198 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>(); <spanclass="comment">/* Gives a preemption chance in a controlled point.*/</span>
<aname="l00226"></a>00226 oqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a> = oqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a> = oqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a> = bp;
<aname="l00227"></a>00227 oqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a> = bp + size;
<aname="l00229"></a>00229 <aclass="code"href="group__semaphores.html#gafe8fc6155a871074e8017efd908b2c58"title="Initializes a semaphore with the specified counter value.">chSemInit</a>(&oqp-><aclass="code"href="struct_generic_queue.html#a21fa1b28fa19bbb1b036c396b44d9fd5"title="Counter Semaphore.">q_sem</a>, (<aclass="code"href="group__types.html#ga090b3bab5602157ebf706a44041dc05e"title="Counter, recommended fastest signed.">cnt_t</a>)size);
<aname="l00241"></a><aclass="code"href="group__io__queues.html#ga0a35a7de945e4b56b5fb5f5c8567e296">00241</a><spanclass="keywordtype">void</span><aclass="code"href="group__io__queues.html#ga0a35a7de945e4b56b5fb5f5c8567e296"title="Resets an output queue.">chOQResetI</a>(<aclass="code"href="struct_generic_queue.html"title="Generic I/O queue structure.">OutputQueue</a> *oqp) {
<aname="l00242"></a>00242
<aname="l00243"></a>00243 oqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a> = oqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a> = oqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00244"></a>00244 <aclass="code"href="group__semaphores.html#gae7972b6b22b80ac09bac5a186277ab81"title="Performs a reset operation on the semaphore.">chSemResetI</a>(&oqp-><aclass="code"href="struct_generic_queue.html#a21fa1b28fa19bbb1b036c396b44d9fd5"title="Counter Semaphore.">q_sem</a>, (<aclass="code"href="group__types.html#ga090b3bab5602157ebf706a44041dc05e"title="Counter, recommended fastest signed.">cnt_t</a>)(oqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a> - oqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>));
<aname="l00265"></a><aclass="code"href="group__io__queues.html#ga3df1926602eb698119990b311b097ad9">00265</a><aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a><aclass="code"href="group__io__queues.html#ga3df1926602eb698119990b311b097ad9"title="Output queue write with timeout.">chOQPutTimeout</a>(<aclass="code"href="struct_generic_queue.html"title="Generic I/O queue structure.">OutputQueue</a> *oqp, <aclass="code"href="group___s_t_m8___c_o_r_e.html#gaba7bc1797add20fe3efdf37ced1182c5">uint8_t</a> b, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> time) {
<aname="l00266"></a>00266 <aclass="code"href="group__types.html#ga35bcb0c321cd7bc45bf1a11fa17ebdd3"title="Message, use signed pointer equivalent.">msg_t</a> msg;
<aname="l00267"></a>00267
<aname="l00268"></a>00268 <aclass="code"href="group__system.html#ga9f6573c0763d1e4e97c63c62edad6e42"title="Enters the kernel lock mode.">chSysLock</a>();
<aname="l00269"></a>00269 <spanclass="keywordflow">if</span> ((msg = <aclass="code"href="group__semaphores.html#ga924ec5d191bb8debe8727ae4dd5d6d03"title="Performs a wait operation on a semaphore with timeout specification.">chSemWaitTimeoutS</a>(&oqp-><aclass="code"href="struct_generic_queue.html#a21fa1b28fa19bbb1b036c396b44d9fd5"title="Counter Semaphore.">q_sem</a>, time)) <<aclass="code"href="group__scheduler.html#gae1c86078318e11c2fa57ee3c2ec69f61"title="Default thread wakeup low level message.">RDY_OK</a>) {
<aname="l00270"></a>00270 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>();
<aname="l00274"></a>00274 <spanclass="keywordflow">if</span> (oqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a>>= oqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a>)
<aname="l00275"></a>00275 oqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a> = oqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00295"></a>00295 <spanclass="keywordflow">if</span> (<aclass="code"href="group__io__queues.html#gabf0eb1ba20cde6d4d9afa1139eaac19d"title="Evaluates to TRUE if the specified Output Queue is empty.">chOQIsEmpty</a>(oqp))
<aname="l00298"></a>00298 b = *oqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a>++;
<aname="l00299"></a>00299 <spanclass="keywordflow">if</span> (oqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a>>= oqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a>)
<aname="l00300"></a>00300 oqp-><aclass="code"href="struct_generic_queue.html#acc1453d7bc5a4ceddba2166b72ba3b47"title="Read pointer.">q_rdptr</a> = oqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00301"></a>00301 <aclass="code"href="group__semaphores.html#gaca0b70cf495a9cb7569e1cf5b07e2b3d"title="Performs a signal operation on a semaphore.">chSemSignalI</a>(&oqp-><aclass="code"href="struct_generic_queue.html#a21fa1b28fa19bbb1b036c396b44d9fd5"title="Counter Semaphore.">q_sem</a>);
<aname="l00328"></a>00328 <spanclass="keywordtype">size_t</span> n, <aclass="code"href="group__types.html#gae3e32a98d431a02106616da3071832dd"title="System Time, recommended fastest unsigned.">systime_t</a> time) {
<aname="l00336"></a>00336 <spanclass="keywordflow">if</span> (<aclass="code"href="group__io__queues.html#gaca8b2bc8aae722ba9f47f21c358420f9"title="Evaluates to TRUE if the specified Output Queue is full.">chOQIsFull</a>(oqp)) {
<aname="l00347"></a>00347 <spanclass="keywordflow">if</span> (oqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a>>= oqp-><aclass="code"href="struct_generic_queue.html#a2345976305f32ce54981ad1ee36e77be"title="Pointer to the first location after the buffer.">q_top</a>)
<aname="l00348"></a>00348 oqp-><aclass="code"href="struct_generic_queue.html#a5cf5a39a1a57b15d1a2491edcbd72442"title="Write pointer.">q_wrptr</a> = oqp-><aclass="code"href="struct_generic_queue.html#a644ac8a420048012cf562a31e8c144c6"title="Pointer to the queue buffer.">q_buffer</a>;
<aname="l00349"></a>00349 <aclass="code"href="group__system.html#ga5a257fa58a09815eb64a45e2dfbdc22e"title="Leaves the kernel lock mode.">chSysUnlock</a>(); <spanclass="comment">/* Gives a preemption chance in a controlled point.*/</span>
Generated on Sun Nov 28 2010 14:09:48 for ChibiOS/RT by <ahref="http://www.doxygen.org/index.html"><imgsrc="doxygen.png"alt="doxygen"align="middle"border="0"></a> 1.7.1</small></address>