ChibiOS/HAL 9.0.0
hal_queues.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_queues.c
19 * @brief I/O Queues code.
20 *
21 * @addtogroup HAL_QUEUES
22 * @details Queues are mostly used in serial-like device drivers.
23 * Serial device drivers are usually designed to have a lower side
24 * (lower driver, it is usually an interrupt service routine) and an
25 * upper side (upper driver, accessed by the application threads).<br>
26 * There are several kind of queues:<br>
27 * - <b>Input queue</b>, unidirectional queue where the writer is the
28 * lower side and the reader is the upper side.
29 * - <b>Output queue</b>, unidirectional queue where the writer is the
30 * upper side and the reader is the lower side.
31 * - <b>Full duplex queue</b>, bidirectional queue. Full duplex queues
32 * are implemented by pairing an input queue and an output queue
33 * together.
34 * .
35 * @{
36 */
37
38#include <string.h>
39
40#include "hal.h"
41
42/*===========================================================================*/
43/* Driver local definitions. */
44/*===========================================================================*/
45
46/**
47 * @brief Non-blocking input queue read.
48 * @details The function reads data from an input queue into a buffer. The
49 * operation completes when the specified amount of data has been
50 * transferred or when the input queue has been emptied.
51 *
52 * @param[in] iqp pointer to an @p input_queue_t structure
53 * @param[out] bp pointer to the data buffer
54 * @param[in] n the maximum amount of data to be transferred, the
55 * value 0 is reserved
56 * @return The number of bytes effectively transferred.
57 *
58 * @notapi
59 */
60static size_t iq_read(input_queue_t *iqp, uint8_t *bp, size_t n) {
61 size_t s1, s2;
62
63 osalDbgCheck(n > 0U);
64
65 /* Number of bytes that can be read in a single atomic operation.*/
66 if (n > iqGetFullI(iqp)) {
67 n = iqGetFullI(iqp);
68 }
69
70 /* Number of bytes before buffer limit.*/
71 /*lint -save -e9033 [10.8] Checked to be safe.*/
72 s1 = (size_t)(iqp->q_top - iqp->q_rdptr);
73 /*lint -restore*/
74 if (n < s1) {
75 memcpy((void *)bp, (void *)iqp->q_rdptr, n);
76 iqp->q_rdptr += n;
77 }
78 else if (n > s1) {
79 memcpy((void *)bp, (void *)iqp->q_rdptr, s1);
80 bp += s1;
81 s2 = n - s1;
82 memcpy((void *)bp, (void *)iqp->q_buffer, s2);
83 iqp->q_rdptr = iqp->q_buffer + s2;
84 }
85 else {
86 memcpy((void *)bp, (void *)iqp->q_rdptr, n);
87 iqp->q_rdptr = iqp->q_buffer;
88 }
89
90 iqp->q_counter -= n;
91 return n;
92}
93
94/**
95 * @brief Non-blocking output queue write.
96 * @details The function writes data from a buffer to an output queue. The
97 * operation completes when the specified amount of data has been
98 * transferred or when the output queue has been filled.
99 *
100 * @param[in] oqp pointer to an @p output_queue_t structure
101 * @param[in] bp pointer to the data buffer
102 * @param[in] n the maximum amount of data to be transferred, the
103 * value 0 is reserved
104 * @return The number of bytes effectively transferred.
105 *
106 * @notapi
107 */
108static size_t oq_write(output_queue_t *oqp, const uint8_t *bp, size_t n) {
109 size_t s1, s2;
110
111 osalDbgCheck(n > 0U);
112
113 /* Number of bytes that can be written in a single atomic operation.*/
114 if (n > oqGetEmptyI(oqp)) {
115 n = oqGetEmptyI(oqp);
116 }
117
118 /* Number of bytes before buffer limit.*/
119 /*lint -save -e9033 [10.8] Checked to be safe.*/
120 s1 = (size_t)(oqp->q_top - oqp->q_wrptr);
121 /*lint -restore*/
122 if (n < s1) {
123 memcpy((void *)oqp->q_wrptr, (const void *)bp, n);
124 oqp->q_wrptr += n;
125 }
126 else if (n > s1) {
127 memcpy((void *)oqp->q_wrptr, (const void *)bp, s1);
128 bp += s1;
129 s2 = n - s1;
130 memcpy((void *)oqp->q_buffer, (const void *)bp, s2);
131 oqp->q_wrptr = oqp->q_buffer + s2;
132 }
133 else {
134 memcpy((void *)oqp->q_wrptr, (const void *)bp, n);
135 oqp->q_wrptr = oqp->q_buffer;
136 }
137
138 oqp->q_counter -= n;
139 return n;
140}
141
142/*===========================================================================*/
143/* Driver exported variables. */
144/*===========================================================================*/
145
146/*===========================================================================*/
147/* Driver local variables and types. */
148/*===========================================================================*/
149
150/*===========================================================================*/
151/* Driver local functions. */
152/*===========================================================================*/
153
154/*===========================================================================*/
155/* Driver interrupt handlers. */
156/*===========================================================================*/
157
158/*===========================================================================*/
159/* Driver exported functions. */
160/*===========================================================================*/
161
162/**
163 * @brief Initializes an input queue.
164 * @details A Semaphore is internally initialized and works as a counter of
165 * the bytes contained in the queue.
166 * @note The callback is invoked from within the S-Locked system state.
167 *
168 * @param[out] iqp pointer to an @p input_queue_t structure
169 * @param[in] bp pointer to a memory area allocated as queue buffer
170 * @param[in] size size of the queue buffer
171 * @param[in] infy pointer to a callback function that is invoked when
172 * data is read from the queue. The value can be @p NULL.
173 * @param[in] link application defined pointer
174 *
175 * @init
176 */
177void iqObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size,
178 qnotify_t infy, void *link) {
179
181 iqp->q_counter = 0;
182 iqp->q_buffer = bp;
183 iqp->q_rdptr = bp;
184 iqp->q_wrptr = bp;
185 iqp->q_top = bp + size;
186 iqp->q_notify = infy;
187 iqp->q_link = link;
188}
189
190/**
191 * @brief Resets an input queue.
192 * @details All the data in the input queue is erased and lost, any waiting
193 * thread is resumed with status @p MSG_RESET.
194 * @note A reset operation can be used by a low level driver in order to
195 * obtain immediate attention from the high level layers.
196 *
197 * @param[in] iqp pointer to an @p input_queue_t structure
198 *
199 * @iclass
200 */
202
204
205 iqp->q_rdptr = iqp->q_buffer;
206 iqp->q_wrptr = iqp->q_buffer;
207 iqp->q_counter = 0;
209}
210
211/**
212 * @brief Input queue write.
213 * @details A byte value is written into the low end of an input queue. The
214 * operation completes immediately.
215 *
216 * @param[in] iqp pointer to an @p input_queue_t structure
217 * @param[in] b the byte value to be written in the queue
218 * @return The operation status.
219 * @retval MSG_OK if the operation has been completed with success.
220 * @retval MSG_TIMEOUT if the queue is full.
221 *
222 * @iclass
223 */
224msg_t iqPutI(input_queue_t *iqp, uint8_t b) {
225
227
228 /* Queue space check.*/
229 if (!iqIsFullI(iqp)) {
230 iqp->q_counter++;
231 *iqp->q_wrptr++ = b;
232 if (iqp->q_wrptr >= iqp->q_top) {
233 iqp->q_wrptr = iqp->q_buffer;
234 }
235
237
238 return MSG_OK;
239 }
240
241 return MSG_TIMEOUT;
242}
243
244/**
245 * @brief Input queue non-blocking read.
246 * @details This function reads a byte value from an input queue. The
247 * operation completes immediately.
248 * @note The callback is invoked after removing a character from the
249 * queue.
250 *
251 * @param[in] iqp pointer to an @p input_queue_t structure
252 * @return A byte value from the queue.
253 * @retval MSG_TIMEOUT if the queue is empty.
254 *
255 * @iclass
256 */
258
260
261 /* Queue data check.*/
262 if (!iqIsEmptyI(iqp)) {
263 uint8_t b;
264
265 /* Getting the character from the queue.*/
266 iqp->q_counter--;
267 b = *iqp->q_rdptr++;
268 if (iqp->q_rdptr >= iqp->q_top) {
269 iqp->q_rdptr = iqp->q_buffer;
270 }
271
272 /* Inform the low side that the queue has at least one slot available.*/
273 if (iqp->q_notify != NULL) {
274 iqp->q_notify(iqp);
275 }
276
277 return (msg_t)b;
278 }
279
280 return MSG_TIMEOUT;
281}
282
283/**
284 * @brief Input queue read with timeout.
285 * @details This function reads a byte value from an input queue. If the queue
286 * is empty then the calling thread is suspended until a byte arrives
287 * in the queue or a timeout occurs.
288 * @note The callback is invoked after removing a character from the
289 * queue.
290 *
291 * @param[in] iqp pointer to an @p input_queue_t structure
292 * @param[in] timeout the number of ticks before the operation timeouts,
293 * the following special values are allowed:
294 * - @a TIME_IMMEDIATE immediate timeout.
295 * - @a TIME_INFINITE no timeout.
296 * @return A byte value from the queue.
297 * @retval MSG_TIMEOUT if the specified time expired.
298 * @retval MSG_RESET if the queue has been reset.
299 *
300 * @api
301 */
303 uint8_t b;
304
305 osalSysLock();
306
307 /* Waiting until there is a character available or a timeout occurs.*/
308 while (iqIsEmptyI(iqp)) {
309 msg_t msg = osalThreadEnqueueTimeoutS(&iqp->q_waiting, timeout);
310 if (msg < MSG_OK) {
312 return msg;
313 }
314 }
315
316 /* Getting the character from the queue.*/
317 iqp->q_counter--;
318 b = *iqp->q_rdptr++;
319 if (iqp->q_rdptr >= iqp->q_top) {
320 iqp->q_rdptr = iqp->q_buffer;
321 }
322
323 /* Inform the low side that the queue has at least one slot available.*/
324 if (iqp->q_notify != NULL) {
325 iqp->q_notify(iqp);
326 }
327
329
330 return (msg_t)b;
331}
332
333/**
334 * @brief Input queue non-blocking read.
335 * @details The function reads data from an input queue into a buffer. The
336 * operation completes immediately.
337 *
338 * @param[in] iqp pointer to an @p input_queue_t structure
339 * @param[out] bp pointer to the data buffer
340 * @param[in] n the maximum amount of data to be transferred, the
341 * value 0 is reserved
342 * @return The number of bytes effectively transferred.
343 *
344 * @iclass
345 */
346size_t iqReadI(input_queue_t *iqp, uint8_t *bp, size_t n) {
347 qnotify_t nfy = iqp->q_notify;
348 size_t rd;
349
351
352 rd = iq_read(iqp, bp, n);
353
354 /* Inform the low side that the queue has at least one character
355 available.*/
356 if ((rd > (size_t)0) && (nfy != NULL)) {
357 nfy(iqp);
358 }
359
360 return rd;
361}
362
363/**
364 * @brief Input queue read with timeout.
365 * @details The function reads data from an input queue into a buffer. The
366 * operation completes when the specified amount of data has been
367 * transferred or after the specified timeout or if the queue has
368 * been reset.
369 * @note The function is not atomic, if you need atomicity it is suggested
370 * to use a semaphore or a mutex for mutual exclusion.
371 * @note The callback is invoked after removing each character from the
372 * queue.
373 *
374 * @param[in] iqp pointer to an @p input_queue_t structure
375 * @param[out] bp pointer to the data buffer
376 * @param[in] n the maximum amount of data to be transferred, the
377 * value 0 is reserved
378 * @param[in] timeout the number of ticks before the operation timeouts,
379 * the following special values are allowed:
380 * - @a TIME_IMMEDIATE immediate timeout.
381 * - @a TIME_INFINITE no timeout.
382 * @return The number of bytes effectively transferred.
383 *
384 * @api
385 */
386size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp,
387 size_t n, sysinterval_t timeout) {
388 qnotify_t nfy = iqp->q_notify;
389 size_t max = n;
390
391 osalDbgCheck(n > 0U);
392
393 osalSysLock();
394
395 while (n > 0U) {
396 size_t done;
397
398 done = iq_read(iqp, bp, n);
399 if (done == (size_t)0) {
400 msg_t msg = osalThreadEnqueueTimeoutS(&iqp->q_waiting, timeout);
401
402 /* Anything except MSG_OK causes the operation to stop.*/
403 if (msg != MSG_OK) {
404 break;
405 }
406 }
407 else {
408 /* Inform the low side that the queue has at least one empty slot
409 available.*/
410 if (nfy != NULL) {
411 nfy(iqp);
412 }
413
414 /* Giving a preemption chance in a controlled point.*/
416
417 n -= done;
418 bp += done;
419
420 osalSysLock();
421 }
422 }
423
425 return max - n;
426}
427
428/**
429 * @brief Initializes an output queue.
430 * @details A Semaphore is internally initialized and works as a counter of
431 * the free bytes in the queue.
432 * @note The callback is invoked from within the S-Locked system state.
433 *
434 * @param[out] oqp pointer to an @p output_queue_t structure
435 * @param[in] bp pointer to a memory area allocated as queue buffer
436 * @param[in] size size of the queue buffer
437 * @param[in] onfy pointer to a callback function that is invoked when
438 * data is written to the queue. The value can be @p NULL.
439 * @param[in] link application defined pointer
440 *
441 * @init
442 */
443void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size,
444 qnotify_t onfy, void *link) {
445
447 oqp->q_counter = size;
448 oqp->q_buffer = bp;
449 oqp->q_rdptr = bp;
450 oqp->q_wrptr = bp;
451 oqp->q_top = bp + size;
452 oqp->q_notify = onfy;
453 oqp->q_link = link;
454}
455
456/**
457 * @brief Resets an output queue.
458 * @details All the data in the output queue is erased and lost, any waiting
459 * thread is resumed with status @p MSG_RESET.
460 * @note A reset operation can be used by a low level driver in order to
461 * obtain immediate attention from the high level layers.
462 *
463 * @param[in] oqp pointer to an @p output_queue_t structure
464 *
465 * @iclass
466 */
468
470
471 oqp->q_rdptr = oqp->q_buffer;
472 oqp->q_wrptr = oqp->q_buffer;
473 oqp->q_counter = qSizeX(oqp);
475}
476
477/**
478 * @brief Output queue non-blocking write.
479 * @details This function writes a byte value to an output queue. The
480 * operation completes immediately.
481 *
482 * @param[in] oqp pointer to an @p output_queue_t structure
483 * @param[in] b the byte value to be written in the queue
484 * @return The operation status.
485 * @retval MSG_OK if the operation succeeded.
486 * @retval MSG_TIMEOUT if the queue is full.
487 *
488 * @iclass
489 */
490msg_t oqPutI(output_queue_t *oqp, uint8_t b) {
491
493
494 /* Queue space check.*/
495 while (!oqIsFullI(oqp)) {
496 /* Putting the character into the queue.*/
497 oqp->q_counter--;
498 *oqp->q_wrptr++ = b;
499 if (oqp->q_wrptr >= oqp->q_top) {
500 oqp->q_wrptr = oqp->q_buffer;
501 }
502
503 /* Inform the low side that the queue has at least one character available.*/
504 if (oqp->q_notify != NULL) {
505 oqp->q_notify(oqp);
506 }
507
508 return MSG_OK;
509 }
510
511 return MSG_TIMEOUT;
512}
513
514/**
515 * @brief Output queue write with timeout.
516 * @details This function writes a byte value to an output queue. If the queue
517 * is full then the calling thread is suspended until there is space
518 * in the queue or a timeout occurs.
519 * @note The callback is invoked after putting the character into the
520 * queue.
521 *
522 * @param[in] oqp pointer to an @p output_queue_t structure
523 * @param[in] b the byte value to be written in the queue
524 * @param[in] timeout the number of ticks before the operation timeouts,
525 * the following special values are allowed:
526 * - @a TIME_IMMEDIATE immediate timeout.
527 * - @a TIME_INFINITE no timeout.
528 * @return The operation status.
529 * @retval MSG_OK if the operation succeeded.
530 * @retval MSG_TIMEOUT if the specified time expired.
531 * @retval MSG_RESET if the queue has been reset.
532 *
533 * @api
534 */
536
537 osalSysLock();
538
539 /* Waiting until there is a slot available or a timeout occurs.*/
540 while (oqIsFullI(oqp)) {
541 msg_t msg = osalThreadEnqueueTimeoutS(&oqp->q_waiting, timeout);
542 if (msg < MSG_OK) {
544 return msg;
545 }
546 }
547
548 /* Putting the character into the queue.*/
549 oqp->q_counter--;
550 *oqp->q_wrptr++ = b;
551 if (oqp->q_wrptr >= oqp->q_top) {
552 oqp->q_wrptr = oqp->q_buffer;
553 }
554
555 /* Inform the low side that the queue has at least one character available.*/
556 if (oqp->q_notify != NULL) {
557 oqp->q_notify(oqp);
558 }
559
561
562 return MSG_OK;
563}
564
565/**
566 * @brief Output queue read.
567 * @details A byte value is read from the low end of an output queue. The
568 * operation completes immediately.
569 *
570 * @param[in] oqp pointer to an @p output_queue_t structure
571 * @return The byte value from the queue.
572 * @retval MSG_TIMEOUT if the queue is empty.
573 *
574 * @iclass
575 */
577
579
580 /* Queue data check.*/
581 if (!oqIsEmptyI(oqp)) {
582 uint8_t b;
583
584 oqp->q_counter++;
585 b = *oqp->q_rdptr++;
586 if (oqp->q_rdptr >= oqp->q_top) {
587 oqp->q_rdptr = oqp->q_buffer;
588 }
589
591
592 return (msg_t)b;
593 }
594
595 return MSG_TIMEOUT;
596}
597
598/**
599 * @brief Output queue non-blocking write.
600 * @details The function writes data from a buffer to an output queue. The
601 * operation completes immediately.
602 *
603 * @param[in] oqp pointer to an @p output_queue_t structure
604 * @param[in] bp pointer to the data buffer
605 * @param[in] n the maximum amount of data to be transferred, the
606 * value 0 is reserved
607 * @return The number of bytes effectively transferred.
608 *
609 * @iclass
610 */
611size_t oqWriteI(output_queue_t *oqp, const uint8_t *bp, size_t n) {
612 qnotify_t nfy = oqp->q_notify;
613 size_t wr;
614
616
617 wr = oq_write(oqp, bp, n);
618
619 /* Inform the low side that the queue has at least one character
620 available.*/
621 if ((wr > (size_t)0) && (nfy != NULL)) {
622 nfy(oqp);
623 }
624
625 return wr;
626}
627
628/**
629 * @brief Output queue write with timeout.
630 * @details The function writes data from a buffer to an output queue. The
631 * operation completes when the specified amount of data has been
632 * transferred or after the specified timeout or if the queue has
633 * been reset.
634 * @note The function is not atomic, if you need atomicity it is suggested
635 * to use a semaphore or a mutex for mutual exclusion.
636 * @note The callback is invoked after putting each character into the
637 * queue.
638 *
639 * @param[in] oqp pointer to an @p output_queue_t structure
640 * @param[in] bp pointer to the data buffer
641 * @param[in] n the maximum amount of data to be transferred, the
642 * value 0 is reserved
643 * @param[in] timeout the number of ticks before the operation timeouts,
644 * the following special values are allowed:
645 * - @a TIME_IMMEDIATE immediate timeout.
646 * - @a TIME_INFINITE no timeout.
647 * @return The number of bytes effectively transferred.
648 *
649 * @api
650 */
651size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp,
652 size_t n, sysinterval_t timeout) {
653 qnotify_t nfy = oqp->q_notify;
654 size_t max = n;
655
656 osalDbgCheck(n > 0U);
657
658 osalSysLock();
659
660 while (n > 0U) {
661 size_t done;
662
663 done = oq_write(oqp, bp, n);
664 if (done == (size_t)0) {
665 msg_t msg = osalThreadEnqueueTimeoutS(&oqp->q_waiting, timeout);
666
667 /* Anything except MSG_OK causes the operation to stop.*/
668 if (msg != MSG_OK) {
669 break;
670 }
671 }
672 else {
673 /* Inform the low side that the queue has at least one character
674 available.*/
675 if (nfy != NULL) {
676 nfy(oqp);
677 }
678
679 /* Giving a preemption chance in a controlled point.*/
681
682 n -= done;
683 bp += done;
684
685 osalSysLock();
686 }
687 }
688
690 return max - n;
691}
692
693/** @} */
#define oqIsEmptyI(oqp)
Evaluates to true if the specified output queue is empty.
Definition hal_queues.h:261
io_queue_t output_queue_t
Type of an output queue structure.
Definition hal_queues.h:109
msg_t iqGetI(input_queue_t *iqp)
Input queue non-blocking read.
Definition hal_queues.c:257
io_queue_t input_queue_t
Type of an input queue structure.
Definition hal_queues.h:97
void iqResetI(input_queue_t *iqp)
Resets an input queue.
Definition hal_queues.c:201
size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, size_t n, sysinterval_t timeout)
Output queue write with timeout.
Definition hal_queues.c:651
msg_t oqPutI(output_queue_t *oqp, uint8_t b)
Output queue non-blocking write.
Definition hal_queues.c:490
#define oqGetEmptyI(oqp)
Returns the empty space into an output queue.
Definition hal_queues.h:249
void iqObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size, qnotify_t infy, void *link)
Initializes an input queue.
Definition hal_queues.c:177
msg_t iqGetTimeout(input_queue_t *iqp, sysinterval_t timeout)
Input queue read with timeout.
Definition hal_queues.c:302
#define iqIsEmptyI(iqp)
Evaluates to true if the specified input queue is empty.
Definition hal_queues.h:198
msg_t iqPutI(input_queue_t *iqp, uint8_t b)
Input queue write.
Definition hal_queues.c:224
size_t oqWriteI(output_queue_t *oqp, const uint8_t *bp, size_t n)
Output queue non-blocking write.
Definition hal_queues.c:611
static size_t oq_write(output_queue_t *oqp, const uint8_t *bp, size_t n)
Non-blocking output queue write.
Definition hal_queues.c:108
#define iqGetFullI(iqp)
Returns the filled space into an input queue.
Definition hal_queues.h:175
void oqResetI(output_queue_t *oqp)
Resets an output queue.
Definition hal_queues.c:467
void(* qnotify_t)(io_queue_t *qp)
Queue notification callback type.
Definition hal_queues.h:65
size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, size_t n, sysinterval_t timeout)
Input queue read with timeout.
Definition hal_queues.c:386
msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, sysinterval_t timeout)
Output queue write with timeout.
Definition hal_queues.c:535
#define qSizeX(qp)
Returns the queue's buffer size.
Definition hal_queues.h:127
static size_t iq_read(input_queue_t *iqp, uint8_t *bp, size_t n)
Non-blocking input queue read.
Definition hal_queues.c:60
void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, qnotify_t onfy, void *link)
Initializes an output queue.
Definition hal_queues.c:443
#define iqIsFullI(iqp)
Evaluates to true if the specified input queue is full.
Definition hal_queues.h:210
msg_t oqGetI(output_queue_t *oqp)
Output queue read.
Definition hal_queues.c:576
#define oqIsFullI(oqp)
Evaluates to true if the specified output queue is full.
Definition hal_queues.h:276
size_t iqReadI(input_queue_t *iqp, uint8_t *bp, size_t n)
Input queue non-blocking read.
Definition hal_queues.c:346
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread.
Definition osal.c:273
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition osal.h:601
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition osal.h:611
void osalThreadDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the queue.
Definition osal.c:305
static void osalThreadQueueObjectInit(threads_queue_t *tqp)
Initializes a threads queue object.
Definition osal.h:725
int32_t msg_t
Type of a message.
Definition osal.h:159
uint32_t sysinterval_t
Type of system time interval.
Definition osal.h:169
#define MSG_OK
Definition osal.h:56
#define MSG_TIMEOUT
Definition osal.h:57
#define MSG_RESET
Definition osal.h:58
#define osalDbgCheck(c)
Function parameters check.
Definition osal.h:284
void osalThreadDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the queue, if any.
Definition osal.c:290
#define osalDbgCheckClassI()
I-Class state check.
Definition osal.h:298
HAL subsystem header.
qnotify_t q_notify
Data notification callback.
Definition hal_queues.h:83
uint8_t * q_buffer
Pointer to the queue buffer.
Definition hal_queues.h:78
uint8_t * q_wrptr
Write pointer.
Definition hal_queues.h:81
threads_queue_t q_waiting
Queue of waiting threads.
Definition hal_queues.h:76
uint8_t * q_rdptr
Read pointer.
Definition hal_queues.h:82
uint8_t * q_top
Pointer to the first location after the buffer.
Definition hal_queues.h:79
void * q_link
Application defined field.
Definition hal_queues.h:84
volatile size_t q_counter
Resources counter.
Definition hal_queues.h:77