Quality RTOS & Embedded Software

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


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 ]    [ Privacy ]    [ Sitemap ]    [ ]


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

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

Xilinx Microblaze and Zynq partner