Add the uxQueueSpacesAvailable() API function.

Move a configASSERT() call in timers.c to prevent a "condition is always true" compiler warning.
This commit is contained in:
Richard Barry 2013-09-10 13:19:12 +00:00
parent dd3fdfa9ff
commit 1902d2b64a
3 changed files with 50 additions and 15 deletions

View File

@ -922,6 +922,23 @@ signed portBASE_TYPE xQueueGenericReceive( xQueueHandle xQueue, const void * con
*/
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle xQueue ) PRIVILEGED_FUNCTION;
/**
* queue. h
* <pre>unsigned portBASE_TYPE uxQueueSpacesAvailable( const xQueueHandle xQueue );</pre>
*
* Return the number of free spaces available in a queue. This is equal to the
* number of items that can be sent to the queue before the queue becomes full
* if no items are removed.
*
* @param xQueue A handle to the queue being queried.
*
* @return The number of spaces available in the queue.
*
* \defgroup uxQueueMessagesWaiting uxQueueMessagesWaiting
* \ingroup QueueManagement
*/
unsigned portBASE_TYPE uxQueueSpacesAvailable( const xQueueHandle xQueue ) PRIVILEGED_FUNCTION;
/**
* queue. h
* <pre>void vQueueDelete( xQueueHandle xQueue );</pre>

View File

@ -497,7 +497,7 @@ xQueueHandle xReturn = NULL;
traceTAKE_MUTEX_RECURSIVE( pxMutex );
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */
if( pxMutex->pxMutexHolder == ( void * ) xTaskGetCurrentTaskHandle() ) /*lint !e961 Cast is not redundant as xTaskHandle is a typedef. */
{
( pxMutex->u.uxRecursiveCallCount )++;
xReturn = pdPASS;
@ -651,7 +651,7 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
}
else
{
/* Entry time was already set. */
/* Entry time was already set. */
}
}
}
@ -1198,17 +1198,17 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
/* RTOS ports that support interrupt nesting have the concept of a maximum
system call (or maximum API call) interrupt priority. Interrupts that are
above the maximum system call priority are keep permanently enabled, even
above the maximum system call priority are keep permanently enabled, even
when the RTOS kernel is in a critical section, but cannot make any calls to
FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion
failure if a FreeRTOS API function is called from an interrupt that has been
assigned a priority above the configured maximum system call priority.
Only FreeRTOS functions that end in FromISR can be called from interrupts
that have been assigned a priority at or (logically) below the maximum
system call interrupt priority. FreeRTOS maintains a separate interrupt
safe API to ensure interrupt entry is as fast and as simple as possible.
More information (albeit Cortex-M specific) is provided on the following
that have been assigned a priority at or (logically) below the maximum
system call interrupt priority. FreeRTOS maintains a separate interrupt
safe API to ensure interrupt entry is as fast and as simple as possible.
More information (albeit Cortex-M specific) is provided on the following
link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
@ -1274,17 +1274,17 @@ xQUEUE * const pxQueue = ( xQUEUE * ) xQueue;
/* RTOS ports that support interrupt nesting have the concept of a maximum
system call (or maximum API call) interrupt priority. Interrupts that are
above the maximum system call priority are keep permanently enabled, even
above the maximum system call priority are keep permanently enabled, even
when the RTOS kernel is in a critical section, but cannot make any calls to
FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
FreeRTOS API functions. If configASSERT() is defined in FreeRTOSConfig.h
then portASSERT_IF_INTERRUPT_PRIORITY_INVALID() will result in an assertion
failure if a FreeRTOS API function is called from an interrupt that has been
assigned a priority above the configured maximum system call priority.
Only FreeRTOS functions that end in FromISR can be called from interrupts
that have been assigned a priority at or (logically) below the maximum
system call interrupt priority. FreeRTOS maintains a separate interrupt
safe API to ensure interrupt entry is as fast and as simple as possible.
More information (albeit Cortex-M specific) is provided on the following
that have been assigned a priority at or (logically) below the maximum
system call interrupt priority. FreeRTOS maintains a separate interrupt
safe API to ensure interrupt entry is as fast and as simple as possible.
More information (albeit Cortex-M specific) is provided on the following
link: http://www.freertos.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
@ -1329,6 +1329,22 @@ unsigned portBASE_TYPE uxReturn;
} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */
/*-----------------------------------------------------------*/
unsigned portBASE_TYPE uxQueueSpacesAvailable( const xQueueHandle xQueue )
{
unsigned portBASE_TYPE uxReturn;
xQUEUE *pxQueue;
pxQueue = ( xQUEUE * ) xQueue;
configASSERT( pxQueue );
taskENTER_CRITICAL();
uxReturn = pxQueue->uxLength - pxQueue->uxMessagesWaiting;
taskEXIT_CRITICAL();
return uxReturn;
} /*lint !e818 Pointer cannot be declared const as xQueue is a typedef not pointer. */
/*-----------------------------------------------------------*/
unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle xQueue )
{
unsigned portBASE_TYPE uxReturn;

View File

@ -233,7 +233,6 @@ xTIMER *pxNewTimer;
if( xTimerPeriodInTicks == ( portTickType ) 0U )
{
pxNewTimer = NULL;
configASSERT( ( xTimerPeriodInTicks > 0 ) );
}
else
{
@ -260,6 +259,9 @@ xTIMER *pxNewTimer;
}
}
/* 0 is not a valid value for xTimerPeriodInTicks. */
configASSERT( ( xTimerPeriodInTicks > 0 ) );
return ( xTimerHandle ) pxNewTimer;
}
/*-----------------------------------------------------------*/