| 1928 | /*-----------------------------------------------------------*/ |
| 1929 | |
| 1930 | BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue, |
| 1931 | void * const pvBuffer ) |
| 1932 | { |
| 1933 | BaseType_t xReturn; |
| 1934 | UBaseType_t uxSavedInterruptStatus; |
| 1935 | int8_t * pcOriginalReadPosition; |
| 1936 | Queue_t * const pxQueue = xQueue; |
| 1937 | |
| 1938 | configASSERT( pxQueue ); |
| 1939 | configASSERT( !( ( pvBuffer == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); |
| 1940 | configASSERT( pxQueue->uxItemSize != 0 ); /* Can't peek a semaphore. */ |
| 1941 | |
| 1942 | /* RTOS ports that support interrupt nesting have the concept of a maximum |
| 1943 | * system call (or maximum API call) interrupt priority. Interrupts that are |
| 1944 | * above the maximum system call priority are kept permanently enabled, even |
| 1945 | * when the RTOS kernel is in a critical section, but cannot make any calls to |
| 1946 | * FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h |
| 1947 | * then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion |
| 1948 | * failure if a FreeRTOS API function is called from an interrupt that has been |
| 1949 | * assigned a priority above the configured maximum system call priority. |
| 1950 | * Only FreeRTOS functions that end in FromISR can be called from interrupts |
| 1951 | * that have been assigned a priority at or (logically) below the maximum |
| 1952 | * system call interrupt priority. FreeRTOS maintains a separate interrupt |
| 1953 | * safe API to ensure interrupt entry is as fast and as simple as possible. |
| 1954 | * More information (albeit Cortex-M specific) is provided on the following |
| 1955 | * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */ |
| 1956 | portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); |
| 1957 | |
| 1958 | uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); |
| 1959 | { |
| 1960 | /* Cannot block in an ISR, so check there is data available. */ |
| 1961 | if( pxQueue->uxMessagesWaiting > ( UBaseType_t ) 0 ) |
| 1962 | { |
| 1963 | traceQUEUE_PEEK_FROM_ISR( pxQueue ); |
| 1964 | |
| 1965 | /* Remember the read position so it can be reset as nothing is |
| 1966 | * actually being removed from the queue. */ |
| 1967 | pcOriginalReadPosition = pxQueue->u.xQueue.pcReadFrom; |
| 1968 | prvCopyDataFromQueue( pxQueue, pvBuffer ); |
| 1969 | pxQueue->u.xQueue.pcReadFrom = pcOriginalReadPosition; |
| 1970 | |
| 1971 | xReturn = pdPASS; |
| 1972 | } |
| 1973 | else |
| 1974 | { |
| 1975 | xReturn = pdFAIL; |
| 1976 | traceQUEUE_PEEK_FROM_ISR_FAILED( pxQueue ); |
| 1977 | } |
| 1978 | } |
| 1979 | portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); |
| 1980 | |
| 1981 | return xReturn; |
| 1982 | } |
| 1983 | /*-----------------------------------------------------------*/ |
| 1984 | |
| 1985 | UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue ) |
nothing calls this directly
no test coverage detected