Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

xQueuePeek() inside an ISR

Posted by Paul Coleman on December 19, 2012
If I use a block time of zero is it safe to use xQueuePeek() inside an ISR?

Thanks, Paul.

RE: xQueuePeek() inside an ISR

Posted by Richard on December 19, 2012
You can't use the existing peek function from an ISR, but could add something like the following (not actually tested!)

signed portBASE_TYPE xQueuePeekFromISR( xQueueHandle pxQueue, void * const pvBuffer )
{
signed portBASE_TYPE xReturn;
unsigned portBASE_TYPE uxSavedInterruptStatus;
signed char *pcOriginalReadPosition;

uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
{
/* We cannot block from an ISR, so check there is data available. */
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
{
/* Remember the read position in case we are just peeking. */
pcOriginalReadPosition = pxQueue->pcReadFrom;

prvCopyDataFromQueue( pxQueue, pvBuffer );

/* The data is not being removed, so reset the read pointer to its
original position. */
pxQueue->pcReadFrom = pcOriginalReadPosition;
xReturn = pdPASS;
}
else
{
xReturn = pdFAIL;
}
}
portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus );

return xReturn;
}



Regards.

RE: xQueuePeek() inside an ISR

Posted by Paul Coleman on December 19, 2012
Okay, thanks.

Paul.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS