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

@ -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;
}
/*-----------------------------------------------------------*/