Formalize new "priority" command category

And send priority commands to front even if the scheduler is disabled.
This commit is contained in:
Jeff Tenney 2021-04-09 07:43:22 -07:00
parent e2235a695e
commit ce66916378
2 changed files with 30 additions and 17 deletions

View file

@ -51,10 +51,16 @@
* be used solely through the macros that make up the public software timer API,
* as defined below. The commands that are sent from interrupts must use the
* highest numbers as tmrFIRST_FROM_ISR_COMMAND is used to determine if the task
* or interrupt version of the queue send function should be used. */
* or interrupt version of the queue send function should be used. Priority
* commands, which are sent to the front of the command queue, must begin at
* zero as tmrLAST_PRIORITY_COMMAND is used to determine if a command is a
* priority command. */
#define tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR ( ( BaseType_t ) -2 )
#define tmrCOMMAND_EXECUTE_CALLBACK ( ( BaseType_t ) -1 )
#define tmrCOMMAND_START_DONT_TRACE ( ( BaseType_t ) 0 )
#define tmrLAST_PRIORITY_COMMAND ( ( BaseType_t ) 0 )
#define tmrCOMMAND_START ( ( BaseType_t ) 1 )
#define tmrCOMMAND_RESET ( ( BaseType_t ) 2 )
#define tmrCOMMAND_STOP ( ( BaseType_t ) 3 )
@ -1316,7 +1322,7 @@ BaseType_t xTimerGenericCommand( TimerHandle_t xTimer,
const BaseType_t xCommandID,
const TickType_t xOptionalValue,
BaseType_t * const pxHigherPriorityTaskWoken,
const TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
TickType_t xTicksToWait ) PRIVILEGED_FUNCTION;
#if ( configUSE_TRACE_FACILITY == 1 )
void vTimerSetTimerNumber( TimerHandle_t xTimer,

View file

@ -375,13 +375,17 @@
const BaseType_t xCommandID,
const TickType_t xOptionalValue,
BaseType_t * const pxHigherPriorityTaskWoken,
const TickType_t xTicksToWait )
TickType_t xTicksToWait )
{
BaseType_t xReturn = pdFAIL;
DaemonTaskMessage_t xMessage;
configASSERT( xTimer );
/* This function accepts only generic commands and not commands to execute
* a callback. */
configASSERT( xCommandID >= 0 );
/* Send a message to the timer service task to perform a particular action
* on a particular timer definition. */
if( xTimerQueue != NULL )
@ -393,24 +397,27 @@
if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )
{
if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING )
/* The calls to xQueueSend below must not wait if the scheduler is
* not running. */
if( xTaskGetSchedulerState() != taskSCHEDULER_RUNNING )
{
/* The "start don't trace" command comes only from the timer
* task itself. This command must be executed before any other
* commands now in the queue for this timer, in case one of
* those commands is stop or delete. */
if( xCommandID == tmrCOMMAND_START_DONT_TRACE )
{
xReturn = xQueueSendToFront( xTimerQueue, &xMessage, xTicksToWait );
}
else
{
xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );
}
xTicksToWait = tmrNO_DELAY;
}
else
{
xReturn = xQueueSendToBack( xTimerQueue, &xMessage, tmrNO_DELAY );
mtCOVERAGE_TEST_MARKER();
}
/* Priority commands must be executed before any standard commands
* now in the queue for this timer, so them to the front of the
* queue. */
if( xCommandID <= tmrLAST_PRIORITY_COMMAND )
{
xReturn = xQueueSendToFront( xTimerQueue, &xMessage, xTicksToWait );
}
else
{
xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );
}
}
else