mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Update QueueOverwrite.c to include a call to xQueuePeekFromISR().
Default new QueuePeekFromISR() trace macros.
This commit is contained in:
parent
3b02b4c8f8
commit
b8a219b30c
|
@ -233,6 +233,13 @@ unsigned long ulRx;
|
||||||
last parameter is not used because there are no tasks blocked on
|
last parameter is not used because there are no tasks blocked on
|
||||||
this queue. */
|
this queue. */
|
||||||
xQueueOverwriteFromISR( xISRQueue, &ulTx1, NULL );
|
xQueueOverwriteFromISR( xISRQueue, &ulTx1, NULL );
|
||||||
|
|
||||||
|
/* Peek the queue to check it holds the expected value. */
|
||||||
|
xQueuePeekFromISR( xISRQueue, &ulRx );
|
||||||
|
if( ulRx != ulTx1 )
|
||||||
|
{
|
||||||
|
xISRTestStatus = pdFAIL;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
@ -410,6 +410,10 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
|
||||||
#define traceQUEUE_PEEK( pxQueue )
|
#define traceQUEUE_PEEK( pxQueue )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef traceQUEUE_PEEK_FROM_ISR
|
||||||
|
#define traceQUEUE_PEEK_FROM_ISR( pxQueue )
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef traceQUEUE_RECEIVE_FAILED
|
#ifndef traceQUEUE_RECEIVE_FAILED
|
||||||
#define traceQUEUE_RECEIVE_FAILED( pxQueue )
|
#define traceQUEUE_RECEIVE_FAILED( pxQueue )
|
||||||
#endif
|
#endif
|
||||||
|
@ -430,6 +434,10 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
|
||||||
#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
|
#define traceQUEUE_RECEIVE_FROM_ISR_FAILED( pxQueue )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef traceQUEUE_PEEK_FROM_ISR_FAILED
|
||||||
|
#define traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue )
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef traceQUEUE_DELETE
|
#ifndef traceQUEUE_DELETE
|
||||||
#define traceQUEUE_DELETE( pxQueue )
|
#define traceQUEUE_DELETE( pxQueue )
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -616,7 +616,9 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
|
||||||
* Successfully received items remain on the queue so will be returned again
|
* Successfully received items remain on the queue so will be returned again
|
||||||
* by the next call, or a call to xQueueReceive().
|
* by the next call, or a call to xQueueReceive().
|
||||||
*
|
*
|
||||||
* This macro must not be used in an interrupt service routine.
|
* This macro must not be used in an interrupt service routine. See
|
||||||
|
* xQueuePeekFromISR() for an alternative that can be called from an interrupt
|
||||||
|
* service routine.
|
||||||
*
|
*
|
||||||
* @param xQueue The handle to the queue from which the item is to be
|
* @param xQueue The handle to the queue from which the item is to be
|
||||||
* received.
|
* received.
|
||||||
|
@ -691,6 +693,39 @@ signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const
|
||||||
*/
|
*/
|
||||||
#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
|
#define xQueuePeek( xQueue, pvBuffer, xTicksToWait ) xQueueGenericReceive( ( xQueue ), ( pvBuffer ), ( xTicksToWait ), pdTRUE )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* queue. h
|
||||||
|
* <pre>
|
||||||
|
portBASE_TYPE xQueuePeekFromISR(
|
||||||
|
xQueueHandle xQueue,
|
||||||
|
void *pvBuffer,
|
||||||
|
);</pre>
|
||||||
|
*
|
||||||
|
* A version of xQueuePeek() that can be called from an interrupt service
|
||||||
|
* routine (ISR).
|
||||||
|
*
|
||||||
|
* Receive an item from a queue without removing the item from the queue.
|
||||||
|
* The item is received by copy so a buffer of adequate size must be
|
||||||
|
* provided. The number of bytes copied into the buffer was defined when
|
||||||
|
* the queue was created.
|
||||||
|
*
|
||||||
|
* Successfully received items remain on the queue so will be returned again
|
||||||
|
* by the next call, or a call to xQueueReceive().
|
||||||
|
*
|
||||||
|
* @param xQueue The handle to the queue from which the item is to be
|
||||||
|
* received.
|
||||||
|
*
|
||||||
|
* @param pvBuffer Pointer to the buffer into which the received item will
|
||||||
|
* be copied.
|
||||||
|
*
|
||||||
|
* @return pdTRUE if an item was successfully received from the queue,
|
||||||
|
* otherwise pdFALSE.
|
||||||
|
*
|
||||||
|
* \defgroup xQueuePeekFromISR xQueuePeekFromISR
|
||||||
|
* \ingroup QueueManagement
|
||||||
|
*/
|
||||||
|
signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* queue. h
|
* queue. h
|
||||||
* <pre>
|
* <pre>
|
||||||
|
|
|
@ -1060,7 +1060,7 @@ xQUEUE *pxQueue;
|
||||||
{
|
{
|
||||||
traceQUEUE_RECEIVE( pxQueue );
|
traceQUEUE_RECEIVE( pxQueue );
|
||||||
|
|
||||||
/* We are actually removing data. */
|
/* Actually removing data, not just peeking. */
|
||||||
--( pxQueue->uxMessagesWaiting );
|
--( pxQueue->uxMessagesWaiting );
|
||||||
|
|
||||||
#if ( configUSE_MUTEXES == 1 )
|
#if ( configUSE_MUTEXES == 1 )
|
||||||
|
@ -1191,7 +1191,7 @@ xQUEUE *pxQueue;
|
||||||
|
|
||||||
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||||
{
|
{
|
||||||
/* We cannot block from an ISR, so check there is data available. */
|
/* Cannot block in an ISR, so check there is data available. */
|
||||||
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
||||||
{
|
{
|
||||||
traceQUEUE_RECEIVE_FROM_ISR( pxQueue );
|
traceQUEUE_RECEIVE_FROM_ISR( pxQueue );
|
||||||
|
@ -1199,9 +1199,10 @@ xQUEUE *pxQueue;
|
||||||
prvCopyDataFromQueue( pxQueue, pvBuffer );
|
prvCopyDataFromQueue( pxQueue, pvBuffer );
|
||||||
--( pxQueue->uxMessagesWaiting );
|
--( pxQueue->uxMessagesWaiting );
|
||||||
|
|
||||||
/* If the queue is locked we will not modify the event list. Instead
|
/* If the queue is locked the event list will not be modified.
|
||||||
we update the lock count so the task that unlocks the queue will know
|
Instead update the lock count so the task that unlocks the queue
|
||||||
that an ISR has removed data while the queue was locked. */
|
will know that an ISR has removed data while the queue was
|
||||||
|
locked. */
|
||||||
if( pxQueue->xRxLock == queueUNLOCKED )
|
if( pxQueue->xRxLock == queueUNLOCKED )
|
||||||
{
|
{
|
||||||
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
|
if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE )
|
||||||
|
@ -1238,6 +1239,44 @@ xQUEUE *pxQueue;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle xQueue, void * const pvBuffer )
|
||||||
|
{
|
||||||
|
signed portBASE_TYPE xReturn;
|
||||||
|
unsigned portBASE_TYPE uxSavedInterruptStatus;
|
||||||
|
signed char *pcOriginalReadPosition;
|
||||||
|
xQUEUE *pxQueue;
|
||||||
|
|
||||||
|
pxQueue = ( xQUEUE * ) xQueue;
|
||||||
|
configASSERT( pxQueue );
|
||||||
|
configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( unsigned portBASE_TYPE ) 0U ) ) );
|
||||||
|
|
||||||
|
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||||
|
{
|
||||||
|
/* Cannot block in an ISR, so check there is data available. */
|
||||||
|
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
|
||||||
|
{
|
||||||
|
traceQUEUE_PEEK_FROM_ISR( pxQueue );
|
||||||
|
|
||||||
|
/* Remember the read position so it can be reset as nothing is
|
||||||
|
actually being removed from the queue. */
|
||||||
|
pcOriginalReadPosition = pxQueue->u.pcReadFrom;
|
||||||
|
prvCopyDataFromQueue( pxQueue, pvBuffer );
|
||||||
|
pxQueue->u.pcReadFrom = pcOriginalReadPosition;
|
||||||
|
|
||||||
|
xReturn = pdPASS;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xReturn = pdFAIL;
|
||||||
|
traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );
|
||||||
|
|
||||||
|
return xReturn;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue )
|
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue )
|
||||||
{
|
{
|
||||||
unsigned portBASE_TYPE uxReturn;
|
unsigned portBASE_TYPE uxReturn;
|
||||||
|
|
Loading…
Reference in a new issue