last parameter is not used because there are no tasks blocked on\r
this queue. */\r
xQueueOverwriteFromISR( xISRQueue, &ulTx1, NULL );\r
+\r
+ /* Peek the queue to check it holds the expected value. */\r
+ xQueuePeekFromISR( xISRQueue, &ulRx );\r
+ if( ulRx != ulTx1 )\r
+ {\r
+ xISRTestStatus = pdFAIL;\r
+ }\r
break;\r
\r
case 1:\r
/* The queue already holds ulTx1. Overwrite the value in the queue\r
with ulTx2. */\r
- xQueueOverwriteFromISR( xISRQueue, &ulTx2, NULL );\r
+ xQueueOverwriteFromISR( xISRQueue, &ulTx2, NULL ); \r
break;\r
\r
case 2:\r
#define traceQUEUE_PEEK( pxQueue )\r
#endif\r
\r
+#ifndef traceQUEUE_PEEK_FROM_ISR\r
+ #define traceQUEUE_PEEK_FROM_ISR( pxQueue )\r
+#endif\r
+\r
#ifndef traceQUEUE_RECEIVE_FAILED\r
#define traceQUEUE_RECEIVE_FAILED( pxQueue )\r
#endif\r
#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )\r
#endif\r
\r
+#ifndef traceQUEUE_PEEK_FROM_ISR_FAILED\r
+ #define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )\r
+#endif\r
+\r
#ifndef traceQUEUE_DELETE\r
#define traceQUEUE_DELETE( pxQueue )\r
#endif\r
* Successfully received items remain on the queue so will be returned again\r
* by the next call, or a call to xQueueReceive().\r
*\r
- * This macro must not be used in an interrupt service routine.\r
+ * This macro must not be used in an interrupt service routine. See\r
+ * xQueuePeekFromISR() for an alternative that can be called from an interrupt\r
+ * service routine.\r
*\r
* @param xQueue The handle to the queue from which the item is to be\r
* received.\r
*/\r
#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )\r
\r
+/**\r
+ * queue. h\r
+ * <pre>\r
+ portBASE_TYPE xQueuePeekFromISR(\r
+ xQueueHandle xQueue,\r
+ void *pvBuffer,\r
+ );</pre>\r
+ *\r
+ * A version of xQueuePeek() that can be called from an interrupt service\r
+ * routine (ISR).\r
+ *\r
+ * Receive an item from a queue without removing the item from the queue.\r
+ * The item is received by copy so a buffer of adequate size must be\r
+ * provided. The number of bytes copied into the buffer was defined when\r
+ * the queue was created.\r
+ *\r
+ * Successfully received items remain on the queue so will be returned again\r
+ * by the next call, or a call to xQueueReceive().\r
+ *\r
+ * @param xQueue The handle to the queue from which the item is to be\r
+ * received.\r
+ *\r
+ * @param pvBuffer Pointer to the buffer into which the received item will\r
+ * be copied.\r
+ *\r
+ * @return pdTRUE if an item was successfully received from the queue,\r
+ * otherwise pdFALSE.\r
+ *\r
+ * \defgroup xQueuePeekFromISR xQueuePeekFromISR\r
+ * \ingroup QueueManagement\r
+ */\r
+signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer );\r
+\r
/**\r
* queue. h\r
* <pre>\r
{\r
traceQUEUE_RECEIVE( pxQueue );\r
\r
- /* We are actually removing data. */\r
+ /* Actually removing data, not just peeking. */\r
--( pxQueue->uxMessagesWaiting );\r
\r
#if ( configUSE_MUTEXES == 1 )\r
\r
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
{\r
- /* We cannot block from an ISR, so check there is data available. */\r
+ /* Cannot block in an ISR, so check there is data available. */\r
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
{\r
traceQUEUE_RECEIVE_FROM_ISR( pxQueue );\r
prvCopyDataFromQueue( pxQueue, pvBuffer );\r
--( pxQueue->uxMessagesWaiting );\r
\r
- /* If the queue is locked we will not modify the event list. Instead\r
- we update the lock count so the task that unlocks the queue will know\r
- that an ISR has removed data while the queue was locked. */\r
+ /* If the queue is locked the event list will not be modified. \r
+ Instead update the lock count so the task that unlocks the queue \r
+ will know that an ISR has removed data while the queue was \r
+ locked. */\r
if( pxQueue->xRxLock == queueUNLOCKED )\r
{\r
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )\r
}\r
/*-----------------------------------------------------------*/\r
\r
+signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer )\r
+{\r
+signed portBASE_TYPE xReturn;\r
+unsigned portBASE_TYPE uxSavedInterruptStatus;\r
+signed char *pcOriginalReadPosition;\r
+xQUEUE *pxQueue;\r
+\r
+ pxQueue = ( xQUEUE * ) xQueue;\r
+ configASSERT( pxQueue );\r
+ configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );\r
+\r
+ uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();\r
+ {\r
+ /* Cannot block in an ISR, so check there is data available. */\r
+ if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )\r
+ {\r
+ traceQUEUE_PEEK_FROM_ISR( pxQueue );\r
+\r
+ /* Remember the read position so it can be reset as nothing is\r
+ actually being removed from the queue. */\r
+ pcOriginalReadPosition = pxQueue->u.pcReadFrom;\r
+ prvCopyDataFromQueue( pxQueue, pvBuffer );\r
+ pxQueue->u.pcReadFrom = pcOriginalReadPosition;\r
+\r
+ xReturn = pdPASS;\r
+ }\r
+ else\r
+ {\r
+ xReturn = pdFAIL;\r
+ traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );\r
+ }\r
+ }\r
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );\r
+\r
+ return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue )\r
{\r
unsigned portBASE_TYPE uxReturn;\r