| 
    ChibiOS
    19.1.4
    
   | 
 
 
 | 
Queues are mostly used in serial-like device drivers. Serial device drivers are usually designed to have a lower side (lower driver, it is usually an interrupt service routine) and an upper side (upper driver, accessed by the application threads).
 There are several kind of queues:
Queue functions returned status value | |
| #define | Q_OK MSG_OK | 
| Operation successful.  More... | |
| #define | Q_TIMEOUT MSG_TIMEOUT | 
| Timeout condition.  More... | |
| #define | Q_RESET MSG_RESET | 
| Queue has been reset.  More... | |
| #define | Q_EMPTY MSG_TIMEOUT | 
| Queue empty.  More... | |
| #define | Q_FULL MSG_TIMEOUT | 
| Queue full,.  More... | |
Macro Functions | |
| #define | qSizeX(qp) | 
| Returns the queue's buffer size.  More... | |
| #define | qSpaceI(qp) ((qp)->q_counter) | 
| Queue space.  More... | |
| #define | qGetLink(qp) ((qp)->q_link) | 
| Returns the queue application-defined link.  More... | |
| #define | qSetLink(qp, lk) ((qp)->q_link = lk) | 
| Sets the queue application-defined link.  More... | |
| #define | iqGetFullI(iqp) qSpaceI(iqp) | 
| Returns the filled space into an input queue.  More... | |
| #define | iqGetEmptyI(iqp) (qSizeX(iqp) - qSpaceI(iqp)) | 
| Returns the empty space into an input queue.  More... | |
| #define | iqIsEmptyI(iqp) ((bool)(qSpaceI(iqp) == 0U)) | 
Evaluates to true if the specified input queue is empty.  More... | |
| #define | iqIsFullI(iqp) | 
Evaluates to true if the specified input queue is full.  More... | |
| #define | iqGet(iqp) iqGetTimeout(iqp, TIME_INFINITE) | 
| Input queue read.  More... | |
| #define | oqGetFullI(oqp) (qSizeX(oqp) - qSpaceI(oqp)) | 
| Returns the filled space into an output queue.  More... | |
| #define | oqGetEmptyI(oqp) qSpaceI(oqp) | 
| Returns the empty space into an output queue.  More... | |
| #define | oqIsEmptyI(oqp) | 
Evaluates to true if the specified output queue is empty.  More... | |
| #define | oqIsFullI(oqp) ((bool)(qSpaceI(oqp) == 0U)) | 
Evaluates to true if the specified output queue is full.  More... | |
| #define | oqPut(oqp, b) oqPutTimeout(oqp, b, TIME_INFINITE) | 
| Output queue write.  More... | |
Typedefs | |
| typedef struct io_queue | io_queue_t | 
| Type of a generic I/O queue structure.  More... | |
| typedef void(* | qnotify_t) (io_queue_t *qp) | 
| Queue notification callback type.  More... | |
| typedef io_queue_t | input_queue_t | 
| Type of an input queue structure.  More... | |
| typedef io_queue_t | output_queue_t | 
| Type of an output queue structure.  More... | |
Data Structures | |
| struct | io_queue | 
| Generic I/O queue structure.  More... | |
Functions | |
| static size_t | iq_read (input_queue_t *iqp, uint8_t *bp, size_t n) | 
| Non-blocking input queue read.  More... | |
| static size_t | oq_write (output_queue_t *oqp, const uint8_t *bp, size_t n) | 
| Non-blocking output queue write.  More... | |
| void | iqObjectInit (input_queue_t *iqp, uint8_t *bp, size_t size, qnotify_t infy, void *link) | 
| Initializes an input queue.  More... | |
| void | iqResetI (input_queue_t *iqp) | 
| Resets an input queue.  More... | |
| msg_t | iqPutI (input_queue_t *iqp, uint8_t b) | 
| Input queue write.  More... | |
| msg_t | iqGetI (input_queue_t *iqp) | 
| Input queue non-blocking read.  More... | |
| msg_t | iqGetTimeout (input_queue_t *iqp, sysinterval_t timeout) | 
| Input queue read with timeout.  More... | |
| size_t | iqReadI (input_queue_t *iqp, uint8_t *bp, size_t n) | 
| Input queue non-blocking read.  More... | |
| size_t | iqReadTimeout (input_queue_t *iqp, uint8_t *bp, size_t n, sysinterval_t timeout) | 
| Input queue read with timeout.  More... | |
| void | oqObjectInit (output_queue_t *oqp, uint8_t *bp, size_t size, qnotify_t onfy, void *link) | 
| Initializes an output queue.  More... | |
| void | oqResetI (output_queue_t *oqp) | 
| Resets an output queue.  More... | |
| msg_t | oqPutI (output_queue_t *oqp, uint8_t b) | 
| Output queue non-blocking write.  More... | |
| msg_t | oqPutTimeout (output_queue_t *oqp, uint8_t b, sysinterval_t timeout) | 
| Output queue write with timeout.  More... | |
| msg_t | oqGetI (output_queue_t *oqp) | 
| Output queue read.  More... | |
| size_t | oqWriteI (output_queue_t *oqp, const uint8_t *bp, size_t n) | 
| Output queue non-blocking write.  More... | |
| size_t | oqWriteTimeout (output_queue_t *oqp, const uint8_t *bp, size_t n, sysinterval_t timeout) | 
| Output queue write with timeout.  More... | |
| #define Q_OK MSG_OK | 
Operation successful.
Definition at line 36 of file hal_queues.h.
| #define Q_TIMEOUT MSG_TIMEOUT | 
Timeout condition.
Definition at line 37 of file hal_queues.h.
| #define Q_RESET MSG_RESET | 
Queue has been reset.
Definition at line 38 of file hal_queues.h.
| #define Q_EMPTY MSG_TIMEOUT | 
Queue empty.
Definition at line 39 of file hal_queues.h.
| #define Q_FULL MSG_TIMEOUT | 
Queue full,.
Definition at line 40 of file hal_queues.h.
| #define qSizeX | ( | qp | ) | 
Returns the queue's buffer size.
| [in] | qp | pointer to a io_queue_t structure  | 
Definition at line 127 of file hal_queues.h.
Referenced by oqResetI().
| #define qSpaceI | ( | qp | ) | ((qp)->q_counter) | 
Queue space.
Returns the used space if used on an input queue or the empty space if used on an output queue.
| [in] | qp | pointer to a io_queue_t structure  | 
Definition at line 142 of file hal_queues.h.
| #define qGetLink | ( | qp | ) | ((qp)->q_link) | 
Returns the queue application-defined link.
| [in] | qp | pointer to a io_queue_t structure  | 
Definition at line 153 of file hal_queues.h.
| #define qSetLink | ( | qp, | |
| lk | |||
| ) | ((qp)->q_link = lk) | 
Sets the queue application-defined link.
| [in] | qp | pointer to a io_queue_t structure  | 
| [in] | lk | The application-defined link. | 
Definition at line 164 of file hal_queues.h.
| #define iqGetFullI | ( | iqp | ) | qSpaceI(iqp) | 
Returns the filled space into an input queue.
| [in] | iqp | pointer to an input_queue_t structure  | 
| 0 | if the queue is empty. | 
Definition at line 175 of file hal_queues.h.
Referenced by iq_read().
Returns the empty space into an input queue.
| [in] | iqp | pointer to an input_queue_t structure  | 
| 0 | if the queue is full. | 
Definition at line 186 of file hal_queues.h.
| #define iqIsEmptyI | ( | iqp | ) | ((bool)(qSpaceI(iqp) == 0U)) | 
Evaluates to true if the specified input queue is empty. 
| [in] | iqp | pointer to an input_queue_t structure  | 
| false | if the queue is not empty. | 
| true | if the queue is empty. | 
Definition at line 198 of file hal_queues.h.
Referenced by iqGetI(), iqGetTimeout(), sdGetWouldBlock(), and sdIncomingDataI().
| #define iqIsFullI | ( | iqp | ) | 
Evaluates to true if the specified input queue is full. 
| [in] | iqp | pointer to an input_queue_t structure  | 
| false | if the queue is not full. | 
| true | if the queue is full. | 
Definition at line 210 of file hal_queues.h.
Referenced by iqPutI().
| #define iqGet | ( | iqp | ) | iqGetTimeout(iqp, TIME_INFINITE) | 
Input queue read.
This function reads a byte value from an input queue. If the queue is empty then the calling thread is suspended until a byte arrives in the queue.
| [in] | iqp | pointer to an input_queue_t structure  | 
| MSG_RESET | if the queue has been reset. | 
Definition at line 227 of file hal_queues.h.
Returns the filled space into an output queue.
| [in] | oqp | pointer to an output_queue_t structure  | 
| 0 | if the queue is empty. | 
Definition at line 238 of file hal_queues.h.
| #define oqGetEmptyI | ( | oqp | ) | qSpaceI(oqp) | 
Returns the empty space into an output queue.
| [in] | oqp | pointer to an output_queue_t structure  | 
| 0 | if the queue is full. | 
Definition at line 249 of file hal_queues.h.
Referenced by oq_write().
| #define oqIsEmptyI | ( | oqp | ) | 
Evaluates to true if the specified output queue is empty. 
| [in] | oqp | pointer to an output_queue_t structure  | 
| false | if the queue is not empty. | 
| true | if the queue is empty. | 
Definition at line 261 of file hal_queues.h.
Referenced by oqGetI().
| #define oqIsFullI | ( | oqp | ) | ((bool)(qSpaceI(oqp) == 0U)) | 
Evaluates to true if the specified output queue is full. 
| [in] | oqp | pointer to an output_queue_t structure  | 
| false | if the queue is not full. | 
| true | if the queue is full. | 
Definition at line 276 of file hal_queues.h.
Referenced by oqPutI(), oqPutTimeout(), and sdPutWouldBlock().
| #define oqPut | ( | oqp, | |
| b | |||
| ) | oqPutTimeout(oqp, b, TIME_INFINITE) | 
Output queue write.
This function writes a byte value to an output queue. If the queue is full then the calling thread is suspended until there is space in the queue.
| [in] | oqp | pointer to an output_queue_t structure  | 
| [in] | b | the byte value to be written in the queue | 
| MSG_OK | if the operation succeeded. | 
| MSG_RESET | if the queue has been reset. | 
Definition at line 292 of file hal_queues.h.
| typedef struct io_queue io_queue_t | 
Type of a generic I/O queue structure.
Definition at line 58 of file hal_queues.h.
| typedef void(* qnotify_t) (io_queue_t *qp) | 
Queue notification callback type.
| [in] | qp | the queue pointer | 
Definition at line 65 of file hal_queues.h.
| typedef io_queue_t input_queue_t | 
Type of an input queue structure.
This structure represents a generic asymmetrical input queue. Writing to the queue is non-blocking and can be performed from interrupt handlers or from within a kernel lock zone. Reading the queue can be a blocking operation and is supposed to be performed by a system thread.
Definition at line 97 of file hal_queues.h.
| typedef io_queue_t output_queue_t | 
Type of an output queue structure.
This structure represents a generic asymmetrical output queue. Reading from the queue is non-blocking and can be performed from interrupt handlers or from within a kernel lock zone. Writing the queue can be a blocking operation and is supposed to be performed by a system thread.
Definition at line 109 of file hal_queues.h.
      
  | 
  static | 
Non-blocking input queue read.
The function reads data from an input queue into a buffer. The operation completes when the specified amount of data has been transferred or when the input queue has been emptied.
| [in] | iqp | pointer to an input_queue_t structure  | 
| [out] | bp | pointer to the data buffer | 
| [in] | n | the maximum amount of data to be transferred, the value 0 is reserved | 
Definition at line 60 of file hal_queues.c.
References iqGetFullI, osalDbgCheck, io_queue::q_buffer, io_queue::q_counter, io_queue::q_rdptr, and io_queue::q_top.
Referenced by iqReadI(), and iqReadTimeout().
      
  | 
  static | 
Non-blocking output queue write.
The function writes data from a buffer to an output queue. The operation completes when the specified amount of data has been transferred or when the output queue has been filled.
| [in] | oqp | pointer to an output_queue_t structure  | 
| [in] | bp | pointer to the data buffer | 
| [in] | n | the maximum amount of data to be transferred, the value 0 is reserved | 
Definition at line 108 of file hal_queues.c.
References oqGetEmptyI, osalDbgCheck, io_queue::q_buffer, io_queue::q_counter, io_queue::q_top, and io_queue::q_wrptr.
Referenced by oqWriteI(), and oqWriteTimeout().
| void iqObjectInit | ( | input_queue_t * | iqp, | 
| uint8_t * | bp, | ||
| size_t | size, | ||
| qnotify_t | infy, | ||
| void * | link | ||
| ) | 
Initializes an input queue.
A Semaphore is internally initialized and works as a counter of the bytes contained in the queue.
| [out] | iqp | pointer to an input_queue_t structure  | 
| [in] | bp | pointer to a memory area allocated as queue buffer | 
| [in] | size | size of the queue buffer | 
| [in] | infy | pointer to a callback function that is invoked when data is read from the queue. The value can be NULL.  | 
| [in] | link | application defined pointer | 
Definition at line 177 of file hal_queues.c.
References osalThreadQueueObjectInit(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_link, io_queue::q_notify, io_queue::q_rdptr, io_queue::q_top, io_queue::q_waiting, and io_queue::q_wrptr.
Referenced by sdObjectInit().

| void iqResetI | ( | input_queue_t * | iqp | ) | 
Resets an input queue.
All the data in the input queue is erased and lost, any waiting thread is resumed with status MSG_RESET. 
| [in] | iqp | pointer to an input_queue_t structure | 
Definition at line 201 of file hal_queues.c.
References MSG_RESET, osalDbgCheckClassI, osalThreadDequeueAllI(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_rdptr, io_queue::q_waiting, and io_queue::q_wrptr.
Referenced by sdStop().

| msg_t iqPutI | ( | input_queue_t * | iqp, | 
| uint8_t | b | ||
| ) | 
Input queue write.
A byte value is written into the low end of an input queue. The operation completes immediately.
| [in] | iqp | pointer to an input_queue_t structure  | 
| [in] | b | the byte value to be written in the queue | 
| MSG_OK | if the operation has been completed with success. | 
| MSG_TIMEOUT | if the queue is full. | 
Definition at line 224 of file hal_queues.c.
References iqIsFullI, MSG_OK, MSG_TIMEOUT, osalDbgCheckClassI, osalThreadDequeueNextI(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_top, io_queue::q_waiting, and io_queue::q_wrptr.
Referenced by sdIncomingDataI().

| msg_t iqGetI | ( | input_queue_t * | iqp | ) | 
Input queue non-blocking read.
This function reads a byte value from an input queue. The operation completes immediately.
| [in] | iqp | pointer to an input_queue_t structure  | 
| MSG_TIMEOUT | if the queue is empty. | 
| MSG_RESET | if the queue has been reset. | 
Definition at line 258 of file hal_queues.c.
References iqIsEmptyI, MSG_TIMEOUT, osalDbgCheckClassI, io_queue::q_buffer, io_queue::q_counter, io_queue::q_notify, io_queue::q_rdptr, and io_queue::q_top.
| msg_t iqGetTimeout | ( | input_queue_t * | iqp, | 
| sysinterval_t | timeout | ||
| ) | 
Input queue read with timeout.
This function reads a byte value from an input queue. If the queue is empty then the calling thread is suspended until a byte arrives in the queue or a timeout occurs.
| [in] | iqp | pointer to an input_queue_t structure  | 
| [in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
  | 
| MSG_TIMEOUT | if the specified time expired. | 
| MSG_RESET | if the queue has been reset. | 
Definition at line 304 of file hal_queues.c.
References iqIsEmptyI, MSG_OK, osalSysLock(), osalSysUnlock(), osalThreadEnqueueTimeoutS(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_notify, io_queue::q_rdptr, io_queue::q_top, and io_queue::q_waiting.

| size_t iqReadI | ( | input_queue_t * | iqp, | 
| uint8_t * | bp, | ||
| size_t | n | ||
| ) | 
Input queue non-blocking read.
The function reads data from an input queue into a buffer. The operation completes immediately.
| [in] | iqp | pointer to an input_queue_t structure  | 
| [out] | bp | pointer to the data buffer | 
| [in] | n | the maximum amount of data to be transferred, the value 0 is reserved | 
Definition at line 348 of file hal_queues.c.
References iq_read(), osalDbgCheckClassI, and io_queue::q_notify.

| size_t iqReadTimeout | ( | input_queue_t * | iqp, | 
| uint8_t * | bp, | ||
| size_t | n, | ||
| sysinterval_t | timeout | ||
| ) | 
Input queue read with timeout.
The function reads data from an input queue into a buffer. The operation completes when the specified amount of data has been transferred or after the specified timeout or if the queue has been reset.
| [in] | iqp | pointer to an input_queue_t structure  | 
| [out] | bp | pointer to the data buffer | 
| [in] | n | the maximum amount of data to be transferred, the value 0 is reserved | 
| [in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
  | 
Definition at line 389 of file hal_queues.c.
References iq_read(), MSG_OK, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadEnqueueTimeoutS(), io_queue::q_notify, and io_queue::q_waiting.

| void oqObjectInit | ( | output_queue_t * | oqp, | 
| uint8_t * | bp, | ||
| size_t | size, | ||
| qnotify_t | onfy, | ||
| void * | link | ||
| ) | 
Initializes an output queue.
A Semaphore is internally initialized and works as a counter of the free bytes in the queue.
| [out] | oqp | pointer to an output_queue_t structure  | 
| [in] | bp | pointer to a memory area allocated as queue buffer | 
| [in] | size | size of the queue buffer | 
| [in] | onfy | pointer to a callback function that is invoked when data is written to the queue. The value can be NULL.  | 
| [in] | link | application defined pointer | 
Definition at line 446 of file hal_queues.c.
References osalThreadQueueObjectInit(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_link, io_queue::q_notify, io_queue::q_rdptr, io_queue::q_top, io_queue::q_waiting, and io_queue::q_wrptr.
Referenced by sdObjectInit().

| void oqResetI | ( | output_queue_t * | oqp | ) | 
Resets an output queue.
All the data in the output queue is erased and lost, any waiting thread is resumed with status MSG_RESET. 
| [in] | oqp | pointer to an output_queue_t structure | 
Definition at line 470 of file hal_queues.c.
References MSG_RESET, osalDbgCheckClassI, osalThreadDequeueAllI(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_rdptr, io_queue::q_waiting, io_queue::q_wrptr, and qSizeX.
Referenced by sdStop().

| msg_t oqPutI | ( | output_queue_t * | oqp, | 
| uint8_t | b | ||
| ) | 
Output queue non-blocking write.
This function writes a byte value to an output queue. The operation completes immediately.
| [in] | oqp | pointer to an output_queue_t structure  | 
| [in] | b | the byte value to be written in the queue | 
| MSG_OK | if the operation succeeded. | 
| MSG_TIMEOUT | if the queue is full. | 
| MSG_RESET | if the queue has been reset. | 
Definition at line 494 of file hal_queues.c.
References MSG_OK, MSG_TIMEOUT, oqIsFullI, osalDbgCheckClassI, io_queue::q_buffer, io_queue::q_counter, io_queue::q_notify, io_queue::q_top, and io_queue::q_wrptr.
| msg_t oqPutTimeout | ( | output_queue_t * | oqp, | 
| uint8_t | b, | ||
| sysinterval_t | timeout | ||
| ) | 
Output queue write with timeout.
This function writes a byte value to an output queue. If the queue is full then the calling thread is suspended until there is space in the queue or a timeout occurs.
| [in] | oqp | pointer to an output_queue_t structure  | 
| [in] | b | the byte value to be written in the queue | 
| [in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
  | 
| MSG_OK | if the operation succeeded. | 
| MSG_TIMEOUT | if the specified time expired. | 
| MSG_RESET | if the queue has been reset. | 
Definition at line 540 of file hal_queues.c.
References MSG_OK, oqIsFullI, osalSysLock(), osalSysUnlock(), osalThreadEnqueueTimeoutS(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_notify, io_queue::q_top, io_queue::q_waiting, and io_queue::q_wrptr.

| msg_t oqGetI | ( | output_queue_t * | oqp | ) | 
Output queue read.
A byte value is read from the low end of an output queue. The operation completes immediately.
| [in] | oqp | pointer to an output_queue_t structure  | 
| MSG_TIMEOUT | if the queue is empty. | 
Definition at line 581 of file hal_queues.c.
References MSG_OK, MSG_TIMEOUT, oqIsEmptyI, osalDbgCheckClassI, osalThreadDequeueNextI(), io_queue::q_buffer, io_queue::q_counter, io_queue::q_rdptr, io_queue::q_top, and io_queue::q_waiting.
Referenced by sdRequestDataI().

| size_t oqWriteI | ( | output_queue_t * | oqp, | 
| const uint8_t * | bp, | ||
| size_t | n | ||
| ) | 
Output queue non-blocking write.
The function writes data from a buffer to an output queue. The operation completes immediately.
| [in] | oqp | pointer to an output_queue_t structure  | 
| [in] | bp | pointer to the data buffer | 
| [in] | n | the maximum amount of data to be transferred, the value 0 is reserved | 
Definition at line 617 of file hal_queues.c.
References oq_write(), osalDbgCheckClassI, and io_queue::q_notify.

| size_t oqWriteTimeout | ( | output_queue_t * | oqp, | 
| const uint8_t * | bp, | ||
| size_t | n, | ||
| sysinterval_t | timeout | ||
| ) | 
Output queue write with timeout.
The function writes data from a buffer to an output queue. The operation completes when the specified amount of data has been transferred or after the specified timeout or if the queue has been reset.
| [in] | oqp | pointer to an output_queue_t structure  | 
| [in] | bp | pointer to the data buffer | 
| [in] | n | the maximum amount of data to be transferred, the value 0 is reserved | 
| [in] | timeout | the number of ticks before the operation timeouts, the following special values are allowed:
  | 
Definition at line 658 of file hal_queues.c.
References MSG_OK, oq_write(), osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadEnqueueTimeoutS(), io_queue::q_notify, and io_queue::q_waiting.
